summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-10-22 10:26:52 -0700
committerPaul Berry <[email protected]>2013-10-23 16:51:05 -0700
commit8e15207c9d206e3698a240092afdf8cddb6f5c02 (patch)
tree2ca1d0e933e792537234d59e9285c1aafed1ec51 /src/glsl
parent867d0cc1fece5343e8c1655fc1b799aa8fcf5a0d (diff)
glsl/gs: Prevent illegal input/output primitive types.
From the GLSL 1.50 spec, section 4.3.8.1 (Input Layout Qualifiers): The layout qualifier identifiers for geometry shader inputs are layout-qualifier-id points lines lines_adjacency triangles triangles_adjacency And from section 4.3.8.2 (Output Layout Qualifiers) The layout qualifier identifiers for geometry shader outputs are layout-qualifier-id points line_strip triangle_strip max_vertices = integer-constant We were erroneously allowing line_strip and triangle_strip to be used as input qualifiers, and we were allowing lines, lines_adjacency, triangles, and triangles_adjacency to be used as output qualifiers. Fixes piglit tests "glsl-1.50-gs-{input,output}-layout-qualifiers *". Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/glsl_parser.yy35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 00589e28ea2..0a0708e9574 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -2372,6 +2372,7 @@ layout_defaults:
| layout_qualifier IN_TOK ';'
{
void *ctx = state;
+ $$ = NULL;
if (state->target != geometry_shader) {
_mesa_glsl_error(& @1, state,
"input layout qualifiers only valid in "
@@ -2380,8 +2381,22 @@ layout_defaults:
_mesa_glsl_error(& @1, state,
"input layout qualifiers must specify a primitive"
" type");
+ } else {
+ /* Make sure this is a valid input primitive type. */
+ switch ($1.prim_type) {
+ case GL_POINTS:
+ case GL_LINES:
+ case GL_LINES_ADJACENCY:
+ case GL_TRIANGLES:
+ case GL_TRIANGLES_ADJACENCY:
+ $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type);
+ break;
+ default:
+ _mesa_glsl_error(&@1, state,
+ "invalid geometry shader input primitive type");
+ break;
+ }
}
- $$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type);
}
| layout_qualifier OUT_TOK ';'
@@ -2390,8 +2405,22 @@ layout_defaults:
_mesa_glsl_error(& @1, state,
"out layout qualifiers only valid in "
"geometry shaders");
- } else if (!state->out_qualifier->merge_qualifier(& @1, state, $1)) {
- YYERROR;
+ } else {
+ if ($1.flags.q.prim_type) {
+ /* Make sure this is a valid output primitive type. */
+ switch ($1.prim_type) {
+ case GL_POINTS:
+ case GL_LINE_STRIP:
+ case GL_TRIANGLE_STRIP:
+ break;
+ default:
+ _mesa_glsl_error(&@1, state, "invalid geometry shader output "
+ "primitive type");
+ break;
+ }
+ }
+ if (!state->out_qualifier->merge_qualifier(& @1, state, $1))
+ YYERROR;
}
$$ = NULL;
}