The ibo.tris extraction in multithread is currently only done if the mesh has only 1 material.
This patch proposes to cache a map indicating the index of each tri after sort and thus allow the extraction of tris with materials to be multithreaded.
As caching is a heavy operation, no improvements are expected if the geometry is not deform only. (Since in this case the cache is also cleared).
Profiling:
The test was done by transforming a geometry with deform only (large_mesh_editing_materials) and a geometry with subdivision modifier that clears the cache during transformation (subdiv_mesh_final_only_materials).
| master: | PATCH: | |
|---|---|---|
| large_mesh_editing_materials: | Average: 23.659796 FPS | Average: 25.971083 FPS |
| rdata 0ms iter 24ms (frame 42ms) | rdata 0ms iter 20ms (frame 39ms) | |
| subdiv_mesh_final_only_materials: | Average: 28.832694 FPS | Average: 28.775633 FPS |
| rdata 0ms iter 1ms (frame 35ms) | rdata 0ms iter 1ms (frame 35ms) | |
1.12x overall speedup