Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/seqprefetch.c
| Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | void BKE_sequencer_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) | |||||
| { | |||||
| Editing *ed = scene->ed; | |||||
| PrefetchJob *pfjob = seq_prefetch_job_get(scene); | |||||
| float cfra = pfjob->cfra + pfjob->num_frames_prefetched; | |||||
| Sequence *seq_arr[MAXSEQ + 1]; | |||||
| int count = BKE_sequencer_get_shown_sequences(ed->seqbasep, cfra, 0, seq_arr); | |||||
| /* Disable prefetching 3D scene strips, but check for disk cache. */ | |||||
| for (int i = 0; i < count; i++) { | |||||
| if (seq_arr[i]->type == SEQ_TYPE_SCENE && (seq_arr[i]->flag & SEQ_SCENE_STRIPS) == 0) { | |||||
| int cached_types = 0; | |||||
| SeqRenderData *ctx = &pfjob->context_cpy; | |||||
| if (BKE_sequencer_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_FINAL_OUT, false)) { | |||||
| cached_types |= SEQ_CACHE_STORE_FINAL_OUT; | |||||
| } | |||||
| if (BKE_sequencer_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_FINAL_OUT, false)) { | |||||
| cached_types |= SEQ_CACHE_STORE_COMPOSITE; | |||||
| } | |||||
| if (BKE_sequencer_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_PREPROCESSED, false)) { | |||||
| cached_types |= SEQ_CACHE_STORE_PREPROCESSED; | |||||
| } | |||||
| if (BKE_sequencer_cache_get(ctx, seq_arr[i], cfra, SEQ_CACHE_STORE_RAW, false)) { | |||||
| cached_types |= SEQ_CACHE_STORE_RAW; | |||||
| } | |||||
| if ((cached_types & SEQ_CACHE_STORE_RAW | SEQ_CACHE_STORE_PREPROCESSED) != 0) { | |||||
| continue; | |||||
| } | |||||
| /* It is only safe to use these cache types if strip is last in stack. */ | |||||
| if (i == count - 1 && | |||||
| (cached_types & SEQ_CACHE_STORE_PREPROCESSED | SEQ_CACHE_STORE_RAW) == 0) { | |||||
| continue; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| static void *seq_prefetch_frames(void *job) | static void *seq_prefetch_frames(void *job) | ||||
| { | { | ||||
| PrefetchJob *pfjob = (PrefetchJob *)job; | PrefetchJob *pfjob = (PrefetchJob *)job; | ||||
| while (pfjob->cfra + pfjob->num_frames_prefetched <= pfjob->scene->r.efra) { | while (pfjob->cfra + pfjob->num_frames_prefetched <= pfjob->scene->r.efra) { | ||||
| pfjob->scene_eval->ed->prefetch_job = NULL; | pfjob->scene_eval->ed->prefetch_job = NULL; | ||||
| seq_prefetch_update_depsgraph(pfjob); | seq_prefetch_update_depsgraph(pfjob); | ||||
| AnimData *adt = BKE_animdata_from_id(&pfjob->context_cpy.scene->id); | AnimData *adt = BKE_animdata_from_id(&pfjob->context_cpy.scene->id); | ||||
| BKE_animsys_evaluate_animdata(&pfjob->context_cpy.scene->id, | BKE_animsys_evaluate_animdata(&pfjob->context_cpy.scene->id, | ||||
| adt, | adt, | ||||
| pfjob->cfra + pfjob->num_frames_prefetched, | pfjob->cfra + pfjob->num_frames_prefetched, | ||||
| ADT_RECALC_ALL, | ADT_RECALC_ALL, | ||||
| false); | false); | ||||
| /* 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)) { | |||||
| pfjob->num_frames_prefetched++; | |||||
| continue; | |||||
| } | |||||
| ImBuf *ibuf = BKE_sequencer_give_ibuf( | ImBuf *ibuf = BKE_sequencer_give_ibuf( | ||||
| &pfjob->context_cpy, pfjob->cfra + pfjob->num_frames_prefetched, 0); | &pfjob->context_cpy, pfjob->cfra + pfjob->num_frames_prefetched, 0); | ||||
| BKE_sequencer_cache_free_temp_cache( | BKE_sequencer_cache_free_temp_cache( | ||||
| pfjob->scene, pfjob->context.task_id, pfjob->cfra + pfjob->num_frames_prefetched); | pfjob->scene, pfjob->context.task_id, pfjob->cfra + pfjob->num_frames_prefetched); | ||||
| IMB_freeImBuf(ibuf); | IMB_freeImBuf(ibuf); | ||||
| /* suspend thread */ | /* suspend thread */ | ||||
| BLI_mutex_lock(&pfjob->prefetch_suspend_mutex); | BLI_mutex_lock(&pfjob->prefetch_suspend_mutex); | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||