Cycles: More accurate volume stack size calculation

The idea is to allow having a lot of non-intersecting volumes without
allocating volume stack to its full size.

With the F11285472 file the memory usage goes from 1400 MiB to 1000
on the RTX6000 card.

The fix makes it so the integrator work memory is allocated after
scene update which has downside of possible less efficient update
when some textures don't fit GPU memory, but has an advantage of
making proper decision and having a clear and consistent internal API.

Fixes memory part of T92014.

Differential Revision: https://developer.blender.org/D12966
This commit is contained in:
Sergey Sharybin
2021-10-22 14:20:22 +02:00
parent 8733d310e5
commit c4fa17c67a
5 changed files with 31 additions and 36 deletions

View File

@@ -114,6 +114,7 @@ Object::Object() : Node(get_node_type())
particle_index = 0;
attr_map_offset = 0;
bounds = BoundBox::empty;
intersects_volume = false;
}
Object::~Object()
@@ -367,22 +368,6 @@ 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) {
return true;
}
}
return false;
}
int Object::get_device_index() const
{
return index;
@@ -775,12 +760,14 @@ void ObjectManager::device_update_flags(
}
if (bounds_valid) {
object->intersects_volume = false;
foreach (Object *volume_object, volume_objects) {
if (object == volume_object) {
continue;
}
if (object->bounds.intersects(volume_object->bounds)) {
object_flag[object->index] |= SD_OBJECT_INTERSECTS_VOLUME;
object->intersects_volume = true;
break;
}
}