Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/seqprefetch.c
| Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void seq_prefetch_free_depsgraph(PrefetchJob *pfjob) | static void seq_prefetch_free_depsgraph(PrefetchJob *pfjob) | ||||
| { | { | ||||
| if (pfjob->depsgraph != NULL) { | if (pfjob->depsgraph != NULL) { | ||||
| DEG_graph_free(pfjob->depsgraph); | DEG_graph_free(pfjob->depsgraph); | ||||
| } | } | ||||
| pfjob->depsgraph = NULL; | pfjob->depsgraph = NULL; | ||||
| pfjob->scene_eval = NULL; | |||||
| } | } | ||||
| static void seq_prefetch_update_depsgraph(PrefetchJob *pfjob) | static void seq_prefetch_update_depsgraph(PrefetchJob *pfjob) | ||||
| { | { | ||||
| DEG_evaluate_on_framechange( | DEG_evaluate_on_framechange( | ||||
| pfjob->bmain_eval, pfjob->depsgraph, pfjob->cfra + pfjob->num_frames_prefetched); | pfjob->bmain_eval, pfjob->depsgraph, pfjob->cfra + pfjob->num_frames_prefetched); | ||||
| } | } | ||||
| static void seq_prefetch_init_depsgraph(PrefetchJob *pfjob) | static void seq_prefetch_init_depsgraph(PrefetchJob *pfjob) | ||||
| { | { | ||||
| Main *bmain = pfjob->bmain_eval; | Main *bmain = pfjob->bmain; | ||||
| Scene *scene = pfjob->scene; | Scene *scene = pfjob->scene; | ||||
| ViewLayer *view_layer = BKE_view_layer_default_render(scene); | ViewLayer *view_layer = BKE_view_layer_default_render(scene); | ||||
| pfjob->depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER); | pfjob->depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_RENDER); | ||||
| DEG_debug_name_set(pfjob->depsgraph, "SEQUENCER PREFETCH"); | DEG_debug_name_set(pfjob->depsgraph, "SEQUENCER PREFETCH"); | ||||
| /* Make sure there is a correct evaluated scene pointer. */ | /* Make sure there is a correct evaluated scene pointer. */ | ||||
| DEG_graph_build_for_render_pipeline(pfjob->depsgraph, bmain, scene, view_layer); | DEG_graph_build_for_render_pipeline(pfjob->depsgraph, bmain, scene, view_layer); | ||||
| /* Update immediately so we have proper evaluated scene. */ | /* Update immediately so we have proper evaluated scene. */ | ||||
| seq_prefetch_update_depsgraph(pfjob); | seq_prefetch_update_depsgraph(pfjob); | ||||
| pfjob->scene_eval = DEG_get_evaluated_scene(pfjob->depsgraph); | |||||
| pfjob->scene_eval->ed->cache_flag = 0; | |||||
| } | } | ||||
| static void seq_prefetch_update_area(PrefetchJob *pfjob) | static void seq_prefetch_update_area(PrefetchJob *pfjob) | ||||
| { | { | ||||
| int cfra = pfjob->scene->r.cfra; | int cfra = pfjob->scene->r.cfra; | ||||
| /* rebase */ | /* rebase */ | ||||
| if (cfra > pfjob->cfra) { | if (cfra > pfjob->cfra) { | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
| static void seq_prefetch_update_scene(Scene *scene) | static void seq_prefetch_update_scene(Scene *scene) | ||||
| { | { | ||||
| PrefetchJob *pfjob = seq_prefetch_job_get(scene); | PrefetchJob *pfjob = seq_prefetch_job_get(scene); | ||||
| if (!pfjob) { | if (!pfjob) { | ||||
| return; | return; | ||||
| } | } | ||||
| pfjob->scene_eval = BKE_scene_copy(pfjob->bmain_eval, pfjob->scene, SCE_COPY_FULL); | |||||
| seq_prefetch_free_depsgraph(pfjob); | seq_prefetch_free_depsgraph(pfjob); | ||||
| seq_prefetch_init_depsgraph(pfjob); | seq_prefetch_init_depsgraph(pfjob); | ||||
| pfjob->scene_eval->ed->cache_flag = 0; | |||||
| } | } | ||||
| static void seq_prefetch_resume(Scene *scene) | static void seq_prefetch_resume(Scene *scene) | ||||
| { | { | ||||
| PrefetchJob *pfjob = seq_prefetch_job_get(scene); | PrefetchJob *pfjob = seq_prefetch_job_get(scene); | ||||
| if (pfjob && pfjob->waiting) { | if (pfjob && pfjob->waiting) { | ||||
| BLI_condition_notify_one(&pfjob->prefetch_suspend_cond); | BLI_condition_notify_one(&pfjob->prefetch_suspend_cond); | ||||
| } | } | ||||
| } | } | ||||
| void BKE_sequencer_prefetch_free(Scene *scene) | void BKE_sequencer_prefetch_free(Scene *scene) | ||||
| { | { | ||||
| PrefetchJob *pfjob = seq_prefetch_job_get(scene); | PrefetchJob *pfjob = seq_prefetch_job_get(scene); | ||||
| if (!pfjob) { | if (!pfjob) { | ||||
| return; | return; | ||||
| } | } | ||||
| BKE_sequencer_prefetch_stop(scene); | BKE_sequencer_prefetch_stop(scene); | ||||
| /* bmain_eval->wm is same as bmain->wm and must not be freed. */ | |||||
| pfjob->bmain_eval->wm.first = NULL; | |||||
| pfjob->bmain_eval->wm.last = NULL; | |||||
| BLI_threadpool_remove(&pfjob->threads, pfjob); | BLI_threadpool_remove(&pfjob->threads, pfjob); | ||||
| BLI_threadpool_end(&pfjob->threads); | BLI_threadpool_end(&pfjob->threads); | ||||
| BLI_mutex_end(&pfjob->prefetch_suspend_mutex); | BLI_mutex_end(&pfjob->prefetch_suspend_mutex); | ||||
| BLI_condition_end(&pfjob->prefetch_suspend_cond); | BLI_condition_end(&pfjob->prefetch_suspend_cond); | ||||
| seq_prefetch_free_depsgraph(pfjob); | seq_prefetch_free_depsgraph(pfjob); | ||||
| BKE_main_free(pfjob->bmain_eval); | BKE_main_free(pfjob->bmain_eval); | ||||
| MEM_freeN(pfjob); | MEM_freeN(pfjob); | ||||
| scene->ed->prefetch_job = NULL; | scene->ed->prefetch_job = NULL; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | if (context->scene->ed) { | ||||
| context->scene->ed->prefetch_job = pfjob; | context->scene->ed->prefetch_job = pfjob; | ||||
| BLI_threadpool_init(&pfjob->threads, seq_prefetch_frames, 1); | BLI_threadpool_init(&pfjob->threads, seq_prefetch_frames, 1); | ||||
| BLI_mutex_init(&pfjob->prefetch_suspend_mutex); | BLI_mutex_init(&pfjob->prefetch_suspend_mutex); | ||||
| BLI_condition_init(&pfjob->prefetch_suspend_cond); | BLI_condition_init(&pfjob->prefetch_suspend_cond); | ||||
| pfjob->bmain = context->bmain; | pfjob->bmain = context->bmain; | ||||
| pfjob->bmain_eval = BKE_main_new(); | pfjob->bmain_eval = BKE_main_new(); | ||||
| pfjob->scene = context->scene; | pfjob->scene = context->scene; | ||||
| /* Needed by BKE_scene_graph_update_for_newframe() */ | |||||
| pfjob->bmain_eval->wm = pfjob->bmain->wm; | |||||
| seq_prefetch_init_depsgraph(pfjob); | seq_prefetch_init_depsgraph(pfjob); | ||||
| } | } | ||||
| } | } | ||||
| seq_prefetch_update_scene(context->scene); | seq_prefetch_update_scene(context->scene); | ||||
| seq_prefetch_update_context(context); | seq_prefetch_update_context(context); | ||||
| pfjob->cfra = cfra; | pfjob->cfra = cfra; | ||||
| pfjob->num_frames_prefetched = 1; | pfjob->num_frames_prefetched = 1; | ||||
| ▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines | |||||