Mesa (7.10): glsl: Emit errors or warnings when 'layout' is used with ' attribute' or 'varying'

Ian Romanick idr at kemper.freedesktop.org
Wed Jan 26 00:19:09 UTC 2011


Module: Mesa
Branch: 7.10
Commit: 092b6f2ca8b61faf1ad4a059c30682878da12430
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=092b6f2ca8b61faf1ad4a059c30682878da12430

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Fri Jan  7 16:53:59 2011 -0800

glsl: Emit errors or warnings when 'layout' is used with 'attribute' or 'varying'

The specs that add 'layout' require the use of 'in' or 'out'.
However, a number of implementations, including Mesa, shipped several
of these extensions allowing the use of 'varying' and 'attribute'.
For these extensions only a warning is emitted.

This differs from the behavior of Mesa 7.10.  Mesa 7.10 would only
accept 'attribute' with 'layout(location)'.  This behavior was clearly
wrong.  Rather than carrying the broken behavior forward, we're just
doing the correct thing.

This is related to (piglit) bugzilla #31804.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
(cherry picked from commit 4bcff0c19091c7df2b2e0bafe58addb5bae28f1a)

---

 src/glsl/ast_to_hir.cpp |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 4019716..517c27f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1960,6 +1960,52 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
       }
    }
 
+   /* Does the declaration use the 'layout' keyword?
+    */
+   const bool uses_layout = qual->flags.q.pixel_center_integer
+      || qual->flags.q.origin_upper_left
+      || qual->flags.q.explicit_location;
+
+   /* Does the declaration use the deprecated 'attribute' or 'varying'
+    * keywords?
+    */
+   const bool uses_deprecated_qualifier = qual->flags.q.attribute
+      || qual->flags.q.varying;
+
+   /* Is the 'layout' keyword used with parameters that allow relaxed checking.
+    * Many implementations of GL_ARB_fragment_coord_conventions_enable and some
+    * implementations (only Mesa?) GL_ARB_explicit_attrib_location_enable
+    * allowed the layout qualifier to be used with 'varying' and 'attribute'.
+    * These extensions and all following extensions that add the 'layout'
+    * keyword have been modified to require the use of 'in' or 'out'.
+    *
+    * The following extension do not allow the deprecated keywords:
+    *
+    *    GL_AMD_conservative_depth
+    *    GL_ARB_gpu_shader5
+    *    GL_ARB_separate_shader_objects
+    *    GL_ARB_tesselation_shader
+    *    GL_ARB_transform_feedback3
+    *    GL_ARB_uniform_buffer_object
+    *
+    * It is unknown whether GL_EXT_shader_image_load_store or GL_NV_gpu_shader5
+    * allow layout with the deprecated keywords.
+    */
+   const bool relaxed_layout_qualifier_checking =
+      state->ARB_fragment_coord_conventions_enable;
+
+   if (uses_layout && uses_deprecated_qualifier) {
+      if (relaxed_layout_qualifier_checking) {
+	 _mesa_glsl_warning(loc, state,
+			    "`layout' qualifier may not be used with "
+			    "`attribute' or `varying'");
+      } else {
+	 _mesa_glsl_error(loc, state,
+			  "`layout' qualifier may not be used with "
+			  "`attribute' or `varying'");
+      }
+   }
+
    if (var->type->is_array() && state->language_version != 110) {
       var->array_lvalue = true;
    }




More information about the mesa-commit mailing list