[Bf-blender-cvs] [a3c45bc3136] soc-2022-many-lights-sampling: Cycles: disable light tree on HIP due to internal compiler errors

Brecht Van Lommel noreply at git.blender.org
Fri Dec 2 19:47:11 CET 2022


Commit: a3c45bc31364fed8f1a16da01c92c04bc19ee097
Author: Brecht Van Lommel
Date:   Fri Dec 2 16:17:54 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBa3c45bc31364fed8f1a16da01c92c04bc19ee097

Cycles: disable light tree on HIP due to internal compiler errors

To avoid this blocking the merge to master, but still plan to fix this for
the 3.5 release.

===================================================================

M	intern/cycles/device/device.cpp
M	intern/cycles/device/device.h
M	intern/cycles/device/hip/device.cpp
M	intern/cycles/kernel/light/sample.h
M	intern/cycles/kernel/types.h
M	intern/cycles/scene/light.cpp

===================================================================

diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 6aef5458246..ff7e46d48ab 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -351,6 +351,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
   info.num = 0;
 
   info.has_nanovdb = true;
+  info.has_light_tree = true;
   info.has_osl = true;
   info.has_guiding = true;
   info.has_profiling = true;
@@ -399,6 +400,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
 
     /* Accumulate device info. */
     info.has_nanovdb &= device.has_nanovdb;
+    info.has_light_tree &= device.has_light_tree;
     info.has_osl &= device.has_osl;
     info.has_guiding &= device.has_guiding;
     info.has_profiling &= device.has_profiling;
diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index 11d693cb25b..b9308dc8949 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -65,6 +65,7 @@ class DeviceInfo {
   int num;
   bool display_device;        /* GPU is used as a display device. */
   bool has_nanovdb;           /* Support NanoVDB volumes. */
+  bool has_light_tree;        /* Support light tree. */
   bool has_osl;               /* Support Open Shading Language. */
   bool has_guiding;           /* Support path guiding. */
   bool has_profiling;         /* Supports runtime collection of profiling info. */
@@ -84,6 +85,7 @@ class DeviceInfo {
     cpu_threads = 0;
     display_device = false;
     has_nanovdb = false;
+    has_light_tree = true;
     has_osl = false;
     has_guiding = false;
     has_profiling = false;
diff --git a/intern/cycles/device/hip/device.cpp b/intern/cycles/device/hip/device.cpp
index 3c9c73e7db0..518239f9877 100644
--- a/intern/cycles/device/hip/device.cpp
+++ b/intern/cycles/device/hip/device.cpp
@@ -137,6 +137,7 @@ void device_hip_info(vector<DeviceInfo> &devices)
     info.num = num;
 
     info.has_nanovdb = true;
+    info.has_light_tree = false;
     info.denoisers = 0;
 
     info.has_gpu_queue = true;
diff --git a/intern/cycles/kernel/light/sample.h b/intern/cycles/kernel/light/sample.h
index 9297746ce35..39bf3a59949 100644
--- a/intern/cycles/kernel/light/sample.h
+++ b/intern/cycles/kernel/light/sample.h
@@ -337,6 +337,7 @@ ccl_device_inline bool light_sample_from_volume_segment(KernelGlobals kg,
   int emitter_shader_flag = 0;
   float emitter_pdf_selection = 0.0f;
 
+#ifdef __LIGHT_TREE__
   if (kernel_data.integrator.use_light_tree) {
     if (!light_tree_sample<true>(kg,
                                  randu,
@@ -355,7 +356,9 @@ ccl_device_inline bool light_sample_from_volume_segment(KernelGlobals kg,
       return false;
     }
   }
-  else {
+  else
+#endif
+  {
     if (!light_distribution_sample(kg,
                                    randu,
                                    randv,
@@ -425,6 +428,7 @@ ccl_device bool light_sample_from_position(KernelGlobals kg,
   int emitter_shader_flag = 0;
   float emitter_pdf_selection = 0.0f;
 
+#ifdef __LIGHT_TREE__
   if (kernel_data.integrator.use_light_tree) {
     if (!light_tree_sample<false>(kg,
                                   randu,
@@ -443,7 +447,9 @@ ccl_device bool light_sample_from_position(KernelGlobals kg,
       return false;
     }
   }
-  else {
+  else
+#endif
+  {
     if (!light_distribution_sample(kg,
                                    randu,
                                    randv,
@@ -509,10 +515,13 @@ ccl_device_inline bool light_sample_new_position(KernelGlobals kg,
       return false;
     }
 
+#ifdef __LIGHT_TREE__
     if (kernel_data.integrator.use_light_tree) {
       ls->pdf *= ls->pdf_selection;
     }
-    else {
+    else
+#endif
+    {
       /* Handled in triangle_light_sample for effeciency. */
     }
     return true;
@@ -558,6 +567,7 @@ ccl_device_inline float light_sample_mis_weight_forward_surface(KernelGlobals kg
   float pdf = triangle_light_pdf(kg, sd, t);
 
   /* Light selection pdf. */
+#ifdef __LIGHT_TREE__
   if (kernel_data.integrator.use_light_tree) {
     float3 ray_P = INTEGRATOR_STATE(state, ray, P);
     const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
@@ -565,7 +575,9 @@ ccl_device_inline float light_sample_mis_weight_forward_surface(KernelGlobals kg
     uint prim_offset = kernel_data_fetch(object_prim_offset, sd->object);
     pdf *= light_tree_pdf(kg, ray_P, N, path_flag, sd->prim - prim_offset + lookup_offset);
   }
-  else {
+  else
+#endif
+  {
     /* Handled in triangle_light_pdf for effeciency. */
   }
 
@@ -582,11 +594,14 @@ ccl_device_inline float light_sample_mis_weight_forward_lamp(KernelGlobals kg,
   float pdf = ls->pdf;
 
   /* Light selection pdf. */
+#ifdef __LIGHT_TREE__
   if (kernel_data.integrator.use_light_tree) {
     const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
     pdf *= light_tree_pdf(kg, P, N, path_flag, ~ls->lamp);
   }
-  else {
+  else
+#endif
+  {
     pdf *= light_distribution_pdf_lamp(kg);
   }
 
@@ -613,11 +628,14 @@ ccl_device_inline float light_sample_mis_weight_forward_background(KernelGlobals
   float pdf = background_light_pdf(kg, ray_P, ray_D);
 
   /* Light selection pdf. */
+#ifdef __LIGHT_TREE__
   if (kernel_data.integrator.use_light_tree) {
     const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
     pdf *= light_tree_pdf(kg, ray_P, N, path_flag, ~kernel_data.background.light_index);
   }
-  else {
+  else
+#endif
+  {
     pdf *= light_distribution_pdf_lamp(kg);
   }
 
diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h
index 3950b2d791a..b42e07c5e1a 100644
--- a/intern/cycles/kernel/types.h
+++ b/intern/cycles/kernel/types.h
@@ -60,6 +60,7 @@ CCL_NAMESPACE_BEGIN
 #define __DENOISING_FEATURES__
 #define __DPDU__
 #define __HAIR__
+#define __LIGHT_TREE__
 #define __OBJECT_MOTION__
 #define __PASSES__
 #define __PATCH_EVAL__
@@ -74,6 +75,11 @@ CCL_NAMESPACE_BEGIN
 #define __VISIBILITY_FLAG__
 #define __VOLUME__
 
+/* TODO: solve internal compiler errors and enable light tree on HIP. */
+#ifdef __KERNEL_HIP__
+#  undef __LIGHT_TREE__
+#endif
+
 /* Device specific features */
 #ifdef WITH_OSL
 #  define __OSL__
diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp
index b18cd63a0ee..3459db6546c 100644
--- a/intern/cycles/scene/light.cpp
+++ b/intern/cycles/scene/light.cpp
@@ -848,7 +848,7 @@ void LightManager::device_update_background(Device *device,
   dscene->light_background_conditional_cdf.copy_to_device();
 }
 
-void LightManager::device_update_lights(Device *, DeviceScene *dscene, Scene *scene)
+void LightManager::device_update_lights(Device *device, DeviceScene *dscene, Scene *scene)
 {
   /* Counts lights in the scene. */
   size_t num_lights = 0;
@@ -882,7 +882,8 @@ void LightManager::device_update_lights(Device *, DeviceScene *dscene, Scene *sc
 
   /* Update integrator settings. */
   KernelIntegrator *kintegrator = &dscene->data.integrator;
-  kintegrator->use_light_tree = scene->integrator->get_use_light_tree();
+  kintegrator->use_light_tree = scene->integrator->get_use_light_tree() &&
+                                device->info.has_light_tree;
   kintegrator->num_lights = num_lights;
   kintegrator->num_distant_lights = num_distant_lights;
   kintegrator->num_background_lights = num_background_lights;



More information about the Bf-blender-cvs mailing list