[Mesa-dev] [PATCH 03/22] i965/meta: Use explicit uniform locations in fast clear shader

Ian Romanick idr at freedesktop.org
Thu Feb 18 01:57:56 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 37dffb9..3917df1 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -62,7 +62,6 @@ struct brw_fast_clear_state {
    struct gl_vertex_array_object *array_obj;
    GLuint vao;
    GLuint shader_prog;
-   GLint color_location;
 };
 
 static bool
@@ -118,7 +117,13 @@ brw_bind_rep_write_shader(struct brw_context *brw, float *color)
       "   gl_Position = position;\n"
       "}\n";
    const char *fs_source =
-      "uniform vec4 color;\n"
+      /* GL_ARB_explicit_uniform_location requires either GLSL 3.30 or
+       * GL_ARB_explicit_attrib_location, and only the later is universally
+       * supported.
+       */
+      "#extension GL_ARB_explicit_attrib_location: require\n"
+      "#extension GL_ARB_explicit_uniform_location: require\n"
+      "layout(location=0) uniform vec4 color;\n"
       "void main()\n"
       "{\n"
       "   gl_FragColor = color;\n"
@@ -141,13 +146,10 @@ brw_bind_rep_write_shader(struct brw_context *brw, float *color)
       _mesa_BindAttribLocation(clear->shader_prog, 0, "position");
       _mesa_ObjectLabel(GL_PROGRAM, clear->shader_prog, -1, "meta repclear");
       _mesa_LinkProgram(clear->shader_prog);
-
-      clear->color_location =
-         _mesa_GetUniformLocation(clear->shader_prog, "color");
    }
 
    _mesa_UseProgram(clear->shader_prog);
-   _mesa_Uniform4fv(clear->color_location, 1, color);
+   _mesa_Uniform4fv(0, 1, color);
 }
 
 void
-- 
2.5.0



More information about the mesa-dev mailing list