<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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Grab the parsed invocation count, check for consistency<br>
during linking, and finally save the result in<br>
gl_shader_program Geom.Invocations.<br>
<br>
Signed-off-by: Jordan Justen <<a href="mailto:jordan.l.justen@intel.com">jordan.l.justen@intel.com</a>><br>
---<br>
 src/glsl/glsl_parser_extras.cpp |  2 ++<br>
 src/glsl/linker.cpp             | 18 ++++++++++++++++++<br>
 src/mesa/main/mtypes.h          |  2 ++<br>
 3 files changed, 22 insertions(+)<br>
<br>
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp<br>
index 87784ed..3e98966 100644<br>
--- a/src/glsl/glsl_parser_extras.cpp<br>
+++ b/src/glsl/glsl_parser_extras.cpp<br>
@@ -1339,6 +1339,8 @@ set_shader_inout_layout(struct gl_shader *shader,<br>
    if (state->out_qualifier->flags.q.max_vertices)<br>
       shader->Geom.VerticesOut = state->out_qualifier->max_vertices;<br>
<br>
+   shader->Geom.Invocations = state->gs_invocations;<br>
+<br></blockquote><div><br></div><div>Considering my comment on patch 1, I think this will change to:<br><br></div><div>shader->Geom.Invocations = 0;<br>if (state->in_qualifier->flags.q.invocations)<br></div><div>
   shader->Geom.Invocations = state->in_qualifier->invocations;<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    if (state->gs_input_prim_type_specified) {<br>
       shader->Geom.InputType = state->gs_input_prim_type;<br>
    } else {<br>
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp<br>
index 93b4754..800de0b 100644<br>
--- a/src/glsl/linker.cpp<br>
+++ b/src/glsl/linker.cpp<br>
@@ -1206,6 +1206,7 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,<br>
                                unsigned num_shaders)<br>
 {<br>
    linked_shader->Geom.VerticesOut = 0;<br>
+   linked_shader->Geom.Invocations = 0;<br>
    linked_shader->Geom.InputType = PRIM_UNKNOWN;<br>
    linked_shader->Geom.OutputType = PRIM_UNKNOWN;<br>
<br>
@@ -1259,6 +1260,18 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,<br>
         }<br>
         linked_shader->Geom.VerticesOut = shader->Geom.VerticesOut;<br>
       }<br>
+<br>
+      if (shader->Geom.Invocations != 0) {<br>
+        if (linked_shader->Geom.Invocations != 0 &&<br>
+            linked_shader->Geom.Invocations != shader->Geom.Invocations) {<br>
+           linker_error(prog, "geometry shader defined with conflicting "<br>
+                        "invocation count (%d and %d)\n",<br>
+                        linked_shader->Geom.Invocations,<br>
+                        shader->Geom.Invocations);<br>
+           return;<br>
+        }<br>
+        linked_shader->Geom.Invocations = shader->Geom.Invocations;<br>
+      }<br>
    }<br>
<br>
    /* Just do the intrastage -> interstage propagation right now,<br>
@@ -1285,6 +1298,11 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,<br>
       return;<br>
    }<br>
    prog->Geom.VerticesOut = linked_shader->Geom.VerticesOut;<br>
+<br>
+   if (linked_shader->Geom.Invocations == 0)<br>
+      linked_shader->Geom.Invocations = 1;<br></blockquote><div><br></div><div>I think it would be equivalent if we dropped these two lines and simply initialized linked_shader->Geom.Invocations to 1 at the top of the function--is that right?<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+   prog->Geom.Invocations = linked_shader->Geom.Invocations;<br>
 }<br>
<br>
 /**<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index 3d42a21..2d90b0a 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -2401,6 +2401,7 @@ struct gl_shader<br>
     */<br>
    struct {<br>
       GLint VerticesOut;<br>
+      GLint Invocations;<br></blockquote><div><br></div><div>It would be nice to have a comment above this declaration explaining that if the shader didn't specify an invocation count, this value will be 1 (so that back-end implementors know they don't have to coerce 0 to 1).<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       /**<br>
        * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or<br>
        * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this<br>
@@ -2599,6 +2600,7 @@ struct gl_shader_program<br>
    struct {<br>
       GLint VerticesIn;<br>
       GLint VerticesOut;<br>
+      GLint Invocations;<br></blockquote><div><br></div><div>Same comment applies here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       GLenum InputType;  /**< GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_ARB,<br>
                               GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */<br>
       GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.5.3<br></font></span></blockquote><div><br></div><div>With those minor issues addressed, this patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div>
</div></div></div>