[Bf-blender-cvs] [2dcb6782e06] master: Draw Mesh Extractor: Fix used thread count

Germano Cavalcante noreply at git.blender.org
Thu Jun 3 00:08:12 CEST 2021


Commit: 2dcb6782e06d285c7d500c34c85c0ab86c7c183a
Author: Germano Cavalcante
Date:   Wed Jun 2 18:04:48 2021 -0300
Branches: master
https://developer.blender.org/rB2dcb6782e06d285c7d500c34c85c0ab86c7c183a

Draw Mesh Extractor: Fix used thread count

Some threads were always idle because of this.

===================================================================

M	source/blender/draw/intern/draw_cache_extract_mesh.cc

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.cc b/source/blender/draw/intern/draw_cache_extract_mesh.cc
index 180ab50257f..b48ee1ddc3f 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.cc
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.cc
@@ -866,7 +866,7 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
   const bool use_thread = (mr->loop_len + mr->loop_loose_len) > CHUNK_SIZE;
 
   if (use_thread) {
-    uint threads_to_use = 0;
+    uint single_threaded_extractors_len = 0;
 
     /* First run the requested extractors that do not support asynchronous ranges. */
     for (const ExtractorRunData &run_data : extractors) {
@@ -879,8 +879,8 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
         struct TaskNode *task_node = extract_single_threaded_task_node_create(task_graph,
                                                                               taskdata);
         BLI_task_graph_edge_create(task_node_mesh_render_data, task_node);
+        single_threaded_extractors_len++;
       }
-      threads_to_use++;
     }
 
     /* Distribute the remaining extractors into ranges per core. */
@@ -893,9 +893,7 @@ static void mesh_buffer_cache_create_requested(struct TaskGraph *task_graph,
        * fill the rest of the threads for range operations.
        */
       int num_threads = BLI_task_scheduler_num_threads();
-      if (threads_to_use < num_threads) {
-        num_threads -= threads_to_use;
-      }
+      num_threads -= single_threaded_extractors_len % num_threads;
 
       UserDataInitTaskData *user_data_init_task_data = new UserDataInitTaskData();
       struct TaskNode *task_node_user_data_init = user_data_init_task_node_create(



More information about the Bf-blender-cvs mailing list