diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2020-01-27 18:39:18 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2020-01-27 18:39:18 +0300 |
commit | f652e38b3710cf3088fe5cbb75cdeb8e6c1564d2 (patch) | |
tree | fb91e76a1ee71ad1311e78ceed4d9c8976883c67 | |
parent | d2de88f47b7c35aa4fc667ddc97365f73f3cbc07 (diff) |
Avoid own global variable, use existing DRWManager structtemp-gizmo-decoupled-redraws
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 4 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_layer.c | 17 |
2 files changed, 12 insertions, 9 deletions
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 7e1b031f662..60a1ddc1b01 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -534,6 +534,10 @@ typedef struct DRWManager { GPUDrawList *draw_list; + /* Global storage of draw-layers which may cache framebuffers for later reuse. Allows decoupled + * redraws of individual layers. */ + GHash *layers_hash; /* DRWLayer * */ + /** GPU Resource State: Memory storage between drawing. */ struct { /* High end GPUs supports up to 32 binds per shader stage. diff --git a/source/blender/draw/intern/draw_manager_layer.c b/source/blender/draw/intern/draw_manager_layer.c index 8953b0a29b7..d4e18d186c6 100644 --- a/source/blender/draw/intern/draw_manager_layer.c +++ b/source/blender/draw/intern/draw_manager_layer.c @@ -43,8 +43,6 @@ typedef struct DRWLayer { } cache; } DRWLayer; -static GHash *DRW_layers_hash = NULL; - /** * If a layer never skips redrawing, it doesn't make sense to keep its framebuffer attachements * cached, they just take up GPU memory. @@ -132,15 +130,15 @@ static bool drw_layer_needs_cache_update(const DRWLayer *layer) static DRWLayer *drw_layer_for_type_ensure(const DRWLayerType *type) { - if (DRW_layers_hash == NULL) { - DRW_layers_hash = BLI_ghash_ptr_new_ex("DRW_layers_hash", DRW_layer_types_count); + if (DST.layers_hash == NULL) { + DST.layers_hash = BLI_ghash_ptr_new_ex("DRW_layers_hash", DRW_layer_types_count); } - DRWLayer *layer = BLI_ghash_lookup(DRW_layers_hash, type); + DRWLayer *layer = BLI_ghash_lookup(DST.layers_hash, type); if (!layer) { layer = drw_layer_create(type, DST.viewport); - BLI_ghash_insert(DRW_layers_hash, (void *)type, layer); + BLI_ghash_insert(DST.layers_hash, (void *)type, layer); } /* Could reinsert layer at tail here, so that the next layer to be drawn is likely first in the @@ -151,8 +149,9 @@ static DRWLayer *drw_layer_for_type_ensure(const DRWLayerType *type) void DRW_layers_free(void) { - if (DRW_layers_hash) { - BLI_ghash_free(DRW_layers_hash, NULL, drw_layer_free_cb); + if (DST.layers_hash) { + BLI_ghash_free(DST.layers_hash, NULL, drw_layer_free_cb); + DST.layers_hash = NULL; } } @@ -183,7 +182,7 @@ void DRW_layers_draw_combined_cached(void) /* Store if poll succeeded, to avoid calling it twice. */ bool *is_layer_visible = BLI_array_alloca(is_layer_visible, DRW_layer_types_count); - BLI_assert(!DRW_layers_hash || (DRW_layer_types_count >= BLI_ghash_len(DRW_layers_hash))); + BLI_assert(!DST.layers_hash || (DRW_layer_types_count >= BLI_ghash_len(DST.layers_hash))); GPU_framebuffer_bind(DST.default_framebuffer); DRW_clear_background(); |