Blender Git Loki

Git Commits -> Revision e0eaa77

June 4, 2021, 10:59 (GMT)
GPU: Thread safe index buffer builders.

Current index builder is designed to be used in a single thread.
This makes all index buffer extractions single threaded.
This patch adds a thread safe solution enabling multithreaded
building of index buffers.

To reduce locking the solution would provide a task/thread local
index buffer builder (called sub builder).
When a thread is finished this thread local index buffer builder
can be joined with the initial index buffer builder.

`GPU_indexbuf_subbuilder_init`: Initialized a sub builder. The
index list is shared between the parent and sub buffer, but the
counters are localized. Ensuring that updating counters would
not need any locking.

`GPU_indexbuf_subbuilder_finish`: merge the information of the
sub builder back to the parent builder. Needs to be invoked outside
the worker thread, or when sure that all worker threads have been
finished. Internal the function is not thread safe.

For testing purposes the extract_points extractor has been migrated to
the new API. Herefore changes to the mesh extractor were needed.

* When creating tasks, the task number of current task is stored in
ExtractTaskData including the total number of tasks.
* The total number of tasks will be passed as parameter to the init
function. In the init function needed space can be reserved in the
userdata.
* Adding two functions in `MeshExtract`.
** `task_init` will initialize the task specific userdata.
** `task_finish` should merge back the task specific userdata back.
* adding task_id parameter to the iteration functions so they can
access the correct data inside the user data without any need for
locking.

Maniphest Tasks: T88822

Differential Revision: https://developer.blender.org/D11499

Commit Details:

Full Hash: e0eaa77f8fbc09cae22afb123156e497e292a84b
Parent Commit: d486ee2
Lines Changed: +578, -244

2 Added Paths:

/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc (+182, -0) (View)
/source/blender/gpu/tests/gpu_index_buffer_test.cc (+47, -0) (View)

8 Modified Paths:

/source/blender/draw/CMakeLists.txt (+1, -0) (Diff)
/source/blender/draw/intern/draw_cache_extract.h (+1, -0) (Diff)
/source/blender/draw/intern/draw_cache_extract_mesh.cc (+142, -54) (Diff)
/source/blender/draw/intern/draw_cache_extract_mesh_extractors.c (+150, -168) (Diff)
/source/blender/draw/intern/draw_cache_extract_mesh_private.h (+22, -22) (Diff)
/source/blender/gpu/CMakeLists.txt (+2, -0) (Diff)
/source/blender/gpu/GPU_index_buffer.h (+14, -0) (Diff)
/source/blender/gpu/intern/gpu_index_buffer.cc (+17, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021