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
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-03-03 00:55:54 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-03-03 04:53:16 +0300
commitbb8a172dfbe1c4ea405f78bd54b07501ff59b98f (patch)
tree9dab0ae4706347a2b4527059b9786c0a574ec772 /source
parent0c1c646118df316468b5a49386da10f6d1ca127b (diff)
Draw Manager: Changed buffer uniform api.
Use a reference to where will the texture be instead of an index.
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/engines/clay/clay.c10
-rw-r--r--source/blender/draw/intern/DRW_render.h2
-rw-r--r--source/blender/draw/intern/draw_manager.c25
3 files changed, 16 insertions, 21 deletions
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index bde1ffe2fa7..7a5beb46482 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -117,13 +117,6 @@ typedef struct CLAY_TextureList {
struct GPUTexture *depth_dup;
} CLAY_TextureList;
-/* for clarity follow the same layout as CLAY_TextureList */
-enum {
- SCENE_COLOR,
- SCENE_DEPTH,
- SCENE_DEPTH_DUP,
-};
-
/* keep it under MAX_PASSES */
typedef struct CLAY_PassList {
struct DRWPass *depth_pass;
@@ -438,9 +431,10 @@ static DRWShadingGroup *CLAY_shgroup_create(DRWPass *pass, int *material_id)
const int depthloc = 0, matcaploc = 1, jitterloc = 2, sampleloc = 3;
DRWShadingGroup *grp = DRW_shgroup_create(data.clay_sh, pass);
+ CLAY_TextureList *txl = DRW_engine_texture_list_get();
DRW_shgroup_uniform_vec2(grp, "screenres", DRW_viewport_size_get(), 1);
- DRW_shgroup_uniform_buffer(grp, "depthtex", SCENE_DEPTH_DUP, depthloc);
+ DRW_shgroup_uniform_buffer(grp, "depthtex", &txl->depth_dup, depthloc);
DRW_shgroup_uniform_texture(grp, "matcaps", data.matcap_array, matcaploc);
DRW_shgroup_uniform_mat4(grp, "WinMatrix", (float *)data.winmat);
DRW_shgroup_uniform_vec4(grp, "viewvecs", (float *)data.viewvecs, 3);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 7ad1c309581..a9d831440dc 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -173,7 +173,7 @@ void DRW_shgroup_attrib_float(DRWShadingGroup *shgroup, const char *name, int si
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const struct GPUTexture *tex, int loc);
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const struct GPUUniformBuffer *ubo, int loc);
-void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, const int value, int loc);
+void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, struct GPUTexture **tex, int loc);
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const bool *value, int arraysize);
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index d4b773f8d1b..1ffff40fb58 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -526,10 +526,9 @@ void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const
DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BLOCK, ubo, 0, 0, loc);
}
-void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, const int value, int loc)
+void DRW_shgroup_uniform_buffer(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex, int loc)
{
- /* we abuse the lenght attrib to store the buffer index */
- DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BUFFER, NULL, value, 0, loc);
+ DRW_interface_uniform(shgroup, name, DRW_UNIFORM_BUFFER, tex, 0, 0, loc);
}
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const bool *value, int arraysize)
@@ -829,6 +828,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup)
BLI_assert(shgroup->interface);
DRWInterface *interface = shgroup->interface;
+ GPUTexture *tex;
if (DST.shader != shgroup->shader) {
if (DST.shader) GPU_shader_unbind();
@@ -858,25 +858,26 @@ static void draw_shgroup(DRWShadingGroup *shgroup)
GPU_shader_uniform_vector(shgroup->shader, uni->location, uni->length, uni->arraysize, (float *)uni->value);
break;
case DRW_UNIFORM_TEXTURE:
- GPU_texture_bind((GPUTexture *)uni->value, uni->bindloc);
+ tex = (GPUTexture *)uni->value;
+ GPU_texture_bind(tex, uni->bindloc);
bound_tex = MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");
- bound_tex->tex = (GPUTexture *)uni->value;
+ bound_tex->tex = tex;
BLI_addtail(&DST.bound_texs, bound_tex);
- GPU_shader_uniform_texture(shgroup->shader, uni->location, (GPUTexture *)uni->value);
+ GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
break;
case DRW_UNIFORM_BUFFER:
- /* restore index from lenght we abused */
- GPU_texture_bind(DST.txl->textures[uni->length], uni->bindloc);
- GPU_texture_compare_mode(DST.txl->textures[uni->length], false);
- GPU_texture_filter_mode(DST.txl->textures[uni->length], false);
+ tex = *((GPUTexture **)uni->value);
+ GPU_texture_bind(tex, uni->bindloc);
+ GPU_texture_compare_mode(tex, false);
+ GPU_texture_filter_mode(tex, false);
bound_tex = MEM_callocN(sizeof(DRWBoundTexture), "DRWBoundTexture");
- bound_tex->tex = DST.txl->textures[uni->length];
+ bound_tex->tex = tex;
BLI_addtail(&DST.bound_texs, bound_tex);
- GPU_shader_uniform_texture(shgroup->shader, uni->location, DST.txl->textures[uni->length]);
+ GPU_shader_uniform_texture(shgroup->shader, uni->location, tex);
break;
case DRW_UNIFORM_BLOCK:
GPU_uniformbuffer_bind((GPUUniformBuffer *)uni->value, uni->bindloc);