summaryrefslogtreecommitdiff
path: root/glamor
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-01-26 14:18:48 -0800
committerEric Anholt <eric@anholt.net>2016-01-29 18:12:57 -0800
commit294e45b60d99cf7d11c657288bbe2670b56775f3 (patch)
treeaab3f1e2f4779e13c301b3932f085a3ecd3a1f36 /glamor
parent5d7bef2eedfd965359dd4eebb6ab806cdad5b83f (diff)
glamor: Set up XV sampler uniforms once at program build time.
No sense doing it on every draw. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'glamor')
-rw-r--r--glamor/glamor_xv.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/glamor/glamor_xv.c b/glamor/glamor_xv.c
index 6e1a58840..5d31fee34 100644
--- a/glamor/glamor_xv.c
+++ b/glamor/glamor_xv.c
@@ -114,7 +114,7 @@ static void
glamor_init_xv_shader(ScreenPtr screen)
{
glamor_screen_private *glamor_priv;
- GLint fs_prog, vs_prog;
+ GLint fs_prog, vs_prog, sampler_loc;
glamor_priv = glamor_get_screen_private(screen);
glamor_make_current(glamor_priv);
@@ -130,6 +130,15 @@ glamor_init_xv_shader(ScreenPtr screen)
glBindAttribLocation(glamor_priv->xv_prog,
GLAMOR_VERTEX_SOURCE, "v_texcoord0");
glamor_link_glsl_prog(screen, glamor_priv->xv_prog, "xv");
+
+ glUseProgram(glamor_priv->xv_prog);
+ sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
+ glUniform1i(sampler_loc, 0);
+ sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
+ glUniform1i(sampler_loc, 1);
+ sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
+ glUniform1i(sampler_loc, 2);
+
}
#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
@@ -258,7 +267,7 @@ glamor_xv_render(glamor_port_private *port_priv)
float uco[3], vco[3], off[3];
float bright, cont, gamma;
int ref = port_priv->transform_index;
- GLint uloc, sampler_loc;
+ GLint uloc;
GLfloat *v;
char *vbo_offset;
@@ -329,13 +338,6 @@ glamor_xv_render(glamor_port_private *port_priv)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
- glUniform1i(sampler_loc, 0);
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
- glUniform1i(sampler_loc, 1);
- sampler_loc = glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
- glUniform1i(sampler_loc, 2);
-
glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);