Fix T91922: Cycles artifacts with high volume nested level
Make volume stack allocated conditionally, potentially based on the actual nested level of objects in the scene. Currently the nested level is estimated by number of volume objects. This is a non-expensive check which is probably enough in practice to get almost perfect memory usage and performance. The conditional allocation is a bit tricky. For the CPU we declare and define maximum possible volume stack, because there are only that many integrator states on the CPU. On the GPU we declare outer SoA to have all volume stack elements, but only allocate actually needed ones. The actually used volume stack size is passed as a pre-processor, which seems to be easiest and fastest for the GPU state copy. There seems to be no speed regression in the demo files on RTX6000. Note that scenes with high nested level of volume will now be slower but correct. Differential Revision: https://developer.blender.org/D12759
This commit is contained in:
@@ -366,6 +366,22 @@ float Object::compute_volume_step_size() const
|
||||
return step_size;
|
||||
}
|
||||
|
||||
bool Object::check_is_volume() const
|
||||
{
|
||||
if (geometry->geometry_type == Geometry::VOLUME) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Node *node : get_geometry()->get_used_shaders()) {
|
||||
const Shader *shader = static_cast<const Shader *>(node);
|
||||
if (shader->has_volume_connected) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int Object::get_device_index() const
|
||||
{
|
||||
return index;
|
||||
|
Reference in New Issue
Block a user