+void
+draw_stats_clipper_primitives(struct draw_context *draw,
+ const struct draw_prim_info *prim_info);
+
+/**
+ * Return index i from the index buffer.
+ * If the index buffer would overflow we return the
+ * maximum possible index.
+ */
+#define DRAW_GET_IDX(_elts, _i) \
+ (((_i) >= draw->pt.user.eltMax) ? DRAW_MAX_FETCH_IDX : (_elts)[_i])
+
+/**
+ * Return index of the given viewport clamping it
+ * to be between 0 <= and < PIPE_MAX_VIEWPORTS
+ */
+static INLINE unsigned
+draw_clamp_viewport_idx(int idx)
+{
+ return ((PIPE_MAX_VIEWPORTS > idx || idx < 0) ? idx : 0);
+}
+
+/**
+ * Adds two unsigned integers and if the addition
+ * overflows then it returns the value from
+ * from the overflow_value variable.
+ */
+static INLINE unsigned
+draw_overflow_uadd(unsigned a, unsigned b,
+ unsigned overflow_value)
+{
+ unsigned res = a + b;
+ if (res < a || res < b) {
+ res = overflow_value;
+ }
+ return res;
+}