From 330d0607ed60fd3edca192e54b4246310f06652f Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 2 Apr 2017 16:24:39 +0200 Subject: 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 --- src/gallium/drivers/nouveau/nv30/nv30_context.c | 7 ------ src/gallium/drivers/nouveau/nv30/nv30_context.h | 1 - src/gallium/drivers/nouveau/nv30/nv30_draw.c | 12 ++++----- src/gallium/drivers/nouveau/nv30/nv30_push.c | 16 ++++++------ src/gallium/drivers/nouveau/nv30/nv30_resource.c | 4 --- src/gallium/drivers/nouveau/nv30/nv30_state.c | 18 -------------- src/gallium/drivers/nouveau/nv30/nv30_vbo.c | 31 ++++++++++++------------ 7 files changed, 30 insertions(+), 59 deletions(-) (limited to 'src/gallium/drivers/nouveau/nv30') diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c index cec3cd06b58..e137525c2b8 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_context.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c @@ -123,13 +123,6 @@ nv30_invalidate_resource_storage(struct nouveau_context *nv, } } } - if (res->bind & PIPE_BIND_INDEX_BUFFER) { - if (nv30->idxbuf.buffer == res) { - nouveau_bufctx_reset(nv30->bufctx, BUFCTX_IDXBUF); - if (!--ref) - return ref; - } - } if (res->bind & PIPE_BIND_SAMPLER_VIEW) { for (i = 0; i < nv30->fragprog.num_textures; ++i) { diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.h b/src/gallium/drivers/nouveau/nv30/nv30_context.h index 0ab2f95bc20..1496b3760dd 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_context.h +++ b/src/gallium/drivers/nouveau/nv30/nv30_context.h @@ -110,7 +110,6 @@ struct nv30_context { struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned num_vtxbufs; - struct pipe_index_buffer idxbuf; uint32_t vbo_fifo; uint32_t vbo_user; unsigned vbo_min_index; diff --git a/src/gallium/drivers/nouveau/nv30/nv30_draw.c b/src/gallium/drivers/nouveau/nv30/nv30_draw.c index 28d3de932ff..4c587fca75d 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_draw.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_draw.c @@ -430,15 +430,15 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) draw_set_mapped_vertex_buffer(draw, i, map, ~0); } - if (info->indexed) { - const void *map = nv30->idxbuf.user_buffer; + if (info->index_size) { + const void *map = info->has_user_indices ? info->index.user : NULL; if (!map) - map = pipe_buffer_map(pipe, nv30->idxbuf.buffer, + map = pipe_buffer_map(pipe, info->index.resource, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transferi); draw_set_indexes(draw, - (ubyte *) map + nv30->idxbuf.offset, - nv30->idxbuf.index_size, ~0); + (ubyte *) map, + info->index_size, ~0); } else { draw_set_indexes(draw, NULL, 0, 0); } @@ -446,7 +446,7 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) draw_vbo(draw, info); draw_flush(draw); - if (info->indexed && transferi) + if (info->index_size && transferi) pipe_buffer_unmap(pipe, transferi); for (i = 0; i < nv30->num_vtxbufs; i++) if (transfer[i]) diff --git a/src/gallium/drivers/nouveau/nv30/nv30_push.c b/src/gallium/drivers/nouveau/nv30/nv30_push.c index 90adfa06799..fc8520b8952 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_push.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_push.c @@ -199,7 +199,7 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) { struct push_context ctx; unsigned i, index_size; - bool apply_bias = info->indexed && info->index_bias; + bool apply_bias = info->index_size && info->index_bias; ctx.push = nv30->base.pushbuf; ctx.translate = nv30->vertex->translate; @@ -224,18 +224,18 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) ctx.translate->set_buffer(ctx.translate, i, data, vb->stride, ~0); } - if (info->indexed) { - if (nv30->idxbuf.buffer) + if (info->index_size) { + if (!info->has_user_indices) ctx.idxbuf = nouveau_resource_map_offset(&nv30->base, - nv04_resource(nv30->idxbuf.buffer), nv30->idxbuf.offset, + nv04_resource(info->index.resource), info->start * info->index_size, NOUVEAU_BO_RD); else - ctx.idxbuf = nv30->idxbuf.user_buffer; + ctx.idxbuf = info->index.user; if (!ctx.idxbuf) { nv30_state_release(nv30); return; } - index_size = nv30->idxbuf.index_size; + index_size = info->index_size; ctx.primitive_restart = info->primitive_restart; ctx.restart_index = info->restart_index; } else { @@ -277,8 +277,8 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) BEGIN_NV04(ctx.push, NV30_3D(VERTEX_BEGIN_END), 1); PUSH_DATA (ctx.push, NV30_3D_VERTEX_BEGIN_END_STOP); - if (info->indexed) - nouveau_resource_unmap(nv04_resource(nv30->idxbuf.buffer)); + if (info->index_size && !info->has_user_indices) + nouveau_resource_unmap(nv04_resource(info->index.resource)); for (i = 0; i < nv30->num_vtxbufs; ++i) { if (nv30->vtxbuf[i].buffer.resource) { diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c b/src/gallium/drivers/nouveau/nv30/nv30_resource.c index d5842dd8a4e..ff34f6e5f9f 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c @@ -44,10 +44,6 @@ nv30_memory_barrier(struct pipe_context *pipe, unsigned flags) if (nv30->vtxbuf[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) nv30->base.vbo_dirty = true; } - - if (nv30->idxbuf.buffer && - nv30->idxbuf.buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) - nv30->base.vbo_dirty = true; } } diff --git a/src/gallium/drivers/nouveau/nv30/nv30_state.c b/src/gallium/drivers/nouveau/nv30/nv30_state.c index 16b668bfe48..2a812252c98 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_state.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_state.c @@ -438,23 +438,6 @@ nv30_set_vertex_buffers(struct pipe_context *pipe, nv30->dirty |= NV30_NEW_ARRAYS; } -static void -nv30_set_index_buffer(struct pipe_context *pipe, - const struct pipe_index_buffer *ib) -{ - struct nv30_context *nv30 = nv30_context(pipe); - - if (ib) { - pipe_resource_reference(&nv30->idxbuf.buffer, ib->buffer); - nv30->idxbuf.index_size = ib->index_size; - nv30->idxbuf.offset = ib->offset; - nv30->idxbuf.user_buffer = ib->user_buffer; - } else { - pipe_resource_reference(&nv30->idxbuf.buffer, NULL); - nv30->idxbuf.user_buffer = NULL; - } -} - void nv30_state_init(struct pipe_context *pipe) { @@ -481,5 +464,4 @@ nv30_state_init(struct pipe_context *pipe) pipe->set_viewport_states = nv30_set_viewport_states; pipe->set_vertex_buffers = nv30_set_vertex_buffers; - pipe->set_index_buffer = nv30_set_index_buffer; } diff --git a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c index d049b55a90f..bb0a8a0b1d5 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c @@ -459,10 +459,11 @@ nv30_draw_elements_inline_u32_short(struct nouveau_pushbuf *push, static void nv30_draw_elements(struct nv30_context *nv30, bool shorten, + const struct pipe_draw_info *info, unsigned mode, unsigned start, unsigned count, - unsigned instance_count, int32_t index_bias) + unsigned instance_count, int32_t index_bias, + unsigned index_size) { - const unsigned index_size = nv30->idxbuf.index_size; struct nouveau_pushbuf *push = nv30->base.pushbuf; struct nouveau_object *eng3d = nv30->screen->eng3d; unsigned prim = nv30_prim_gl(mode); @@ -474,9 +475,9 @@ nv30_draw_elements(struct nv30_context *nv30, bool shorten, } if (eng3d->oclass == NV40_3D_CLASS && index_size > 1 && - nv30->idxbuf.buffer) { - struct nv04_resource *res = nv04_resource(nv30->idxbuf.buffer); - unsigned offset = nv30->idxbuf.offset; + !info->has_user_indices) { + struct nv04_resource *res = nv04_resource(info->index.resource); + unsigned offset = 0; assert(nouveau_resource_mapped_by_gpu(&res->base)); @@ -511,12 +512,12 @@ nv30_draw_elements(struct nv30_context *nv30, bool shorten, PUSH_RESET(push, BUFCTX_IDXBUF); } else { const void *data; - if (nv30->idxbuf.buffer) + if (!info->has_user_indices) data = nouveau_resource_map_offset(&nv30->base, - nv04_resource(nv30->idxbuf.buffer), - nv30->idxbuf.offset, NOUVEAU_BO_RD); + nv04_resource(info->index.resource), + start * index_size, NOUVEAU_BO_RD); else - data = nv30->idxbuf.user_buffer; + data = info->index.user; if (!data) return; @@ -559,7 +560,7 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * if index count is larger and we expect repeated vertices, suggest upload. */ nv30->vbo_push_hint = /* the 64 is heuristic */ - !(info->indexed && + !(info->index_size && ((info->max_index - info->min_index + 64) < info->count)); nv30->vbo_min_index = info->min_index; @@ -589,8 +590,8 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) nv30->base.vbo_dirty = true; } - if (!nv30->base.vbo_dirty && nv30->idxbuf.buffer && - nv30->idxbuf.buffer->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) + if (!nv30->base.vbo_dirty && info->index_size && !info->has_user_indices && + info->index.resource->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nv30->base.vbo_dirty = true; if (nv30->base.vbo_dirty) { @@ -599,7 +600,7 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) nv30->base.vbo_dirty = false; } - if (!info->indexed) { + if (!info->index_size) { nv30_draw_arrays(nv30, info->mode, info->start, info->count, info->instance_count); @@ -628,9 +629,9 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) shorten = false; } - nv30_draw_elements(nv30, shorten, + nv30_draw_elements(nv30, shorten, info, info->mode, info->start, info->count, - info->instance_count, info->index_bias); + info->instance_count, info->index_bias, info->index_size); } nv30_state_release(nv30); -- cgit v1.2.3