diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-02-24 19:22:41 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-02-24 19:43:04 +0300 |
commit | f8507ca3720e6bcec934d01ef3af129e9bf1d3a8 (patch) | |
tree | 40212108d57ade951aed120b0776657ce4dd76ca /source/blender | |
parent | b7a954218b0d1b90b67f228ae3ab8498710a1a65 (diff) |
EEVEE: Fix crash when shadow caster count is reduced to 0.
The crash was catched by ASAN. It was caused by the buffer shrinking logic
being faulty.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_shadows.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c index d8a40fd13cc..7d8dc85bea6 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.c +++ b/source/blender/draw/engines/eevee/eevee_shadows.c @@ -288,11 +288,9 @@ void EEVEE_shadows_update(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) /* Resize shcasters buffers if too big. */ if (frontbuffer->alloc_count - frontbuffer->count > SH_CASTER_ALLOC_CHUNK) { - frontbuffer->alloc_count = (frontbuffer->count / SH_CASTER_ALLOC_CHUNK) * + frontbuffer->alloc_count = divide_ceil_u(max_ii(1, frontbuffer->count), + SH_CASTER_ALLOC_CHUNK) * SH_CASTER_ALLOC_CHUNK; - frontbuffer->alloc_count += (frontbuffer->count % SH_CASTER_ALLOC_CHUNK != 0) ? - SH_CASTER_ALLOC_CHUNK : - 0; frontbuffer->bbox = MEM_reallocN(frontbuffer->bbox, sizeof(EEVEE_BoundBox) * frontbuffer->alloc_count); BLI_BITMAP_RESIZE(frontbuffer->update, frontbuffer->alloc_count); |