[Bf-blender-cvs] [00164f3c70a] blender2.8: Correct own error using u32 for back-buffer select

Campbell Barton noreply at git.blender.org
Thu May 18 14:31:37 CEST 2017


Commit: 00164f3c70aceed2103adbce1c04164e2bc62f6c
Author: Campbell Barton
Date:   Thu May 18 22:33:34 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB00164f3c70aceed2103adbce1c04164e2bc62f6c

Correct own error using u32 for back-buffer select

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

M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl

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

diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index aad175e8a65..6f8e5efee2a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -9335,7 +9335,7 @@ static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, const floa
 	if (!(mv->flag & ME_HIDE)) {
 		int selcol;
 		GPU_select_index_get(data->offset + index, &selcol);
-		immAttrib3ubv(data->col, (unsigned char *)&selcol);
+		immAttrib1u(data->col, selcol);
 		immVertex3fv(data->pos, co);
 	}
 }
@@ -9354,7 +9354,7 @@ static void bbs_obmode_mesh_verts(Object *ob, DerivedMesh *dm, int offset)
 
 	VertexFormat *format = immVertexFormat();
 	data.pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
-	data.col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, KEEP_INT);
+	data.col = VertexFormat_add_attrib(format, "color", COMP_U32, 1, KEEP_INT);
 
 	immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
@@ -9376,7 +9376,7 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, const float co[3]
 	if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
 		int selcol;
 		GPU_select_index_get(data->offset + index, &selcol);
-		immAttrib3ubv(data->col, (unsigned char *)&selcol);
+		immAttrib1u(data->col, selcol);
 		immVertex3fv(data->pos, co);
 	}
 }
@@ -9387,7 +9387,7 @@ static void bbs_mesh_verts(BMEditMesh *em, DerivedMesh *dm, int offset)
 	data.offset = offset;
 	VertexFormat *format = immVertexFormat();
 	data.pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
-	data.col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, KEEP_INT);
+	data.col = VertexFormat_add_attrib(format, "color", COMP_U32, 1, KEEP_INT);
 
 	immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
@@ -9423,7 +9423,7 @@ static void bbs_mesh_wire__mapFunc(void *userData, int index, const float v0co[3
 	if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
 		int selcol;
 		GPU_select_index_get(data->offset + index, &selcol);
-		immAttrib3ubv(data->col, (unsigned char *)&selcol);
+		immAttrib1u(data->col, selcol);
 		immVertex3fv(data->pos, v0co);
 		immVertex3fv(data->pos, v1co);
 	}
@@ -9445,7 +9445,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset)
 	if (imm_len == 0) return;
 
 	data.pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
-	data.col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, KEEP_INT);
+	data.col = VertexFormat_add_attrib(format, "color", COMP_U32, 1, KEEP_INT);
 
 	immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
@@ -9516,7 +9516,7 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
 
 	VertexFormat *format = immVertexFormat();
 	data.pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
-	data.col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, KEEP_INT);
+	data.col = VertexFormat_add_attrib(format, "color", COMP_U32, 1, KEEP_INT);
 
 	immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
@@ -9525,7 +9525,7 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
 	if (use_select == false) {
 		int selcol;
 		GPU_select_index_get(0, &selcol);
-		immAttrib3ubv(data.col, (unsigned char *)&selcol);
+		immAttrib1u(data.col, selcol);
 	}
 
 	int index = 0;
@@ -9536,7 +9536,7 @@ static void bbs_mesh_face(BMEditMesh *em, DerivedMesh *dm, const bool use_select
 			if (use_select) {
 				int selcol;
 				GPU_select_index_get(BM_elem_index_get(f) + 1, &selcol);
-				immAttrib3ubv(data.col, (unsigned char *)&selcol);
+				immAttrib1u(data.col, selcol);
 			}
 			for (int t = 0; t < ntris; t++) {
 				immVertex3fv(data.pos, em->looptris[index][0]->v->co);
@@ -9563,7 +9563,7 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, const float ce
 	if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
 		int selcol;
 		GPU_select_index_get(index + 1, &selcol);
-		immAttrib3ubv(data->col, (unsigned char *)&selcol);
+		immAttrib1u(data->col, selcol);
 		immVertex3fv(data->pos, cent);
 	}
 }
@@ -9574,7 +9574,7 @@ static void bbs_mesh_face_dot(BMEditMesh *em, DerivedMesh *dm)
 	data.bm = em->bm;
 	VertexFormat *format = immVertexFormat();
 	data.pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 3, KEEP_FLOAT);
-	data.col = VertexFormat_add_attrib(format, "color", COMP_U8, 3, KEEP_INT);
+	data.col = VertexFormat_add_attrib(format, "color", COMP_U32, 1, KEEP_INT);
 
 	immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR_U32);
 
diff --git a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl
index 7dccddf8acf..7db7e28d8e6 100644
--- a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl
@@ -3,7 +3,7 @@ uniform mat4 ModelViewProjectionMatrix;
 
 in vec3 pos;
 #if defined(USE_COLOR_U32)
-in int color;
+in uint color;
 #else
 in vec4 color;
 #endif
@@ -16,10 +16,10 @@ void main()
 
 #if defined(USE_COLOR_U32)
 	finalColor = vec4(
-		((color      ) & 0xFF) * (1.0f / 255.0f),
-		((color >>  8) & 0xFF) * (1.0f / 255.0f),
-		((color >> 16) & 0xFF) * (1.0f / 255.0f),
-		((color >> 24)       ) * (1.0f / 255.0f));
+		((color      ) & uint(0xFF)) * (1.0f / 255.0f),
+		((color >>  8) & uint(0xFF)) * (1.0f / 255.0f),
+		((color >> 16) & uint(0xFF)) * (1.0f / 255.0f),
+		((color >> 24)             ) * (1.0f / 255.0f));
 #else
 	finalColor = color;
 #endif




More information about the Bf-blender-cvs mailing list