draw: Implement draw_arrays() in terms of draw_arrays_instanced().
authorMichal Krol <michal@vmware.com>
Wed, 30 Dec 2009 17:54:04 +0000 (18:54 +0100)
committerMichal Krol <michal@vmware.com>
Wed, 30 Dec 2009 17:54:04 +0000 (18:54 +0100)
src/gallium/auxiliary/draw/draw_pt.c

index 1217b9e5d784f326b71bf9f06f146ad334de8093..a5ddec52863fb21654fb52c4e8cf3d61240fe0e6 100644 (file)
@@ -280,20 +280,33 @@ void
 draw_arrays(struct draw_context *draw, unsigned prim,
             unsigned start, unsigned count)
 {
-   unsigned reduced_prim = u_reduced_prim(prim);
+   draw_arrays_instanced(draw, prim, start, count, 0, 1);
+}
+
+void
+draw_arrays_instanced(struct draw_context *draw,
+                      unsigned mode,
+                      unsigned start,
+                      unsigned count,
+                      unsigned startInstance,
+                      unsigned instanceCount)
+{
+   unsigned reduced_prim = u_reduced_prim(mode);
+   unsigned instance;
+
    if (reduced_prim != draw->reduced_prim) {
-      draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
+      draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
       draw->reduced_prim = reduced_prim;
    }
 
    if (0)
-      draw_print_arrays(draw, prim, start, MIN2(count, 20));
+      draw_print_arrays(draw, mode, start, MIN2(count, 20));
 
 #if 0
    {
       int i;
-      debug_printf("draw_arrays(prim=%u start=%u count=%u):\n",
-                   prim, start, count);
+      debug_printf("draw_arrays(mode=%u start=%u count=%u):\n",
+                   mode, start, count);
       tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
       debug_printf("Elements:\n");
       for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
@@ -311,27 +324,6 @@ draw_arrays(struct draw_context *draw, unsigned prim,
    }
 #endif
 
-   /* drawing done here: */
-   draw->instance_id = 0;
-   draw_pt_arrays(draw, prim, start, count);
-}
-
-void
-draw_arrays_instanced(struct draw_context *draw,
-                      unsigned mode,
-                      unsigned start,
-                      unsigned count,
-                      unsigned startInstance,
-                      unsigned instanceCount)
-{
-   unsigned reduced_prim = u_reduced_prim(mode);
-   unsigned instance;
-
-   if (reduced_prim != draw->reduced_prim) {
-      draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
-      draw->reduced_prim = reduced_prim;
-   }
-
    for (instance = 0; instance < instanceCount; instance++) {
       draw->instance_id = instance + startInstance;
       draw_pt_arrays(draw, mode, start, count);