Merge branch 'master' into blender2.8
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 31 Oct 2018 10:49:04 +0000 (11:49 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 31 Oct 2018 10:49:04 +0000 (11:49 +0100)
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 906c01c619dd738d706e769bf6f54f87e9120406..428cd4158bc1430f5c94ad2ceafe8ff49501bd0e 100644 (file)
@@ -504,7 +504,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) {
@@ -539,7 +538,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 585d98022791c7f299b9d36835ca729946d386fa..b09843e9f1278610a343050b1608e362ef8d7658 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;
        }
@@ -294,6 +292,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 22b1bc493c848b67c4aa67773342cc99bdf1edd3..1c2d35061cc5edf4cd2565293782e6021d83f7fc 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
@@ -2477,7 +2481,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 587840e551fb0a52a126d53ba3dc2ca37ec3b16a..67f0f88028737b26988b66b836abc6307388f4ea 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;