[Mesa-dev] [PATCH 3/3] glsl: Relax qualifier ordering restriction in ES 3.1.
Matt Turner
mattst88 at gmail.com
Mon Dec 7 15:35:17 PST 2015
... and allow the "binding" qualifier in ES 3.1 as well.
GLSL ES 3.1 incorporates only a few features from the extension
ARB_shading_language_420pack: the relaxed qualifier ordering
requirements and the binding qualifier.
Cc: "11.1" <mesa-stable at lists.freedesktop.org>
---
src/glsl/glsl_parser.yy | 20 ++++++++++----------
src/glsl/glsl_parser_extras.h | 5 +++++
2 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 5a8f980..1afc2b7 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -948,7 +948,7 @@ parameter_qualifier:
if (($1.flags.q.in || $1.flags.q.out) && ($2.flags.q.in || $2.flags.q.out))
_mesa_glsl_error(&@1, state, "duplicate in/out/inout qualifier");
- if (!state->has_420pack() && $2.flags.q.constant)
+ if (!state->has_420pack_or_es31() && $2.flags.q.constant)
_mesa_glsl_error(&@1, state, "in/out/inout must come after const "
"or precise");
@@ -960,7 +960,7 @@ parameter_qualifier:
if ($2.precision != ast_precision_none)
_mesa_glsl_error(&@1, state, "duplicate precision qualifier");
- if (!(state->has_420pack() || state->is_version(420, 310)) &&
+ if (!(state->has_420pack_or_es31() || state->is_version(420, 310)) &&
$2.flags.i != 0)
_mesa_glsl_error(&@1, state, "precision qualifiers must come last");
@@ -1482,7 +1482,7 @@ layout_qualifier_id:
$$.index = $3;
}
- if ((state->has_420pack() ||
+ if ((state->has_420pack_or_es31() ||
state->has_atomic_counters() ||
state->has_shader_storage_buffer_objects()) &&
match_layout_qualifier("binding", $1, state) == 0) {
@@ -1714,7 +1714,7 @@ type_qualifier:
if ($2.flags.q.invariant)
_mesa_glsl_error(&@1, state, "duplicate \"invariant\" qualifier");
- if (!state->has_420pack() && $2.flags.q.precise)
+ if (!state->has_420pack_or_es31() && $2.flags.q.precise)
_mesa_glsl_error(&@1, state,
"\"invariant\" must come after \"precise\"");
@@ -1747,7 +1747,7 @@ type_qualifier:
if ($2.has_interpolation())
_mesa_glsl_error(&@1, state, "duplicate interpolation qualifier");
- if (!state->has_420pack() &&
+ if (!state->has_420pack_or_es31() &&
($2.flags.q.precise || $2.flags.q.invariant)) {
_mesa_glsl_error(&@1, state, "interpolation qualifiers must come "
"after \"precise\" or \"invariant\"");
@@ -1767,7 +1767,7 @@ type_qualifier:
* precise qualifiers since these are useful in ARB_separate_shader_objects.
* There is no clear spec guidance on this either.
*/
- if (!state->has_420pack() && $2.has_layout())
+ if (!state->has_420pack_or_es31() && $2.has_layout())
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
$$ = $1;
@@ -1785,7 +1785,7 @@ type_qualifier:
"duplicate auxiliary storage qualifier (centroid or sample)");
}
- if (!state->has_420pack() &&
+ if (!state->has_420pack_or_es31() &&
($2.flags.q.precise || $2.flags.q.invariant ||
$2.has_interpolation() || $2.has_layout())) {
_mesa_glsl_error(&@1, state, "auxiliary storage qualifiers must come "
@@ -1803,7 +1803,7 @@ type_qualifier:
if ($2.has_storage())
_mesa_glsl_error(&@1, state, "duplicate storage qualifier");
- if (!state->has_420pack() &&
+ if (!state->has_420pack_or_es31() &&
($2.flags.q.precise || $2.flags.q.invariant || $2.has_interpolation() ||
$2.has_layout() || $2.has_auxiliary_storage())) {
_mesa_glsl_error(&@1, state, "storage qualifiers must come after "
@@ -1819,7 +1819,7 @@ type_qualifier:
if ($2.precision != ast_precision_none)
_mesa_glsl_error(&@1, state, "duplicate precision qualifier");
- if (!(state->has_420pack() || state->is_version(420, 310)) &&
+ if (!(state->has_420pack_or_es31()) &&
$2.flags.i != 0)
_mesa_glsl_error(&@1, state, "precision qualifiers must come last");
@@ -2575,7 +2575,7 @@ interface_block:
{
ast_interface_block *block = (ast_interface_block *) $2;
- if (!state->has_420pack() && block->layout.has_layout() &&
+ if (!state->has_420pack_or_es31() && block->layout.has_layout() &&
!block->layout.is_default_qualifier) {
_mesa_glsl_error(&@1, state, "duplicate layout(...) qualifiers");
YYERROR;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 17ff0b5..6bded3e 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -255,6 +255,11 @@ struct _mesa_glsl_parse_state {
return ARB_shading_language_420pack_enable || is_version(420, 0);
}
+ bool has_420pack_or_es31() const
+ {
+ return ARB_shading_language_420pack_enable || is_version(420, 310);
+ }
+
bool has_compute_shader() const
{
return ARB_compute_shader_enable || is_version(430, 310);
--
2.4.9
More information about the mesa-dev
mailing list