gallium: add an inline that returns number of vertices per primitive
authorZack Rusin <zackr@vmware.com>
Wed, 23 Dec 2009 17:39:21 +0000 (12:39 -0500)
committerZack Rusin <zackr@vmware.com>
Fri, 25 Dec 2009 10:52:18 +0000 (05:52 -0500)
src/gallium/include/pipe/p_inlines.h

index 5fbd62a03d2bba16e3f9bda3d8cbb6ede5edb222..95ec55d145e8351187b31994c6692a1649546ae3 100644 (file)
@@ -192,6 +192,38 @@ pipe_transfer_buffer_flags( struct pipe_transfer *transf )
    }
 }
 
+static INLINE unsigned
+pipe_vertices_per_primitive(int primitive)
+{
+   switch(primitive) {
+   case PIPE_PRIM_POINTS:
+      return 1;
+   case PIPE_PRIM_LINES:
+   case PIPE_PRIM_LINE_LOOP:
+   case PIPE_PRIM_LINE_STRIP:
+      return 2;
+   case PIPE_PRIM_TRIANGLES:
+   case PIPE_PRIM_TRIANGLE_STRIP:
+   case PIPE_PRIM_TRIANGLE_FAN:
+      return 3;
+   case PIPE_PRIM_LINES_ADJACENCY:
+   case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+      return 4;
+   case PIPE_PRIM_TRIANGLES_ADJACENCY:
+   case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+      return 6;
+
+   /* following primitives should never be used
+    * with geometry shaders */
+   case PIPE_PRIM_POLYGON:
+   case PIPE_PRIM_QUADS:
+   case PIPE_PRIM_QUAD_STRIP:
+   default:
+      debug_printf("Unrecognized geometry shader primitive");
+      return 3;
+   }
+}
+
 #ifdef __cplusplus
 }
 #endif