diff options
author | Marek Olšák <[email protected]> | 2012-03-31 04:56:48 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-04-24 01:39:21 +0200 |
commit | 31714ea4d5a20285f398286fe45b53d0609926dd (patch) | |
tree | 55bef20927e0c26953bfbfd5e7747e17bcdc564b /src/gallium/drivers | |
parent | 76c4760e5d8522780d770f9a0a62d710806206a0 (diff) |
u_vbuf: override set_index_buffer
This makes u_vbuf_mgr call the driver instead of the other way around.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 22 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 15 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_pipe.h | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_state_common.c | 16 |
5 files changed, 31 insertions, 26 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index b679592c0bf..de582666ec9 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -579,7 +579,7 @@ struct r300_context { void *dsa_decompress_zmask; struct u_vbuf *vbuf_mgr; - struct pipe_index_buffer swtcl_index_buffer; + struct pipe_index_buffer index_buffer; struct pipe_vertex_buffer swtcl_vertex_buffer[PIPE_MAX_ATTRIBS]; unsigned swtcl_nr_vertex_buffers; diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 5981bec4023..49013c061b7 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -511,7 +511,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, uint8_t *ptr1; uint16_t *ptr2; uint32_t *ptr4; - unsigned index_size = r300->vbuf_mgr->index_buffer.index_size; + unsigned index_size = r300->index_buffer.index_size; unsigned i, count_dwords = index_size == 4 ? info->count : (info->count + 1) / 2; CS_LOCALS(r300); @@ -529,7 +529,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, switch (index_size) { case 1: - ptr1 = r300_resource(r300->vbuf_mgr->index_buffer.buffer)->b.user_ptr; + ptr1 = r300_resource(r300->index_buffer.buffer)->b.user_ptr; ptr1 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -553,7 +553,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, break; case 2: - ptr2 = (uint16_t*)r300_resource(r300->vbuf_mgr->index_buffer.buffer)->b.user_ptr; + ptr2 = (uint16_t*)r300_resource(r300->index_buffer.buffer)->b.user_ptr; ptr2 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -572,7 +572,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, break; case 4: - ptr4 = (uint32_t*)r300_resource(r300->vbuf_mgr->index_buffer.buffer)->b.user_ptr; + ptr4 = (uint32_t*)r300_resource(r300->index_buffer.buffer)->b.user_ptr; ptr4 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -594,8 +594,8 @@ static void r300_draw_elements(struct r300_context *r300, const struct pipe_draw_info *info, int instance_id) { - struct pipe_resource *indexBuffer = r300->vbuf_mgr->index_buffer.buffer; - unsigned indexSize = r300->vbuf_mgr->index_buffer.index_size; + struct pipe_resource *indexBuffer = r300->index_buffer.buffer; + unsigned indexSize = r300->index_buffer.index_size; struct pipe_resource* orgIndexBuffer = indexBuffer; unsigned start = info->start; unsigned count = info->count; @@ -746,7 +746,7 @@ static void r300_draw_vbo(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); struct pipe_draw_info info = *dinfo; - info.indexed = info.indexed && r300->vbuf_mgr->index_buffer.buffer; + info.indexed = info.indexed && r300->index_buffer.buffer; if (r300->skip_rendering || !u_trim_pipe_prim(info.mode, &info.count)) { @@ -776,11 +776,11 @@ static void r300_draw_vbo(struct pipe_context* pipe, } info.max_index = max_count - 1; - info.start += r300->vbuf_mgr->index_buffer.offset / r300->vbuf_mgr->index_buffer.index_size; + info.start += r300->index_buffer.offset / r300->index_buffer.index_size; if (info.instance_count <= 1) { if (info.count <= 8 && - r300_resource(r300->vbuf_mgr->index_buffer.buffer)->b.user_ptr) { + r300_resource(r300->index_buffer.buffer)->b.user_ptr) { r300_draw_elements_immediate(r300, &info); } else { r300_draw_elements(r300, &info, -1); @@ -818,7 +818,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, struct pipe_transfer *ib_transfer = NULL; int i; void *indices = NULL; - boolean indexed = info->indexed && r300->swtcl_index_buffer.buffer; + boolean indexed = info->indexed && r300->index_buffer.buffer; if (r300->skip_rendering) { return; @@ -843,7 +843,7 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, } if (indexed) { - indices = pipe_buffer_map(pipe, r300->swtcl_index_buffer.buffer, + indices = pipe_buffer_map(pipe, r300->index_buffer.buffer, PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED, &ib_transfer); } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 10625b45e3e..ab5c18158d1 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1618,15 +1618,14 @@ static void r300_set_index_buffer(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); - if (r300->screen->caps.has_tcl) { - u_vbuf_set_index_buffer(r300->vbuf_mgr, ib); + if (ib) { + pipe_resource_reference(&r300->index_buffer.buffer, ib->buffer); + memcpy(&r300->index_buffer, ib, sizeof(*ib)); } else { - if (ib) { - pipe_resource_reference(&r300->swtcl_index_buffer.buffer, ib->buffer); - memcpy(&r300->swtcl_index_buffer, ib, sizeof(*ib)); - } else { - pipe_resource_reference(&r300->swtcl_index_buffer.buffer, NULL); - } + pipe_resource_reference(&r300->index_buffer.buffer, NULL); + } + + if (!r300->screen->caps.has_tcl) { draw_set_index_buffer(r300->draw, ib); } } diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h index fd134fae0c6..e49fbdf898a 100644 --- a/src/gallium/drivers/r600/r600_pipe.h +++ b/src/gallium/drivers/r600/r600_pipe.h @@ -353,6 +353,8 @@ struct r600_context { bool vertex_buffers_dirty; boolean dual_src_blend; unsigned color0_format; + + struct pipe_index_buffer index_buffer; }; static INLINE void r600_emit_atom(struct r600_context *rctx, struct r600_atom *atom) diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 706b00c77e5..a2cf05def17 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -382,13 +382,17 @@ void r600_delete_vertex_element(struct pipe_context *ctx, void *state) FREE(state); } - void r600_set_index_buffer(struct pipe_context *ctx, const struct pipe_index_buffer *ib) { struct r600_context *rctx = (struct r600_context *)ctx; - u_vbuf_set_index_buffer(rctx->vbuf_mgr, ib); + if (ib) { + pipe_resource_reference(&rctx->index_buffer.buffer, ib->buffer); + memcpy(&rctx->index_buffer, ib, sizeof(*ib)); + } else { + pipe_resource_reference(&rctx->index_buffer.buffer, NULL); + } } void r600_set_vertex_buffers(struct pipe_context *ctx, unsigned count, @@ -748,7 +752,7 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo) uint8_t *ptr; if ((!info.count && (info.indexed || !info.count_from_stream_output)) || - (info.indexed && !rctx->vbuf_mgr->index_buffer.buffer) || + (info.indexed && !rctx->index_buffer.buffer) || !r600_conv_pipe_prim(info.mode, &prim)) { assert(0); return; @@ -773,9 +777,9 @@ void r600_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo) if (info.indexed) { /* Initialize the index buffer struct. */ - pipe_resource_reference(&ib.buffer, rctx->vbuf_mgr->index_buffer.buffer); - ib.index_size = rctx->vbuf_mgr->index_buffer.index_size; - ib.offset = rctx->vbuf_mgr->index_buffer.offset + info.start * ib.index_size; + pipe_resource_reference(&ib.buffer, rctx->index_buffer.buffer); + ib.index_size = rctx->index_buffer.index_size; + ib.offset = rctx->index_buffer.offset + info.start * ib.index_size; /* Translate or upload, if needed. */ r600_translate_index_buffer(rctx, &ib, info.count); |