Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 4,503 Lines • ▼ Show 20 Lines | case MR_EXTRACT_MESH: | ||||
| for (int v = start; v < lv_end; v++) { | for (int v = start; v < lv_end; v++) { | ||||
| extract->iter_lvert(mr, v, &mr->mvert[mr->lverts[v]], user_data); | extract->iter_lvert(mr, v, &mr->mvert[mr->lverts[v]], user_data); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| static void extract_run(TaskPool *__restrict UNUSED(pool), void *taskdata, int UNUSED(threadid)) | static void extract_run(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| { | { | ||||
| ExtractTaskData *data = taskdata; | ExtractTaskData *data = taskdata; | ||||
| mesh_extract_iter( | mesh_extract_iter( | ||||
| data->mr, data->iter_type, data->start, data->end, data->extract, data->user_data); | data->mr, data->iter_type, data->start, data->end, data->extract, data->user_data); | ||||
| /* If this is the last task, we do the finish function. */ | /* If this is the last task, we do the finish function. */ | ||||
| int remainin_tasks = atomic_sub_and_fetch_int32(data->task_counter, 1); | int remainin_tasks = atomic_sub_and_fetch_int32(data->task_counter, 1); | ||||
| if (remainin_tasks == 0 && data->extract->finish != NULL) { | if (remainin_tasks == 0 && data->extract->finish != NULL) { | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | static void extract_task_create(TaskPool *task_pool, | ||||
| else if (use_thread) { | else if (use_thread) { | ||||
| /* One task for the whole VBO. */ | /* One task for the whole VBO. */ | ||||
| (*task_counter)++; | (*task_counter)++; | ||||
| BLI_task_pool_push(task_pool, extract_run, taskdata, true, NULL); | BLI_task_pool_push(task_pool, extract_run, taskdata, true, NULL); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Single threaded extraction. */ | /* Single threaded extraction. */ | ||||
| (*task_counter)++; | (*task_counter)++; | ||||
| extract_run(NULL, taskdata, -1); | extract_run(NULL, taskdata); | ||||
| MEM_freeN(taskdata); | MEM_freeN(taskdata); | ||||
| } | } | ||||
| } | } | ||||
| void mesh_buffer_cache_create_requested(MeshBatchCache *cache, | void mesh_buffer_cache_create_requested(MeshBatchCache *cache, | ||||
| MeshBufferCache mbc, | MeshBufferCache mbc, | ||||
| Mesh *me, | Mesh *me, | ||||
| const bool is_editmode, | const bool is_editmode, | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | #endif | ||||
| mr->use_hide = use_hide; | mr->use_hide = use_hide; | ||||
| mr->use_subsurf_fdots = use_subsurf_fdots; | mr->use_subsurf_fdots = use_subsurf_fdots; | ||||
| mr->use_final_mesh = do_final; | mr->use_final_mesh = do_final; | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| double rdata_end = PIL_check_seconds_timer(); | double rdata_end = PIL_check_seconds_timer(); | ||||
| #endif | #endif | ||||
| TaskScheduler *task_scheduler; | |||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| task_scheduler = BLI_task_scheduler_get(); | task_pool = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH); | ||||
brecht: See {rB05721cd} for why this must be a suspended task pool.
I'm not sure about the other… | |||||
| task_pool = BLI_task_pool_create_suspended(task_scheduler, NULL, TASK_PRIORITY_HIGH); | |||||
| size_t counters_size = (sizeof(mbc) / sizeof(void *)) * sizeof(int32_t); | size_t counters_size = (sizeof(mbc) / sizeof(void *)) * sizeof(int32_t); | ||||
| int32_t *task_counters = MEM_callocN(counters_size, __func__); | int32_t *task_counters = MEM_callocN(counters_size, __func__); | ||||
| int counter_used = 0; | int counter_used = 0; | ||||
| #define EXTRACT(buf, name) \ | #define EXTRACT(buf, name) \ | ||||
| if (mbc.buf.name) { \ | if (mbc.buf.name) { \ | ||||
| extract_task_create( \ | extract_task_create( \ | ||||
| ▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines | |||||
See rB05721cd00ad1: Mesh Batch Cache: Fix threading issue for why this must be a suspended task pool.
I'm not sure about the other places that use suspended pools. It should be slightly faster not to suspend, but it might not be safe.