Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_extract_mesh.c
| Show First 20 Lines • Show All 4,518 Lines • ▼ Show 20 Lines | |||||
| static void extract_range_task_create( | static void extract_range_task_create( | ||||
| TaskPool *task_pool, ExtractTaskData *taskdata, const eMRIterType type, int start, int length) | TaskPool *task_pool, ExtractTaskData *taskdata, const eMRIterType type, int start, int length) | ||||
| { | { | ||||
| taskdata = MEM_dupallocN(taskdata); | taskdata = MEM_dupallocN(taskdata); | ||||
| atomic_add_and_fetch_int32(taskdata->task_counter, 1); | atomic_add_and_fetch_int32(taskdata->task_counter, 1); | ||||
| taskdata->iter_type = type; | taskdata->iter_type = type; | ||||
| taskdata->start = start; | taskdata->start = start; | ||||
| taskdata->end = start + length; | taskdata->end = start + length; | ||||
| BLI_task_pool_push(task_pool, extract_run, taskdata, true, TASK_PRIORITY_HIGH); | BLI_task_pool_push(task_pool, extract_run, taskdata, true, NULL); | ||||
| } | } | ||||
| static void extract_task_create(TaskPool *task_pool, | static void extract_task_create(TaskPool *task_pool, | ||||
| const Scene *scene, | const Scene *scene, | ||||
| const MeshRenderData *mr, | const MeshRenderData *mr, | ||||
| const MeshExtract *extract, | const MeshExtract *extract, | ||||
| void *buf, | void *buf, | ||||
| int32_t *task_counter) | int32_t *task_counter) | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | if (taskdata->iter_type & MR_ITER_LVERT) { | ||||
| extract_range_task_create(task_pool, taskdata, MR_ITER_LVERT, i, chunk_size); | extract_range_task_create(task_pool, taskdata, MR_ITER_LVERT, i, chunk_size); | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(taskdata); | MEM_freeN(taskdata); | ||||
| } | } | ||||
| 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, TASK_PRIORITY_HIGH); | 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, -1); | ||||
| MEM_freeN(taskdata); | MEM_freeN(taskdata); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | |||||
| #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; | TaskScheduler *task_scheduler; | ||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| task_scheduler = BLI_task_scheduler_get(); | task_scheduler = BLI_task_scheduler_get(); | ||||
| task_pool = BLI_task_pool_create_suspended(task_scheduler, NULL); | 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 | |||||