diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2021-01-30 18:35:52 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2021-01-30 18:35:52 +0300 |
commit | 3a954af862038affb86daa8dbaa7a5b7d7687e4b (patch) | |
tree | 9626e3e48bda7260285e32b14a581371e72c3807 /source/blender/draw/engines | |
parent | 5d215d522541e32b9e33e92f836d2cf8eb6080c2 (diff) |
EEVEE: Fix crash when using animated visibility with motion blur steps
This was caused by the same VBO being remapped twice by
`EEVEE_motion_blur_cache_finish`. Leading to memory corruption.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/eevee_motion_blur.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 530becfe771..59842ec50f7 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -457,9 +457,6 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) } else { GPUVertBuf *vbo = mb_geom->vbo[mb_step]; - /* If this assert fails, it means that different EEVEE_GeometryMotionDatas - * has been used for each motion blur step. */ - BLI_assert(vbo); if (vbo) { /* Use the vbo to perform the copy on the GPU. */ GPU_vertbuf_use(vbo); @@ -470,6 +467,10 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata) int attrib_id = GPU_vertformat_attr_id_get(format, "pos"); GPU_vertformat_attr_rename(format, attrib_id, (mb_step == MB_PREV) ? "prv" : "nxt"); } + else { + /* This might happen if the object visibility has been animated. */ + mb_geom->use_deform = false; + } } break; @@ -515,6 +516,8 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata) DRW_TEXTURE_FREE_SAFE(mb_hair->psys[i].hair_pos_tx[MB_PREV]); mb_hair->psys[i].hair_pos[MB_PREV] = mb_hair->psys[i].hair_pos[MB_NEXT]; mb_hair->psys[i].hair_pos_tx[MB_PREV] = mb_hair->psys[i].hair_pos_tx[MB_NEXT]; + mb_hair->psys[i].hair_pos[MB_NEXT] = NULL; + mb_hair->psys[i].hair_pos_tx[MB_NEXT] = NULL; } break; @@ -529,9 +532,10 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata) } GPU_VERTBUF_DISCARD_SAFE(mb_geom->vbo[MB_PREV]); mb_geom->vbo[MB_PREV] = mb_geom->vbo[MB_NEXT]; + mb_geom->vbo[MB_NEXT] = NULL; - if (mb_geom->vbo[MB_NEXT]) { - GPUVertBuf *vbo = mb_geom->vbo[MB_NEXT]; + if (mb_geom->vbo[MB_PREV]) { + GPUVertBuf *vbo = mb_geom->vbo[MB_PREV]; GPUVertFormat *format = (GPUVertFormat *)GPU_vertbuf_get_format(vbo); int attrib_id = GPU_vertformat_attr_id_get(format, "nxt"); GPU_vertformat_attr_rename(format, attrib_id, "prv"); |