Cycles: Fix wrong BVH used when disabling AVX2 in debug settings
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 31 Oct 2018 10:46:52 +0000 (11:46 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 31 Oct 2018 10:46:52 +0000 (11:46 +0100)
Mainly useful for debugging. Previously, when AVX2 was disabled
in the debug panel but BVH layout was kept on BVH8 nothing was
rendered.

Needed to make it so supported BVH layout mask for devices is
queried in "dynamic", so it is possible to use DebugFlags there.

intern/cycles/device/device.cpp
intern/cycles/device/device.h
intern/cycles/device/device_cpu.cpp
intern/cycles/device/device_cuda.cpp
intern/cycles/device/device_multi.cpp
intern/cycles/device/device_network.cpp
intern/cycles/device/device_opencl.cpp
intern/cycles/device/opencl/opencl_mega.cpp
intern/cycles/device/opencl/opencl_split.cpp
intern/cycles/render/mesh.cpp

index 6959dd73c3208c6ac4de721be8f3b5cef28e22b3..7e20bb449c3be384bff52637aa0812f558a3af15 100644 (file)
@@ -361,7 +361,6 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo>& subdevices, int th
 
        info.has_half_images = true;
        info.has_volume_decoupled = true;
-       info.bvh_layout_mask = BVH_LAYOUT_ALL;
        info.has_osl = true;
 
        foreach(const DeviceInfo &device, subdevices) {
@@ -396,7 +395,6 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo>& subdevices, int th
                /* Accumulate device info. */
                info.has_half_images &= device.has_half_images;
                info.has_volume_decoupled &= device.has_volume_decoupled;
-               info.bvh_layout_mask = device.bvh_layout_mask & info.bvh_layout_mask;
                info.has_osl &= device.has_osl;
        }
 
index 2400788c8331cbe088d7ea4acb37bcad321f3773..54a3ae1fe9f7d4b2bd3b1cdc98dec8931ca7587e 100644 (file)
@@ -58,7 +58,6 @@ public:
        bool advanced_shading;          /* Supports full shading system. */
        bool has_half_images;           /* Support half-float textures. */
        bool has_volume_decoupled;      /* Decoupled volume shading. */
-       BVHLayoutMask bvh_layout_mask;  /* Bitmask of supported BVH layouts. */
        bool has_osl;                   /* Support Open Shading Language. */
        bool use_split_kernel;          /* Use split or mega kernel. */
        int cpu_threads;
@@ -74,7 +73,6 @@ public:
                advanced_shading = true;
                has_half_images = false;
                has_volume_decoupled = false;
-               bvh_layout_mask = BVH_LAYOUT_NONE;
                has_osl = false;
                use_split_kernel = false;
        }
@@ -281,6 +279,7 @@ public:
                fflush(stderr);
        }
        virtual bool show_samples() const { return false; }
+       virtual BVHLayoutMask get_bvh_layout_mask() const = 0;
 
        /* statistics */
        Stats &stats;
