From 3d1da2532b8f5202a3f0ca4cfcbfef891dec1ee1 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 5 Oct 2023 10:52:26 +0200 Subject: [PATCH] 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 --- source/blender/draw/engines/eevee_next/eevee_velocity.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/eevee_next/eevee_velocity.cc b/source/blender/draw/engines/eevee_next/eevee_velocity.cc index 12dba2e7e85..1c3dd6f6e46 100644 --- a/source/blender/draw/engines/eevee_next/eevee_velocity.cc +++ b/source/blender/draw/engines/eevee_next/eevee_velocity.cc @@ -327,7 +327,7 @@ void VelocityModule::end_sync() { Vector deleted_obj; - uint32_t max_resource_id_ = 1u; + uint32_t max_resource_id_ = 0u; for (MapItem 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. */