glsl: During linking, record whether a GS uses EndPrimitive().
authorPaul Berry <stereotype441@gmail.com>
Mon, 19 Aug 2013 03:59:37 +0000 (20:59 -0700)
committerPaul Berry <stereotype441@gmail.com>
Wed, 11 Sep 2013 18:16:35 +0000 (11:16 -0700)
This information will be useful in the i965 back end, since we can
save some compilation effort if we know from the outset that the
shader never calls EndPrimitive().

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c

index 65afc2e69b4ff4474071c66a78bccf4fb7a756b0..8a143fddfca8299576fd411fd6ce0d4f7cc43816 100644 (file)
@@ -249,6 +249,33 @@ public:
 };
 
 
+/**
+ * Visitor that determines whether or not a shader uses ir_end_primitive.
+ */
+class find_end_primitive_visitor : public ir_hierarchical_visitor {
+public:
+   find_end_primitive_visitor()
+      : found(false)
+   {
+      /* empty */
+   }
+
+   virtual ir_visitor_status visit(ir_end_primitive *)
+   {
+      found = true;
+      return visit_stop;
+   }
+
+   bool end_primitive_found()
+   {
+      return found;
+   }
+
+private:
+   bool found;
+};
+
+
 void
 linker_error(gl_shader_program *prog, const char *fmt, ...)
 {
@@ -517,6 +544,10 @@ validate_geometry_shader_executable(struct gl_shader_program *prog,
 
    analyze_clip_usage("geometry", prog, shader, &prog->Geom.UsesClipDistance,
                       &prog->Geom.ClipDistanceArraySize);
+
+   find_end_primitive_visitor end_primitive;
+   end_primitive.run(shader->ir);
+   prog->Geom.UsesEndPrimitive = end_primitive.end_primitive_found();
 }
 
 
index ca7111e509b008aa5902112e3c3fb9e3e0b26556..9df165403bdb2d01dc19d4f58fe67af30e203848 100644 (file)
@@ -1931,6 +1931,7 @@ struct gl_geometry_program
                            GL_TRIANGLES, or GL_TRIANGLES_ADJACENCY_ARB */
    GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */
    GLboolean UsesClipDistance;
+   GLboolean UsesEndPrimitive;
 };
 
 
@@ -2364,6 +2365,7 @@ struct gl_shader_program
       GLboolean UsesClipDistance;
       GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
                                          0 if not present. */
+      GLboolean UsesEndPrimitive;
    } Geom;
 
    /** Vertex shader state */
index 4fe9d9ca252e12c53b1376f3ea57d4bbecf1e495..a2386fb133e105102fc70da5109f766a9fee4e37 100644 (file)
@@ -1872,6 +1872,7 @@ _mesa_copy_linked_program_data(gl_shader_type type,
       dst_gp->InputType = src->Geom.InputType;
       dst_gp->OutputType = src->Geom.OutputType;
       dst_gp->UsesClipDistance = src->Geom.UsesClipDistance;
+      dst_gp->UsesEndPrimitive = src->Geom.UsesEndPrimitive;
    }
       break;
    default: