Mesa (master): glsl: Error out on invalid uses of the early_fragment_tests layout qualifier.
Francisco Jerez
currojerez at kemper.freedesktop.org
Mon May 4 15:40:22 UTC 2015
Module: Mesa
Branch: master
Commit: 6c1f6f8291859209a9b585f65258e090d91f0347
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c1f6f8291859209a9b585f65258e090d91f0347
Author: Francisco Jerez <currojerez at riseup.net>
Date: Thu Dec 4 10:54:13 2014 +0200
glsl: Error out on invalid uses of the early_fragment_tests layout qualifier.
Reviewed-by: Matt Turner <mattst88 at gmail.com>
---
src/glsl/ast_to_hir.cpp | 14 ++++++++++++++
src/glsl/ast_type.cpp | 10 +++++-----
src/glsl/glsl_parser.yy | 15 +++++++++++++++
3 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index fa05c65..7051d93 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2802,6 +2802,20 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
}
apply_image_qualifier_to_variable(qual, var, state, loc);
+
+ /* From section 4.4.1.3 of the GLSL 4.50 specification (Fragment Shader
+ * Inputs):
+ *
+ * "Fragment shaders also allow the following layout qualifier on in only
+ * (not with variable declarations)
+ * layout-qualifier-id
+ * early_fragment_tests
+ * [...]"
+ */
+ if (qual->flags.q.early_fragment_tests) {
+ _mesa_glsl_error(loc, state, "early_fragment_tests layout qualifier only "
+ "valid in fragment shader input layout declaration.");
+ }
}
/**
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index b596cd5..34c2b73 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -293,11 +293,7 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
valid_in_mask.flags.q.invocations = 1;
break;
case MESA_SHADER_FRAGMENT:
- if (q.flags.q.early_fragment_tests) {
- state->early_fragment_tests = true;
- } else {
- _mesa_glsl_error(loc, state, "invalid input layout qualifier");
- }
+ valid_in_mask.flags.q.early_fragment_tests = 1;
break;
case MESA_SHADER_COMPUTE:
create_cs_ast |=
@@ -345,6 +341,10 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
this->invocations = q.invocations;
}
+ if (q.flags.q.early_fragment_tests) {
+ state->early_fragment_tests = true;
+ }
+
if (create_gs_ast) {
node = new(mem_ctx) ast_gs_input_layout(*loc, q.prim_type);
} else if (create_cs_ast) {
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index c305889..a3ba3f6 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1366,6 +1366,21 @@ layout_qualifier_id:
if (!$$.flags.i &&
match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
+ /* From section 4.4.1.3 of the GLSL 4.50 specification
+ * (Fragment Shader Inputs):
+ *
+ * "Fragment shaders also allow the following layout
+ * qualifier on in only (not with variable declarations)
+ * layout-qualifier-id
+ * early_fragment_tests
+ * [...]"
+ */
+ if (state->stage != MESA_SHADER_FRAGMENT) {
+ _mesa_glsl_error(& @1, state,
+ "early_fragment_tests layout qualifier only "
+ "valid in fragment shaders");
+ }
+
$$.flags.q.early_fragment_tests = 1;
}
}
More information about the mesa-commit
mailing list