Merge remote branch 'origin/7.8'
[mesa.git] / src / gallium / drivers / i965 / brw_draw.c
index ea8d39adaf0ec06c96c6b1006be1fd5992b6c8b6..4625c2048f91e5744fe40448fa7c7848e38a11f8 100644 (file)
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 
+#include "util/u_inlines.h"
 #include "util/u_prim.h"
 #include "util/u_upload_mgr.h"
 
@@ -34,7 +35,6 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_debug.h"
-#include "brw_screen.h"
 
 #include "brw_batchbuffer.h"
 
@@ -142,7 +142,7 @@ static int brw_emit_prim(struct brw_context *brw,
  */
 static int
 try_draw_range_elements(struct brw_context *brw,
-                       struct pipe_buffer *index_buffer,
+                       struct pipe_resource *index_buffer,
                        unsigned hw_prim, 
                        unsigned start, unsigned count)
 {
@@ -178,8 +178,8 @@ try_draw_range_elements(struct brw_context *brw,
 
 static void
 brw_draw_range_elements(struct pipe_context *pipe,
-                       struct pipe_buffer *index_buffer,
-                       unsigned index_size,
+                       struct pipe_resource *index_buffer,
+                       unsigned index_size, int index_bias,
                        unsigned min_index,
                        unsigned max_index,
                        unsigned mode, unsigned start, unsigned count)
@@ -194,6 +194,8 @@ brw_draw_range_elements(struct pipe_context *pipe,
       debug_printf("PRIM: %s start %d count %d index_buffer %p\n",
                    u_prim_name(mode), start, count, (void *)index_buffer);
 
+   assert(index_bias == 0);
+
    /* Potentially trigger upload of new index buffer.
     *
     * XXX: do we need to go through state validation to achieve this?
@@ -201,7 +203,7 @@ brw_draw_range_elements(struct pipe_context *pipe,
     */
    if (brw->curr.index_buffer != index_buffer ||
        brw->curr.index_size != index_size) {
-      pipe_buffer_reference( &brw->curr.index_buffer, index_buffer );
+      pipe_resource_reference( &brw->curr.index_buffer, index_buffer );
       brw->curr.index_size = index_size;
       brw->state.dirty.mesa |= PIPE_NEW_INDEX_BUFFER;
    }
@@ -232,13 +234,13 @@ brw_draw_range_elements(struct pipe_context *pipe,
 
 static void
 brw_draw_elements(struct pipe_context *pipe,
-                 struct pipe_buffer *index_buffer,
-                 unsigned index_size,
+                 struct pipe_resource *index_buffer,
+                 unsigned index_size, int index_bias,
                  unsigned mode, 
                  unsigned start, unsigned count)
 {
    brw_draw_range_elements( pipe, index_buffer,
-                            index_size,
+                            index_size, index_bias,
                             0, 0xffffffff,
                             mode, 
                             start, count );
@@ -248,7 +250,7 @@ static void
 brw_draw_arrays(struct pipe_context *pipe, unsigned mode,
                      unsigned start, unsigned count)
 {
-   brw_draw_elements(pipe, NULL, 0, mode, start, count);
+   brw_draw_elements(pipe, NULL, 0, 0, mode, start, count);
 }
 
 
@@ -263,17 +265,17 @@ boolean brw_draw_init( struct brw_context *brw )
 
    /* Create helpers for uploading data in user buffers:
     */
-   brw->vb.upload_vertex = u_upload_create( brw->base.screen,
+   brw->vb.upload_vertex = u_upload_create( &brw->base,
                                            128 * 1024,
                                            64,
-                                           PIPE_BUFFER_USAGE_VERTEX );
+                                           PIPE_BIND_VERTEX_BUFFER );
    if (brw->vb.upload_vertex == NULL)
       return FALSE;
 
-   brw->vb.upload_index = u_upload_create( brw->base.screen,
+   brw->vb.upload_index = u_upload_create( &brw->base,
                                           32 * 1024,
                                           64,
-                                          PIPE_BUFFER_USAGE_INDEX );
+                                          PIPE_BIND_INDEX_BUFFER );
    if (brw->vb.upload_index == NULL)
       return FALSE;