[Mesa-dev] [PATCH 12/22] meta/blit: Use explicit uniform locations in scaled MSAA blit shader

Ian Romanick idr at freedesktop.org
Thu Feb 18 01:58:05 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/common/meta_blit.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c
index 6cabae2..342627a 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -61,7 +61,6 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
                                    struct gl_renderbuffer *src_rb,
                                    GLenum target, GLenum filter)
 {
-   GLint loc_src_width, loc_src_height;
    int i, samples;
    int shader_offset = 0;
    void *mem_ctx = ralloc_context(NULL);
@@ -107,12 +106,8 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
    if (blit->msaa_shaders[shader_index]) {
       _mesa_UseProgram(blit->msaa_shaders[shader_index]);
       /* Update the uniform values. */
-      loc_src_width =
-         _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width");
-      loc_src_height =
-         _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height");
-      _mesa_Uniform1f(loc_src_width, src_rb->Width);
-      _mesa_Uniform1f(loc_src_height, src_rb->Height);
+      _mesa_Uniform1f(0, src_rb->Width);
+      _mesa_Uniform1f(1, src_rb->Height);
       return;
    }
 
@@ -183,8 +178,16 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
    fs_source = ralloc_asprintf(mem_ctx,
                                "#version 130\n"
                                "#extension GL_ARB_texture_multisample : enable\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"
                                "uniform sampler2DMS%s texSampler;\n"
-                               "uniform float src_width, src_height;\n"
+                               "layout(location=0) uniform float src_width;\n"
+                               "layout(location=1) uniform float src_height;\n"
                                "in vec2 texCoords;\n"
                                "flat in int layer;\n"
                                "out vec4 out_color;\n"
@@ -235,12 +238,8 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
 
    _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name,
                                        &blit->msaa_shaders[shader_index]);
-   loc_src_width =
-      _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width");
-   loc_src_height =
-      _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height");
-   _mesa_Uniform1f(loc_src_width, src_rb->Width);
-   _mesa_Uniform1f(loc_src_height, src_rb->Height);
+   _mesa_Uniform1f(0, src_rb->Width);
+   _mesa_Uniform1f(1, src_rb->Height);
 
    ralloc_free(mem_ctx);
 }
-- 
2.5.0



More information about the mesa-dev mailing list