[Bf-blender-cvs] [cc043999378] master: Fix missing Cycles volume stack re-allocation

Sergey Sharybin noreply at git.blender.org
Tue Oct 12 12:01:16 CEST 2021


Commit: cc043999378dbe04e1cc601c01b43dc0b727e553
Author: Sergey Sharybin
Date:   Tue Oct 12 11:54:33 2021 +0200
Branches: master
https://developer.blender.org/rBcc043999378dbe04e1cc601c01b43dc0b727e553

Fix missing Cycles volume stack re-allocation

Need to check allocation size, as the features do not change with
volume stack depth detection.

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

M	intern/cycles/integrator/path_trace_work_gpu.cpp
M	intern/cycles/integrator/path_trace_work_gpu.h

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

diff --git a/intern/cycles/integrator/path_trace_work_gpu.cpp b/intern/cycles/integrator/path_trace_work_gpu.cpp
index 706fc5799d0..df393bac0de 100644
--- a/intern/cycles/integrator/path_trace_work_gpu.cpp
+++ b/intern/cycles/integrator/path_trace_work_gpu.cpp
@@ -97,11 +97,15 @@ void PathTraceWorkGPU::alloc_integrator_soa()
   /* IntegrateState allocated as structure of arrays. */
 
   /* Check if we already allocated memory for the required features. */
+  const int requested_volume_stack_size = device_scene_->data.volume_stack_size;
   const uint kernel_features = device_scene_->data.kernel_features;
-  if ((integrator_state_soa_kernel_features_ & kernel_features) == kernel_features) {
+  if ((integrator_state_soa_kernel_features_ & kernel_features) == kernel_features &&
+      integrator_state_soa_volume_stack_size_ >= requested_volume_stack_size) {
     return;
   }
   integrator_state_soa_kernel_features_ = kernel_features;
+  integrator_state_soa_volume_stack_size_ = max(integrator_state_soa_volume_stack_size_,
+                                                requested_volume_stack_size);
 
   /* Allocate a device only memory buffer before for each struct member, and then
    * write the pointers into a struct that resides in constant memory.
@@ -133,7 +137,7 @@ void PathTraceWorkGPU::alloc_integrator_soa()
     break; \
   } \
   }
-#define KERNEL_STRUCT_VOLUME_STACK_SIZE (device_scene_->data.volume_stack_size)
+#define KERNEL_STRUCT_VOLUME_STACK_SIZE (integrator_state_soa_volume_stack_size_)
 #include "kernel/integrator/integrator_state_template.h"
 #undef KERNEL_STRUCT_BEGIN
 #undef KERNEL_STRUCT_MEMBER
diff --git a/intern/cycles/integrator/path_trace_work_gpu.h b/intern/cycles/integrator/path_trace_work_gpu.h
index 9212537d2fd..e66851cc8d8 100644
--- a/intern/cycles/integrator/path_trace_work_gpu.h
+++ b/intern/cycles/integrator/path_trace_work_gpu.h
@@ -124,6 +124,7 @@ class PathTraceWorkGPU : public PathTraceWork {
   /* SoA arrays for integrator state. */
   vector<unique_ptr<device_memory>> integrator_state_soa_;
   uint integrator_state_soa_kernel_features_;
+  int integrator_state_soa_volume_stack_size_ = 0;
   /* Keep track of number of queued kernels. */
   device_vector<IntegratorQueueCounter> integrator_queue_counter_;
   /* Shader sorting. */



More information about the Bf-blender-cvs mailing list