Draw: Reduce overhead of sharing meshes without attributes

When using a lot of instances the requested and needed attributes
are merged. This process uses a lock even when no work needs to be
done.

By early exiting the merging process when no work needs to be done
the performance of navigating 60k cubes went from 17.5 fps to 18.3 fps.

Detected when researching #126391.

Pull Request: https://projects.blender.org/blender/blender/pulls/129791
This commit is contained in:
Jeroen Bakker
2024-11-07 08:31:08 +01:00
parent a3a3dda563
commit bc480f05d5

View File

@@ -50,6 +50,9 @@ void drw_attributes_clear(DRW_Attributes *attributes)
void drw_attributes_merge(DRW_Attributes *dst, const DRW_Attributes *src, std::mutex &render_mutex)
{
if (src->num_requests == 0) {
return;
}
std::lock_guard lock{render_mutex};
drw_attributes_merge_requests(src, dst);
}