Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-03-26 21:13:34 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-03-27 15:01:47 +0300
commitdeda6a43fc710f30ceb9e3b30d1f8d79180fe8d1 (patch)
treecbe8c10668a697b47e5cbc219fef05ce24bceb60 /source/blender/draw/engines
parent7ee41920fa0b7ed51a03fe4ee15c6fd782d294a8 (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/engines')
-rw-r--r--source/blender/draw/engines/clay/clay.c18
-rw-r--r--source/blender/draw/engines/eevee/eevee.c48
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c11
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h13
4 files changed, 50 insertions, 40 deletions
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index 750e6f4ebfe..9f46556b7c2 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -76,6 +76,7 @@ typedef struct CLAY_Storage {
typedef struct CLAY_StorageList {
struct CLAY_Storage *storage;
struct GPUUniformBuffer *mat_ubo;
+ struct g_data *g_data;
} CLAY_StorageList;
/* keep it under MAX_BUFFERS */
@@ -100,6 +101,7 @@ typedef struct CLAY_PassList {
struct DRWPass *depth_pass;
struct DRWPass *depth_pass_cull;
struct DRWPass *clay_pass;
+ struct g_data *g_data;
} CLAY_PassList;
typedef struct CLAY_Data {
@@ -134,15 +136,14 @@ static struct {
int ubo_mat_idxs[MAX_CLAY_MAT];
} e_data = {NULL}; /* Engine data */
-static struct {
+typedef struct g_data {
DRWShadingGroup *depth_shgrp;
DRWShadingGroup *depth_shgrp_select;
DRWShadingGroup *depth_shgrp_active;
DRWShadingGroup *depth_shgrp_cull;
DRWShadingGroup *depth_shgrp_cull_select;
DRWShadingGroup *depth_shgrp_cull_active;
- CLAY_Data *vedata;
-} g_data = {NULL}; /* Transient data */
+} g_data; /* Transient data */
/* Functions */
@@ -604,13 +605,18 @@ static void CLAY_cache_init(void *vedata)
CLAY_PassList *psl = ((CLAY_Data *)vedata)->psl;
CLAY_StorageList *stl = ((CLAY_Data *)vedata)->stl;
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
+ }
+
/* Depth Pass */
{
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- g_data.depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
- g_data.depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
+ stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
}
/* Clay Pass */
@@ -640,7 +646,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
geom = DRW_cache_surface_get(ob);
/* Depth Prepass */
- DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull : g_data.depth_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
/* Shading */
clay_shgrp = CLAY_object_shgrp_get(vedata, ob, stl, psl);
diff --git a/source/blender/draw/engines/eevee/eevee.c b/source/blender/draw/engines/eevee/eevee.c
index bb17a6b46b0..eceb72279f6 100644
--- a/source/blender/draw/engines/eevee/eevee.c
+++ b/source/blender/draw/engines/eevee/eevee.c
@@ -37,17 +37,6 @@ static struct {
struct GPUShader *tonemap;
} e_data = {NULL}; /* Engine data */
-static struct {
- DRWShadingGroup *default_lit_grp;
- DRWShadingGroup *depth_shgrp;
- DRWShadingGroup *depth_shgrp_select;
- DRWShadingGroup *depth_shgrp_active;
- DRWShadingGroup *depth_shgrp_cull;
- DRWShadingGroup *depth_shgrp_cull_select;
- DRWShadingGroup *depth_shgrp_cull_active;
- EEVEE_Data *vedata;
-} g_data = {NULL}; /* Transient data */
-
extern char datatoc_lit_surface_frag_glsl[];
extern char datatoc_lit_surface_vert_glsl[];
extern char datatoc_tonemap_frag_glsl[];
@@ -91,33 +80,38 @@ static void EEVEE_cache_init(void *vedata)
EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl;
EEVEE_StorageList *stl = ((EEVEE_Data *)vedata)->stl;
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(g_data), "g_data");
+ }
+
{
psl->depth_pass = DRW_pass_create("Depth Pass", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS);
- g_data.depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
- g_data.depth_shgrp_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
- DRW_shgroup_state_set(g_data.depth_shgrp_select, DRW_STATE_WRITE_STENCIL_SELECT);
+ stl->g_data->depth_shgrp_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ DRW_shgroup_state_set(stl->g_data->depth_shgrp_select, DRW_STATE_WRITE_STENCIL_SELECT);
- g_data.depth_shgrp_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
- DRW_shgroup_state_set(g_data.depth_shgrp_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
+ stl->g_data->depth_shgrp_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ DRW_shgroup_state_set(stl->g_data->depth_shgrp_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
psl->depth_pass_cull = DRW_pass_create("Depth Pass Cull", DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS | DRW_STATE_CULL_BACK);
- g_data.depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
+ stl->g_data->depth_shgrp_cull = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
- g_data.depth_shgrp_cull_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
- DRW_shgroup_state_set(g_data.depth_shgrp_cull_select, DRW_STATE_WRITE_STENCIL_SELECT);
+ stl->g_data->depth_shgrp_cull_select = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
+ DRW_shgroup_state_set(stl->g_data->depth_shgrp_cull_select, DRW_STATE_WRITE_STENCIL_SELECT);
- g_data.depth_shgrp_cull_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
- DRW_shgroup_state_set(g_data.depth_shgrp_cull_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
+ stl->g_data->depth_shgrp_cull_active = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass_cull);
+ DRW_shgroup_state_set(stl->g_data->depth_shgrp_cull_active, DRW_STATE_WRITE_STENCIL_ACTIVE);
}
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_EQUAL;
psl->pass = DRW_pass_create("Default Light Pass", state);
- g_data.default_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->pass);
- DRW_shgroup_uniform_block(g_data.default_lit_grp, "light_block", stl->lights_ubo, 0);
- DRW_shgroup_uniform_int(g_data.default_lit_grp, "light_count", &stl->lights_info->light_count, 1);
+ stl->g_data->default_lit_grp = DRW_shgroup_create(e_data.default_lit, psl->pass);
+ DRW_shgroup_uniform_block(stl->g_data->default_lit_grp, "light_block", stl->lights_ubo, 0);
+ DRW_shgroup_uniform_int(stl->g_data->default_lit_grp, "light_count", &stl->lights_info->light_count, 1);
}
{
@@ -149,11 +143,11 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
// if ((ob->base_flag & BASE_ACTIVE) != 0)
// DRW_shgroup_call_add((do_cull) ? depth_shgrp_cull_active : depth_shgrp_active, geom, ob->obmat);
if ((ob->base_flag & BASE_SELECTED) != 0)
- DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull_select : g_data.depth_shgrp_select, geom, ob->obmat);
+ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull_select : stl->g_data->depth_shgrp_select, geom, ob->obmat);
else
- DRW_shgroup_call_add((do_cull) ? g_data.depth_shgrp_cull : g_data.depth_shgrp, geom, ob->obmat);
+ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
- DRW_shgroup_call_add(g_data.default_lit_grp, geom, ob->obmat);
+ DRW_shgroup_call_add(stl->g_data->default_lit_grp, geom, ob->obmat);
}
else if (ob->type == OB_LAMP) {
EEVEE_lights_cache_add(stl, ob);
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index b3459901616..c0359cdd042 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -35,9 +35,6 @@ typedef struct EEVEE_Light {
float spot_size, spot_blend, area_x, area_y;
} EEVEE_Light;
-static struct {
- ListBase lamps; /* Lamps gathered during cache iteration */
-} g_data = {NULL}; /* Transient data */
void EEVEE_lights_init(EEVEE_StorageList *stl)
{
@@ -49,13 +46,13 @@ void EEVEE_lights_init(EEVEE_StorageList *stl)
void EEVEE_lights_cache_init(EEVEE_StorageList *stl)
{
- BLI_listbase_clear(&g_data.lamps);
+ BLI_listbase_clear(&stl->g_data->lamps);
stl->lights_info->light_count = 0;
}
void EEVEE_lights_cache_add(EEVEE_StorageList *stl, Object *ob)
{
- BLI_addtail(&g_data.lamps, BLI_genericNodeN(ob));
+ BLI_addtail(&stl->g_data->lamps, BLI_genericNodeN(ob));
stl->lights_info->light_count += 1;
}
@@ -70,12 +67,12 @@ void EEVEE_lights_cache_finish(EEVEE_StorageList *stl)
if (light_ct > 0) {
int i = 0;
- for (LinkData *link = g_data.lamps.first; link && i < MAX_LIGHT; link = link->next, i++) {
+ for (LinkData *link = stl->g_data->lamps.first; link && i < MAX_LIGHT; link = link->next, i++) {
Object *ob = (Object *)link->data;
stl->lights_ref[i] = ob;
}
}
- BLI_freelistN(&g_data.lamps);
+ BLI_freelistN(&stl->g_data->lamps);
/* We changed light data so we need to upload it */
EEVEE_lights_update(stl);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 4d8f697cc64..b81731a9188 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -50,6 +50,7 @@ typedef struct EEVEE_StorageList {
struct EEVEE_Light *lights_data; /* Array, Packed lights data info, duplication of what is in the Uniform Buffer in Vram */
struct Object **lights_ref; /* List of all lights in the buffer. */
struct GPUUniformBuffer *lights_ubo;
+ struct g_data *g_data;
} EEVEE_StorageList;
typedef struct EEVEE_LightsInfo {
@@ -64,6 +65,18 @@ typedef struct EEVEE_Data {
EEVEE_StorageList *stl;
} EEVEE_Data;
+typedef struct g_data{
+ struct DRWShadingGroup *default_lit_grp;
+ struct DRWShadingGroup *depth_shgrp;
+ struct DRWShadingGroup *depth_shgrp_select;
+ struct DRWShadingGroup *depth_shgrp_active;
+ struct DRWShadingGroup *depth_shgrp_cull;
+ struct DRWShadingGroup *depth_shgrp_cull_select;
+ struct DRWShadingGroup *depth_shgrp_cull_active;
+
+ struct ListBase lamps; /* Lamps gathered during cache iteration */
+} g_data; /* Transient data */
+
/* eevee_lights.c */
void EEVEE_lights_init(EEVEE_StorageList *stl);
void EEVEE_lights_cache_init(EEVEE_StorageList *stl);