diff --git a/source/blender/blenkernel/intern/seqprefetch.c b/source/blender/blenkernel/intern/seqprefetch.c index c1109347e76..16175be65d9 100644 --- a/source/blender/blenkernel/intern/seqprefetch.c +++ b/source/blender/blenkernel/intern/seqprefetch.c @@ -32,4 +32,5 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_anim_types.h" #include "BLI_listbase.h" @@ -230,5 +231,7 @@ static void seq_prefetch_update_area(PrefetchJob *pfjob) } -/* Use also to update scene and context changes */ +/* Use also to update scene and context changes + * This function should almost always be called by cache invalidation, not directly. + */ void BKE_sequencer_prefetch_stop(Scene *scene) { @@ -323,14 +326,25 @@ static void *seq_prefetch_frames(void *job) PrefetchJob *pfjob = (PrefetchJob *)job; - /* set to NULL before return! */ - pfjob->scene_eval->ed->prefetch_job = pfjob; - while (pfjob->cfra + pfjob->num_frames_prefetched < pfjob->scene->r.efra) { - BKE_animsys_evaluate_all_animation(pfjob->context_cpy.bmain, - pfjob->context_cpy.depsgraph, - pfjob->context_cpy.scene, - pfjob->cfra + pfjob->num_frames_prefetched); + pfjob->scene_eval->ed->prefetch_job = NULL; + seq_prefetch_update_depsgraph(pfjob); + AnimData *adt = BKE_animdata_from_id(&pfjob->context_cpy.scene->id); + BKE_animsys_evaluate_animdata(pfjob->context_cpy.scene, + &pfjob->context_cpy.scene->id, + adt, + pfjob->cfra + pfjob->num_frames_prefetched, + ADT_RECALC_ALL, + false); + + /* This is quite hacky solution: + * 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. + * Scene copy don't reference original scene. Perhaps, this could be done by depsgraph. + * Set to NULL before return! + */ + pfjob->scene_eval->ed->prefetch_job = pfjob; + ImBuf *ibuf = BKE_sequencer_give_ibuf( &pfjob->context_cpy, pfjob->cfra + pfjob->num_frames_prefetched, 0); @@ -374,6 +388,5 @@ static void *seq_prefetch_frames(void *job) static PrefetchJob *seq_prefetch_start(const SeqRenderData *context, float cfra) { - PrefetchJob *pfjob; - pfjob = seq_prefetch_job_get(context->scene); + PrefetchJob *pfjob = seq_prefetch_job_get(context->scene); if (!pfjob) {