Fix T68826 Eevee: Multi-Mat not working if switching from Solid shading
The correct fix would be to avoid all those hacks but this is needed if we want to be able to parallelize object vbo extractions. This is the fixed version of the hack. The issue was that the ibo ranges were saved before the batch were reset and the IBO was discarded, leading to a read after free error. All previous reported crash were tested and are now not reproductible.
This commit is contained in:
parent
b9f61eb874
commit
742119bcb5
Notes:
blender-bot
2023-04-14 09:18:04 +02:00
Referenced by issue #68826, eevee not showing multi material object properly when blend is loaded until mesh is updated
|
@ -999,6 +999,26 @@ void DRW_mesh_batch_cache_create_requested(
|
|||
}
|
||||
}
|
||||
|
||||
/* HACK: if MBC_SURF_PER_MAT is requested and ibo.tris is already available, it won't have it's
|
||||
* index ranges initialized. So discard ibo.tris in order to recreate it.
|
||||
* This needs to happen before saved_elem_ranges is populated. */
|
||||
if ((batch_requested & MBC_SURF_PER_MAT) != 0 && (cache->batch_ready & MBC_SURF_PER_MAT) == 0) {
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbuffercache)
|
||||
{
|
||||
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.tris);
|
||||
}
|
||||
/* Clear all batches that reference ibo.tris. */
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.surface);
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.surface_weights);
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.edit_mesh_analysis);
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.edit_triangles);
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.edit_lnor);
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.edit_selection_faces);
|
||||
|
||||
cache->batch_ready &= ~(MBC_SURFACE | MBC_SURFACE_WEIGHTS | MBC_EDIT_MESH_ANALYSIS |
|
||||
MBC_EDIT_TRIANGLES | MBC_EDIT_LNOR | MBC_EDIT_SELECTION_FACES);
|
||||
}
|
||||
|
||||
if (batch_requested &
|
||||
(MBC_SURFACE | MBC_SURF_PER_MAT | MBC_WIRE_LOOPS_UVS | MBC_EDITUV_FACES_STRECH_AREA |
|
||||
MBC_EDITUV_FACES_STRECH_ANGLE | MBC_EDITUV_FACES | MBC_EDITUV_EDGES | MBC_EDITUV_VERTS)) {
|
||||
|
|
Loading…
Reference in New Issue