[Mesa-dev] [PATCH 7/7] util/prim: add u_reduced_prims_for_vertices()

Chia-I Wu olvaffe at gmail.com
Thu May 2 00:55:53 PDT 2013


The function returns the number of reduced/tessellated primitives for the
given vertex count.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
---
 src/gallium/auxiliary/util/u_prim.h |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index cf19c88..a63afb8 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -243,6 +243,26 @@ u_decomposed_prims_for_vertices(int primitive, int vertices)
    }
 }
 
+/**
+ * Returns the number of reduced/tessellated primitives for the given vertex
+ * count.  Each quad is treated as two triangles.  Polygons are treated as
+ * triangle fans.
+ */
+static INLINE unsigned
+u_reduced_prims_for_vertices(int primitive, int vertices)
+{
+   switch (primitive) {
+   case PIPE_PRIM_QUADS:
+   case PIPE_PRIM_QUAD_STRIP:
+      return u_decomposed_prims_for_vertices(primitive, vertices) * 2;
+   case PIPE_PRIM_POLYGON:
+      primitive = PIPE_PRIM_TRIANGLE_FAN;
+      /* fall through */
+   default:
+      return u_decomposed_prims_for_vertices(primitive, vertices);
+   }
+}
+
 const char *u_prim_name( unsigned pipe_prim );
 
 #endif
-- 
1.7.10.4



More information about the mesa-dev mailing list