diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-07 19:40:02 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-08 18:49:28 +0300 |
commit | ac2e23c739ab118ad1a6c516c454bc78b5cf6807 (patch) | |
tree | 4bcabac62186f422fd879aad5267b2b6774b6c0b /source | |
parent | 820a64b9e5cf9c737fd484c6794e2e22c3f66d9f (diff) |
DRW: Remove uneeded calls to drw_viewport_engine_data_ensure when iterating
This remove a bit of overhead specially in scene with lots of objects.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 18 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 1 |
2 files changed, 14 insertions, 5 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index f0d802c69e1..05fb893bec5 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -1043,9 +1043,14 @@ static void drw_engines_init(void) static void drw_engines_cache_init(void) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + int enabled_engine_count = BLI_listbase_count(&DST.enabled_engines); + DST.vedata_array = MEM_mallocN(sizeof(void *) * enabled_engine_count, __func__); + + int i = 0; + for (LinkData *link = DST.enabled_engines.first; link; link = link->next, i++) { DrawEngineType *engine = link->data; ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); + DST.vedata_array[i] = data; if (data->text_draw_cache) { DRW_text_cache_destroy(data->text_draw_cache); @@ -1087,9 +1092,10 @@ static void drw_engines_cache_populate(Object *ob) * ourselves here. */ drw_drawdata_unlink_dupli((ID *)ob); - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + int i = 0; + for (LinkData *link = DST.enabled_engines.first; link; link = link->next, i++) { DrawEngineType *engine = link->data; - ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); + ViewportEngineData *data = DST.vedata_array[i]; if (engine->id_update) { engine->id_update(data, &ob->id); @@ -1111,14 +1117,16 @@ static void drw_engines_cache_populate(Object *ob) static void drw_engines_cache_finish(void) { - for (LinkData *link = DST.enabled_engines.first; link; link = link->next) { + int i = 0; + for (LinkData *link = DST.enabled_engines.first; link; link = link->next, i++) { DrawEngineType *engine = link->data; - ViewportEngineData *data = drw_viewport_engine_data_ensure(engine); + ViewportEngineData *data = DST.vedata_array[i]; if (engine->cache_finish) { engine->cache_finish(data); } } + MEM_freeN(DST.vedata_array); } static void drw_engines_draw_background(void) diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index 77cf6d20117..6dd112e3ad7 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -364,6 +364,7 @@ typedef struct DRWManager { struct DRWTextStore **text_store_p; ListBase enabled_engines; /* RenderEngineType */ + void **vedata_array; /* ViewportEngineData */ bool buffer_finish_called; /* Avoid bad usage of DRW_render_instance_buffer_finish */ |