glsl: Apply the link error conditions to GL_ARB_fragment_coord_conventions
authorAnuj Phogat <anuj.phogat@gmail.com>
Mon, 10 Feb 2014 22:12:40 +0000 (14:12 -0800)
committerAnuj Phogat <anuj.phogat@gmail.com>
Thu, 1 May 2014 17:58:39 +0000 (10:58 -0700)
Link error conditions added in previous patch are equally applicable
to GL_ARB_fragment_coord_conventions implementation. Extension's spec
says:
   "If gl_FragCoord is redeclared in any fragment shader in a program,
    it must be redeclared in all the fragment shaders in that program
    that have a static use of gl_FragCoord. All redeclarations of
    gl_FragCoord in all fragment shaders in a single program must have
    the same set of qualifiers."

Signed-off-by: Anuj Phogat <anuj.phogat@gmail.com>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/glsl/glsl_parser_extras.cpp
src/glsl/linker.cpp
src/mesa/main/mtypes.h

index 600658d9788572f2d714fac2f7d8b52b067ec766..8f09cc7293afaf0a04a64d5de7acb5fe019ed986 100644 (file)
@@ -1408,6 +1408,8 @@ set_shader_inout_layout(struct gl_shader *shader,
       shader->uses_gl_fragcoord = state->fs_uses_gl_fragcoord;
       shader->pixel_center_integer = state->fs_pixel_center_integer;
       shader->origin_upper_left = state->fs_origin_upper_left;
+      shader->ARB_fragment_coord_conventions_enable =
+         state->ARB_fragment_coord_conventions_enable;
       break;
 
    default:
index 9a018774f80f086be95f768afdbf8319fc835bd2..a1bae297eaaec9bb69ba0fb939b189f400764b6e 100644 (file)
@@ -1210,7 +1210,8 @@ link_fs_input_layout_qualifiers(struct gl_shader_program *prog,
    linked_shader->origin_upper_left = false;
    linked_shader->pixel_center_integer = false;
 
-   if (linked_shader->Stage != MESA_SHADER_FRAGMENT || prog->Version < 150)
+   if (linked_shader->Stage != MESA_SHADER_FRAGMENT ||
+       (prog->Version < 150 && !prog->ARB_fragment_coord_conventions_enable))
       return;
 
    for (unsigned i = 0; i < num_shaders; i++) {
@@ -2249,6 +2250,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
    ralloc_free(prog->AtomicBuffers);
    prog->AtomicBuffers = NULL;
    prog->NumAtomicBuffers = 0;
+   prog->ARB_fragment_coord_conventions_enable = false;
 
    /* Separate the shaders into groups based on their type.
     */
@@ -2275,6 +2277,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
         goto done;
       }
 
+      prog->ARB_fragment_coord_conventions_enable |=
+         prog->Shaders[i]->ARB_fragment_coord_conventions_enable;
+
       gl_shader_stage shader_type = prog->Shaders[i]->Stage;
       shader_list[shader_type][num_shaders[shader_type]] = prog->Shaders[i];
       num_shaders[shader_type]++;
index d9fb297a96691c1ad009d31b6ad4cd85aa6f2b63..0fd81ff6d39a972b5df2d5b28af8666eb965a058 100644 (file)
@@ -2434,6 +2434,7 @@ struct gl_shader
    bool uses_builtin_functions;
    bool uses_gl_fragcoord;
    bool redeclares_gl_fragcoord;
+   bool ARB_fragment_coord_conventions_enable;
 
    /**
     * Fragment shader state from GLSL 1.50 layout qualifiers.
@@ -2765,6 +2766,11 @@ struct gl_shader_program
     * \c NULL.
     */
    struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES];
+
+   /* True if any of the fragment shaders attached to this program use:
+    * #extension ARB_fragment_coord_conventions: enable
+    */
+   GLboolean ARB_fragment_coord_conventions_enable;
 };