Re: [Mesa-dev] [PATCH] meta: Use ARB_explicit_attrib_location in the rest of the meta shaders.

2016-03-22 Thread Ian Romanick
I thought I already had this patch, but it looks like it was on my to-do
list.  I had patches to use GL_ARB_explicit_uniform_location, and those
needed GL_ARB_explicit_attrib_location (to get the layout keyword).

https://patchwork.freedesktop.org/patch/74220/ (and others... I'm not
sure why I haven't landed these.)

Every driver that supports GLSL also supports
GL_ARB_explicit_attrib_location.

On 03/15/2016 12:05 PM, Kenneth Graunke wrote:
> This is cleaner than using glBindAttribLocation().
> 
> Not all drivers support the extension, but I don't think those drivers
> use GLSL in the first place.  Apparently some Meta shaders already use
> GL_ARB_explicit_attrib_location, so I think it should be okay.
> 
> Honestly, I'm not sure how the old code worked anyway - we bound the
> attribute location for "texcoords", while all the shaders capitalized
> or spelled it differently.
> 
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/common/meta.c  | 17 ++---
>  src/mesa/drivers/common/meta_blit.c | 15 +--
>  2 files changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index ab78f45..b05dfc7 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -207,8 +207,6 @@ _mesa_meta_compile_and_link_program(struct gl_context 
> *ctx,
> _mesa_DeleteShader(fs);
> _mesa_AttachShader(*program, vs);
> _mesa_DeleteShader(vs);
> -   _mesa_BindAttribLocation(*program, 0, "position");
> -   _mesa_BindAttribLocation(*program, 1, "texcoords");
> _mesa_meta_link_program_with_debug(ctx, *program);
>  
> _mesa_UseProgram(*program);
> @@ -230,19 +228,15 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
>  {
> char *vs_source, *fs_source;
> struct blit_shader *shader = choose_blit_shader(target, table);
> -   const char *vs_input, *vs_output, *fs_input, *vs_preprocess, 
> *fs_preprocess;
> +   const char *fs_input, *vs_preprocess, *fs_preprocess;
> void *mem_ctx;
>  
> if (ctx->Const.GLSLVersion < 130) {
>vs_preprocess = "";
> -  vs_input = "attribute";
> -  vs_output = "varying";
>fs_preprocess = "#extension GL_EXT_texture_array : enable";
>fs_input = "varying";
> } else {
>vs_preprocess = "#version 130";
> -  vs_input = "in";
> -  vs_output = "out";
>fs_preprocess = "#version 130";
>fs_input = "in";
>shader->func = "texture";
> @@ -259,15 +253,16 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
>  
> vs_source = ralloc_asprintf(mem_ctx,
>  "%s\n"
> -"%s vec2 position;\n"
> -"%s vec4 textureCoords;\n"
> -"%s vec4 texCoords;\n"
> +"#extension GL_ARB_explicit_attrib_location: enable\n"
> +"layout(location = 0) in vec2 position;\n"
> +"layout(location = 1) in vec4 textureCoords;\n"
> +"out vec4 texCoords;\n"
>  "void main()\n"
>  "{\n"
>  "   texCoords = textureCoords;\n"
>  "   gl_Position = vec4(position, 0.0, 1.0);\n"
>  "}\n",
> -vs_preprocess, vs_input, vs_input, vs_output);
> +vs_preprocess);
>  
> fs_source = ralloc_asprintf(mem_ctx,
>  "%s\n"
> diff --git a/src/mesa/drivers/common/meta_blit.c 
> b/src/mesa/drivers/common/meta_blit.c
> index 5d80f7d..179dc0d 100644
> --- a/src/mesa/drivers/common/meta_blit.c
> +++ b/src/mesa/drivers/common/meta_blit.c
> @@ -168,8 +168,9 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
>  
> static const char vs_source[] =
> "#version 130\n"
> -   "in vec2 position;\n"
> -   "in vec3 textureCoords;\n"
> +   "#extension GL_ARB_explicit_attrib_location: 
> enable\n"
> +   "layout(location = 0) in vec2 position;\n"
> +   "layout(location = 1) in vec3 
> textureCoords;\n"
> "out vec2 texCoords;\n"
> "flat out int layer;\n"
> "void main()\n"
> @@ -384,8 +385,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
>  
>vs_source = ralloc_asprintf(mem_ctx,
>"#version 130\n"
> -  "in vec2 position;\n"
> -  "in %s textureCoords;\n"
> +  "#extension 
> GL_ARB_explicit_attrib_location: enable\n"
> +  "layout(location = 0) in vec2 position;\n"
> +  "layout(location = 1) in %s 
> textureCoords;\n"
>"out %s texCoords;\n"
>"void main()\n"

Re: [Mesa-dev] [PATCH] meta: Use ARB_explicit_attrib_location in the rest of the meta shaders.

2016-03-15 Thread Matt Turner
Indeed, none of nouveau_vieux, radeon, or r200 support GLSL. Of
course, no classic driver except i965 supports #version 130, so those
are clear.

Reviewed-by: Matt Turner 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] meta: Use ARB_explicit_attrib_location in the rest of the meta shaders.

2016-03-15 Thread Kenneth Graunke
This is cleaner than using glBindAttribLocation().

Not all drivers support the extension, but I don't think those drivers
use GLSL in the first place.  Apparently some Meta shaders already use
GL_ARB_explicit_attrib_location, so I think it should be okay.

Honestly, I'm not sure how the old code worked anyway - we bound the
attribute location for "texcoords", while all the shaders capitalized
or spelled it differently.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/common/meta.c  | 17 ++---
 src/mesa/drivers/common/meta_blit.c | 15 +--
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index ab78f45..b05dfc7 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -207,8 +207,6 @@ _mesa_meta_compile_and_link_program(struct gl_context *ctx,
_mesa_DeleteShader(fs);
_mesa_AttachShader(*program, vs);
_mesa_DeleteShader(vs);
-   _mesa_BindAttribLocation(*program, 0, "position");
-   _mesa_BindAttribLocation(*program, 1, "texcoords");
_mesa_meta_link_program_with_debug(ctx, *program);
 
_mesa_UseProgram(*program);
@@ -230,19 +228,15 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
 {
char *vs_source, *fs_source;
struct blit_shader *shader = choose_blit_shader(target, table);
-   const char *vs_input, *vs_output, *fs_input, *vs_preprocess, *fs_preprocess;
+   const char *fs_input, *vs_preprocess, *fs_preprocess;
void *mem_ctx;
 
if (ctx->Const.GLSLVersion < 130) {
   vs_preprocess = "";
-  vs_input = "attribute";
-  vs_output = "varying";
   fs_preprocess = "#extension GL_EXT_texture_array : enable";
   fs_input = "varying";
} else {
   vs_preprocess = "#version 130";
-  vs_input = "in";
-  vs_output = "out";
   fs_preprocess = "#version 130";
   fs_input = "in";
   shader->func = "texture";
@@ -259,15 +253,16 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
 
vs_source = ralloc_asprintf(mem_ctx,
 "%s\n"
-"%s vec2 position;\n"
-"%s vec4 textureCoords;\n"
-"%s vec4 texCoords;\n"
+"#extension GL_ARB_explicit_attrib_location: enable\n"
+"layout(location = 0) in vec2 position;\n"
+"layout(location = 1) in vec4 textureCoords;\n"
+"out vec4 texCoords;\n"
 "void main()\n"
 "{\n"
 "   texCoords = textureCoords;\n"
 "   gl_Position = vec4(position, 0.0, 1.0);\n"
 "}\n",
-vs_preprocess, vs_input, vs_input, vs_output);
+vs_preprocess);
 
fs_source = ralloc_asprintf(mem_ctx,
 "%s\n"
diff --git a/src/mesa/drivers/common/meta_blit.c 
b/src/mesa/drivers/common/meta_blit.c
index 5d80f7d..179dc0d 100644
--- a/src/mesa/drivers/common/meta_blit.c
+++ b/src/mesa/drivers/common/meta_blit.c
@@ -168,8 +168,9 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx,
 
static const char vs_source[] =
"#version 130\n"
-   "in vec2 position;\n"
-   "in vec3 textureCoords;\n"
+   "#extension GL_ARB_explicit_attrib_location: 
enable\n"
+   "layout(location = 0) in vec2 position;\n"
+   "layout(location = 1) in vec3 textureCoords;\n"
"out vec2 texCoords;\n"
"flat out int layer;\n"
"void main()\n"
@@ -384,8 +385,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
 
   vs_source = ralloc_asprintf(mem_ctx,
   "#version 130\n"
-  "in vec2 position;\n"
-  "in %s textureCoords;\n"
+  "#extension GL_ARB_explicit_attrib_location: 
enable\n"
+  "layout(location = 0) in vec2 position;\n"
+  "layout(location = 1) in %s textureCoords;\n"
   "out %s texCoords;\n"
   "void main()\n"
   "{\n"
@@ -506,8 +508,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx,
 
   vs_source = ralloc_asprintf(mem_ctx,
   "#version 130\n"
-  "in vec2 position;\n"
-  "in %s textureCoords;\n"
+  "#extension GL_ARB_explicit_attrib_location: 
enable\n"
+  "layout(location = 0) in vec2 position;\n"
+  "layout(location = 1) in %s textureCoords;\n"
   "out %s texCoords;\n"