Page MenuHome

DrawManager: Multithreaded counting of material buckets.
ClosedPublic

Authored by Jeroen Bakker (jbakker) on Jun 15 2021, 4:37 PM.

Details

Summary

When having multiple materials in a mesh the triangles are sorted based
on material index. This sorting is done single threaded, but needs two
loops over the data. One to count the bucket size and the second one to
add the triangles to the right position in the buckets.

This patch will do the counting in a multithreaded approach that would
speed up the cache creation. It has been measured that this part is the
most blocking part of the cache creation.

Diff Detail

Repository
rB Blender
Branch
master
Build Status
Buildable 15212
Build 15212: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) requested review of this revision.Jun 15 2021, 4:37 PM
Jeroen Bakker (jbakker) created this revision.
Germano Cavalcante (mano-wii) requested changes to this revision.Jun 15 2021, 5:15 PM
Germano Cavalcante (mano-wii) added inline comments.
source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
234

If I'm not mistaken, int mat_tri_len[0] is usually used to indicate that the struct has variable size and the last member is an array.
This is also useful when using sizeof(MatOffsetUserData).

257

It seems good to comment on why (mr->mat_len - 1).
(Shouldn't it just be mr->mat_len?)

264

Since the range_funcs are not that heavy, it seems good to specify a settings.min_iter_per_thread.
I see this being specified elsewhere in the code but I'm not sure what the impact is.

277

A bit confusing this variable has the same name as the UNUSED(userdata).

This revision now requires changes to proceed.Jun 15 2021, 5:15 PM
source/blender/draw/intern/draw_cache_extract_mesh_render_data.c
257

Ignore, (I'm the one who didn't see comment XD)

Jeroen Bakker (jbakker) marked 5 inline comments as done.
  • Use [0] to indicate that the struct has a dynamic size.
  • Use min_iter_per_thread.
  • Use different variable name for userdata.
This revision is now accepted and ready to land.Jun 16 2021, 3:00 PM