EEVEE: Motion Blur: Fix issue with batch overflowing with VBOs

This commit is contained in:
Clément Foucault 2020-08-12 17:44:47 +02:00
parent bea79e0c7b
commit 879ed5a165
Notes: blender-bot 2023-02-13 21:01:10 +01:00
Referenced by issue #82808, Eevee Render Crashed when Enable Motion Blur
Referenced by issue #81193, EEVEE crash when keyframing integer properties on modifiers with motion blur enabled
1 changed files with 10 additions and 8 deletions

View File

@ -492,14 +492,7 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
}
else {
/* Modify the batch to include the previous & next position. */
if (i == MB_PREV) {
GPU_batch_vertbuf_add_ex(batch, vbo, true);
mb_geom->vbo[i] = NULL;
}
else {
/* This VBO can be reuse by next time step. Don't pass ownership. */
GPU_batch_vertbuf_add_ex(batch, vbo, false);
}
GPU_batch_vertbuf_add_ex(batch, vbo, false);
}
}
}
@ -568,6 +561,15 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata)
break;
case EEVEE_MOTION_DATA_MESH:
if (mb_geom->batch != NULL) {
for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN; i++) {
if (mb_geom->batch->verts[i] == mb_geom->vbo[MB_PREV] ||
mb_geom->batch->verts[i] == mb_geom->vbo[MB_NEXT]) {
/* Avoid double reference of the VBOs. */
mb_geom->batch->verts[i] = NULL;
}
}
}
GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_PREV]);
mb_geom->vbo[MB_PREV] = mb_geom->vbo[MB_NEXT];