<div dir="ltr">On 27 October 2013 14:59, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>

<br>
This will simplify the addition of layout(location) qualifiers for<br>
separate shader objects.  This was validated with new piglit tests<br>
arb_explicit_attrib_location/1.30/compiler/not-enabled-01.vert and<br>
arb_explicit_attrib_location/1.30/compiler/not-enabled-02.vert.<br>
<br>
Signed-off-by: Ian Romanick <<a href="mailto:ian.d.romanick@intel.com">ian.d.romanick@intel.com</a>><br>
---<br>
 src/glsl/ast_to_hir.cpp | 23 +++++++++++++++++++++++<br>
 src/glsl/glsl_parser.yy | 34 +++++++++++++++-------------------<br>
 2 files changed, 38 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp<br>
index 8441360..4343176 100644<br>
--- a/src/glsl/ast_to_hir.cpp<br>
+++ b/src/glsl/ast_to_hir.cpp<br>
@@ -2059,6 +2059,9 @@ validate_explicit_location(const struct ast_type_qualifier *qual,<br>
    switch (state->target) {<br>
    case vertex_shader:<br>
       if (var->mode == ir_var_shader_in) {<br>
+         if (!state->has_explicit_attrib_location())<br>
+            goto needed_explicit_attrib_location;<br>
+<br>
          break;<br>
       }<br>
<br>
@@ -2073,6 +2076,9 @@ validate_explicit_location(const struct ast_type_qualifier *qual,<br>
<br>
    case fragment_shader:<br>
       if (var->mode == ir_var_shader_out) {<br>
+         if (!state->has_explicit_attrib_location())<br>
+            goto needed_explicit_attrib_location;<br>
+<br>
          break;<br>
       }<br>
<br>
@@ -2122,6 +2128,23 @@ validate_explicit_location(const struct ast_type_qualifier *qual,<br>
          }<br>
       }<br>
    }<br>
+<br>
+   return;<br>
+<br>
+needed_explicit_attrib_location:<br>
+   if (state->es_shader) {<br>
+      _mesa_glsl_error(loc, state,<br>
+                       "%s explicit location requires %s",<br>
+                       mode_string(var),<br>
+                       "GLSL ES 300");<br>
+   } else {<br>
+      _mesa_glsl_error(loc, state,<br>
+                       "%s explicit location requires %s",<br>
+                       mode_string(var),<br>
+                       "GL_ARB_explicit_attrib_location extension or GLSL 330");<br>
+   }<br>
+<br>
+   return;<br></blockquote><div><br></div><div>I'm not really a fan of the goto statements here.  We already have a convention of adding "check_" functions which return true if something is ok, and report an error and return false if it's not (see check_version, check_precision_qualifiers_allowed, and check_bitwise_operations_allowed).  How about if we do a similar thing and create a "check_explicit_attrib_location_allowed()" function.  Then the hunks above can just say:<br>
<br></div><div>if (!state->check_explicit_attrib_location_allowed())<br></div><div>   return;<br><br></div><div>With that change, this patch is:<br><br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br>
<br></div><div>I sent out comments on patches 1, 2, and 4.  Patches 3 and 5 are:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

 }<br>
<br>
 static void<br>
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy<br>
index 0a0708e..4aacc67 100644<br>
--- a/src/glsl/glsl_parser.yy<br>
+++ b/src/glsl/glsl_parser.yy<br>
@@ -1308,29 +1308,25 @@ layout_qualifier_id:<br>
    {<br>
       memset(& $$, 0, sizeof($$));<br>
<br>
-      if (state->has_explicit_attrib_location()) {<br>
-         if (match_layout_qualifier("location", $1, state) == 0) {<br>
-            $$.flags.q.explicit_location = 1;<br>
+      if (match_layout_qualifier("location", $1, state) == 0) {<br>
+         $$.flags.q.explicit_location = 1;<br>
<br>
-            if ($3 >= 0) {<br>
-               $$.location = $3;<br>
-            } else {<br>
-               _mesa_glsl_error(& @3, state,<br>
-                                "invalid location %d specified", $3);<br>
-               YYERROR;<br>
-            }<br>
+         if ($3 >= 0) {<br>
+            $$.location = $3;<br>
+         } else {<br>
+             _mesa_glsl_error(& @3, state, "invalid location %d specified", $3);<br>
+             YYERROR;<br>
          }<br>
+      }<br>
<br>
-         if (match_layout_qualifier("index", $1, state) == 0) {<br>
-            $$.flags.q.explicit_index = 1;<br>
+      if (match_layout_qualifier("index", $1, state) == 0) {<br>
+         $$.flags.q.explicit_index = 1;<br>
<br>
-            if ($3 >= 0) {<br>
-               $$.index = $3;<br>
-            } else {<br>
-               _mesa_glsl_error(& @3, state,<br>
-                                "invalid index %d specified", $3);<br>
-               YYERROR;<br>
-            }<br>
+         if ($3 >= 0) {<br>
+            $$.index = $3;<br>
+         } else {<br>
+            _mesa_glsl_error(& @3, state, "invalid index %d specified", $3);<br>
+            YYERROR;<br>
          }<br>
       }<br>
<span class=""><font color="#888888"><br>
--<br>
1.8.1.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>