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.
This commit is contained in:
Ian Romanick 2011-01-07 16:53:59 -08:00
parent 82c4b4f88a
commit 4bcff0c190
1 changed files with 46 additions and 0 deletions

View File

@ -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;
}