Merge branch 'mesa_7_6_branch'
[mesa.git] / src / gallium / drivers / softpipe / sp_draw_arrays.c
index 7e3a25e34b1afa145c0e9c7f873e956f0b80f983..d4045816d03ed7a428d8ea6849d057ad84c3b956 100644 (file)
@@ -35,6 +35,7 @@
 #include "pipe/p_context.h"
 #include "pipe/internal/p_winsys_screen.h"
 #include "pipe/p_inlines.h"
+#include "util/u_prim.h"
 
 #include "sp_context.h"
 #include "sp_state.h"
@@ -65,6 +66,7 @@ softpipe_map_constant_buffers(struct softpipe_context *sp)
                                    size);
 }
 
+
 static void
 softpipe_unmap_constant_buffers(struct softpipe_context *sp)
 {
@@ -86,20 +88,6 @@ softpipe_unmap_constant_buffers(struct softpipe_context *sp)
 }
 
 
-static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
-   PIPE_PRIM_POINTS,
-   PIPE_PRIM_LINES,
-   PIPE_PRIM_LINES,
-   PIPE_PRIM_LINES,
-   PIPE_PRIM_TRIANGLES,
-   PIPE_PRIM_TRIANGLES,
-   PIPE_PRIM_TRIANGLES,
-   PIPE_PRIM_TRIANGLES,
-   PIPE_PRIM_TRIANGLES,
-   PIPE_PRIM_TRIANGLES
-};
-
-
 boolean
 softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
@@ -108,15 +96,11 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
 }
 
 
-
 /**
  * Draw vertex arrays, with optional indexing.
  * Basically, map the vertex buffers (and drawing surfaces), then hand off
  * the drawing to the 'draw' module.
- *
- * XXX should the element buffer be specified/bound with a separate function?
  */
-
 boolean
 softpipe_draw_range_elements(struct pipe_context *pipe,
                              struct pipe_buffer *indexBuffer,
@@ -129,12 +113,12 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
    struct draw_context *draw = sp->draw;
    unsigned i;
 
-   sp->reduced_api_prim = reduced_prim[mode];
+   sp->reduced_api_prim = u_reduced_prim(mode);
 
    if (sp->dirty)
       softpipe_update_derived( sp );
 
-   softpipe_map_surfaces(sp);
+   softpipe_map_transfers(sp);
    softpipe_map_constant_buffers(sp);
 
    /*
@@ -147,6 +131,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
                                     PIPE_BUFFER_USAGE_CPU_READ);
       draw_set_mapped_vertex_buffer(draw, i, buf);
    }
+
    /* Map index buffer, if present */
    if (indexBuffer) {
       void *mapped_indexes
@@ -159,10 +144,10 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
    }
    else {
       /* no index/element buffer */
-      draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
+      draw_set_mapped_element_buffer_range(draw, 0, start,
+                                           start + count - 1, NULL);
    }
 
-
    /* draw! */
    draw_arrays(draw, mode, start, count);
 
@@ -182,9 +167,12 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
    /* Note: leave drawing surfaces mapped */
    softpipe_unmap_constant_buffers(sp);
 
+   sp->dirty_render_cache = TRUE;
+   
    return TRUE;
 }
 
+
 boolean
 softpipe_draw_elements(struct pipe_context *pipe,
                        struct pipe_buffer *indexBuffer,
@@ -198,11 +186,9 @@ softpipe_draw_elements(struct pipe_context *pipe,
 }
 
 
-
 void
 softpipe_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
 {
    struct softpipe_context *sp = softpipe_context(pipe);
    draw_set_edgeflags(sp->draw, edgeflags);
 }
-