Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/imageprocess.c
| Show First 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | void IMB_processor_apply_threaded( | ||||
| const int lines_per_task = 64; | const int lines_per_task = 64; | ||||
| 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(do_thread, TASK_PRIORITY_LOW); | task_pool = BLI_task_pool_create(do_thread, TASK_PRIORITY_LOW, TASK_ISOLATION_ON); | ||||
| 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; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| 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; | ||||
| TaskPool *task_pool = BLI_task_pool_create(&data, TASK_PRIORITY_LOW); | TaskPool *task_pool = BLI_task_pool_create(&data, TASK_PRIORITY_LOW, TASK_ISOLATION_ON); | ||||
| 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( | BLI_task_pool_push( | ||||
| task_pool, processor_apply_scanline_func, POINTER_FROM_INT(start_line), false, NULL); | task_pool, processor_apply_scanline_func, POINTER_FROM_INT(start_line), false, NULL); | ||||
| 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); | ||||
| ▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines | |||||