Commit: 337cac760ba9d198fc45459f4274a94a87558528 Author: Richard Antalik Date: Sun Apr 28 14:13:41 2019 -0700 Branches: master https://developer.blender.org/rB337cac760ba9d198fc45459f4274a94a87558528
VSE: Cache rewrite This patch implements new cache system. Aim is to give user more control over cache, so it can be maximally utilized. This is done through sequencer timeline side panel in category proxy & cache. Cached images are also visualized in timeline, controled by sequencer timeline view->cache menu Functional changes: - NOT use IMB_moviecache API - refactor names of cached image types - each scene owns 1 sequencer cache - merge preprocess cache into per-sequencer cache - cache links images rendered per frame in order as they are created - add cache content visualization tool - add RNA properties to control the cache More info can be found in design notes in blenkernel/intern/seqcache.c and in https://developer.blender.org/D4443 Reviewed By: brecht Differential Revision: https://developer.blender.org/D4443 =================================================================== M release/scripts/startup/bl_ui/space_sequencer.py M source/blender/blenkernel/BKE_blender_version.h M source/blender/blenkernel/BKE_sequencer.h M source/blender/blenkernel/intern/blender.c M source/blender/blenkernel/intern/seqcache.c M source/blender/blenkernel/intern/sequencer.c M source/blender/blenloader/intern/readfile.c M source/blender/blenloader/intern/versioning_280.c M source/blender/editors/render/render_internal.c M source/blender/editors/space_sequencer/sequencer_draw.c M source/blender/editors/space_sequencer/space_sequencer.c M source/blender/editors/transform/transform_generics.c M source/blender/imbuf/IMB_imbuf.h M source/blender/imbuf/intern/allocimbuf.c M source/blender/imbuf/intern/moviecache.c M source/blender/makesdna/DNA_sequence_types.h M source/blender/makesrna/intern/rna_camera.c M source/blender/makesrna/intern/rna_color.c M source/blender/makesrna/intern/rna_scene.c M source/blender/makesrna/intern/rna_sequencer.c =================================================================== diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 87ebf365a1e..bd3eb2bc304 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -159,6 +159,25 @@ class SEQUENCER_MT_view_toggle(Menu): layout.operator("sequencer.view_toggle").type = 'SEQUENCER_PREVIEW' +class SEQUENCER_MT_view_cache(Menu): + bl_label = "Cache" + + def draw(self, context): + layout = self.layout + + ed = context.scene.sequence_editor + layout.prop(ed, "show_cache") + layout.separator() + + col = layout.column() + col.enabled = ed.show_cache + + col.prop(ed, "show_cache_final_out") + col.prop(ed, "show_cache_raw") + col.prop(ed, "show_cache_preprocessed") + col.prop(ed, "show_cache_composite") + + class SEQUENCER_MT_view(Menu): bl_label = "View" @@ -212,6 +231,7 @@ class SEQUENCER_MT_view(Menu): layout.prop(st, "show_frame_indicator") layout.prop(st, "show_strip_offset") layout.prop(st, "show_marker_lines") + layout.menu("SEQUENCER_MT_view_cache") layout.prop_menu_enum(st, "waveform_display_type") @@ -1145,9 +1165,29 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): layout.prop(strip, "use_float", text="Convert to Float") +class SEQUENCER_PT_cache_settings(SequencerButtonsPanel, Panel): + bl_label = "Cache Settings" + bl_category = "Proxy & Cache" + + @classmethod + def poll(cls, context): + return cls.has_sequencer(context) + + def draw(self, context): + layout = self.layout + ed = context.scene.sequence_editor + + layout.prop(ed, "cache_raw") + layout.prop(ed, "cache_preprocessed") + layout.prop(ed, "cache_composite") + layout.prop(ed, "cache_final") + layout.separator() + layout.prop(ed, "recycle_max_cost") + + class SEQUENCER_PT_proxy_settings(SequencerButtonsPanel, Panel): - bl_label = "Proxy settings" - bl_category = "Proxy" + bl_label = "Proxy Settings" + bl_category = "Proxy & Cache" @classmethod def poll(cls, context): return cls.has_sequencer(context) @@ -1168,8 +1208,8 @@ class SEQUENCER_PT_proxy_settings(SequencerButtonsPanel, Panel): class SEQUENCER_PT_strip_proxy(SequencerButtonsPanel, Panel): - bl_label = "Strip Proxy/Timecode" - bl_category = "Proxy" + bl_label = "Strip Proxy & Timecode" + bl_category = "Proxy & Cache" @classmethod def poll(cls, context): @@ -1225,8 +1265,33 @@ class SEQUENCER_PT_strip_proxy(SequencerButtonsPanel, Panel): col.prop(proxy, "timecode") +class SEQUENCER_PT_strip_cache(SequencerButtonsPanel, Panel): + bl_label = "Strip Cache" + bl_category = "Proxy & Cache" + + @classmethod + def poll(cls, context): + if not cls.has_sequencer(context): + return False + if act_strip(context) is not None: + return True + + def draw_header(self, context): + strip = act_strip(context) + self.layout.prop(strip, "override_cache_settings", text="") + + def draw(self, context): + layout = self.layout + strip = act_strip(context) + layout.active = strip.override_cache_settings + + layout.prop(strip, "cache_raw") + layout.prop(strip, "cache_preprocessed") + layout.prop(strip, "cache_composite") + + class SEQUENCER_PT_preview(SequencerButtonsPanel_Output, Panel): - bl_label = "Scene Preview/Render" + bl_label = "Scene Preview & Render" bl_space_type = 'SEQUENCE_EDITOR' bl_region_type = 'UI' bl_category = "Strip" @@ -1411,6 +1476,7 @@ classes = ( SEQUENCER_HT_header, SEQUENCER_MT_editor_menus, SEQUENCER_MT_view, + SEQUENCER_MT_view_cache, SEQUENCER_MT_view_toggle, SEQUENCER_MT_select, SEQUENCER_MT_marker, @@ -1430,8 +1496,10 @@ classes = ( SEQUENCER_PT_scene, SEQUENCER_PT_mask, SEQUENCER_PT_filter, + SEQUENCER_PT_cache_settings, SEQUENCER_PT_proxy_settings, SEQUENCER_PT_strip_proxy, + SEQUENCER_PT_strip_cache, SEQUENCER_PT_preview, SEQUENCER_PT_view, SEQUENCER_PT_view_safe_areas, diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 16655d9b060..e01f6a6b751 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ * \note Use #STRINGIFY() rather than defining with quotes. */ #define BLENDER_VERSION 280 -#define BLENDER_SUBVERSION 59 +#define BLENDER_SUBVERSION 60 /** Several breakages with 280, e.g. collections vs layers. */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 820f28fb363..5485b2d3619 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -302,46 +302,33 @@ void BKE_sequencer_proxy_set(struct Sequence *seq, bool value); * Sequencer memory cache management functions * ********************************************************************** */ -typedef enum { - SEQ_STRIPELEM_IBUF, - SEQ_STRIPELEM_IBUF_COMP, - SEQ_STRIPELEM_IBUF_STARTSTILL, - SEQ_STRIPELEM_IBUF_ENDSTILL, -} eSeqStripElemIBuf; +#define SEQ_CACHE_COST_MAX 10.0f -void BKE_sequencer_cache_destruct(void); -void BKE_sequencer_cache_cleanup(void); - -/* returned ImBuf is properly refed and has to be freed */ struct ImBuf *BKE_sequencer_cache_get(const SeqRenderData *context, struct Sequence *seq, float cfra, - eSeqStripElemIBuf type); - -/* passed ImBuf is properly refed, so ownership is *not* - * transferred to the cache. - * you can pass the same ImBuf multiple times to the cache without problems. - */ - + int type); void BKE_sequencer_cache_put(const SeqRenderData *context, struct Sequence *seq, float cfra, - eSeqStripElemIBuf type, - struct ImBuf *nval); - -void BKE_sequencer_cache_cleanup_sequence(struct Sequence *seq); - -struct ImBuf *BKE_sequencer_preprocessed_cache_get(const SeqRenderData *context, - struct Sequence *seq, - float cfra, - eSeqStripElemIBuf type); -void BKE_sequencer_preprocessed_cache_put(const SeqRenderData *context, - struct Sequence *seq, - float cfra, - eSeqStripElemIBuf type, - struct ImBuf *ibuf); -void BKE_sequencer_preprocessed_cache_cleanup(void); -void BKE_sequencer_preprocessed_cache_cleanup_sequence(struct Sequence *seq); + int type, + struct ImBuf *nval, + float cost); +bool BKE_sequencer_cache_put_if_possible(const SeqRenderData *context, + struct Sequence *seq, + float cfra, + int type, + struct ImBuf *nval, + float cost); +void BKE_sequencer_cache_free_temp_cache(struct Scene *scene, short id, int cfra); +void BKE_sequencer_cache_destruct(struct Scene *scene); +void BKE_sequencer_cache_cleanup_all(struct Main *bmain); +void BKE_sequencer_cache_cleanup(struct Scene *scene); +void BKE_sequencer_cache_cleanup_sequence(struct Scene *scene, struct Sequence *seq); +void BKE_sequencer_cache_iterate( + struct Scene *scene, + void *userdata, + bool callback(void *userdata, struct Sequence *seq, int cfra, int cache_type, float cost)); /* ********************************************************************** * seqeffects.c diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d6599498a65..48b271cf277 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -97,7 +97,6 @@ void BKE_blender_free(void) BLI_callback_global_finalize(); - BKE_sequencer_cache_destruct(); IMB_moviecache_destruct(); free_nodesystem(); diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index b022819ca8c..c50f3f3f141 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -21,49 +21,84 @@ */ #include <stddef.h> - -#include "BLI_sys_types.h" /* for intptr_t */ +#include <memory.h> #include "MEM_guardedalloc.h" #include "DNA_sequence_types.h" #include "DNA_scene_types.h" -#include "IMB_moviecache.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "BLI_mempool.h" +#include "BLI_threads.h" #include "BLI_listbase.h" +#include "BLI_ghash.h" #include "BKE_sequencer.h" #include "BKE_scene.h" +#include "BKE_main.h" + +/* ***************************** Sequencer cache design notes ****************************** + * + * Cache key members: + * is_temp_cache - this cache entry will be freed before rendering next frame + * creator_id - ID of thread that created entry + * cost - In short: render time divided by playback frame rate + * link_prev/next - link to another entry created during rendering of the frame + * + * Linking: We use links to reduce number of iterations needed to manage cache. + * Entries are linked in order as they are put into cache. + * Only pernament (is_temp_cache = 0) cache entries are linked. + * Putting SEQ_CACHE_STORE_FINAL_OUT will reset linking + * + * Function: + * All images created during rendering are added to cache, even if the cache is already full. + * @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs