[Mesa-dev] [PATCH 07/37] glsl: add validation for out layout qualifiers
Timothy Arceri
timothy.arceri at collabora.com
Tue Mar 15 12:56:57 UTC 2016
This adds validation for all qualifiers as allowed by the
table in Section 4.4 (Layout Qualifiers) of the GLSL 4.5 spec.
---
src/compiler/glsl/ast_type.cpp | 33 +++++++++++++++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
index 4f537a9..611f048 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -364,6 +364,8 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
{
void *mem_ctx = state;
const bool r = this->merge_qualifier(loc, state, q, false);
+ ast_type_qualifier valid_out_mask;
+ valid_out_mask.flags.i = 0;
if (state->stage == MESA_SHADER_GEOMETRY) {
if (q.flags.q.prim_type) {
@@ -382,20 +384,47 @@ ast_type_qualifier::merge_out_qualifier(YYLTYPE *loc,
/* Allow future assigments of global out's stream id value */
this->flags.q.explicit_stream = 0;
+
+ valid_out_mask.flags.q.stream = 1;
+ valid_out_mask.flags.q.explicit_stream = 1;
+ valid_out_mask.flags.q.explicit_xfb_buffer = 1;
+ valid_out_mask.flags.q.xfb_buffer = 1;
+ valid_out_mask.flags.q.explicit_xfb_stride = 1;
+ valid_out_mask.flags.q.xfb_stride = 1;
+ valid_out_mask.flags.q.max_vertices = 1;
+ valid_out_mask.flags.q.prim_type = 1;
} else if (state->stage == MESA_SHADER_TESS_CTRL) {
if (create_node) {
node = new(mem_ctx) ast_tcs_output_layout(*loc);
}
- } else if (!(state->stage == MESA_SHADER_TESS_EVAL ||
- state->stage == MESA_SHADER_VERTEX)) {
+ valid_out_mask.flags.q.vertices = 1;
+ valid_out_mask.flags.q.explicit_xfb_buffer = 1;
+ valid_out_mask.flags.q.xfb_buffer = 1;
+ valid_out_mask.flags.q.explicit_xfb_stride = 1;
+ valid_out_mask.flags.q.xfb_stride = 1;
+ } else if (state->stage == MESA_SHADER_TESS_EVAL ||
+ state->stage == MESA_SHADER_VERTEX) {
+ valid_out_mask.flags.q.explicit_xfb_buffer = 1;
+ valid_out_mask.flags.q.xfb_buffer = 1;
+ valid_out_mask.flags.q.explicit_xfb_stride = 1;
+ valid_out_mask.flags.q.xfb_stride = 1;
+ } else {
_mesa_glsl_error(loc, state, "out layout qualifiers only valid in "
"geometry, tessellation and vertex shaders");
+ return false;
}
/* Allow future assigments of global out's */
this->flags.q.explicit_xfb_buffer = 0;
this->flags.q.explicit_xfb_stride = 0;
+ /* Generate an error when invalid input layout qualifiers are used. */
+ if ((q.flags.i & ~valid_out_mask.flags.i) != 0) {
+ _mesa_glsl_error(loc, state,
+ "invalid output layout qualifiers used");
+ return false;
+ }
+
return r;
}
--
2.5.0
More information about the mesa-dev
mailing list