summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-05-02 14:28:12 +0800
committerChia-I Wu <[email protected]>2013-05-03 11:59:10 +0800
commitf87dccdc19416fd8d47b995f9b0f0c54534bfd16 (patch)
tree0a52b345f3235cb222d298e5099e5c32573a4e1f /src/gallium
parent90d5190594c57c5f5ac63442ff526b312ea79744 (diff)
util/prim: add u_reduced_prims_for_vertices()
The function returns the number of reduced/tessellated primitives for the given vertex count. Signed-off-by: Chia-I Wu <[email protected]> Acked-by: Zack Rusin <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/util/u_prim.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index 624a508c42c..8f444a30529 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