**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_prim.h"
#include "util/u_upload_mgr.h"
#include "brw_context.h"
#include "brw_state.h"
#include "brw_debug.h"
-#include "brw_screen.h"
#include "brw_batchbuffer.h"
struct brw_3d_primitive prim_packet;
int ret;
+ if (BRW_DEBUG & DEBUG_PRIMS)
+ debug_printf("%s start %d count %d indexed %d hw_prim %d\n",
+ __FUNCTION__, start, count, indexed, hw_prim);
+
prim_packet.header.opcode = CMD_3D_PRIM;
prim_packet.header.length = sizeof(prim_packet)/4 - 2;
prim_packet.header.pad = 0;
prim_packet.start_vert_location += brw->ib.start_vertex_offset;
prim_packet.instance_count = 1;
prim_packet.start_instance_location = 0;
- prim_packet.base_vert_location = 0; // prim->basevertex; XXX: add this to gallium
+ prim_packet.base_vert_location = 0; /* prim->basevertex; XXX: add this to gallium */
/* If we're set to always flush, do it before and after the primitive emit.
*/
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)
{
}
-static boolean
+static void
brw_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
hw_prim = brw_set_prim(brw, mode);
if (BRW_DEBUG & DEBUG_PRIMS)
- debug_printf("PRIM: %s %d %d\n", u_prim_name(mode), start, count);
+ debug_printf("PRIM: %s start %d count %d index_buffer %p\n",
+ u_prim_name(mode), start, count, (void *)index_buffer);
/* Potentially trigger upload of new index buffer.
*
* XXX: do we need to go through state validation to achieve this?
* Could just call upload code directly.
*/
- if (brw->curr.index_buffer != index_buffer) {
- pipe_buffer_reference( &brw->curr.index_buffer, index_buffer );
+ if (brw->curr.index_buffer != index_buffer ||
+ brw->curr.index_size != index_size) {
+ pipe_resource_reference( &brw->curr.index_buffer, index_buffer );
+ brw->curr.index_size = index_size;
brw->state.dirty.mesa |= PIPE_NEW_INDEX_BUFFER;
}
ret = try_draw_range_elements(brw, index_buffer, hw_prim, start, count );
assert(ret == 0);
}
-
- return TRUE;
}
-static boolean
+static void
brw_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned mode,
unsigned start, unsigned count)
{
- return brw_draw_range_elements( pipe, index_buffer,
- index_size,
- 0, 0xffffffff,
- mode,
- start, count );
+ brw_draw_range_elements( pipe, index_buffer,
+ index_size,
+ 0, 0xffffffff,
+ mode,
+ start, count );
}
-static boolean
+static void
brw_draw_arrays(struct pipe_context *pipe, unsigned mode,
unsigned start, unsigned count)
{
- return brw_draw_elements(pipe, NULL, 0, mode, start, count);
+ brw_draw_elements(pipe, NULL, 0, mode, start, count);
}
/* Create helpers for uploading data in user buffers:
*/
- brw->vb.upload_vertex = u_upload_create( &brw->brw_screen->base,
+ 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->brw_screen->base,
- 128 * 1024,
+ 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;
u_upload_destroy( brw->vb.upload_vertex );
u_upload_destroy( brw->vb.upload_index );
- brw->sws->bo_unreference(brw->ib.bo);
- brw->ib.bo = NULL;
+ bo_reference(&brw->ib.bo, NULL);
}