diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2021-06-10 17:13:01 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2021-06-11 16:49:50 +0300 |
commit | 0eb9351296dbed5e7ac10ca56132d5e51e5f388d (patch) | |
tree | 48de5ef4538c9346d1cc9130ffe50ee8c052fc32 /source/blender/gpu | |
parent | 2330cec2c6a7632459c21f51723497e349a042bf (diff) |
Refactor: use 'BLI_task_parallel_range' in Draw Cache
One drawback to trying to predict the number of threads that will be
used in the `task_graph` is that we are only sure of the number when the
threads are running.
Using `BLI_task_parallel_range` allows the driver to
choose the best thread distribution through `parallel_reduce`.
The benefit is most evident on hardware with fewer cores.
This is the result on an 4-core laptop:
||before:|after:
|---|---|---|
|large_mesh_editing:|Average: 5.203638 FPS|Average: 5.398925 FPS
||rdata 15ms iter 43ms (frame 193ms)|rdata 14ms iter 36ms (frame 187ms)
Differential Revision: https://developer.blender.org/D11558
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_index_buffer.h | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_index_buffer.cc | 3 | ||||
-rw-r--r-- | source/blender/gpu/tests/gpu_index_buffer_test.cc | 4 |
3 files changed, 4 insertions, 6 deletions
diff --git a/source/blender/gpu/GPU_index_buffer.h b/source/blender/gpu/GPU_index_buffer.h index 48f80e321b6..a89ed91674f 100644 --- a/source/blender/gpu/GPU_index_buffer.h +++ b/source/blender/gpu/GPU_index_buffer.h @@ -58,8 +58,7 @@ GPUIndexBuf *GPU_indexbuf_build_on_device(uint index_len); * * Function inspired by the reduction directives of multithread work APIs.. */ -void GPU_indexbuf_join_copies(GPUIndexBufBuilder *builder, - const GPUIndexBufBuilder *parent_builder); +void GPU_indexbuf_join(GPUIndexBufBuilder *builder, const GPUIndexBufBuilder *parent_builder); void GPU_indexbuf_add_generic_vert(GPUIndexBufBuilder *, uint v); void GPU_indexbuf_add_primitive_restart(GPUIndexBufBuilder *); diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc index 993bcdf743b..be7470e79c1 100644 --- a/source/blender/gpu/intern/gpu_index_buffer.cc +++ b/source/blender/gpu/intern/gpu_index_buffer.cc @@ -79,8 +79,7 @@ GPUIndexBuf *GPU_indexbuf_build_on_device(uint index_len) return elem_; } -void GPU_indexbuf_join_copies(GPUIndexBufBuilder *builder_to, - const GPUIndexBufBuilder *builder_from) +void GPU_indexbuf_join(GPUIndexBufBuilder *builder_to, const GPUIndexBufBuilder *builder_from) { BLI_assert(builder_to->data == builder_from->data); builder_to->index_len = max_uu(builder_to->index_len, builder_from->index_len); diff --git a/source/blender/gpu/tests/gpu_index_buffer_test.cc b/source/blender/gpu/tests/gpu_index_buffer_test.cc index ebc110056e3..78e351af7f1 100644 --- a/source/blender/gpu/tests/gpu_index_buffer_test.cc +++ b/source/blender/gpu/tests/gpu_index_buffer_test.cc @@ -21,7 +21,7 @@ TEST_F(GPUTest, gpu_index_buffer_subbuilders) GPUIndexBufBuilder subbuilders[num_subbuilders]; for (int subbuilder_index = 0; subbuilder_index < num_subbuilders; subbuilder_index++) { - GPU_indexbuf_subbuilder_init(&builder, &subbuilders[subbuilder_index]); + memcpy(&subbuilders[subbuilder_index], &builder, sizeof(builder)); } for (int subbuilder_index = 0; subbuilder_index < num_subbuilders; subbuilder_index++) { @@ -35,7 +35,7 @@ TEST_F(GPUTest, gpu_index_buffer_subbuilders) for (int subbuilder_index = 0; subbuilder_index < num_subbuilders; subbuilder_index++) { EXPECT_EQ(builder.index_len, subbuilder_index * verts_per_subbuilders); - GPU_indexbuf_subbuilder_finish(&builder, &subbuilders[subbuilder_index]); + GPU_indexbuf_join(&builder, &subbuilders[subbuilder_index]); EXPECT_EQ(builder.index_len, (subbuilder_index + 1) * verts_per_subbuilders); } |