diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-03-26 21:13:34 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-03-27 15:01:47 +0300 |
commit | deda6a43fc710f30ceb9e3b30d1f8d79180fe8d1 (patch) | |
tree | cbe8c10668a697b47e5cbc219fef05ce24bceb60 /source/blender/draw/modes/edit_lattice_mode.c | |
parent | 7ee41920fa0b7ed51a03fe4ee15c6fd782d294a8 (diff) |
Draw Engines: Make g_data struct part of the viewport storage
This makes viewport cache construction independant from each others and will allow multithread down the road.
Diffstat (limited to 'source/blender/draw/modes/edit_lattice_mode.c')
-rw-r--r-- | source/blender/draw/modes/edit_lattice_mode.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/source/blender/draw/modes/edit_lattice_mode.c b/source/blender/draw/modes/edit_lattice_mode.c index 32862ca444c..27ea05650cb 100644 --- a/source/blender/draw/modes/edit_lattice_mode.c +++ b/source/blender/draw/modes/edit_lattice_mode.c @@ -76,6 +76,7 @@ typedef struct EDIT_LATTICE_StorageList { * free with MEM_freeN() when viewport is freed. * (not per object) */ struct CustomStruct *block; + struct g_data *g_data; } EDIT_LATTICE_StorageList; typedef struct EDIT_LATTICE_Data { @@ -99,16 +100,11 @@ static struct { struct GPUShader *custom_shader; } e_data = {NULL}; /* Engine data */ -static struct { +typedef struct g_data { /* This keeps the references of the shading groups for * easy access in EDIT_LATTICE_cache_populate() */ DRWShadingGroup *group; - - /* This keeps the reference of the viewport engine data because - * DRW_viewport_engine_data_get is slow and we don't want to - * call it for every object */ - EDIT_LATTICE_Data *vedata; -} g_data = {NULL}; /* Transient data */ +} g_data; /* Transient data */ /* *********** FUNCTIONS *********** */ @@ -117,7 +113,6 @@ static struct { * (Optional) */ static void EDIT_LATTICE_engine_init(void *vedata) { - EDIT_LATTICE_TextureList *txl = ((EDIT_LATTICE_Data *)vedata)->txl; EDIT_LATTICE_FramebufferList *fbl = ((EDIT_LATTICE_Data *)vedata)->fbl; EDIT_LATTICE_StorageList *stl = ((EDIT_LATTICE_Data *)vedata)->stl; @@ -148,11 +143,13 @@ static void EDIT_LATTICE_engine_init(void *vedata) * Assume that all Passes are NULL */ static void EDIT_LATTICE_cache_init(void *vedata) { - EDIT_LATTICE_PassList *psl = ((EDIT_LATTICE_Data *)vedata)->psl; EDIT_LATTICE_StorageList *stl = ((EDIT_LATTICE_Data *)vedata)->stl; - UNUSED_VARS(stl); + if (!stl->g_data) { + /* Alloc transient pointers */ + stl->g_data = MEM_mallocN(sizeof(g_data), "g_data"); + } { /* Create a pass */ @@ -161,16 +158,16 @@ static void EDIT_LATTICE_cache_init(void *vedata) /* Create a shadingGroup using a function in draw_common.c or custom one */ /* - * g_data.group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire); + * stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire); * -- or -- - * g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass); + * stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass); */ - g_data.group = DRW_shgroup_create(e_data.custom_shader, psl->pass); + stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass); /* Uniforms need a pointer to it's value so be sure it's accessible at * any given time (i.e. use static vars) */ static float color[4] = {1.0f, 0.0f, 0.0f, 1.0}; - DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1); + DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1); } } @@ -188,7 +185,7 @@ static void EDIT_LATTICE_cache_populate(void *vedata, Object *ob) struct Batch *geom = DRW_cache_surface_get(ob); /* Add geom to a shading group */ - DRW_shgroup_call_add(g_data.group, geom, ob->obmat); + DRW_shgroup_call_add(stl->g_data->group, geom, ob->obmat); } } |