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/nouveau/nv50 | |
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/nouveau/nv50')
-rw-r--r-- | src/gallium/drivers/nouveau/nv50/nv50_context.c | 14 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nv50/nv50_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nv50/nv50_push.c | 12 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nv50/nv50_state.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/nv50/nv50_vbo.c | 30 |
5 files changed, 24 insertions, 57 deletions
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c index d0729276e1d..d2c37ac276d 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_context.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c @@ -68,10 +68,6 @@ nv50_memory_barrier(struct pipe_context *pipe, unsigned flags) nv50->base.vbo_dirty = true; } - if (nv50->idxbuf.buffer && - nv50->idxbuf.buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) - nv50->base.vbo_dirty = true; - for (s = 0; s < 3 && !nv50->cb_dirty; ++s) { uint32_t valid = nv50->constbuf_valid[s]; @@ -146,8 +142,6 @@ nv50_context_unreference_resources(struct nv50_context *nv50) for (i = 0; i < nv50->num_vtxbufs; ++i) pipe_resource_reference(&nv50->vtxbuf[i].buffer.resource, NULL); - pipe_resource_reference(&nv50->idxbuf.buffer, NULL); - for (s = 0; s < 3; ++s) { assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS); for (i = 0; i < nv50->num_textures[s]; ++i) @@ -238,14 +232,6 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx, } } - if (nv50->idxbuf.buffer == res) { - /* Just rebind to the bufctx as there is no separate dirty bit */ - nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_3D_INDEX); - BCTX_REFN(nv50->bufctx_3d, 3D_INDEX, nv04_resource(res), RD); - if (!--ref) - return ref; - } - for (s = 0; s < 3; ++s) { assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS); for (i = 0; i < nv50->num_textures[s]; ++i) { diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.h b/src/gallium/drivers/nouveau/nv50/nv50_context.h index cca44f5bb21..224535a9381 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_context.h +++ b/src/gallium/drivers/nouveau/nv50/nv50_context.h @@ -143,7 +143,6 @@ struct nv50_context { struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned num_vtxbufs; uint32_t vtxbufs_coherent; - struct pipe_index_buffer idxbuf; uint32_t vbo_fifo; /* bitmask of vertex elements to be pushed to FIFO */ uint32_t vbo_user; /* bitmask of vertex buffers pointing to user memory */ uint32_t vbo_constant; /* bitmask of user buffers with stride 0 */ diff --git a/src/gallium/drivers/nouveau/nv50/nv50_push.c b/src/gallium/drivers/nouveau/nv50/nv50_push.c index d3419012e98..9ee9a8eed19 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_push.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_push.c @@ -244,7 +244,7 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info) unsigned i, index_size; unsigned inst_count = info->instance_count; unsigned vert_count = info->count; - bool apply_bias = info->indexed && info->index_bias; + bool apply_bias = info->index_size && info->index_bias; ctx.push = nv50->base.pushbuf; ctx.translate = nv50->vertex->translate; @@ -276,17 +276,17 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info) ctx.translate->set_buffer(ctx.translate, i, data, vb->stride, ~0); } - if (info->indexed) { - if (nv50->idxbuf.buffer) { + if (info->index_size) { + if (!info->has_user_indices) { ctx.idxbuf = nouveau_resource_map_offset(&nv50->base, - nv04_resource(nv50->idxbuf.buffer), nv50->idxbuf.offset, + nv04_resource(info->index.resource), info->start * info->index_size, NOUVEAU_BO_RD); } else { - ctx.idxbuf = nv50->idxbuf.user_buffer; + ctx.idxbuf = info->index.user; } if (!ctx.idxbuf) return; - index_size = nv50->idxbuf.index_size; + index_size = info->index_size; ctx.primitive_restart = info->primitive_restart; ctx.restart_index = info->restart_index; } else { diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c index d5af6c9d1ff..a7d86b0f90c 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c @@ -1081,29 +1081,6 @@ nv50_set_vertex_buffers(struct pipe_context *pipe, } static void -nv50_set_index_buffer(struct pipe_context *pipe, - const struct pipe_index_buffer *ib) -{ - struct nv50_context *nv50 = nv50_context(pipe); - - if (nv50->idxbuf.buffer) - nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_3D_INDEX); - - if (ib) { - pipe_resource_reference(&nv50->idxbuf.buffer, ib->buffer); - nv50->idxbuf.index_size = ib->index_size; - if (ib->buffer) { - nv50->idxbuf.offset = ib->offset; - BCTX_REFN(nv50->bufctx_3d, 3D_INDEX, nv04_resource(ib->buffer), RD); - } else { - nv50->idxbuf.user_buffer = ib->user_buffer; - } - } else { - pipe_resource_reference(&nv50->idxbuf.buffer, NULL); - } -} - -static void nv50_vertex_state_bind(struct pipe_context *pipe, void *hwcso) { struct nv50_context *nv50 = nv50_context(pipe); @@ -1341,7 +1318,6 @@ nv50_init_state_functions(struct nv50_context *nv50) pipe->bind_vertex_elements_state = nv50_vertex_state_bind; pipe->set_vertex_buffers = nv50_set_vertex_buffers; - pipe->set_index_buffer = nv50_set_index_buffer; pipe->create_stream_output_target = nv50_so_target_create; pipe->stream_output_target_destroy = nv50_so_target_destroy; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c index 60970d7603e..37dca97c870 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c @@ -595,12 +595,13 @@ nv50_draw_elements_inline_u32_short(struct nouveau_pushbuf *push, static void nv50_draw_elements(struct nv50_context *nv50, 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) { struct nouveau_pushbuf *push = nv50->base.pushbuf; unsigned prim; - const unsigned index_size = nv50->idxbuf.index_size; prim = nv50_prim_gl(mode); @@ -614,15 +615,15 @@ nv50_draw_elements(struct nv50_context *nv50, bool shorten, nv50->state.index_bias = index_bias; } - if (nv50->idxbuf.buffer) { - struct nv04_resource *buf = nv04_resource(nv50->idxbuf.buffer); + if (!info->has_user_indices) { + struct nv04_resource *buf = nv04_resource(info->index.resource); unsigned pb_start; unsigned pb_bytes; - const unsigned base = (buf->offset + nv50->idxbuf.offset) & ~3; + const unsigned base = buf->offset & ~3; - start += ((buf->offset + nv50->idxbuf.offset) & 3) >> (index_size >> 1); + start += (buf->offset & 3) >> (index_size >> 1); - assert(nouveau_resource_mapped_by_gpu(nv50->idxbuf.buffer)); + assert(nouveau_resource_mapped_by_gpu(info->index.resource)); /* This shouldn't have to be here. The going theory is that the buffer * is being filled in by PGRAPH, and it's not done yet by the time it @@ -675,7 +676,7 @@ nv50_draw_elements(struct nv50_context *nv50, bool shorten, prim |= NV50_3D_VERTEX_BEGIN_GL_INSTANCE_NEXT; } } else { - const void *data = nv50->idxbuf.user_buffer; + const void *data = info->index.user; while (instance_count--) { BEGIN_NV04(push, NV50_3D(VERTEX_BEGIN_GL), 1); @@ -769,6 +770,11 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) bool tex_dirty = false; int s; + if (info->index_size && !info->has_user_indices) { + nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_3D_INDEX); + BCTX_REFN(nv50->bufctx_3d, 3D_INDEX, nv04_resource(info->index.resource), RD); + } + /* NOTE: caller must ensure that (min_index + index_bias) is >= 0 */ nv50->vb_elt_first = info->min_index + info->index_bias; nv50->vb_elt_limit = info->max_index - info->min_index; @@ -779,7 +785,7 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * if index count is larger and we expect repeated vertices, suggest upload. */ nv50->vbo_push_hint = /* the 64 is heuristic */ - !(info->indexed && ((nv50->vb_elt_limit + 64) < info->count)); + !(info->index_size && ((nv50->vb_elt_limit + 64) < info->count)); if (nv50->vbo_user && !(nv50->dirty_3d & (NV50_NEW_3D_ARRAYS | NV50_NEW_3D_VERTEX))) { if (!!nv50->vbo_fifo != nv50->vbo_push_hint) @@ -853,7 +859,7 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) nv50->base.vbo_dirty = false; } - if (info->indexed) { + if (info->index_size) { bool shorten = info->max_index <= 65535; if (info->primitive_restart != nv50->state.prim_restart) { @@ -878,9 +884,9 @@ nv50_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) shorten = false; } - nv50_draw_elements(nv50, shorten, + nv50_draw_elements(nv50, shorten, info, info->mode, info->start, info->count, - info->instance_count, info->index_bias); + info->instance_count, info->index_bias, info->index_size); } else if (unlikely(info->count_from_stream_output)) { nva0_draw_stream_output(nv50, info); |