Hold the vertex buffer handle.

This commit is contained in:
José Fonseca 2007-10-31 15:11:18 +00:00
parent 44e6944e9d
commit fe55eab8fa
2 changed files with 13 additions and 8 deletions

View file

@ -81,6 +81,8 @@ struct vbuf_stage {
ushort *element_map; ushort *element_map;
unsigned nr_elements; unsigned nr_elements;
struct pipe_buffer_handle *buf;
unsigned prim; unsigned prim;
struct i915_context *i915; struct i915_context *i915;
@ -278,7 +280,6 @@ static void vbuf_draw( struct draw_stage *stage )
unsigned hwprim; unsigned hwprim;
unsigned i; unsigned i;
char *ptr; char *ptr;
struct pipe_buffer_handle *buf;
switch(vbuf->prim) { switch(vbuf->prim) {
case PIPE_PRIM_POINTS: case PIPE_PRIM_POINTS:
@ -298,9 +299,11 @@ static void vbuf_draw( struct draw_stage *stage )
assert(vbuf->vertex_ptr - vbuf->vertex_map == vbuf->nr_vertices * vertex_size / 4); assert(vbuf->vertex_ptr - vbuf->vertex_map == vbuf->nr_vertices * vertex_size / 4);
/* FIXME: handle failure */ /* FIXME: handle failure */
buf = winsys->buffer_create(winsys, 64); if(!vbuf->buf)
winsys->buffer_data(winsys, buf, 8 + nr * vertex_size, NULL); vbuf->buf = winsys->buffer_create(winsys, 64);
ptr = winsys->buffer_map(winsys, buf, PIPE_BUFFER_FLAG_WRITE);
winsys->buffer_data(winsys, vbuf->buf, 8 + nr * vertex_size, NULL);
ptr = winsys->buffer_map(winsys, vbuf->buf, PIPE_BUFFER_FLAG_WRITE);
*(unsigned *)ptr = _3DPRIMITIVE | *(unsigned *)ptr = _3DPRIMITIVE |
hwprim | hwprim |
((4 + vertex_size * nr)/4 - 2); ((4 + vertex_size * nr)/4 - 2);
@ -313,7 +316,7 @@ static void vbuf_draw( struct draw_stage *stage )
} }
*(unsigned *)ptr = MI_BATCH_BUFFER_END; *(unsigned *)ptr = MI_BATCH_BUFFER_END;
ptr += 4; ptr += 4;
winsys->buffer_unmap(winsys, buf); winsys->buffer_unmap(winsys, vbuf->buf);
if (i915->dirty) if (i915->dirty)
i915_update_derived( i915 ); i915_update_derived( i915 );
@ -345,12 +348,10 @@ static void vbuf_draw( struct draw_stage *stage )
/* chain the vertex buffer in the batch buffer */ /* chain the vertex buffer in the batch buffer */
OUT_BATCH(MI_BATCH_BUFFER_START OUT_BATCH(MI_BATCH_BUFFER_START
| (2 << 6) /* GTT-mapped memory */); | (2 << 6) /* GTT-mapped memory */);
OUT_RELOC( buf, I915_BUFFER_ACCESS_READ, 0 ); OUT_RELOC( vbuf->buf, I915_BUFFER_ACCESS_READ, 0 );
/* FIXME: we need to flush here since control after chained buffers returns /* FIXME: we need to flush here since control after chained buffers returns
* directly to the ring buffer */ * directly to the ring buffer */
FLUSH_BATCH(); FLUSH_BATCH();
winsys->buffer_reference(winsys, &buf, NULL);
} }

View file

@ -69,6 +69,10 @@ struct i915_winsys {
unsigned delta ); unsigned delta );
void (*batch_flush)( struct i915_winsys *sws ); void (*batch_flush)( struct i915_winsys *sws );
#if 0
void (*batch_chain)( struct i915_winsys *sws,
struct pipe_buffer_handle *buf ):
#endif
}; };
#define I915_BUFFER_ACCESS_WRITE 0x1 #define I915_BUFFER_ACCESS_WRITE 0x1