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
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-03-28 00:57:29 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-03-28 01:05:51 +0300
commit637993fafe0c0bd1a2a12d3896673b929531f364 (patch)
tree2ca4f312df60177bfd388f07528ba6e1279a86c9 /source/blender/editors/interface/interface_icons.c
parent3bb720a7de4ae7363ce45e8218e29095e1913be5 (diff)
UI: Perf: Make icon_draw_texture use GWN_draw_primitive.
This bypass the use of immediate mode for theses drawcalls. Placement and and icon select (via uvs) is done inside the vertex shader.
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r--source/blender/editors/interface/interface_icons.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index f7cdb5cdc9c..eca8273ee3a 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1029,31 +1029,18 @@ static void icon_draw_texture(
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, icongltex.id);
- Gwn_VertFormat *format = immVertexFormat();
- unsigned int pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
- unsigned int texCoord = GWN_vertformat_attr_add(format, "texCoord", GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
-
- immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
- if (rgb) immUniformColor3fvAlpha(rgb, alpha);
- else immUniformColor4f(alpha, alpha, alpha, alpha);
-
- immUniform1i("image", 0);
- immBegin(GWN_PRIM_TRI_STRIP, 4);
- immAttrib2f(texCoord, x1, y2);
- immVertex2f(pos, x, y + h);
+ GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+ GPU_shader_bind(shader);
- immAttrib2f(texCoord, x1, y1);
- immVertex2f(pos, x, y);
+ if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha);
+ else glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha);
- immAttrib2f(texCoord, x2, y2);
- immVertex2f(pos, x + w, y + h);
+ glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h);
- immAttrib2f(texCoord, x2, y1);
- immVertex2f(pos, x + w, y);
- immEnd();
-
- immUnbindProgram();
+ GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
glBindTexture(GL_TEXTURE_2D, 0);
}