index eb816e1fdd0805158722e1c7c5246c562c37136d..731d6c0d631814694e40e18fcb1f584ff929adc8 100644 (file)
@@ -278,6 +278,17 @@ public:
                return (info.cpu_threads == 1);
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_BVH2;
+               if(DebugFlags().cpu.has_sse2() && system_cpu_support_sse2()) {
+                       bvh_layout_mask |= BVH_LAYOUT_BVH4;
+               }
+               if(DebugFlags().cpu.has_avx2() && system_cpu_support_avx2()) {
+                       bvh_layout_mask |= BVH_LAYOUT_BVH8;
+               }
+               return bvh_layout_mask;
+       }
+
        void load_texture_info()
        {
                if(need_texture_info) {
@@ -1041,13 +1052,6 @@ void device_cpu_info(vector<DeviceInfo>& devices)
        info.id = "CPU";
        info.num = 0;
        info.advanced_shading = true;
-       info.bvh_layout_mask = BVH_LAYOUT_BVH2;
-       if(system_cpu_support_sse2()) {
-               info.bvh_layout_mask |= BVH_LAYOUT_BVH4;
-       }
-       if(system_cpu_support_avx2()) {
-               info.bvh_layout_mask |= BVH_LAYOUT_BVH8;
-       }
        info.has_volume_decoupled = true;
        info.has_osl = true;
        info.has_half_images = true;
index 5b46d5a507d44ab13afcbc72a7fbc7023acecd29..f0e58f22ad40733c844241fd118cd91073a44844 100644 (file)
@@ -181,6 +181,10 @@ public:
                return true;
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               return BVH_LAYOUT_BVH2;
+       }
+
 /*#ifdef NDEBUG
 #define cuda_abort()
 #else
@@ -2459,7 +2463,6 @@ void device_cuda_info(vector<DeviceInfo>& devices)
                info.advanced_shading = (major >= 3);
                info.has_half_images = (major >= 3);
                info.has_volume_decoupled = false;
-               info.bvh_layout_mask = BVH_LAYOUT_BVH2;
 
                int pci_location[3] = {0, 0, 0};
                cuDeviceGetAttribute(&pci_location[0], CU_DEVICE_ATTRIBUTE_PCI_DOMAIN_ID, num);
index f1bd3fd13e1b20da65def400f41014f2c528144a..490ee3951c9f6506537b12e6313bdf418690133b 100644 (file)
@@ -103,6 +103,14 @@ public:
                return devices.front().device->show_samples();
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL;
+               foreach(const SubDevice& sub_device, devices) {
+                       bvh_layout_mask &= sub_device.device->get_bvh_layout_mask();
+               }
+               return bvh_layout_mask;
+       }
+
        bool load_kernels(const DeviceRequestedFeatures& requested_features)
        {
                foreach(SubDevice& sub, devices)
index 204e405421d80832acd353ecf88fd011b601f490..b6e18621f12fc2467271b05bfd6c36dfcbc966fe 100644 (file)
@@ -87,6 +87,10 @@ public:
                snd.write();
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               return BVH_LAYOUT_BVH2;
+       }
+
        void mem_alloc(device_memory& mem)
        {
                if(mem.name) {
@@ -306,7 +310,6 @@ void device_network_info(vector<DeviceInfo>& devices)
        /* todo: get this info from device */
        info.advanced_shading = true;
        info.has_volume_decoupled = false;
-       info.bvh_layout_mask = BVH_LAYOUT_BVH2;
        info.has_osl = false;
 
        devices.push_back(info);
index be0f8f45399a49db522e7746007a1abeda4267f7..0f622430abbdaebe66a391bf63a4b7154bc3ff91 100644 (file)
@@ -136,7 +136,6 @@ void device_opencl_info(vector<DeviceInfo>& devices)
                info.use_split_kernel = OpenCLInfo::kernel_use_split(platform_name,
                                                                     device_type);
                info.has_volume_decoupled = false;
-               info.bvh_layout_mask = BVH_LAYOUT_BVH2;
                info.id = id;
 
                /* Check OpenCL extensions */
index e004c0b44f4822f0a7411f8c372d0c2e0184920d..89001366d9dd864bf8ce33dfa93a035e659fb974 100644 (file)
@@ -43,6 +43,10 @@ public:
                return true;
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               return BVH_LAYOUT_BVH2;
+       }
+
        virtual bool load_kernels(const DeviceRequestedFeatures& /*requested_features*/,
                                  vector<OpenCLProgram*> &programs)
        {
index 66a4aa7e891b8d54740f912a1955c8de89f25b7e..83389ef7cc8e5efa8fa5db0ca754cd0ab622c5c9 100644 (file)
@@ -95,6 +95,10 @@ public:
                return true;
        }
 
+       virtual BVHLayoutMask get_bvh_layout_mask() const {
+               return BVH_LAYOUT_BVH2;
+       }
+
        virtual bool load_kernels(const DeviceRequestedFeatures& requested_features,
                                  vector<OpenCLDeviceBase::OpenCLProgram*> &programs)
        {
index 8a00b88af123306063d2b4c244421e78c4a42c40..6f619380988d5f492129d0b88cb77506fce80d6f 100644 (file)
@@ -1068,7 +1068,7 @@ void Mesh::compute_bvh(Device *device,
                        bparams.use_spatial_split = params->use_bvh_spatial_split;
                        bparams.bvh_layout = BVHParams::best_bvh_layout(
                                params->bvh_layout,
-                               device->info.bvh_layout_mask);
+                               device->get_bvh_layout_mask());
                        bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
                                                      params->use_bvh_unaligned_nodes;
                        bparams.num_motion_triangle_steps = params->num_bvh_time_steps;
@@ -1855,7 +1855,7 @@ void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *
        bparams.top_level = true;
        bparams.bvh_layout = BVHParams::best_bvh_layout(
                scene->params.bvh_layout,
-               device->info.bvh_layout_mask);
+               device->get_bvh_layout_mask());
        bparams.use_spatial_split = scene->params.use_bvh_spatial_split;
        bparams.use_unaligned_nodes = dscene->data.bvh.have_curves &&
                                      scene->params.use_bvh_unaligned_nodes;