Changeset View
Changeset View
Standalone View
Standalone View
source/blender/sequencer/intern/prefetch.c
| Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "DEG_depsgraph_debug.h" | #include "DEG_depsgraph_debug.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "SEQ_prefetch.h" | #include "SEQ_prefetch.h" | ||||
| #include "SEQ_render.h" | #include "SEQ_render.h" | ||||
| #include "SEQ_sequencer.h" | |||||
| #include "image_cache.h" | #include "image_cache.h" | ||||
| #include "prefetch.h" | #include "prefetch.h" | ||||
| #include "render.h" | #include "render.h" | ||||
| typedef struct PrefetchJob { | typedef struct PrefetchJob { | ||||
| struct PrefetchJob *next, *prev; | struct PrefetchJob *next, *prev; | ||||
| ▲ Show 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | void seq_prefetch_free(Scene *scene) | ||||
| 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; | ||||
| } | } | ||||
| static bool seq_prefetch_do_skip_frame(Scene *scene) | /* Skip frame if we need to render 3D scene strip. Rendering 3D scene requires main lock or setting | ||||
| * up render job that doesn't have API to do openGL renders which can be used for sequencer. */ | |||||
| static bool seq_prefetch_do_skip_frame(PrefetchJob *pfjob, ListBase *seqbase) | |||||
| { | { | ||||
| Editing *ed = scene->ed; | |||||
| PrefetchJob *pfjob = seq_prefetch_job_get(scene); | |||||
| float cfra = seq_prefetch_cfra(pfjob); | float cfra = seq_prefetch_cfra(pfjob); | ||||
| Sequence *seq_arr[MAXSEQ + 1]; | Sequence *seq_arr[MAXSEQ + 1]; | ||||
| int count = seq_get_shown_sequences(ed->seqbasep, cfra, 0, seq_arr); | int count = seq_get_shown_sequences(seqbase, cfra, 0, seq_arr); | ||||
| SeqRenderData *ctx = &pfjob->context_cpy; | SeqRenderData *ctx = &pfjob->context_cpy; | ||||
| ImBuf *ibuf = NULL; | ImBuf *ibuf = NULL; | ||||
| /* Disable prefetching 3D scene strips, but check for disk cache. */ | /* Disable prefetching 3D scene strips, but check for disk cache. */ | ||||
| for (int i = 0; i < count; i++) { | for (int i = 0; i < count; i++) { | ||||
| if (seq_arr[i]->type == SEQ_TYPE_META && | |||||
| seq_prefetch_do_skip_frame(pfjob, &seq_arr[i]->seqbase)) { | |||||
| return true; | |||||
| } | |||||
| if (seq_arr[i]->type == SEQ_TYPE_SCENE && (seq_arr[i]->flag & SEQ_SCENE_STRIPS) == 0) { | if (seq_arr[i]->type == SEQ_TYPE_SCENE && (seq_arr[i]->flag & SEQ_SCENE_STRIPS) == 0) { | ||||
| int cached_types = 0; | int cached_types = 0; | ||||
| ibuf = seq_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_FINAL_OUT, false); | ibuf = seq_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_FINAL_OUT, false); | ||||
| if (ibuf != NULL) { | if (ibuf != NULL) { | ||||
| cached_types |= SEQ_CACHE_STORE_FINAL_OUT; | cached_types |= SEQ_CACHE_STORE_FINAL_OUT; | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| ibuf = NULL; | ibuf = NULL; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | while (seq_prefetch_cfra(pfjob) <= pfjob->scene->r.efra) { | ||||
| /* This is quite hacky solution: | /* This is quite hacky solution: | ||||
| * We need cross-reference original scene with copy for cache. | * We need cross-reference original scene with copy for cache. | ||||
| * However depsgraph must not have this data, because it will try to kill this job. | * However depsgraph must not have this data, because it will try to kill this job. | ||||
| * Scene copy don't reference original scene. Perhaps, this could be done by depsgraph. | * Scene copy don't reference original scene. Perhaps, this could be done by depsgraph. | ||||
| * Set to NULL before return! | * Set to NULL before return! | ||||
| */ | */ | ||||
| pfjob->scene_eval->ed->prefetch_job = pfjob; | pfjob->scene_eval->ed->prefetch_job = pfjob; | ||||
| if (seq_prefetch_do_skip_frame(pfjob->scene)) { | ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(pfjob->scene, false)); | ||||
| if (seq_prefetch_do_skip_frame(pfjob, seqbase)) { | |||||
| pfjob->num_frames_prefetched++; | pfjob->num_frames_prefetched++; | ||||
| continue; | continue; | ||||
| } | } | ||||
| ImBuf *ibuf = SEQ_render_give_ibuf(&pfjob->context_cpy, seq_prefetch_cfra(pfjob), 0); | ImBuf *ibuf = SEQ_render_give_ibuf(&pfjob->context_cpy, seq_prefetch_cfra(pfjob), 0); | ||||
| seq_cache_free_temp_cache(pfjob->scene, pfjob->context.task_id, seq_prefetch_cfra(pfjob)); | seq_cache_free_temp_cache(pfjob->scene, pfjob->context.task_id, seq_prefetch_cfra(pfjob)); | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| ▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines | |||||