Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/imageprocess.c
| Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | void IMB_processor_apply_threaded( | ||||
| TaskScheduler *task_scheduler = BLI_task_scheduler_get(); | TaskScheduler *task_scheduler = BLI_task_scheduler_get(); | ||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| void *handles; | void *handles; | ||||
| int total_tasks = (buffer_lines + lines_per_task - 1) / lines_per_task; | int total_tasks = (buffer_lines + lines_per_task - 1) / lines_per_task; | ||||
| int i, start_line; | int i, start_line; | ||||
| task_pool = BLI_task_pool_create(task_scheduler, do_thread); | task_pool = BLI_task_pool_create(task_scheduler, do_thread, TASK_PRIORITY_LOW); | ||||
| handles = MEM_callocN(handle_size * total_tasks, "processor apply threaded handles"); | handles = MEM_callocN(handle_size * total_tasks, "processor apply threaded handles"); | ||||
| start_line = 0; | start_line = 0; | ||||
| for (i = 0; i < total_tasks; i++) { | for (i = 0; i < total_tasks; i++) { | ||||
| int lines_per_current_task; | int lines_per_current_task; | ||||
| void *handle = ((char *)handles) + handle_size * i; | void *handle = ((char *)handles) + handle_size * i; | ||||
| if (i < total_tasks - 1) { | if (i < total_tasks - 1) { | ||||
| lines_per_current_task = lines_per_task; | lines_per_current_task = lines_per_task; | ||||
| } | } | ||||
| else { | else { | ||||
| lines_per_current_task = buffer_lines - start_line; | lines_per_current_task = buffer_lines - start_line; | ||||
| } | } | ||||
| init_handle(handle, start_line, lines_per_current_task, init_customdata); | init_handle(handle, start_line, lines_per_current_task, init_customdata); | ||||
| BLI_task_pool_push(task_pool, processor_apply_func, handle, false, TASK_PRIORITY_LOW); | BLI_task_pool_push(task_pool, processor_apply_func, handle, false, NULL); | ||||
| start_line += lines_per_task; | start_line += lines_per_task; | ||||
| } | } | ||||
| /* work and wait until tasks are done */ | /* work and wait until tasks are done */ | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_work_and_wait(task_pool); | ||||
| /* Free memory. */ | /* Free memory. */ | ||||
| Show All 25 Lines | void IMB_processor_apply_threaded_scanlines(int total_scanlines, | ||||
| const int scanlines_per_task = 64; | const int scanlines_per_task = 64; | ||||
| ScanlineGlobalData data; | ScanlineGlobalData data; | ||||
| data.custom_data = custom_data; | data.custom_data = custom_data; | ||||
| data.do_thread = do_thread; | data.do_thread = do_thread; | ||||
| data.scanlines_per_task = scanlines_per_task; | data.scanlines_per_task = scanlines_per_task; | ||||
| data.total_scanlines = total_scanlines; | data.total_scanlines = total_scanlines; | ||||
| const int total_tasks = (total_scanlines + scanlines_per_task - 1) / scanlines_per_task; | const int total_tasks = (total_scanlines + scanlines_per_task - 1) / scanlines_per_task; | ||||
| TaskScheduler *task_scheduler = BLI_task_scheduler_get(); | TaskScheduler *task_scheduler = BLI_task_scheduler_get(); | ||||
| TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &data); | TaskPool *task_pool = BLI_task_pool_create(task_scheduler, &data, TASK_PRIORITY_LOW); | ||||
| for (int i = 0, start_line = 0; i < total_tasks; i++) { | for (int i = 0, start_line = 0; i < total_tasks; i++) { | ||||
| BLI_task_pool_push(task_pool, | BLI_task_pool_push( | ||||
| processor_apply_scanline_func, | task_pool, processor_apply_scanline_func, POINTER_FROM_INT(start_line), false, NULL); | ||||
| POINTER_FROM_INT(start_line), | |||||
| false, | |||||
| TASK_PRIORITY_LOW); | |||||
| start_line += scanlines_per_task; | start_line += scanlines_per_task; | ||||
| } | } | ||||
| /* work and wait until tasks are done */ | /* work and wait until tasks are done */ | ||||
| BLI_task_pool_work_and_wait(task_pool); | BLI_task_pool_work_and_wait(task_pool); | ||||
| /* Free memory. */ | /* Free memory. */ | ||||
| BLI_task_pool_free(task_pool); | BLI_task_pool_free(task_pool); | ||||
| ▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines | |||||