Cleanup: remove Cycles layer bits checking in the kernel.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 22 May 2016 07:57:36 +0000 (09:57 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 22 May 2016 15:36:38 +0000 (17:36 +0200)
At some point the idea was that we could have an optimization where we could
render multiple render layers without re-exporting the scene, by just updating
the layer bits. We are not doing this now and in practice with the available
render layer control like exclude layers it's not always possible anyway.

This makes it easier to support an arbitrary number of layers in the future
(hopefully this summer), and frees up some useful bits in the kernel.

Reviewed By: sergey, dingto

Differential Revision: https://developer.blender.org/D2020

intern/cycles/blender/blender_object.cpp
intern/cycles/blender/blender_sync.cpp
intern/cycles/blender/blender_sync.h
intern/cycles/blender/blender_util.h
intern/cycles/kernel/kernel_path_state.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/kernel_volume.h
intern/cycles/render/integrator.cpp
intern/cycles/render/integrator.h

index edd5f292c790c94092dee4d571ee0d3a920f6a69..80768c096e36534bc428df658f01ac3306292209 100644 (file)
@@ -365,13 +365,12 @@ Object *BlenderSync::sync_object(BL::Object& b_parent,
        }
 
        /* make holdout objects on excluded layer invisible for non-camera rays */
-       if(use_holdout && (layer_flag & render_layer.exclude_layer))
+       if(use_holdout && (layer_flag & render_layer.exclude_layer)) {
                visibility &= ~(PATH_RAY_ALL_VISIBILITY - PATH_RAY_CAMERA);
+       }
 
-       /* camera flag is not actually used, instead is tested against render layer
-        * flags */
-       if(visibility & PATH_RAY_CAMERA) {
-               visibility |= layer_flag << PATH_RAY_LAYER_SHIFT;
+       /* hide objects not on render layer from camera rays */
+       if(!(layer_flag & render_layer.layer)) {
                visibility &= ~PATH_RAY_CAMERA;
        }
 
@@ -572,7 +571,6 @@ void BlenderSync::sync_objects(BL::SpaceView3D& b_v3d, float motion_time)
                        bool hide = (render_layer.use_viewport_visibility)? b_ob.hide(): b_ob.hide_render();
                        uint ob_layer = get_layer(b_base->layers(),
                                                  b_base->layers_local_view(),
-                                                 render_layer.use_localview,
                                                  object_is_light(b_ob),
                                                  scene_layers);
                        hide = hide || !(ob_layer & scene_layer);
index fd24593c6b61fb0e64479cc4974c5ba14c5f956a..00f9f58cd12b0602ecda41e03bc2d6b81e00eb7c 100644 (file)
@@ -269,8 +269,6 @@ void BlenderSync::sync_integrator()
                SAMPLING_NUM_PATTERNS,
                SAMPLING_PATTERN_SOBOL);
 
-       integrator->layer_flag = render_layer.layer;
-
        integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
        integrator->sample_clamp_indirect = get_float(cscene, "sample_clamp_indirect");
 #ifdef __CAMERA_MOTION__
@@ -377,8 +375,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer)
                        layer = layername.c_str();
                }
                else {
-                       render_layer.use_localview = (b_v3d.local_view() ? true : false);
-                       render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view(), render_layer.use_localview);
+                       render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
                        render_layer.layer = render_layer.scene_layer;
                        render_layer.exclude_layer = 0;
                        render_layer.holdout_layer = 0;
@@ -421,7 +418,6 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer)
                        render_layer.use_surfaces = b_rlay->use_solid();
                        render_layer.use_hair = b_rlay->use_strand();
                        render_layer.use_viewport_visibility = false;
-                       render_layer.use_localview = false;
 
                        render_layer.bound_samples = (use_layer_samples == 1);
                        if(use_layer_samples != 2) {
index e7062d1322a1f70983ee223967dfcfa07a52045d..d690adb56623a503da04ad0d8bc77d0a2e531ff7 100644 (file)
@@ -185,7 +185,6 @@ private:
                  use_surfaces(true),
                  use_hair(true),
                  use_viewport_visibility(false),
-                 use_localview(false),
                  samples(0), bound_samples(false)
                {}
 
@@ -200,7 +199,6 @@ private:
                bool use_surfaces;
                bool use_hair;
                bool use_viewport_visibility;
-               bool use_localview;
                int samples;
                bool bound_samples;
        } render_layer;
index d856982fddbce1d09cef8cc01661a282d613ffd9..e23d8bf4e2d48f7aacb140b1c4aa6ff11aa5b186 100644 (file)
@@ -275,7 +275,6 @@ static inline uint get_layer(const BL::Array<int, 20>& array)
 
 static inline uint get_layer(const BL::Array<int, 20>& array,
                              const BL::Array<int, 8>& local_array,
-                             bool use_local,
                              bool is_light = false,
                              uint scene_layers = (1 << 20) - 1)
 {
@@ -300,13 +299,6 @@ static inline uint get_layer(const BL::Array<int, 20>& array,
                                layer |= (1 << (20+i));
        }
 
-       /* we don't have spare bits for localview (normally 20-28) because
-        * PATH_RAY_LAYER_SHIFT uses 20-32. So - check if we have localview and if
-        * so, shift local view bits down to 1-8, since this is done for the view
-        * port only - it should be OK and not conflict with render layers. */
-       if(use_local)
-               layer >>= 20;
-
        return layer;
 }
 
