diff options
author | Marek Olšák <[email protected]> | 2017-04-02 16:24:39 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-05-10 19:00:16 +0200 |
commit | 330d0607ed60fd3edca192e54b4246310f06652f (patch) | |
tree | 56bceba5b291ffcf42209ef1ab7ec515a8f5b666 /src/gallium/drivers/r300 | |
parent | 22f6624ed318e8131681ec1f2e7b3a59449df412 (diff) |
gallium: remove pipe_index_buffer and set_index_buffer
pipe_draw_info::indexed is replaced with index_size. index_size == 0 means
non-indexed.
Instead of pipe_index_buffer::offset, pipe_draw_info::start is used.
For indexed indirect draws, pipe_draw_info::start is added to the indirect
start. This is the only case when "start" affects indirect draws.
pipe_draw_info::index is a union. Use either index::resource or
index::user depending on the value of pipe_draw_info::has_user_indices.
v2: fixes for nine, svga
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_render_translate.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 33 |
4 files changed, 25 insertions, 52 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 264ace530a2..ce1fab48d5e 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -591,7 +591,6 @@ struct r300_context { void *dsa_decompress_zmask; - struct pipe_index_buffer index_buffer; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; unsigned nr_vertex_buffers; struct u_upload_mgr *uploader; @@ -733,7 +732,7 @@ void r300_stop_query(struct r300_context *r300); /* r300_render_translate.c */ void r300_translate_index_buffer(struct r300_context *r300, - struct pipe_index_buffer *ib, + const struct pipe_draw_info *info, struct pipe_resource **out_index_buffer, unsigned *index_size, unsigned index_offset, unsigned *start, unsigned count); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 1d3e676e322..8eca1438603 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -501,7 +501,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, const uint8_t *ptr1; const uint16_t *ptr2; const uint32_t *ptr4; - unsigned index_size = r300->index_buffer.index_size; + unsigned index_size = info->index_size; unsigned i, count_dwords = index_size == 4 ? info->count : (info->count + 1) / 2; CS_LOCALS(r300); @@ -519,7 +519,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, switch (index_size) { case 1: - ptr1 = (uint8_t*)r300->index_buffer.user_buffer; + ptr1 = (uint8_t*)info->index.user; ptr1 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -543,7 +543,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, break; case 2: - ptr2 = (uint16_t*)r300->index_buffer.user_buffer; + ptr2 = (uint16_t*)info->index.user; ptr2 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -562,7 +562,7 @@ static void r300_draw_elements_immediate(struct r300_context *r300, break; case 4: - ptr4 = (uint32_t*)r300->index_buffer.user_buffer; + ptr4 = (uint32_t*)info->index.user; ptr4 += info->start; OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (info->count << 16) | @@ -584,8 +584,9 @@ static void r300_draw_elements(struct r300_context *r300, const struct pipe_draw_info *info, int instance_id) { - struct pipe_resource *indexBuffer = r300->index_buffer.buffer; - unsigned indexSize = r300->index_buffer.index_size; + struct pipe_resource *indexBuffer = + info->has_user_indices ? NULL : info->index.resource; + unsigned indexSize = info->index_size; struct pipe_resource* orgIndexBuffer = indexBuffer; unsigned start = info->start; unsigned count = info->count; @@ -600,7 +601,7 @@ static void r300_draw_elements(struct r300_context *r300, &index_offset); } - r300_translate_index_buffer(r300, &r300->index_buffer, &indexBuffer, + r300_translate_index_buffer(r300, info, &indexBuffer, &indexSize, index_offset, &start, count); /* Fallback for misaligned ushort indices. */ @@ -621,10 +622,10 @@ static void r300_draw_elements(struct r300_context *r300, count, (uint8_t*)ptr); } } else { - if (r300->index_buffer.user_buffer) + if (info->has_user_indices) r300_upload_index_buffer(r300, &indexBuffer, indexSize, &start, count, - r300->index_buffer.user_buffer); + info->index.user); } /* 19 dwords for emit_draw_elements. Give up if the function fails. */ @@ -792,7 +793,7 @@ static void r300_draw_vbo(struct pipe_context* pipe, r300_update_derived_state(r300); /* Draw. */ - if (info.indexed) { + if (info.index_size) { unsigned max_count = r300_max_vertex_count(r300); if (!max_count) { @@ -807,11 +808,9 @@ static void r300_draw_vbo(struct pipe_context* pipe, } info.max_index = max_count - 1; - info.start += r300->index_buffer.offset / r300->index_buffer.index_size; if (info.instance_count <= 1) { - if (info.count <= 8 && - r300->index_buffer.user_buffer) { + if (info.count <= 8 && info.has_user_indices) { r300_draw_elements_immediate(r300, &info); } else { r300_draw_elements(r300, &info, -1); @@ -850,6 +849,14 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, if (!u_trim_pipe_prim(info->mode, (unsigned*)&info->count)) return; + if (info->index_size) { + draw_set_indexes(r300->draw, + info->has_user_indices ? + info->index.user : + r300_resource(info->index.resource)->malloced_buffer, + info->index_size, ~0); + } + r300_update_derived_state(r300); draw_vbo(r300->draw, info); diff --git a/src/gallium/drivers/r300/r300_render_translate.c b/src/gallium/drivers/r300/r300_render_translate.c index 7800f6eea22..7dc49d35298 100644 --- a/src/gallium/drivers/r300/r300_render_translate.c +++ b/src/gallium/drivers/r300/r300_render_translate.c @@ -26,7 +26,7 @@ void r300_translate_index_buffer(struct r300_context *r300, - struct pipe_index_buffer *ib, + const struct pipe_draw_info *info, struct pipe_resource **out_buffer, unsigned *index_size, unsigned index_offset, unsigned *start, unsigned count) @@ -41,7 +41,7 @@ void r300_translate_index_buffer(struct r300_context *r300, &out_offset, out_buffer, &ptr); util_shorten_ubyte_elts_to_userptr( - &r300->context, ib, PIPE_TRANSFER_UNSYNCHRONIZED, index_offset, + &r300->context, info, PIPE_TRANSFER_UNSYNCHRONIZED, index_offset, *start, count, ptr); *index_size = 2; @@ -54,7 +54,7 @@ void r300_translate_index_buffer(struct r300_context *r300, u_upload_alloc(r300->uploader, 0, count * 2, 4, &out_offset, out_buffer, &ptr); - util_rebuild_ushort_elts_to_userptr(&r300->context, ib, + util_rebuild_ushort_elts_to_userptr(&r300->context, info, PIPE_TRANSFER_UNSYNCHRONIZED, index_offset, *start, count, ptr); @@ -69,7 +69,7 @@ void r300_translate_index_buffer(struct r300_context *r300, u_upload_alloc(r300->uploader, 0, count * 4, 4, &out_offset, out_buffer, &ptr); - util_rebuild_uint_elts_to_userptr(&r300->context, ib, + util_rebuild_uint_elts_to_userptr(&r300->context, info, PIPE_TRANSFER_UNSYNCHRONIZED, index_offset, *start, count, ptr); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index b3bfafd376a..c2b99372f8e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1783,37 +1783,6 @@ static void r300_set_vertex_buffers_swtcl(struct pipe_context* pipe, } } -static void r300_set_index_buffer_hwtcl(struct pipe_context* pipe, - const struct pipe_index_buffer *ib) -{ - struct r300_context* r300 = r300_context(pipe); - - if (ib) { - pipe_resource_reference(&r300->index_buffer.buffer, ib->buffer); - memcpy(&r300->index_buffer, ib, sizeof(*ib)); - } else { - pipe_resource_reference(&r300->index_buffer.buffer, NULL); - } -} - -static void r300_set_index_buffer_swtcl(struct pipe_context* pipe, - const struct pipe_index_buffer *ib) -{ - struct r300_context* r300 = r300_context(pipe); - - if (ib) { - const void *buf = NULL; - if (ib->user_buffer) { - buf = ib->user_buffer; - } else if (ib->buffer) { - buf = r300_resource(ib->buffer)->malloced_buffer; - } - draw_set_indexes(r300->draw, - (const ubyte *) buf + ib->offset, - ib->index_size, ~0); - } -} - /* Initialize the PSC tables. */ static void r300_vertex_psc(struct r300_vertex_element_state *velems) { @@ -2125,10 +2094,8 @@ void r300_init_state_functions(struct r300_context* r300) if (r300->screen->caps.has_tcl) { r300->context.set_vertex_buffers = r300_set_vertex_buffers_hwtcl; - r300->context.set_index_buffer = r300_set_index_buffer_hwtcl; } else { r300->context.set_vertex_buffers = r300_set_vertex_buffers_swtcl; - r300->context.set_index_buffer = r300_set_index_buffer_swtcl; } r300->context.create_vertex_elements_state = r300_create_vertex_elements_state; |