summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2013-09-25 13:53:56 -0700
committerIan Romanick <[email protected]>2013-10-30 13:49:30 -0700
commit9d6294f5a2337c5aa975c8ac65f775467b51043d (patch)
tree10a6466620c83229e37258d119219fa7aede7c77 /src/glsl
parentf8c579dc0fc0ffed41a86daecbcfe6c3b9843e61 (diff)
glsl: Slightly restructure error generation in validate_explicit_location
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 <[email protected]> Reviewed-by: Paul Berry <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/ast_to_hir.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d30463aa613..68dd7778380 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2053,7 +2053,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.
@@ -2063,10 +2062,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:
@@ -2076,19 +2076,19 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
return;
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;