Mesa (master): util/prim: assorted fixes for u_decomposed_prims_for_vertices()
Chia-I Wu
olv at kemper.freedesktop.org
Fri May 3 04:00:37 UTC 2013
Module: Mesa
Branch: master
Commit: 90d5190594c57c5f5ac63442ff526b312ea79744
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=90d5190594c57c5f5ac63442ff526b312ea79744
Author: Chia-I Wu <olvaffe at gmail.com>
Date: Thu May 2 14:12:27 2013 +0800
util/prim: assorted fixes for u_decomposed_prims_for_vertices()
Switch to '>=' for comparisons, and it becomes obvious that the comparison for
PIPE_PRIM_QUAD_STRIP was wrong.
Add minimum vertex count check for PIPE_PRIM_LINE_LOOP. Return 1 for
PIPE_PRIM_POLYGON with 3 vertices.
Signed-off-by: Chia-I Wu <olvaffe at gmail.com>
Acked-by: Zack Rusin <zackr at vmware.com>
---
src/gallium/auxiliary/util/u_prim.h | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h
index 94312c2..624a508 100644
--- a/src/gallium/auxiliary/util/u_prim.h
+++ b/src/gallium/auxiliary/util/u_prim.h
@@ -204,42 +204,42 @@ u_vertices_per_prim(int primitive)
static INLINE unsigned
u_decomposed_prims_for_vertices(int primitive, int vertices)
{
- switch(primitive) {
+ switch (primitive) {
case PIPE_PRIM_POINTS:
return vertices;
case PIPE_PRIM_LINES:
return vertices / 2;
case PIPE_PRIM_LINE_LOOP:
- return vertices;
+ return (vertices >= 2) ? vertices : 0;
case PIPE_PRIM_LINE_STRIP:
- return (vertices > 1) ? vertices - 1 : 0;
+ return (vertices >= 2) ? vertices - 1 : 0;
case PIPE_PRIM_TRIANGLES:
- return vertices / 3;
+ return vertices / 3;
case PIPE_PRIM_TRIANGLE_STRIP:
- return (vertices > 2) ? vertices - 2 : 0;
+ return (vertices >= 3) ? vertices - 2 : 0;
case PIPE_PRIM_TRIANGLE_FAN:
- return (vertices > 2) ? vertices - 2 : 0;
+ return (vertices >= 3) ? vertices - 2 : 0;
case PIPE_PRIM_LINES_ADJACENCY:
return vertices / 4;
case PIPE_PRIM_LINE_STRIP_ADJACENCY:
- return (vertices > 3) ? vertices - 3 : 0;
+ return (vertices >= 4) ? vertices - 3 : 0;
case PIPE_PRIM_TRIANGLES_ADJACENCY:
return vertices / 6;
case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
- return (vertices > 5) ? 1 + (vertices - 6)/2 : 0;
+ return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0;
case PIPE_PRIM_QUADS:
return vertices / 4;
case PIPE_PRIM_QUAD_STRIP:
- return (vertices > 4) ? (vertices - 2) / 2 : 0;
+ return (vertices >= 4) ? (vertices - 2) / 2 : 0;
/* Polygons can't be decomposed
* because the number of their vertices isn't known so
* for them and whatever else we don't recognize just
* return 1 if the number of vertices is greater than
- * 3 and zero otherwise */
+ * or equal to 3 and zero otherwise */
case PIPE_PRIM_POLYGON:
default:
debug_printf("Invalid decomposition primitive!\n");
- return (vertices > 3) ? 1 : 0;
+ return (vertices >= 3) ? 1 : 0;
}
}
More information about the mesa-commit
mailing list