draw: trim incoming primitives
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 30 May 2008 13:51:09 +0000 (14:51 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 30 May 2008 16:49:10 +0000 (17:49 +0100)
src/gallium/auxiliary/draw/draw_pt.c

index 7230771..f0d7b51 100644 (file)
 #include "draw/draw_private.h"
 #include "draw/draw_pt.h"
 
+static unsigned trim( unsigned count, unsigned first, unsigned incr )
+{
+   return count - (count - first) % incr; 
+}
 
 
 
@@ -54,6 +58,17 @@ draw_pt_arrays(struct draw_context *draw,
    struct draw_pt_middle_end *middle = NULL;
    unsigned opt = 0;
 
+   /* Sanitize primitive length:
+    */
+   {
+      unsigned first, incr;
+      draw_pt_split_prim(prim, &first, &incr);
+      count = trim(count, first, incr); 
+      if (count < first)
+         return TRUE;
+   }
+
+
    if (!draw->render) {
       opt |= PT_PIPELINE;
    }