[Mesa-dev] [PATCH] glsl/gs: Prevent illegal input/output primitive types.
Ian Romanick
idr at freedesktop.org
Tue Oct 22 22:35:24 CEST 2013
On 10/22/2013 10:41 AM, Paul Berry wrote:
> 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 <ian.d.romanick at intel.com>
> ---
> src/glsl/glsl_parser.yy | 35 ++++++++++++++++++++++++++++++++---
> 1 file changed, 32 insertions(+), 3 deletions(-)
>
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index 00589e2..0a0708e 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;
> }
>
More information about the mesa-dev
mailing list