EEVEE-Next: Fix Crash With Exact 128 Resources

When the scene has exact 128 resources or a multiple in the scene
Blender crashes as the velocity buffer doesn't allocates the
right amount of space inside its buffer.

Pull Request: https://projects.blender.org/blender/blender/pulls/113277
This commit is contained in:
Jeroen Bakker
2023-10-05 10:52:26 +02:00
parent 355a30c106
commit 3d1da2532b

View File

@@ -327,7 +327,7 @@ void VelocityModule::end_sync()
{
Vector<ObjectKey, 0> deleted_obj;
uint32_t max_resource_id_ = 1u;
uint32_t max_resource_id_ = 0u;
for (MapItem<ObjectKey, VelocityObjectData> item : velocity_map.items()) {
if (item.value.obj.resource_id == uint32_t(-1)) {
@@ -350,7 +350,7 @@ void VelocityModule::end_sync()
velocity_map.remove(key);
}
indirection_buf.resize(ceil_to_multiple_u(max_resource_id_, 128));
indirection_buf.resize(ceil_to_multiple_u(max_resource_id_ + 1, 128));
/* Avoid uploading more data to the GPU as well as an extra level of
* indirection on the GPU by copying back offsets the to VelocityIndex. */