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/particle_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/particle_mode.c')
-rw-r--r-- | source/blender/draw/modes/particle_mode.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/source/blender/draw/modes/particle_mode.c b/source/blender/draw/modes/particle_mode.c index b2d9d39281b..84426b28752 100644 --- a/source/blender/draw/modes/particle_mode.c +++ b/source/blender/draw/modes/particle_mode.c @@ -70,6 +70,7 @@ typedef struct PARTICLE_StorageList { * free with MEM_freeN() when viewport is freed. * (not per object) */ struct CustomStruct *block; + struct g_data *g_data; } PARTICLE_StorageList; typedef struct PARTICLE_Data { @@ -93,16 +94,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 PARTICLE_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 */ - PARTICLE_Data *vedata; -} g_data = {NULL}; /* Transient data */ +} g_data; /* Transient data */ /* *********** FUNCTIONS *********** */ @@ -111,7 +107,6 @@ static struct { * (Optional) */ static void PARTICLE_engine_init(void *vedata) { - PARTICLE_TextureList *txl = ((PARTICLE_Data *)vedata)->txl; PARTICLE_FramebufferList *fbl = ((PARTICLE_Data *)vedata)->fbl; PARTICLE_StorageList *stl = ((PARTICLE_Data *)vedata)->stl; @@ -142,11 +137,13 @@ static void PARTICLE_engine_init(void *vedata) * Assume that all Passes are NULL */ static void PARTICLE_cache_init(void *vedata) { - PARTICLE_PassList *psl = ((PARTICLE_Data *)vedata)->psl; PARTICLE_StorageList *stl = ((PARTICLE_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 */ @@ -155,16 +152,16 @@ static void PARTICLE_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] = {0.2f, 0.5f, 0.3f, 1.0}; - DRW_shgroup_uniform_vec4(g_data.group, "color", color, 1); + DRW_shgroup_uniform_vec4(stl->g_data->group, "color", color, 1); } } @@ -182,7 +179,7 @@ static void PARTICLE_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); } } |