index 540f289eae0d64c9d12a18f5bf4d4d81aef6f81d..ef3765f7d89676f642e9a264c7e044a87bf8e720 100644 (file)
@@ -131,9 +131,6 @@ ccl_device_inline uint path_state_ray_visibility(KernelGlobals *kg, PathState *s
        /* todo: this is not supported as its own ray visibility yet */
        if(state->flag & PATH_RAY_VOLUME_SCATTER)
                flag |= PATH_RAY_DIFFUSE;
-       /* for camera visibility, use render layer flags */
-       if(flag & PATH_RAY_CAMERA)
-               flag |= kernel_data.integrator.layer_flag;
 
        return flag;
 }
index cc261ed37f8e2e1d5de7f92b9e385ac872a4b2f0..ba50d180acf7670f08cc523b0cf9d4a35d83d31f 100644 (file)
@@ -276,10 +276,7 @@ enum SamplingPattern {
        SAMPLING_NUM_PATTERNS,
 };
 
-/* these flags values correspond to raytypes in osl.cpp, so keep them in sync!
- *
- * for ray visibility tests in BVH traversal, the upper 20 bits are used for
- * layer visibility tests. */
+/* these flags values correspond to raytypes in osl.cpp, so keep them in sync! */
 
 enum PathRayFlag {
        PATH_RAY_CAMERA = 1,
@@ -303,9 +300,6 @@ enum PathRayFlag {
        PATH_RAY_MIS_SKIP = 2048,
        PATH_RAY_DIFFUSE_ANCESTOR = 4096,
        PATH_RAY_SINGLE_PASS_DONE = 8192,
-
-       /* we need layer member flags to be the 20 upper bits */
-       PATH_RAY_LAYER_SHIFT = (32-20)
 };
 
 /* Closure Label */
@@ -1081,9 +1075,6 @@ typedef struct KernelIntegrator {
        /* seed */
        int seed;
 
-       /* render layer */
-       int layer_flag;
-
        /* clamp */
        float sample_clamp_direct;
        float sample_clamp_indirect;
index 0af5ff506194b87e49841d755bed4dacdd595f8d..30a978f6c9e79c90669bd3066f85e2335fc10688 100644 (file)
@@ -1026,14 +1026,13 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
 
        int stack_index = 0, enclosed_index = 0;
 
-       const uint visibility = PATH_RAY_ALL_VISIBILITY | kernel_data.integrator.layer_flag;
 #ifdef __VOLUME_RECORD_ALL__
        Intersection hits[2*VOLUME_STACK_SIZE];
        uint num_hits = scene_intersect_volume_all(kg,
                                                   &volume_ray,
                                                   hits,
                                                   2*VOLUME_STACK_SIZE,
-                                                  visibility);
+                                                  PATH_RAY_ALL_VISIBILITY);
        if(num_hits > 0) {
                int enclosed_volumes[VOLUME_STACK_SIZE];
                Intersection *isect = hits;
@@ -1083,7 +1082,7 @@ ccl_device void kernel_volume_stack_init(KernelGlobals *kg,
              step < 2 * VOLUME_STACK_SIZE)
        {
                Intersection isect;
-               if(!scene_intersect_volume(kg, &volume_ray, &isect, visibility)) {
+               if(!scene_intersect_volume(kg, &volume_ray, &isect, PATH_RAY_ALL_VISIBILITY)) {
                        break;
                }
 
index a136e9ad76b4a3b56fd4795529ea269c82315830..41e2571dc247a45c365b1aca3dad467cffeb418d 100644 (file)
@@ -50,7 +50,6 @@ NODE_DEFINE(Integrator)
        SOCKET_BOOLEAN(caustics_refractive, "Refractive Caustics", true);
        SOCKET_FLOAT(filter_glossy, "Filter Glossy", 0.0f);
        SOCKET_INT(seed, "Seed", 0);
-       SOCKET_INT(layer_flag, "Layer Flag", ~0);
        SOCKET_FLOAT(sample_clamp_direct, "Sample Clamp Direct", 0.0f);
        SOCKET_FLOAT(sample_clamp_indirect, "Sample Clamp Indirect", 0.0f);
        SOCKET_BOOLEAN(motion_blur, "Motion Blur", false);
@@ -137,7 +136,6 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
        kintegrator->filter_glossy = (filter_glossy == 0.0f)? FLT_MAX: 1.0f/filter_glossy;
 
        kintegrator->seed = hash_int(seed);
-       kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT;
 
        kintegrator->use_ambient_occlusion =
                ((Pass::contains(scene->film->passes, PASS_AO)) || dscene->data.background.ao_factor != 0.0f);
index 7d2cda3e116690e1870a1fd96f6d0b3dd894da8a..a5cfb0c78634a6c4f590f5b90a321f668dc15591 100644 (file)
@@ -51,7 +51,6 @@ public:
        float filter_glossy;
 
        int seed;
-       int layer_flag;
 
        float sample_clamp_direct;
        float sample_clamp_indirect;