<div dir="ltr">On 28 January 2014 11:22, Jordan Justen <span dir="ltr"><<a href="mailto:jordan.l.justen@intel.com" target="_blank">jordan.l.justen@intel.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">_mesa_glsl_parse_state::gs_invocations will store the<br>
invocation count.<br>
<br>
Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br></blockquote><div><br></div><div>This looks like it will work if the shader contains a line like this:<br><br>
layout(triangles, invocations=6) in;<br><br></div><div>But it won't handle this:<br><br></div><div> layout(triangles) in;<br></div><div> layout(invocations=6) in;<br><br></div>Although it's not explicitly mentioned in the GLSL spec, I believe that this should be allowed too. (The spec does explicitly allow similar splitting of geometry shader output layout qualifiers.)<br>
<br></div><div class="gmail_quote">Note that the way we handle geometry shader input primitive types is unusual, so it might not have been the best to imitate. For other types of shader-global layout qualifiers (i.e. geometry shader output primitive count and geometry shader max_vertices), the code in glsl_parser.yy simply merges the qualifiers into the global state->out_qualifier object at the time that they are parsed. The reason we handle geometry shader input primitive types specially is because they have additional semantics (they cause geometry shader input arrays to be resized), so we can't process them until ast-to-hir time. But that doesn't apply to the invocation count.<br>
<br></div><div class="gmail_quote">I'd recommend an in_qualifier field to _mesa_glsl_parse_state, and handling invocations the same way that geometry shader output qualifiers are handled (grep for "->out_qualifier" to how this works). Unfortuneatly, because of the extra semantics associated with input primitive types, we'll still have to process them specially.<br>
<br>So I think the code in glsl_parser.yy will need to look something like this:<br><br> | layout_qualifier IN_TOK ';'<br> {<br> void *ctx = state;<br> $$ = NULL;<br> if (state->stage != MESA_SHADER_GEOMETRY) {<br>
_mesa_glsl_error(& @1, state,<br> "input layout qualifiers only valid in "<br> "geometry shaders");<br> } else {<br> if ($1.flags.q.prim_type) {<br>
/* Make sure this is a valid input primitive type. */<br> switch ($1.prim_type) {<br> case GL_POINTS:<br> case GL_LINES:<br> case GL_LINES_ADJACENCY:<br> case GL_TRIANGLES:<br>
case GL_TRIANGLES_ADJACENCY:<br> $$ = new(ctx) ast_gs_input_layout(@1, $1);<br> break;<br> default:<br> _mesa_glsl_error(&@1, state,<br> "invalid geometry shader input primitive type");<br>
break;<br> }<br> }<br> if (!state->in_qualifier->merge_qualifier(& @1, state, $1))<br> YYERROR;<br> }<br> }<br></div></div></div>