[Bf-blender-cvs] [bb8a172dfb] blender2.8: Draw Manager: Changed buffer uniform api.

Clément Foucault noreply at git.blender.org
Fri Mar 3 02:55:21 CET 2017


Commit: bb8a172dfbe1c4ea405f78bd54b07501ff59b98f
Author: Clément Foucault
Date:   Thu Mar 2 22:55:54 2017 +0100
Branches: blender2.8
https://developer.blender.org/rBbb8a172dfbe1c4ea405f78bd54b07501ff59b98f

Draw Manager: Changed buffer uniform api.

Use a reference to where will the texture be instead of an index.

===================================================================

M	source/blender/draw/engines/clay/clay.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.c

===================================================================

diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index bde1ffe2fa..7a5beb4648 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 7ad1c30958..a9d831440d 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 d4b773f8d1..1ffff40fb5 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);




More information about the Bf-blender-cvs mailing list