util/prim: use vertex count info in u_validate_pipe_prim()
authorChia-I Wu <olvaffe@gmail.com>
Thu, 2 May 2013 05:49:30 +0000 (13:49 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Fri, 3 May 2013 03:59:10 +0000 (11:59 +0800)
As a side effect, primitives with adjacency are now correctly validated.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Acked-by: Zack Rusin <zackr@vmware.com>
src/gallium/auxiliary/util/u_prim.h

index 7415e76c1e7f9cb2a201572b9bad52c23bd9e807..94312c2f4c5dc6bbb25823f0e1358506ac725b77 100644 (file)
@@ -138,39 +138,9 @@ u_prim_vertex_count(unsigned prim)
 
 static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr )
 {
-   boolean ok = TRUE;
-
-   switch (pipe_prim) {
-   case PIPE_PRIM_POINTS:
-      ok = (nr >= 1);
-      break;
-   case PIPE_PRIM_LINES:
-      ok = (nr >= 2);
-      break;
-   case PIPE_PRIM_LINE_STRIP:
-   case PIPE_PRIM_LINE_LOOP:
-      ok = (nr >= 2);
-      break;
-   case PIPE_PRIM_TRIANGLES:
-      ok = (nr >= 3);
-      break;
-   case PIPE_PRIM_TRIANGLE_STRIP:
-   case PIPE_PRIM_TRIANGLE_FAN:
-   case PIPE_PRIM_POLYGON:
-      ok = (nr >= 3);
-      break;
-   case PIPE_PRIM_QUADS:
-      ok = (nr >= 4);
-      break;
-   case PIPE_PRIM_QUAD_STRIP:
-      ok = (nr >= 4);
-      break;
-   default:
-      ok = 0;
-      break;
-   }
+   const struct u_prim_vertex_count *count = u_prim_vertex_count(pipe_prim);
 
-   return ok;
+   return (count && nr >= count->min);
 }