[Mesa-dev] [PATCH 5/6] glsl: Slightly restructure error generation in validate_explicit_location

Ian Romanick idr at freedesktop.org
Sun Oct 27 22:59:06 CET 2013


From: Ian Romanick <ian.d.romanick at intel.com>

Use mode_string to get the name of the variable mode.  Slightly change
the control flow.  Both of these changes make it easier to support
separate shader object location layouts.

The format of the message changed because mode_string can return a
string like "shader output".  This would result in an awkward message
like "vertex shader shader output..."

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/ast_to_hir.cpp | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 9bce893..8441360 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2049,7 +2049,6 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
                            YYLTYPE *loc)
 {
    bool fail = false;
-   const char *string = "";
 
    /* In the vertex shader only shader inputs can be given explicit
     * locations.
@@ -2059,10 +2058,11 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
     */
    switch (state->target) {
    case vertex_shader:
-      if (var->mode != ir_var_shader_in) {
-         fail = true;
-         string = "input";
+      if (var->mode == ir_var_shader_in) {
+         break;
       }
+
+      fail = true;
       break;
 
    case geometry_shader:
@@ -2072,19 +2072,19 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
       break;
 
    case fragment_shader:
-      if (var->mode != ir_var_shader_out) {
-         fail = true;
-         string = "output";
+      if (var->mode == ir_var_shader_out) {
+         break;
       }
+
+      fail = true;
       break;
    };
 
    if (fail) {
       _mesa_glsl_error(loc, state,
-                       "only %s shader %s variables can be given an "
-                       "explicit location",
-                       _mesa_glsl_shader_target_name(state->target),
-                       string);
+                       "%s cannot be given an explicit location in %s shader",
+                       mode_string(var),
+		       _mesa_glsl_shader_target_name(state->target));
    } else {
       var->explicit_location = true;
 
-- 
1.8.1.4



More information about the mesa-dev mailing list