[Bf-blender-cvs] [ad648b76939] blender2.8: DRW: Add DRW_UNIFORM_INT_COPY.

Clément Foucault noreply at git.blender.org
Tue Apr 17 13:25:14 CEST 2018


Commit: ad648b769395492e9735eec7fe3998619952b1d8
Author: Clément Foucault
Date:   Tue Apr 17 12:59:18 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBad648b769395492e9735eec7fe3998619952b1d8

DRW: Add DRW_UNIFORM_INT_COPY.

This allow to use int uniforms that are not references. Convenient for ids.

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

M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.h
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/draw/intern/draw_manager_exec.c

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

diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 27f2d891cc0..1f1c7f322f4 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -379,6 +379,8 @@ void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const
 void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize);
 void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float *value);
 void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float *value);
+/* Store value instead of referencing it. */
+void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value);
 
 /* Passes */
 DRWPass *DRW_pass_create(const char *name, DRWState state);
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 4f322b11931..fd75405f346 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -157,6 +157,7 @@ typedef enum {
 	DRW_UNIFORM_SHORT_TO_INT,
 	DRW_UNIFORM_SHORT_TO_FLOAT,
 	DRW_UNIFORM_INT,
+	DRW_UNIFORM_INT_COPY,
 	DRW_UNIFORM_FLOAT,
 	DRW_UNIFORM_TEXTURE,
 	DRW_UNIFORM_TEXTURE_PERSIST,
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 544129ea124..74f39cf9073 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -211,6 +211,12 @@ void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const
 	drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 16, 1);
 }
 
+/* Stores the int instead of a pointer. */
+void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
+{
+	drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, SET_INT_IN_POINTER(value), 1, 1);
+}
+
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index dcd976805fd..3716c9d9acf 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -873,7 +873,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
 			case DRW_UNIFORM_SHORT_TO_INT:
 				val = (int)*((short *)uni->value);
 				GPU_shader_uniform_vector_int(
-				        shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)&val);
+				        shgroup->shader, uni->location, uni->length, uni->arraysize, &val);
+				break;
+			case DRW_UNIFORM_INT_COPY:
+				val = GET_INT_FROM_POINTER(uni->value);
+				GPU_shader_uniform_vector_int(
+				        shgroup->shader, uni->location, uni->length, uni->arraysize, &val);
 				break;
 			case DRW_UNIFORM_SHORT_TO_FLOAT:
 				fval = (float)*((short *)uni->value);



More information about the Bf-blender-cvs mailing list