diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-30 01:36:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-30 14:43:34 +0300 |
commit | 7cdd5ed7bd228d46b5eecc3355b01d00f26d1ca2 (patch) | |
tree | ae4956f14f3718b27fea8b11a961482ba0d63305 /source/blender/draw/intern/draw_manager.c | |
parent | 9f2e154e020999263b17db5345111eba5fed9a90 (diff) |
DRW: Add unit_state to avoid lots of DRWCallState duplication
A lot of drawcalls don't use the object's properties and don't
need a dedicated DRWCallState. We allocate a unique one at
the begining and use it for all calls that uses the default
unit matrix.
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 8897d14c5fd..bfb38a12fa9 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -587,6 +587,29 @@ static void drw_context_state_init(void) } } +static DRWCallState *draw_unit_state_create(void) +{ + DRWCallState *state = BLI_memblock_alloc(DST.vmempool->states); + state->flag = 0; + state->matflag = 0; + + unit_m4(state->model); + unit_m4(state->modelinverse); + + copy_v3_fl(state->orcotexfac[0], 0.0f); + copy_v3_fl(state->orcotexfac[1], 1.0f); + + state->ob_index = 0; + state->ob_random = 0.0f; + + /* TODO(fclem) get rid of this. */ + state->culling = BLI_memblock_alloc(DST.vmempool->cullstates); + state->culling->bsphere.radius = -1.0f; + state->culling->user_data = NULL; + + return state; +} + /* It also stores viewport variable to an immutable place: DST * This is because a cache uniform only store reference * to its value. And we don't want to invalidate the cache @@ -634,6 +657,9 @@ static void drw_viewport_var_init(void) DST.vmempool->images = BLI_memblock_create(sizeof(GPUTexture *)); } + /* Alloc default unit state */ + DST.unit_state = draw_unit_state_create(); + DST.idatalist = GPU_viewport_instance_data_list_get(DST.viewport); DRW_instance_data_list_reset(DST.idatalist); } @@ -646,6 +672,8 @@ static void drw_viewport_var_init(void) DST.default_framebuffer = NULL; DST.vmempool = NULL; + + DST.unit_state = NULL; } DST.primary_view_ct = 0; |