Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/render/render_opengl.c
| Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | typedef struct OGLRender { | ||||
| /* wm vars for timer and progress cursor */ | /* wm vars for timer and progress cursor */ | ||||
| wmWindowManager *wm; | wmWindowManager *wm; | ||||
| wmWindow *win; | wmWindow *win; | ||||
| wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/ | wmTimer *timer; /* use to check if running modal or not (invoke'd or exec'd)*/ | ||||
| void **movie_ctx_arr; | void **movie_ctx_arr; | ||||
| TaskScheduler *task_scheduler; | |||||
| TaskPool *task_pool; | TaskPool *task_pool; | ||||
| bool pool_ok; | bool pool_ok; | ||||
| bool is_animation; | bool is_animation; | ||||
| eImageFormatDepth color_depth; | eImageFormatDepth color_depth; | ||||
| SpinLock reports_lock; | SpinLock reports_lock; | ||||
| uint num_scheduled_frames; | uint num_scheduled_frames; | ||||
| ThreadMutex task_mutex; | ThreadMutex task_mutex; | ||||
| ▲ Show 20 Lines • Show All 695 Lines • ▼ Show 20 Lines | static bool screen_opengl_render_init(bContext *C, wmOperator *op) | ||||
| oglrender->mh = NULL; | oglrender->mh = NULL; | ||||
| oglrender->movie_ctx_arr = NULL; | oglrender->movie_ctx_arr = NULL; | ||||
| if (is_animation) { | if (is_animation) { | ||||
| if (is_render_keyed_only) { | if (is_render_keyed_only) { | ||||
| gather_frames_to_render(C, oglrender); | gather_frames_to_render(C, oglrender); | ||||
| } | } | ||||
| TaskScheduler *task_scheduler = BLI_task_scheduler_get(); | |||||
| if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { | if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { | ||||
| task_scheduler = BLI_task_scheduler_create(1); | oglrender->task_pool = BLI_task_pool_create_background_serial(oglrender, TASK_PRIORITY_LOW); | ||||
| oglrender->task_scheduler = task_scheduler; | |||||
| oglrender->task_pool = BLI_task_pool_create_background( | |||||
| task_scheduler, oglrender, TASK_PRIORITY_LOW); | |||||
| } | } | ||||
| else { | else { | ||||
| oglrender->task_scheduler = NULL; | oglrender->task_pool = BLI_task_pool_create(oglrender, TASK_PRIORITY_LOW); | ||||
| oglrender->task_pool = BLI_task_pool_create(task_scheduler, oglrender, TASK_PRIORITY_LOW); | |||||
| } | } | ||||
| oglrender->pool_ok = true; | oglrender->pool_ok = true; | ||||
| BLI_spin_init(&oglrender->reports_lock); | BLI_spin_init(&oglrender->reports_lock); | ||||
| } | } | ||||
| else { | else { | ||||
| oglrender->task_scheduler = NULL; | |||||
| oglrender->task_pool = NULL; | oglrender->task_pool = NULL; | ||||
| } | } | ||||
| oglrender->num_scheduled_frames = 0; | oglrender->num_scheduled_frames = 0; | ||||
| BLI_mutex_init(&oglrender->task_mutex); | BLI_mutex_init(&oglrender->task_mutex); | ||||
| BLI_condition_init(&oglrender->task_condition); | BLI_condition_init(&oglrender->task_condition); | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| oglrender->time_start = PIL_check_seconds_timer(); | oglrender->time_start = PIL_check_seconds_timer(); | ||||
| Show All 22 Lines | if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { | ||||
| BLI_mutex_lock(&oglrender->task_mutex); | BLI_mutex_lock(&oglrender->task_mutex); | ||||
| while (oglrender->num_scheduled_frames > 0) { | while (oglrender->num_scheduled_frames > 0) { | ||||
| BLI_condition_wait(&oglrender->task_condition, &oglrender->task_mutex); | BLI_condition_wait(&oglrender->task_condition, &oglrender->task_mutex); | ||||
| } | } | ||||
| BLI_mutex_unlock(&oglrender->task_mutex); | BLI_mutex_unlock(&oglrender->task_mutex); | ||||
| } | } | ||||
| BLI_task_pool_work_and_wait(oglrender->task_pool); | BLI_task_pool_work_and_wait(oglrender->task_pool); | ||||
| BLI_task_pool_free(oglrender->task_pool); | BLI_task_pool_free(oglrender->task_pool); | ||||
| /* Depending on various things we might or might not use global scheduler. */ | |||||
| if (oglrender->task_scheduler != NULL) { | |||||
| BLI_task_scheduler_free(oglrender->task_scheduler); | |||||
| } | |||||
| BLI_spin_end(&oglrender->reports_lock); | BLI_spin_end(&oglrender->reports_lock); | ||||
| } | } | ||||
| BLI_mutex_end(&oglrender->task_mutex); | BLI_mutex_end(&oglrender->task_mutex); | ||||
| BLI_condition_end(&oglrender->task_condition); | BLI_condition_end(&oglrender->task_condition); | ||||
| #ifdef DEBUG_TIME | #ifdef DEBUG_TIME | ||||
| printf("Total render time: %f\n", PIL_check_seconds_timer() - oglrender->time_start); | printf("Total render time: %f\n", PIL_check_seconds_timer() - oglrender->time_start); | ||||
| #endif | #endif | ||||
| ▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | static bool screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) | ||||
| return true; | return true; | ||||
| } | } | ||||
| typedef struct WriteTaskData { | typedef struct WriteTaskData { | ||||
| RenderResult *rr; | RenderResult *rr; | ||||
| Scene tmp_scene; | Scene tmp_scene; | ||||
| } WriteTaskData; | } WriteTaskData; | ||||
| static void write_result_func(TaskPool *__restrict pool, void *task_data_v, int UNUSED(thread_id)) | static void write_result_func(TaskPool *__restrict pool, void *task_data_v) | ||||
| { | { | ||||
| OGLRender *oglrender = (OGLRender *)BLI_task_pool_user_data(pool); | OGLRender *oglrender = (OGLRender *)BLI_task_pool_user_data(pool); | ||||
| WriteTaskData *task_data = (WriteTaskData *)task_data_v; | WriteTaskData *task_data = (WriteTaskData *)task_data_v; | ||||
| Scene *scene = &task_data->tmp_scene; | Scene *scene = &task_data->tmp_scene; | ||||
| RenderResult *rr = task_data->rr; | RenderResult *rr = task_data->rr; | ||||
| const bool is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype); | const bool is_movie = BKE_imtype_is_movie(scene->r.im_format.imtype); | ||||
| const int cfra = scene->r.cfra; | const int cfra = scene->r.cfra; | ||||
| bool ok; | bool ok; | ||||
| ▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines | |||||