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-04-08 18:00:15 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-04-08 19:31:50 +0300
commitfc6b69bedc96bb3a09385c3238d1221e7ee2e1b9 (patch)
tree4d95f0b5c4fb3aaa5ef70067796de836f8fea3a2 /source/blender/gpu/intern/gpu_viewport.c
parent0b06e73258a00d5a44d48fa9d7ac6637a0ee8641 (diff)
UI: Perf: Use GWN_draw_primitive for drawing viewport textures.
Diffstat (limited to 'source/blender/gpu/intern/gpu_viewport.c')
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index e635174eca2..5d89bd59277 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -521,35 +521,23 @@ void GPU_viewport_draw_to_screen(GPUViewport *viewport, const rcti *rect)
BLI_assert(w == BLI_rcti_size_x(rect) + 1);
BLI_assert(h == BLI_rcti_size_y(rect) + 1);
- 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);
+ float x1 = rect->xmin;
+ float x2 = rect->xmin + w;
+ float y1 = rect->ymin;
+ float y2 = rect->ymin + h;
- immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_ALPHA);
- GPU_texture_bind(color, 0);
-
- immUniform1i("image", 0); /* default GL_TEXTURE0 unit */
- immUniform1f("alpha", 1.0f);
-
- immBegin(GWN_PRIM_TRI_STRIP, 4);
-
- immAttrib2f(texcoord, 0.0f, 0.0f);
- immVertex2f(pos, rect->xmin, rect->ymin);
+ GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR);
+ GPU_shader_bind(shader);
- immAttrib2f(texcoord, 1.0f, 0.0f);
- immVertex2f(pos, rect->xmin + w, rect->ymin);
-
- immAttrib2f(texcoord, 0.0f, 1.0f);
- immVertex2f(pos, rect->xmin, rect->ymin + h);
-
- immAttrib2f(texcoord, 1.0f, 1.0f);
- immVertex2f(pos, rect->xmin + w, rect->ymin + h);
+ GPU_texture_bind(color, 0);
+ glUniform1i(GPU_shader_get_uniform(shader, "image"), 0);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), 0.0f, 0.0f, 1.0f, 1.0f);
+ glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x1, y1, x2, y2);
+ glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), 1.0f, 1.0f, 1.0f, 1.0f);
- immEnd();
+ GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4);
GPU_texture_unbind(color);
-
- immUnbindProgram();
}
void GPU_viewport_unbind(GPUViewport *UNUSED(viewport))