[Bf-blender-cvs] [0b06e73258a] blender2.8: UI: Perf: Use GWN_draw_primitive for drawing triple buffers texture.

Clément Foucault noreply at git.blender.org
Sun Apr 8 18:25:55 CEST 2018


Commit: 0b06e73258a00d5a44d48fa9d7ac6637a0ee8641
Author: Clément Foucault
Date:   Sun Apr 8 16:59:39 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0b06e73258a00d5a44d48fa9d7ac6637a0ee8641

UI: Perf: Use GWN_draw_primitive for drawing triple buffers texture.

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

M	source/blender/windowmanager/intern/wm_draw.c

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

diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index cfd3291293c..ed276aa690d 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -474,35 +474,24 @@ void wm_triple_draw_textures(wmWindow *win, wmDrawTriple *triple, float alpha)
 	const float halfx = GLA_PIXEL_OFS / sizex;
 	const float halfy = GLA_PIXEL_OFS / sizey;
 
-	Gwn_VertFormat *format = immVertexFormat();
-	unsigned int texcoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-	unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
 	const int activeTex = 7; /* arbitrary */
 	glActiveTexture(GL_TEXTURE0 + activeTex);
 	glBindTexture(GL_TEXTURE_2D, triple->bind);
 
-	immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_ALPHA);
-
-	immUniform1f("alpha", alpha);
-	immUniform1i("image", activeTex);
-
-	immBegin(GWN_PRIM_TRI_FAN, 4);
-
-	immAttrib2f(texcoord, halfx, halfy);
-	immVertex2f(pos, 0.0f, 0.0f);
-
-	immAttrib2f(texcoord, ratiox + halfx, halfy);
-	immVertex2f(pos, sizex, 0.0f);
+	float x1 = halfx;
+	float x2 = ratiox + halfx;
+	float y1 = halfy;
+	float y2 = ratioy + halfy;
 
-	immAttrib2f(texcoord, ratiox + halfx, ratioy + halfy);
-	immVertex2f(pos, sizex, sizey);
+	GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+	GPU_shader_bind(shader);
 
-	immAttrib2f(texcoord, halfx, ratioy + halfy);
-	immVertex2f(pos, 0.0f, sizey);
+	glUniform1i(GPU_shader_get_uniform(shader, "image"), activeTex);
+	glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2);
+	glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), 0.0f, 0.0f, sizex, sizey);
+	glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
 
-	immEnd();
-	immUnbindProgram();
+	GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
 
 	glBindTexture(GL_TEXTURE_2D, 0);
 }



More information about the Bf-blender-cvs mailing list