summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw/draw_private.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/draw/draw_private.h')
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 84344c36773..44698db93d0 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -186,7 +186,8 @@ struct draw_context
/** bytes per index (0, 1, 2 or 4) */
unsigned eltSizeIB;
unsigned eltSize;
- int eltBias;
+ unsigned eltMax;
+ int eltBias;
unsigned min_index;
unsigned max_index;
@@ -460,4 +461,12 @@ draw_get_rasterizer_no_cull( struct draw_context *draw,
boolean flatshade );
+/**
+ * Return index i from the index buffer.
+ * If the index buffer would overflow we return the
+ * index of the first element in the vb.
+ */
+#define DRAW_GET_IDX(elts, i) \
+ ((i) >= draw->pt.user.eltMax) ? 0 : elts[i]
+
#endif /* DRAW_PRIVATE_H */