summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-01-07 16:53:59 -0800
committerIan Romanick <[email protected]>2011-01-13 13:38:50 -0800
commit4bcff0c19091c7df2b2e0bafe58addb5bae28f1a (patch)
tree532006bc9f212ecbd2245c3a061b892a06e44a77
parent82c4b4f88af97395a3d1b01e1998ec828cd5d305 (diff)
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.
-rw-r--r--src/glsl/ast_to_hir.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d70978c838b..365a6e2676f 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -1957,6 +1957,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;
}