[Bf-blender-cvs] [b7b3f4dc764] soc-2022-many-lights-sampling: Support GPU rendering with Many Light Sampling

Brecht Van Lommel noreply at git.blender.org
Mon Sep 12 20:19:07 CEST 2022


Commit: b7b3f4dc76447ddc529d3006e2d2d747c4f61326
Author: Brecht Van Lommel
Date:   Mon Sep 12 15:15:00 2022 +0200
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBb7b3f4dc76447ddc529d3006e2d2d747c4f61326

Support GPU rendering with Many Light Sampling

This patch makes the changes neccesary to avoid errors with GPU rendering when
using Many Lights Sampling. CUDA and OptiX sometimes have errors still.

Contributed by Alaska.

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

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

M	intern/cycles/kernel/integrator/shade_surface.h
M	intern/cycles/kernel/light/light_tree.h

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

diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h
index 62eaf6b3882..0215213e12f 100644
--- a/intern/cycles/kernel/integrator/shade_surface.h
+++ b/intern/cycles/kernel/integrator/shade_surface.h
@@ -161,7 +161,7 @@ ccl_device_forceinline void integrate_surface_direct_light(KernelGlobals kg,
     const uint bounce = INTEGRATOR_STATE(state, path, bounce);
     const float2 rand_light = path_state_rng_2D(kg, rng_state, PRNG_LIGHT);
 
-    if (kg->data.integrator.use_light_tree) {
+    if (kernel_data.integrator.use_light_tree) {
       if (!light_tree_sample_from_position(
               kg, rng_state, rand_light.x, rand_light.y, sd->time, sd->P, sd->N, bounce, path_flag, &ls)) {
         return;
diff --git a/intern/cycles/kernel/light/light_tree.h b/intern/cycles/kernel/light/light_tree.h
index 0e41f83bd05..9f13980e38e 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -219,11 +219,11 @@ ccl_device float light_tree_cluster_importance(KernelGlobals kg,
 }
 
 ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg,
-                                                 float *randu,
+                                                 ccl_private float *randu,
                                                  const float3 P,
                                                  const float3 N,
                                                  const ccl_global KernelLightTreeNode *knode,
-                                                 float *pdf_factor)
+                                                 ccl_private float *pdf_factor)
 {
   float total_emitter_importance = 0.0f;
   for (int i = 0; i < knode->num_prims; i++) {
@@ -262,7 +262,7 @@ ccl_device int light_tree_cluster_select_emitter(KernelGlobals kg,
 template<bool in_volume_segment>
 ccl_device bool light_tree_sample(KernelGlobals kg,
                                   ccl_private const RNGState *rng_state,
-                                  float *randu,
+                                  ccl_private float *randu,
                                   const float randv,
                                   const float time,
                                   const float3 N,
@@ -270,7 +270,7 @@ ccl_device bool light_tree_sample(KernelGlobals kg,
                                   const int bounce,
                                   const uint32_t path_flag,
                                   ccl_private LightSample *ls,
-                                  float *pdf_factor)
+                                  ccl_private float *pdf_factor)
 {
   /* We keep track of the currently selected primitive and its weight,
    * as well as the total weight as part of the weighted reservoir sampling. */
@@ -448,7 +448,7 @@ ccl_device float light_tree_distant_light_importance(KernelGlobals kg,
 template<bool in_volume_segment>
 ccl_device bool light_tree_sample_distant_lights(KernelGlobals kg,
                                                 ccl_private const RNGState *rng_state,
-                                                float *randu,
+                                                ccl_private float *randu,
                                                 const float randv,
                                                 const float time,
                                                 const float3 N,
@@ -456,7 +456,7 @@ ccl_device bool light_tree_sample_distant_lights(KernelGlobals kg,
                                                 const int bounce,
                                                 const uint32_t path_flag,
                                                 ccl_private LightSample *ls,
-                                                float *pdf_factor)
+                                                ccl_private float *pdf_factor)
 {
   const int num_distant_lights = kernel_data.integrator.num_distant_lights;
   float total_importance = 0.0f;



More information about the Bf-blender-cvs mailing list