diff options
author | Marek Olšák <[email protected]> | 2017-04-02 14:30:16 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-05-10 19:00:16 +0200 |
commit | c24c3b94ed29ecd99b1101c74c6c4606f9b5580e (patch) | |
tree | 81f6966bc59a68d9867693c65d35fae9bb1d9819 /src/gallium/drivers | |
parent | fe437882ea2d60e91c244cc95beb4b79c615af49 (diff) |
gallium: decrease the size of pipe_vertex_buffer - 24 -> 16 bytes
Diffstat (limited to 'src/gallium/drivers')
51 files changed, 173 insertions, 172 deletions
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c index 63f115727b7..90ccf160e68 100644 --- a/src/gallium/drivers/ddebug/dd_draw.c +++ b/src/gallium/drivers/ddebug/dd_draw.c @@ -308,11 +308,10 @@ dd_dump_draw_vbo(struct dd_draw_state *dstate, struct pipe_draw_info *info, FILE dd_dump_render_condition(dstate, f); for (i = 0; i < PIPE_MAX_ATTRIBS; i++) - if (dstate->vertex_buffers[i].buffer || - dstate->vertex_buffers[i].user_buffer) { + if (dstate->vertex_buffers[i].buffer.resource) { DUMP_I(vertex_buffer, &dstate->vertex_buffers[i], i); - if (dstate->vertex_buffers[i].buffer) - DUMP_M(resource, &dstate->vertex_buffers[i], buffer); + if (!dstate->vertex_buffers[i].is_user_buffer) + DUMP_M(resource, &dstate->vertex_buffers[i], buffer.resource); } if (dstate->velems) { @@ -765,7 +764,7 @@ dd_unreference_copy_of_draw_state(struct dd_draw_state_copy *state) util_set_index_buffer(&dst->index_buffer, NULL); for (i = 0; i < ARRAY_SIZE(dst->vertex_buffers); i++) - pipe_resource_reference(&dst->vertex_buffers[i].buffer, NULL); + pipe_vertex_buffer_unreference(&dst->vertex_buffers[i]); for (i = 0; i < ARRAY_SIZE(dst->so_targets); i++) pipe_so_target_reference(&dst->so_targets[i], NULL); @@ -802,10 +801,8 @@ dd_copy_draw_state(struct dd_draw_state *dst, struct dd_draw_state *src) util_set_index_buffer(&dst->index_buffer, &src->index_buffer); for (i = 0; i < ARRAY_SIZE(src->vertex_buffers); i++) { - pipe_resource_reference(&dst->vertex_buffers[i].buffer, - src->vertex_buffers[i].buffer); - memcpy(&dst->vertex_buffers[i], &src->vertex_buffers[i], - sizeof(src->vertex_buffers[i])); + pipe_vertex_buffer_reference(&dst->vertex_buffers[i], + &src->vertex_buffers[i]); } dst->num_so_targets = src->num_so_targets; diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index e426d4f1d19..2e5e7f6446a 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -234,8 +234,8 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) /* Mark VBOs as being read */ for (i = 0; i < ctx->vertex_buffer.count; i++) { - assert(!ctx->vertex_buffer.vb[i].user_buffer); - resource_read(ctx, ctx->vertex_buffer.vb[i].buffer); + assert(!ctx->vertex_buffer.vb[i].is_user_buffer); + resource_read(ctx, ctx->vertex_buffer.vb[i].buffer.resource); } /* Mark index buffer as being read */ diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c index d96b445632d..dcc587daccb 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_state.c +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c @@ -428,11 +428,11 @@ etna_set_vertex_buffers(struct pipe_context *pctx, unsigned start_slot, struct compiled_set_vertex_buffer *cs = &so->cvb[idx]; struct pipe_vertex_buffer *vbi = &so->vb[idx]; - assert(!vbi->user_buffer); /* XXX support user_buffer using - etna_usermem_map */ + assert(!vbi->is_user_buffer); /* XXX support user_buffer using + etna_usermem_map */ - if (vbi->buffer) { /* GPU buffer */ - cs->FE_VERTEX_STREAM_BASE_ADDR.bo = etna_resource(vbi->buffer)->bo; + if (vbi->buffer.resource) { /* GPU buffer */ + cs->FE_VERTEX_STREAM_BASE_ADDR.bo = etna_resource(vbi->buffer.resource)->bo; cs->FE_VERTEX_STREAM_BASE_ADDR.offset = vbi->buffer_offset; cs->FE_VERTEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ; cs->FE_VERTEX_STREAM_CONTROL = diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c index f360ec2f6e2..eeae10b9ff2 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_draw.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_draw.c @@ -69,8 +69,8 @@ emit_vertexbufs(struct fd_context *ctx) struct pipe_vertex_buffer *vb = &vertexbuf->vb[elem->vertex_buffer_index]; bufs[i].offset = vb->buffer_offset; - bufs[i].size = fd_bo_size(fd_resource(vb->buffer)->bo); - bufs[i].prsc = vb->buffer; + bufs[i].size = fd_bo_size(fd_resource(vb->buffer.resource)->bo); + bufs[i].prsc = vb->buffer.resource; } // NOTE I believe the 0x78 (or 0x9c in solid_vp) relates to the diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c index ca97a08d544..3b61cac47dc 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c @@ -401,7 +401,7 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd3_emit *emit) struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; const struct pipe_vertex_buffer *vb = &vtx->vertexbuf.vb[elem->vertex_buffer_index]; - struct fd_resource *rsc = fd_resource(vb->buffer); + struct fd_resource *rsc = fd_resource(vb->buffer.resource); enum pipe_format pfmt = elem->src_format; enum a3xx_vtx_fmt fmt = fd3_pipe2vtx(pfmt); bool switchnext = (i != last) || diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c index f0a1fdea0df..ba024bde165 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c @@ -403,7 +403,7 @@ fd4_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd4_emit *emit) struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; const struct pipe_vertex_buffer *vb = &vtx->vertexbuf.vb[elem->vertex_buffer_index]; - struct fd_resource *rsc = fd_resource(vb->buffer); + struct fd_resource *rsc = fd_resource(vb->buffer.resource); enum pipe_format pfmt = elem->src_format; enum a4xx_vtx_fmt fmt = fd4_pipe2vtx(pfmt); bool switchnext = (i != last) || diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c index b89981d269c..737f188e4ff 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c @@ -425,7 +425,7 @@ fd5_emit_vertex_bufs(struct fd_ringbuffer *ring, struct fd5_emit *emit) struct pipe_vertex_element *elem = &vtx->vtx->pipe[i]; const struct pipe_vertex_buffer *vb = &vtx->vertexbuf.vb[elem->vertex_buffer_index]; - struct fd_resource *rsc = fd_resource(vb->buffer); + struct fd_resource *rsc = fd_resource(vb->buffer.resource); enum pipe_format pfmt = elem->src_format; enum a5xx_vtx_fmt fmt = fd5_pipe2vtx(pfmt); bool isint = util_format_is_pure_integer(pfmt); diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c index d9d334e5926..8a86f0be149 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.c +++ b/src/gallium/drivers/freedreno/freedreno_context.c @@ -210,7 +210,7 @@ fd_context_setup_common_vbos(struct fd_context *ctx) }}); ctx->solid_vbuf_state.vertexbuf.count = 1; ctx->solid_vbuf_state.vertexbuf.vb[0].stride = 12; - ctx->solid_vbuf_state.vertexbuf.vb[0].buffer = ctx->solid_vbuf; + ctx->solid_vbuf_state.vertexbuf.vb[0].buffer.resource = ctx->solid_vbuf; /* setup blit_vbuf_state: */ ctx->blit_vbuf_state.vtx = pctx->create_vertex_elements_state( @@ -225,9 +225,9 @@ fd_context_setup_common_vbos(struct fd_context *ctx) }}); ctx->blit_vbuf_state.vertexbuf.count = 2; ctx->blit_vbuf_state.vertexbuf.vb[0].stride = 8; - ctx->blit_vbuf_state.vertexbuf.vb[0].buffer = ctx->blit_texcoord_vbuf; + ctx->blit_vbuf_state.vertexbuf.vb[0].buffer.resource = ctx->blit_texcoord_vbuf; ctx->blit_vbuf_state.vertexbuf.vb[1].stride = 12; - ctx->blit_vbuf_state.vertexbuf.vb[1].buffer = ctx->solid_vbuf; + ctx->blit_vbuf_state.vertexbuf.vb[1].buffer.resource = ctx->solid_vbuf; } void diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c index 4e7827ddd02..f7b132e0ef4 100644 --- a/src/gallium/drivers/freedreno/freedreno_draw.c +++ b/src/gallium/drivers/freedreno/freedreno_draw.c @@ -164,8 +164,8 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) /* Mark VBOs as being read */ foreach_bit(i, ctx->vtx.vertexbuf.enabled_mask) { - assert(!ctx->vtx.vertexbuf.vb[i].user_buffer); - resource_read(batch, ctx->vtx.vertexbuf.vb[i].buffer); + assert(!ctx->vtx.vertexbuf.vb[i].is_user_buffer); + resource_read(batch, ctx->vtx.vertexbuf.vb[i].buffer.resource); } /* Mark index buffer as being read */ diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index b5afe861e0f..8adbaaa64a6 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -58,7 +58,7 @@ fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc) /* VBOs */ for (unsigned i = 0; i < ctx->vtx.vertexbuf.count && !(ctx->dirty & FD_DIRTY_VTXBUF); i++) { - if (ctx->vtx.vertexbuf.vb[i].buffer == prsc) + if (ctx->vtx.vertexbuf.vb[i].buffer.resource == prsc) ctx->dirty |= FD_DIRTY_VTXBUF; } diff --git a/src/gallium/drivers/freedreno/freedreno_state.c b/src/gallium/drivers/freedreno/freedreno_state.c index 75bf1b142bd..489578b0dc7 100644 --- a/src/gallium/drivers/freedreno/freedreno_state.c +++ b/src/gallium/drivers/freedreno/freedreno_state.c @@ -259,8 +259,8 @@ fd_set_vertex_buffers(struct pipe_context *pctx, */ if (ctx->screen->gpu_id < 300) { for (i = 0; i < count; i++) { - bool new_enabled = vb && (vb[i].buffer || vb[i].user_buffer); - bool old_enabled = so->vb[i].buffer || so->vb[i].user_buffer; + bool new_enabled = vb && vb[i].buffer.resource; + bool old_enabled = so->vb[i].buffer.resource != NULL; uint32_t new_stride = vb ? vb[i].stride : 0; uint32_t old_stride = so->vb[i].stride; if ((new_enabled != old_enabled) || (new_stride != old_stride)) { diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index c22e4056424..d2297006cb5 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -73,9 +73,10 @@ i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * Map vertex buffers */ for (i = 0; i < i915->nr_vertex_buffers; i++) { - const void *buf = i915->vertex_buffers[i].user_buffer; + const void *buf = i915->vertex_buffers[i].is_user_buffer ? + i915->vertex_buffers[i].buffer.user : NULL; if (!buf) - buf = i915_buffer(i915->vertex_buffers[i].buffer)->data; + buf = i915_buffer(i915->vertex_buffers[i].buffer.resource)->data; draw_set_mapped_vertex_buffer(draw, i, buf, ~0); } diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 9a1a7b9ad5f..c18e72c49f2 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -96,7 +96,7 @@ static void llvmpipe_destroy( struct pipe_context *pipe ) } for (i = 0; i < llvmpipe->num_vertex_buffers; i++) { - pipe_resource_reference(&llvmpipe->vertex_buffer[i].buffer, NULL); + pipe_vertex_buffer_unreference(&llvmpipe->vertex_buffer[i]); } lp_delete_setup_variants(llvmpipe); diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index 22ef5fc17f9..9a9c2f7ce76 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -73,14 +73,15 @@ llvmpipe_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) * Map vertex buffers */ for (i = 0; i < lp->num_vertex_buffers; i++) { - const void *buf = lp->vertex_buffer[i].user_buffer; + const void *buf = lp->vertex_buffer[i].is_user_buffer ? + lp->vertex_buffer[i].buffer.user : NULL; size_t size = ~0; if (!buf) { - if (!lp->vertex_buffer[i].buffer) { + if (!lp->vertex_buffer[i].buffer.resource) { continue; } - buf = llvmpipe_resource_data(lp->vertex_buffer[i].buffer); - size = lp->vertex_buffer[i].buffer->width0; + buf = llvmpipe_resource_data(lp->vertex_buffer[i].buffer.resource); + size = lp->vertex_buffer[i].buffer.resource->width0; } draw_set_mapped_vertex_buffer(draw, i, buf, size); } diff --git a/src/gallium/drivers/nouveau/nv30/nv30_context.c b/src/gallium/drivers/nouveau/nv30/nv30_context.c index 4c16e0c41df..cec3cd06b58 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_context.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_context.c @@ -115,7 +115,7 @@ nv30_invalidate_resource_storage(struct nouveau_context *nv, if (res->bind & PIPE_BIND_VERTEX_BUFFER) { for (i = 0; i < nv30->num_vtxbufs; ++i) { - if (nv30->vtxbuf[i].buffer == res) { + if (nv30->vtxbuf[i].buffer.resource == res) { nv30->dirty |= NV30_NEW_ARRAYS; nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VTXBUF); if (!--ref) diff --git a/src/gallium/drivers/nouveau/nv30/nv30_draw.c b/src/gallium/drivers/nouveau/nv30/nv30_draw.c index 10c9f56fad5..28d3de932ff 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_draw.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_draw.c @@ -419,10 +419,11 @@ nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } for (i = 0; i < nv30->num_vtxbufs; i++) { - const void *map = nv30->vtxbuf[i].user_buffer; + const void *map = nv30->vtxbuf[i].is_user_buffer ? + nv30->vtxbuf[i].buffer.user : NULL; if (!map) { - if (nv30->vtxbuf[i].buffer) - map = pipe_buffer_map(pipe, nv30->vtxbuf[i].buffer, + if (nv30->vtxbuf[i].buffer.resource) + map = pipe_buffer_map(pipe, nv30->vtxbuf[i].buffer.resource, PIPE_TRANSFER_UNSYNCHRONIZED | PIPE_TRANSFER_READ, &transfer[i]); } diff --git a/src/gallium/drivers/nouveau/nv30/nv30_push.c b/src/gallium/drivers/nouveau/nv30/nv30_push.c index 67ab0508c17..90adfa06799 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_push.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_push.c @@ -209,9 +209,9 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) for (i = 0; i < nv30->num_vtxbufs; ++i) { uint8_t *data; struct pipe_vertex_buffer *vb = &nv30->vtxbuf[i]; - struct nv04_resource *res = nv04_resource(vb->buffer); + struct nv04_resource *res = nv04_resource(vb->buffer.resource); - if (!vb->buffer && !vb->user_buffer) { + if (!vb->buffer.resource) { continue; } @@ -281,8 +281,8 @@ nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info) nouveau_resource_unmap(nv04_resource(nv30->idxbuf.buffer)); for (i = 0; i < nv30->num_vtxbufs; ++i) { - if (nv30->vtxbuf[i].buffer) { - nouveau_resource_unmap(nv04_resource(nv30->vtxbuf[i].buffer)); + if (nv30->vtxbuf[i].buffer.resource) { + nouveau_resource_unmap(nv04_resource(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 6238a2384cb..d5842dd8a4e 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c @@ -39,9 +39,9 @@ nv30_memory_barrier(struct pipe_context *pipe, unsigned flags) if (flags & PIPE_BARRIER_MAPPED_BUFFER) { for (i = 0; i < nv30->num_vtxbufs; ++i) { - if (!nv30->vtxbuf[i].buffer) + if (!nv30->vtxbuf[i].buffer.resource) continue; - if (nv30->vtxbuf[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) + if (nv30->vtxbuf[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) nv30->base.vbo_dirty = true; } diff --git a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c index 9338f2ed700..d049b55a90f 100644 --- a/src/gallium/drivers/nouveau/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nouveau/nv30/nv30_vbo.c @@ -40,7 +40,7 @@ nv30_emit_vtxattr(struct nv30_context *nv30, struct pipe_vertex_buffer *vb, { const unsigned nc = util_format_get_nr_components(ve->src_format); struct nouveau_pushbuf *push = nv30->base.pushbuf; - struct nv04_resource *res = nv04_resource(vb->buffer); + struct nv04_resource *res = nv04_resource(vb->buffer.resource); const struct util_format_description *desc = util_format_description(ve->src_format); const void *data; @@ -102,12 +102,12 @@ nv30_prevalidate_vbufs(struct nv30_context *nv30) for (i = 0; i < nv30->num_vtxbufs; i++) { vb = &nv30->vtxbuf[i]; - if (!vb->stride || !vb->buffer) /* NOTE: user_buffer not implemented */ + if (!vb->stride || !vb->buffer.resource) /* NOTE: user_buffer not implemented */ continue; - buf = nv04_resource(vb->buffer); + buf = nv04_resource(vb->buffer.resource); /* NOTE: user buffers with temporary storage count as mapped by GPU */ - if (!nouveau_resource_mapped_by_gpu(vb->buffer)) { + if (!nouveau_resource_mapped_by_gpu(vb->buffer.resource)) { if (nv30->vbo_push_hint) { nv30->vbo_fifo = ~0; continue; @@ -138,7 +138,7 @@ nv30_update_user_vbufs(struct nv30_context *nv30) struct pipe_vertex_element *ve = &nv30->vertex->pipe[i]; const int b = ve->vertex_buffer_index; struct pipe_vertex_buffer *vb = &nv30->vtxbuf[b]; - struct nv04_resource *buf = nv04_resource(vb->buffer); + struct nv04_resource *buf = nv04_resource(vb->buffer.resource); if (!(nv30->vbo_user & (1 << b))) continue; @@ -173,7 +173,7 @@ nv30_release_user_vbufs(struct nv30_context *nv30) int i = ffs(vbo_user) - 1; vbo_user &= ~(1 << i); - nouveau_buffer_release_gpu_storage(nv04_resource(nv30->vtxbuf[i].buffer)); + nouveau_buffer_release_gpu_storage(nv04_resource(nv30->vtxbuf[i].buffer.resource)); } nouveau_bufctx_reset(nv30->bufctx, BUFCTX_VTXTMP); @@ -235,7 +235,7 @@ nv30_vbo_validate(struct nv30_context *nv30) vb = &nv30->vtxbuf[ve->vertex_buffer_index]; user = (nv30->vbo_user & (1 << ve->vertex_buffer_index)); - res = nv04_resource(vb->buffer); + res = nv04_resource(vb->buffer.resource); if (nv30->vbo_fifo || unlikely(vb->stride == 0)) { if (!nv30->vbo_fifo) @@ -583,9 +583,9 @@ nv30_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } for (i = 0; i < nv30->num_vtxbufs && !nv30->base.vbo_dirty; ++i) { - if (!nv30->vtxbuf[i].buffer) + if (!nv30->vtxbuf[i].buffer.resource) continue; - if (nv30->vtxbuf[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) + if (nv30->vtxbuf[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nv30->base.vbo_dirty = true; } diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c b/src/gallium/drivers/nouveau/nv50/nv50_context.c index bf768bc6db5..d0729276e1d 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_context.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c @@ -62,9 +62,9 @@ nv50_memory_barrier(struct pipe_context *pipe, unsigned flags) if (flags & PIPE_BARRIER_MAPPED_BUFFER) { for (i = 0; i < nv50->num_vtxbufs; ++i) { - if (!nv50->vtxbuf[i].buffer) + if (!nv50->vtxbuf[i].buffer.resource && !nv50->vtxbuf[i].is_user_buffer) continue; - if (nv50->vtxbuf[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) + if (nv50->vtxbuf[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) nv50->base.vbo_dirty = true; } @@ -144,7 +144,7 @@ nv50_context_unreference_resources(struct nv50_context *nv50) assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS); for (i = 0; i < nv50->num_vtxbufs; ++i) - pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL); + pipe_resource_reference(&nv50->vtxbuf[i].buffer.resource, NULL); pipe_resource_reference(&nv50->idxbuf.buffer, NULL); @@ -230,7 +230,7 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx, assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS); for (i = 0; i < nv50->num_vtxbufs; ++i) { - if (nv50->vtxbuf[i].buffer == res) { + if (nv50->vtxbuf[i].buffer.resource == res) { nv50->dirty_3d |= NV50_NEW_3D_ARRAYS; nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_3D_VERTEX); if (!--ref) diff --git a/src/gallium/drivers/nouveau/nv50/nv50_push.c b/src/gallium/drivers/nouveau/nv50/nv50_push.c index 6a53ad09768..d3419012e98 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_push.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_push.c @@ -264,11 +264,11 @@ nv50_push_vbo(struct nv50_context *nv50, const struct pipe_draw_info *info) const struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; const uint8_t *data; - if (unlikely(vb->buffer)) + if (unlikely(!vb->is_user_buffer)) data = nouveau_resource_map_offset(&nv50->base, - nv04_resource(vb->buffer), vb->buffer_offset, NOUVEAU_BO_RD); + nv04_resource(vb->buffer.resource), vb->buffer_offset, NOUVEAU_BO_RD); else - data = vb->user_buffer; + data = vb->buffer.user; if (apply_bias && likely(!(nv50->vertex->instance_bufs & (1 << i)))) data += (ptrdiff_t)info->index_bias * vb->stride; diff --git a/src/gallium/drivers/nouveau/nv50/nv50_state.c b/src/gallium/drivers/nouveau/nv50/nv50_state.c index 6fa3d2cdc3c..d5af6c9d1ff 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_state.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_state.c @@ -1060,7 +1060,7 @@ nv50_set_vertex_buffers(struct pipe_context *pipe, for (i = 0; i < count; ++i) { unsigned dst_index = start_slot + i; - if (!vb[i].buffer && vb[i].user_buffer) { + if (vb[i].is_user_buffer) { nv50->vbo_user |= 1 << dst_index; if (!vb[i].stride) nv50->vbo_constant |= 1 << dst_index; @@ -1071,8 +1071,8 @@ nv50_set_vertex_buffers(struct pipe_context *pipe, nv50->vbo_user &= ~(1 << dst_index); nv50->vbo_constant &= ~(1 << dst_index); - if (vb[i].buffer && - vb[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) + if (vb[i].buffer.resource && + vb[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nv50->vtxbufs_coherent |= (1 << dst_index); else nv50->vtxbufs_coherent &= ~(1 << dst_index); diff --git a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c index 227038e95a5..60970d7603e 100644 --- a/src/gallium/drivers/nouveau/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nouveau/nv50/nv50_vbo.c @@ -141,13 +141,13 @@ nv50_emit_vtxattr(struct nv50_context *nv50, struct pipe_vertex_buffer *vb, struct pipe_vertex_element *ve, unsigned attr) { struct nouveau_pushbuf *push = nv50->base.pushbuf; - const void *data = (const uint8_t *)vb->user_buffer + ve->src_offset; + const void *data = (const uint8_t *)vb->buffer.user + ve->src_offset; float v[4]; const unsigned nc = util_format_get_nr_components(ve->src_format); const struct util_format_description *desc = util_format_description(ve->src_format); - assert(vb->user_buffer); + assert(vb->is_user_buffer); if (desc->channel[0].pure_integer) { if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED) { @@ -200,7 +200,7 @@ nv50_user_vbuf_range(struct nv50_context *nv50, unsigned vbi, if (unlikely(nv50->vertex->instance_bufs & (1 << vbi))) { /* TODO: use min and max instance divisor to get a proper range */ *base = 0; - *size = nv50->vtxbuf[vbi].buffer->width0; + *size = nv50->vtxbuf[vbi].buffer.resource->width0; } else { /* NOTE: if there are user buffers, we *must* have index bounds */ assert(nv50->vb_elt_limit != ~0); @@ -227,7 +227,7 @@ nv50_upload_user_buffers(struct nv50_context *nv50, nv50_user_vbuf_range(nv50, b, &base, &size); limits[b] = base + size - 1; - addrs[b] = nouveau_scratch_data(&nv50->base, vb->user_buffer, base, size, + addrs[b] = nouveau_scratch_data(&nv50->base, vb->buffer.user, base, size, &bo); if (addrs[b]) BCTX_REFN_bo(nv50->bufctx_3d, 3D_VERTEX_TMP, NOUVEAU_BO_GART | @@ -266,7 +266,7 @@ nv50_update_user_vbufs(struct nv50_context *nv50) struct nouveau_bo *bo; const uint32_t bo_flags = NOUVEAU_BO_GART | NOUVEAU_BO_RD; written |= 1 << b; - address[b] = nouveau_scratch_data(&nv50->base, vb->user_buffer, + address[b] = nouveau_scratch_data(&nv50->base, vb->buffer.user, base, size, &bo); if (address[b]) BCTX_REFN_bo(nv50->bufctx_3d, 3D_VERTEX_TMP, bo_flags, bo); @@ -317,8 +317,9 @@ nv50_vertex_arrays_validate(struct nv50_context *nv50) /* if vertex buffer was written by GPU - flush VBO cache */ assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS); for (i = 0; i < nv50->num_vtxbufs; ++i) { - struct nv04_resource *buf = nv04_resource(nv50->vtxbuf[i].buffer); - if (buf && buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { + struct nv04_resource *buf = nv04_resource(nv50->vtxbuf[i].buffer.resource); + if (!nv50->vtxbuf[i].is_user_buffer && + buf && buf->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { buf->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; nv50->base.vbo_dirty = true; } @@ -386,12 +387,12 @@ nv50_vertex_arrays_validate(struct nv50_context *nv50) address = addrs[b] + ve->pipe.src_offset; limit = addrs[b] + limits[b]; } else - if (!vb->buffer) { + if (!vb->buffer.resource) { BEGIN_NV04(push, NV50_3D(VERTEX_ARRAY_FETCH(i)), 1); PUSH_DATA (push, 0); continue; } else { - struct nv04_resource *buf = nv04_resource(vb->buffer); + struct nv04_resource *buf = nv04_resource(vb->buffer.resource); if (!(refd & (1 << b))) { refd |= 1 << b; BCTX_REFN(nv50->bufctx_3d, 3D_VERTEX, buf, RD); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c index d0f4da303bb..ef61256816a 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c @@ -62,9 +62,9 @@ nvc0_memory_barrier(struct pipe_context *pipe, unsigned flags) if (flags & PIPE_BARRIER_MAPPED_BUFFER) { for (i = 0; i < nvc0->num_vtxbufs; ++i) { - if (!nvc0->vtxbuf[i].buffer) + if (!nvc0->vtxbuf[i].buffer.resource && !nvc0->vtxbuf[i].is_user_buffer) continue; - if (nvc0->vtxbuf[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) + if (nvc0->vtxbuf[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_PERSISTENT) nvc0->base.vbo_dirty = true; } @@ -147,7 +147,7 @@ nvc0_context_unreference_resources(struct nvc0_context *nvc0) util_unreference_framebuffer_state(&nvc0->framebuffer); for (i = 0; i < nvc0->num_vtxbufs; ++i) - pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); + pipe_vertex_buffer_unreference(&nvc0->vtxbuf[i]); pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); @@ -260,7 +260,7 @@ nvc0_invalidate_resource_storage(struct nouveau_context *ctx, if (res->target == PIPE_BUFFER) { for (i = 0; i < nvc0->num_vtxbufs; ++i) { - if (nvc0->vtxbuf[i].buffer == res) { + if (nvc0->vtxbuf[i].buffer.resource == res) { nvc0->dirty_3d |= NVC0_NEW_3D_ARRAYS; nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_3D_VTX); if (!--ref) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c index c51c9a7778f..bf33746802c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c @@ -941,7 +941,7 @@ nvc0_set_vertex_buffers(struct pipe_context *pipe, for (i = 0; i < count; ++i) { unsigned dst_index = start_slot + i; - if (vb[i].user_buffer) { + if (vb[i].is_user_buffer) { nvc0->vbo_user |= 1 << dst_index; if (!vb[i].stride && nvc0->screen->eng3d->oclass < GM107_3D_CLASS) nvc0->constant_vbos |= 1 << dst_index; @@ -952,8 +952,8 @@ nvc0_set_vertex_buffers(struct pipe_context *pipe, nvc0->vbo_user &= ~(1 << dst_index); nvc0->constant_vbos &= ~(1 << dst_index); - if (vb[i].buffer && - vb[i].buffer->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) + if (vb[i].buffer.resource && + vb[i].buffer.resource->flags & PIPE_RESOURCE_FLAG_MAP_COHERENT) nvc0->vtxbufs_coherent |= (1 << dst_index); else nvc0->vtxbufs_coherent &= ~(1 << dst_index); diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c index 9a3eb06bd4b..b42b4685607 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c @@ -176,8 +176,8 @@ nvc0_set_constant_vertex_attrib(struct nvc0_context *nvc0, const unsigned a) uint32_t mode; const struct util_format_description *desc; void *dst; - const void *src = (const uint8_t *)vb->user_buffer + ve->src_offset; - assert(!vb->buffer); + const void *src = (const uint8_t *)vb->buffer.user + ve->src_offset; + assert(vb->is_user_buffer); desc = util_format_description(ve->src_format); @@ -254,7 +254,7 @@ nvc0_update_user_vbufs(struct nvc0_context *nvc0) struct nouveau_bo *bo; const uint32_t bo_flags = NOUVEAU_BO_RD | NOUVEAU_BO_GART; written |= 1 << b; - address[b] = nouveau_scratch_data(&nvc0->base, vb->user_buffer, + address[b] = nouveau_scratch_data(&nvc0->base, vb->buffer.user, base, size, &bo); if (bo) BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, bo_flags, bo); @@ -289,7 +289,7 @@ nvc0_update_user_vbufs_shared(struct nvc0_context *nvc0) nvc0_user_vbuf_range(nvc0, b, &base, &size); - address = nouveau_scratch_data(&nvc0->base, nvc0->vtxbuf[b].user_buffer, + address = nouveau_scratch_data(&nvc0->base, nvc0->vtxbuf[b].buffer.user, base, size, &bo); if (bo) BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, bo_flags, bo); @@ -346,9 +346,9 @@ nvc0_validate_vertex_buffers(struct nvc0_context *nvc0) /* address/value set in nvc0_update_user_vbufs */ continue; } - res = nv04_resource(vb->buffer); + res = nv04_resource(vb->buffer.resource); offset = ve->pipe.src_offset + vb->buffer_offset; - limit = vb->buffer->width0 - 1; + limit = vb->buffer.resource->width0 - 1; if (unlikely(ve->pipe.instance_divisor)) { BEGIN_NVC0(push, NVC0_3D(VERTEX_ARRAY_FETCH(i)), 4); @@ -395,12 +395,12 @@ nvc0_validate_vertex_buffers_shared(struct nvc0_context *nvc0) } /* address/value set in nvc0_update_user_vbufs_shared */ continue; - } else if (!vb->buffer) { + } else if (!vb->buffer.resource) { /* there can be holes in the vertex buffer lists */ IMMED_NVC0(push, NVC0_3D(VERTEX_ARRAY_FETCH(b)), 0); continue; } - buf = nv04_resource(vb->buffer); + buf = nv04_resource(vb->buffer.resource); offset = vb->buffer_offset; limit = buf->base.width0 - 1; diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c index fd2bcbb961c..e4ccac88c14 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c @@ -69,11 +69,11 @@ nvc0_vertex_configure_translate(struct nvc0_context *nvc0, int32_t index_bias) const uint8_t *map; const struct pipe_vertex_buffer *vb = &nvc0->vtxbuf[i]; - if (likely(!vb->buffer)) - map = (const uint8_t *)vb->user_buffer; + if (likely(vb->is_user_buffer)) + map = (const uint8_t *)vb->buffer.user; else map = nouveau_resource_map_offset(&nvc0->base, - nv04_resource(vb->buffer), vb->buffer_offset, NOUVEAU_BO_RD); + nv04_resource(vb->buffer.resource), vb->buffer_offset, NOUVEAU_BO_RD); if (index_bias && !unlikely(nvc0->vertex->instance_bufs & (1 << i))) map += (intptr_t)index_bias * vb->stride; @@ -101,16 +101,16 @@ nvc0_push_map_edgeflag(struct push_context *ctx, struct nvc0_context *nvc0, unsigned attr = nvc0->vertprog->vp.edgeflag; struct pipe_vertex_element *ve = &nvc0->vertex->element[attr].pipe; struct pipe_vertex_buffer *vb = &nvc0->vtxbuf[ve->vertex_buffer_index]; - struct nv04_resource *buf = nv04_resource(vb->buffer); + struct nv04_resource *buf = nv04_resource(vb->buffer.resource); ctx->edgeflag.stride = vb->stride; ctx->edgeflag.width = util_format_get_blocksize(ve->src_format); - if (buf) { + if (!vb->is_user_buffer) { unsigned offset = vb->buffer_offset + ve->src_offset; ctx->edgeflag.data = nouveau_resource_map_offset(&nvc0->base, buf, offset, NOUVEAU_BO_RD); } else { - ctx->edgeflag.data = (const uint8_t *)vb->user_buffer + ve->src_offset; + ctx->edgeflag.data = (const uint8_t *)vb->buffer.user + ve->src_offset; } if (index_bias) @@ -586,7 +586,7 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct pipe_draw_info *info) if (info->indexed) nouveau_resource_unmap(nv04_resource(nvc0->idxbuf.buffer)); for (i = 0; i < nvc0->num_vtxbufs; ++i) - nouveau_resource_unmap(nv04_resource(nvc0->vtxbuf[i].buffer)); + nouveau_resource_unmap(nv04_resource(nvc0->vtxbuf[i].buffer.resource)); NOUVEAU_DRV_STAT(&nvc0->screen->base, draw_calls_fallback_count, 1); } diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 02af5d7f2f8..6f4231d76e3 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -63,7 +63,7 @@ static void r300_release_referenced_objects(struct r300_context *r300) } /* Manually-created vertex buffers. */ - pipe_resource_reference(&r300->dummy_vb.buffer, NULL); + pipe_vertex_buffer_unreference(&r300->dummy_vb); pb_reference(&r300->vbo, NULL); r300->context.delete_depth_stencil_alpha_state(&r300->context, @@ -468,7 +468,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, vb.height0 = 1; vb.depth0 = 1; - r300->dummy_vb.buffer = screen->resource_create(screen, &vb); + r300->dummy_vb.buffer.resource = screen->resource_create(screen, &vb); r300->context.set_vertex_buffers(&r300->context, 0, 1, &r300->dummy_vb); } diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 671aa623bd3..63f12de0a86 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -966,7 +966,7 @@ void r300_emit_vertex_arrays(struct r300_context* r300, int offset, } for (i = 0; i < vertex_array_count; i++) { - buf = r300_resource(vbuf[velem[i].vertex_buffer_index].buffer); + buf = r300_resource(vbuf[velem[i].vertex_buffer_index].buffer.resource); OUT_CS_RELOC(buf); } } else { @@ -1018,7 +1018,7 @@ void r300_emit_vertex_arrays(struct r300_context* r300, int offset, } for (i = 0; i < vertex_array_count; i++) { - buf = r300_resource(vbuf[velem[i].vertex_buffer_index].buffer); + buf = r300_resource(vbuf[velem[i].vertex_buffer_index].buffer.resource); OUT_CS_RELOC(buf); } } @@ -1381,7 +1381,7 @@ validate: struct pipe_resource *buf; for (; vbuf != last; vbuf++) { - buf = vbuf->buffer; + buf = vbuf->buffer.resource; if (!buf) continue; diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 9702a2e32ed..1d3e676e322 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -373,7 +373,7 @@ static void r300_draw_arrays_immediate(struct r300_context *r300, /* Map the buffer. */ if (!map[vbi]) { map[vbi] = (uint32_t*)r300->rws->buffer_map( - r300_resource(vbuf->buffer)->buf, + r300_resource(vbuf->buffer.resource)->buf, r300->cs, PIPE_TRANSFER_READ | PIPE_TRANSFER_UNSYNCHRONIZED); map[vbi] += (vbuf->buffer_offset / 4) + stride[i] * info->start; } @@ -741,13 +741,13 @@ static unsigned r300_max_vertex_count(struct r300_context *r300) unsigned size, max_count, value; /* We're not interested in constant and per-instance attribs. */ - if (!vb->buffer || + if (!vb->buffer.resource || !vb->stride || velems[i].instance_divisor) { continue; } - size = vb->buffer->width0; + size = vb->buffer.resource->width0; /* Subtract buffer_offset. */ value = vb->buffer_offset; diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c index 95ada570e66..4af1c46856e 100644 --- a/src/gallium/drivers/r300/r300_screen_buffer.c +++ b/src/gallium/drivers/r300/r300_screen_buffer.c @@ -111,7 +111,7 @@ r300_buffer_transfer_map( struct pipe_context *context, /* We changed the buffer, now we need to bind it where the old one was bound. */ for (i = 0; i < r300->nr_vertex_buffers; i++) { - if (r300->vertex_buffer[i].buffer == &rbuf->b.b) { + if (r300->vertex_buffer[i].buffer.resource == &rbuf->b.b) { r300->vertex_arrays_dirty = TRUE; break; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 709cbd1a1f4..b3bfafd376a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1773,12 +1773,12 @@ static void r300_set_vertex_buffers_swtcl(struct pipe_context* pipe, return; for (i = 0; i < count; i++) { - if (buffers[i].user_buffer) { + if (buffers[i].is_user_buffer) { draw_set_mapped_vertex_buffer(r300->draw, start_slot + i, - buffers[i].user_buffer, ~0); - } else if (buffers[i].buffer) { + buffers[i].buffer.user, ~0); + } else if (buffers[i].buffer.resource) { draw_set_mapped_vertex_buffer(r300->draw, start_slot + i, - r300_resource(buffers[i].buffer)->malloced_buffer, ~0); + r300_resource(buffers[i].buffer.resource)->malloced_buffer, ~0); } } } diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index ca2081a50d9..37ef1058d3f 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -146,8 +146,8 @@ static void evergreen_cs_set_vertex_buffer(struct r600_context *rctx, struct pipe_vertex_buffer *vb = &state->vb[vb_index]; vb->stride = 1; vb->buffer_offset = offset; - vb->buffer = buffer; - vb->user_buffer = NULL; + vb->buffer.resource = buffer; + vb->is_user_buffer = false; /* The vertex instructions in the compute shaders use the texture cache, * so we need to invalidate it. */ diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 19ad5040979..64935013471 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -1953,7 +1953,7 @@ static void evergreen_emit_vertex_buffers(struct r600_context *rctx, unsigned buffer_index = u_bit_scan(&dirty_mask); vb = &state->vb[buffer_index]; - rbuffer = (struct r600_resource*)vb->buffer; + rbuffer = (struct r600_resource*)vb->buffer.resource; assert(rbuffer); va = rbuffer->gpu_address + vb->buffer_offset; diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index fc93eb02ad2..2001cfd512a 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -1658,7 +1658,7 @@ static void r600_emit_vertex_buffers(struct r600_context *rctx, struct r600_atom unsigned buffer_index = u_bit_scan(&dirty_mask); vb = &rctx->vertex_buffer_state.vb[buffer_index]; - rbuffer = (struct r600_resource*)vb->buffer; + rbuffer = (struct r600_resource*)vb->buffer.resource; assert(rbuffer); offset = vb->buffer_offset; diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 7b52be36cda..f3011c82cf9 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -562,21 +562,21 @@ static void r600_set_vertex_buffers(struct pipe_context *ctx, if (input) { for (i = 0; i < count; i++) { if (memcmp(&input[i], &vb[i], sizeof(struct pipe_vertex_buffer))) { - if (input[i].buffer) { + if (input[i].buffer.resource) { vb[i].stride = input[i].stride; vb[i].buffer_offset = input[i].buffer_offset; - pipe_resource_reference(&vb[i].buffer, input[i].buffer); + pipe_resource_reference(&vb[i].buffer.resource, input[i].buffer.resource); new_buffer_mask |= 1 << i; - r600_context_add_resource_size(ctx, input[i].buffer); + r600_context_add_resource_size(ctx, input[i].buffer.resource); } else { - pipe_resource_reference(&vb[i].buffer, NULL); + pipe_resource_reference(&vb[i].buffer.resource, NULL); disable_mask |= 1 << i; } } } } else { for (i = 0; i < count; i++) { - pipe_resource_reference(&vb[i].buffer, NULL); + pipe_resource_reference(&vb[i].buffer.resource, NULL); } disable_mask = ((1ull << count) - 1); } @@ -2838,7 +2838,7 @@ static void r600_invalidate_buffer(struct pipe_context *ctx, struct pipe_resourc mask = rctx->vertex_buffer_state.enabled_mask; while (mask) { i = u_bit_scan(&mask); - if (rctx->vertex_buffer_state.vb[i].buffer == &rbuffer->b.b) { + if (rctx->vertex_buffer_state.vb[i].buffer.resource == &rbuffer->b.b) { rctx->vertex_buffer_state.dirty_mask |= 1 << i; r600_vertex_buffers_dirty(rctx); } diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index fc94e43f921..8d3454194dd 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -1008,11 +1008,11 @@ static void si_vertex_buffers_begin_new_cs(struct si_context *sctx) if (vb >= ARRAY_SIZE(sctx->vertex_buffer)) continue; - if (!sctx->vertex_buffer[vb].buffer) + if (!sctx->vertex_buffer[vb].buffer.resource) continue; radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, - (struct r600_resource*)sctx->vertex_buffer[vb].buffer, + (struct r600_resource*)sctx->vertex_buffer[vb].buffer.resource, RADEON_USAGE_READ, RADEON_PRIO_VERTEX_BUFFER); } @@ -1071,7 +1071,7 @@ bool si_upload_vertex_buffer_descriptors(struct si_context *sctx) uint32_t *desc = &ptr[i*4]; vb = &sctx->vertex_buffer[vbo_index]; - rbuffer = (struct r600_resource*)vb->buffer; + rbuffer = (struct r600_resource*)vb->buffer.resource; if (!rbuffer) { memset(desc, 0, 16); continue; @@ -1087,18 +1087,18 @@ bool si_upload_vertex_buffer_descriptors(struct si_context *sctx) if (sctx->b.chip_class != VI && vb->stride) { /* Round up by rounding down and adding 1 */ - desc[2] = (vb->buffer->width0 - offset - + desc[2] = (vb->buffer.resource->width0 - offset - velems->format_size[i]) / vb->stride + 1; } else { - desc[2] = vb->buffer->width0 - offset; + desc[2] = vb->buffer.resource->width0 - offset; } desc[3] = velems->rsrc_word3[i]; if (first_vb_use_mask & (1 << i)) { radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx, - (struct r600_resource*)vb->buffer, + (struct r600_resource*)vb->buffer.resource, RADEON_USAGE_READ, RADEON_PRIO_VERTEX_BUFFER); } } @@ -1658,10 +1658,10 @@ static void si_invalidate_buffer(struct pipe_context *ctx, struct pipe_resource if (vb >= ARRAY_SIZE(sctx->vertex_buffer)) continue; - if (!sctx->vertex_buffer[vb].buffer) + if (!sctx->vertex_buffer[vb].buffer.resource) continue; - if (sctx->vertex_buffer[vb].buffer == buf) { + if (sctx->vertex_buffer[vb].buffer.resource == buf) { sctx->vertex_buffers_dirty = true; break; } diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 9d5804c380a..86de578e64a 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -3845,7 +3845,7 @@ static void si_set_vertex_buffers(struct pipe_context *ctx, const struct pipe_vertex_buffer *src = buffers + i; struct pipe_vertex_buffer *dsti = dst + i; - if (unlikely(src->user_buffer)) { + if (unlikely(src->is_user_buffer)) { /* Zero-stride attribs only. */ assert(src->stride == 0); @@ -3856,14 +3856,14 @@ static void si_set_vertex_buffers(struct pipe_context *ctx, * Use const_uploader to upload into VRAM directly. */ u_upload_data(sctx->b.b.const_uploader, 0, 32, 32, - src->user_buffer, + src->buffer.user, &dsti->buffer_offset, - &dsti->buffer); + &dsti->buffer.resource); dsti->stride = 0; } else { - struct pipe_resource *buf = src->buffer; + struct pipe_resource *buf = src->buffer.resource; - pipe_resource_reference(&dsti->buffer, buf); + pipe_resource_reference(&dsti->buffer.resource, buf); dsti->buffer_offset = src->buffer_offset; dsti->stride = src->stride; r600_context_add_resource_size(ctx, buf); @@ -3873,7 +3873,7 @@ static void si_set_vertex_buffers(struct pipe_context *ctx, } } else { for (i = 0; i < count; i++) { - pipe_resource_reference(&dst[i].buffer, NULL); + pipe_resource_reference(&dst[i].buffer.resource, NULL); } } sctx->vertex_buffers_dirty = true; diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c index 5d002076b49..91b1ac66ebe 100644 --- a/src/gallium/drivers/rbug/rbug_context.c +++ b/src/gallium/drivers/rbug/rbug_context.c @@ -778,8 +778,11 @@ rbug_set_vertex_buffers(struct pipe_context *_pipe, if (num_buffers && _buffers) { memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers)); - for (i = 0; i < num_buffers; i++) - unwrapped_buffers[i].buffer = rbug_resource_unwrap(_buffers[i].buffer); + for (i = 0; i < num_buffers; i++) { + if (!_buffers[i].is_user_buffer) + unwrapped_buffers[i].buffer.resource = + rbug_resource_unwrap(_buffers[i].buffer.resource); + } buffers = unwrapped_buffers; } diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 05973012504..a3ebc00016c 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -114,7 +114,7 @@ softpipe_destroy( struct pipe_context *pipe ) } for (i = 0; i < softpipe->num_vertex_buffers; i++) { - pipe_resource_reference(&softpipe->vertex_buffer[i].buffer, NULL); + pipe_vertex_buffer_unreference(&softpipe->vertex_buffer[i]); } tgsi_exec_machine_destroy(softpipe->fs_machine); diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 03fcf64fd2e..137ad0565b3 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -82,14 +82,15 @@ softpipe_draw_vbo(struct pipe_context *pipe, /* Map vertex buffers */ for (i = 0; i < sp->num_vertex_buffers; i++) { - const void *buf = sp->vertex_buffer[i].user_buffer; + const void *buf = sp->vertex_buffer[i].is_user_buffer ? + sp->vertex_buffer[i].buffer.user : NULL; size_t size = ~0; if (!buf) { - if (!sp->vertex_buffer[i].buffer) { + if (!sp->vertex_buffer[i].buffer.resource) { continue; } - buf = softpipe_resource_data(sp->vertex_buffer[i].buffer); - size = sp->vertex_buffer[i].buffer->width0; + buf = softpipe_resource_data(sp->vertex_buffer[i].buffer.resource); + size = sp->vertex_buffer[i].buffer.resource->width0; } draw_set_mapped_vertex_buffer(draw, i, buf, size); } diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c index 6de233888f6..6a89e661dd7 100644 --- a/src/gallium/drivers/svga/svga_draw.c +++ b/src/gallium/drivers/svga/svga_draw.c @@ -74,7 +74,7 @@ svga_hwtnl_destroy(struct svga_hwtnl *hwtnl) } for (i = 0; i < hwtnl->cmd.vbuf_count; i++) - pipe_resource_reference(&hwtnl->cmd.vbufs[i].buffer, NULL); + pipe_vertex_buffer_unreference(&hwtnl->cmd.vbufs[i]); for (i = 0; i < hwtnl->cmd.prim_count; i++) pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL); @@ -139,16 +139,12 @@ svga_hwtnl_vertex_buffers(struct svga_hwtnl *hwtnl, unsigned i; for (i = 0; i < count; i++) { - pipe_resource_reference(&dst[i].buffer, src[i].buffer); - dst[i].user_buffer = src[i].user_buffer; - dst[i].stride = src[i].stride; - dst[i].buffer_offset = src[i].buffer_offset; + pipe_vertex_buffer_reference(&dst[i], &src[i]); } /* release old buffer references */ for ( ; i < hwtnl->cmd.vbuf_count; i++) { - pipe_resource_reference(&dst[i].buffer, NULL); - dst[i].user_buffer = NULL; /* just to be safe */ + pipe_vertex_buffer_unreference(&dst[i]); /* don't bother zeroing stride/offset fields */ } @@ -175,7 +171,7 @@ svga_hwtnl_is_buffer_referred(struct svga_hwtnl *hwtnl, } for (i = 0; i < hwtnl->cmd.vbuf_count; ++i) { - if (hwtnl->cmd.vbufs[i].buffer == buffer) { + if (hwtnl->cmd.vbufs[i].buffer.resource == buffer) { return TRUE; } } @@ -205,7 +201,7 @@ draw_vgpu9(struct svga_hwtnl *hwtnl) for (i = 0; i < hwtnl->cmd.vdecl_count; i++) { unsigned j = hwtnl->cmd.vdecl_buffer_index[i]; - handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer); + handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer.resource); if (!handle) return PIPE_ERROR_OUT_OF_MEMORY; @@ -526,7 +522,7 @@ draw_vgpu10(struct svga_hwtnl *hwtnl, /* Get handle for each referenced vertex buffer */ for (i = 0; i < vbuf_count; i++) { - struct svga_buffer *sbuf = svga_buffer(hwtnl->cmd.vbufs[i].buffer); + struct svga_buffer *sbuf = svga_buffer(hwtnl->cmd.vbufs[i].buffer.resource); if (sbuf) { assert(sbuf->key.flags & SVGA3D_SURFACE_BIND_VERTEX_BUFFER); @@ -800,7 +796,7 @@ check_draw_params(struct svga_hwtnl *hwtnl, for (i = 0; i < hwtnl->cmd.vdecl_count; i++) { unsigned j = hwtnl->cmd.vdecl_buffer_index[i]; const struct pipe_vertex_buffer *vb = &hwtnl->cmd.vbufs[j]; - unsigned size = vb->buffer ? vb->buffer->width0 : 0; + unsigned size = vb->buffer.resource ? vb->buffer.resource->width0 : 0; unsigned offset = hwtnl->cmd.vdecl[i].array.offset; unsigned stride = hwtnl->cmd.vdecl[i].array.stride; int index_bias = (int) range->indexBias + hwtnl->index_bias; diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index 4b3f5d82e8c..5243ae613ee 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -328,7 +328,7 @@ void svga_cleanup_vertex_state( struct svga_context *svga ) unsigned i; for (i = 0 ; i < svga->curr.num_vertex_buffers; i++) - pipe_resource_reference(&svga->curr.vb[i].buffer, NULL); + pipe_vertex_buffer_unreference(&svga->curr.vb[i]); pipe_resource_reference(&svga->state.hw_draw.ib, NULL); diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c index e1b6a1c2a44..fd6a238ef16 100644 --- a/src/gallium/drivers/svga/svga_state_vdecl.c +++ b/src/gallium/drivers/svga/svga_state_vdecl.c @@ -73,10 +73,10 @@ emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty) unsigned int offset = vb->buffer_offset + ve[i].src_offset; unsigned tmp_neg_bias = 0; - if (!vb->buffer) + if (!vb->buffer.resource) continue; - buffer = svga_buffer(vb->buffer); + buffer = svga_buffer(vb->buffer.resource); if (buffer->uploaded.start > offset) { tmp_neg_bias = buffer->uploaded.start - offset; if (vb->stride) @@ -91,10 +91,10 @@ emit_hw_vs_vdecl(struct svga_context *svga, unsigned dirty) unsigned usage, index; struct svga_buffer *buffer; - if (!vb->buffer) + if (!vb->buffer.resource) continue; - buffer = svga_buffer(vb->buffer); + buffer = svga_buffer(vb->buffer.resource); svga_generate_vdecl_semantics( i, &usage, &index ); /* SVGA_NEW_VELEMENT diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c index 576fd853e7f..51be4846183 100644 --- a/src/gallium/drivers/svga/svga_swtnl_backend.c +++ b/src/gallium/drivers/svga/svga_swtnl_backend.c @@ -245,10 +245,10 @@ svga_vbuf_submit_state( struct svga_vbuf_render *svga_render ) /* Specify the vertex buffer (there's only ever one) */ { struct pipe_vertex_buffer vb; - vb.buffer = svga_render->vbuf; + vb.is_user_buffer = false; + vb.buffer.resource = svga_render->vbuf; vb.buffer_offset = svga_render->vdecl_offset; vb.stride = vdecl[0].array.stride; - vb.user_buffer = NULL; svga_hwtnl_vertex_buffers(svga->hwtnl, 1, &vb); } diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c index 24b4f5cdc28..76d128d3ced 100644 --- a/src/gallium/drivers/svga/svga_swtnl_draw.c +++ b/src/gallium/drivers/svga/svga_swtnl_draw.c @@ -70,9 +70,9 @@ svga_swtnl_draw_vbo(struct svga_context *svga, * Map vertex buffers */ for (i = 0; i < svga->curr.num_vertex_buffers; i++) { - if (svga->curr.vb[i].buffer) { + if (svga->curr.vb[i].buffer.resource) { map = pipe_buffer_map(&svga->pipe, - svga->curr.vb[i].buffer, + svga->curr.vb[i].buffer.resource, PIPE_TRANSFER_READ, &vb_transfer[i]); @@ -120,7 +120,7 @@ svga_swtnl_draw_vbo(struct svga_context *svga, * unmap vertex/index buffers */ for (i = 0; i < svga->curr.num_vertex_buffers; i++) { - if (svga->curr.vb[i].buffer) { + if (svga->curr.vb[i].buffer.resource) { pipe_buffer_unmap(&svga->pipe, vb_transfer[i]); draw_set_mapped_vertex_buffer(draw, i, NULL, 0); } diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 12b4e9d6398..d2a51faaa1e 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -744,8 +744,8 @@ swr_update_resource_status(struct pipe_context *pipe, /* VBO vertex buffers */ for (uint32_t i = 0; i < ctx->num_vertex_buffers; i++) { struct pipe_vertex_buffer *vb = &ctx->vertex_buffer[i]; - if (!vb->user_buffer) - swr_resource_read(vb->buffer); + if (!vb->is_user_buffer) + swr_resource_read(vb->buffer.resource); } /* VBO index buffer */ @@ -1236,7 +1236,7 @@ swr_update_derived(struct pipe_context *pipe, for (UINT i = 0; i < ctx->num_vertex_buffers; i++) { struct pipe_vertex_buffer *vb = &ctx->vertex_buffer[i]; - if (!vb->user_buffer) + if (!vb->is_user_buffer) continue; uint32_t elems, base, size; @@ -1258,16 +1258,16 @@ swr_update_derived(struct pipe_context *pipe, struct pipe_vertex_buffer *vb = &ctx->vertex_buffer[i]; pitch = vb->stride; - if (!vb->user_buffer) { + if (!vb->is_user_buffer) { /* VBO * size is based on buffer->width0 rather than info.max_index * to prevent having to validate VBO on each draw */ - size = vb->buffer->width0; + size = vb->buffer.resource->width0; elems = size / pitch; partial_inbounds = size % pitch; min_vertex_index = 0; - p_data = swr_resource_data(vb->buffer) + vb->buffer_offset; + p_data = swr_resource_data(vb->buffer.resource) + vb->buffer_offset; } else { /* Client buffer * client memory is one-time use, re-trigger SWR_NEW_VERTEX to @@ -1281,7 +1281,7 @@ swr_update_derived(struct pipe_context *pipe, /* Copy only needed vertices to scratch space */ size = AlignUp(size, 4); - const void *ptr = (const uint8_t *) vb->user_buffer + base; + const void *ptr = (const uint8_t *) vb->buffer.user + base; memcpy(scratch, ptr, size); ptr = scratch; scratch += size; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 4c6f6d60e0c..13c0a9d5bcb 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -653,9 +653,9 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state) trace_dump_struct_begin("pipe_vertex_buffer"); trace_dump_member(uint, state, stride); + trace_dump_member(bool, state, is_user_buffer); trace_dump_member(uint, state, buffer_offset); - trace_dump_member(ptr, state, buffer); - trace_dump_member(ptr, state, user_buffer); + trace_dump_member(ptr, state, buffer.resource); trace_dump_struct_end(); } diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c index 61694ecda6c..01fae27cc1e 100644 --- a/src/gallium/drivers/vc4/vc4_draw.c +++ b/src/gallium/drivers/vc4/vc4_draw.c @@ -186,7 +186,7 @@ vc4_emit_gl_shader_state(struct vc4_context *vc4, struct pipe_vertex_element *elem = &vtx->pipe[i]; struct pipe_vertex_buffer *vb = &vertexbuf->vb[elem->vertex_buffer_index]; - struct vc4_resource *rsc = vc4_resource(vb->buffer); + struct vc4_resource *rsc = vc4_resource(vb->buffer.resource); /* not vc4->dirty tracked: vc4->last_index_bias */ uint32_t offset = (vb->buffer_offset + elem->src_offset + diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c index 25b24c895d3..8d7094f4e18 100644 --- a/src/gallium/drivers/virgl/virgl_context.c +++ b/src/gallium/drivers/virgl/virgl_context.c @@ -124,7 +124,7 @@ static void virgl_attach_res_vertex_buffers(struct virgl_context *vctx) unsigned i; for (i = 0; i < vctx->num_vertex_buffers; i++) { - res = virgl_resource(vctx->vertex_buffer[i].buffer); + res = virgl_resource(vctx->vertex_buffer[i].buffer.resource); if (res) vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE); } diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c index cbe8d19c9d8..8a6a5fbcd6d 100644 --- a/src/gallium/drivers/virgl/virgl_encode.c +++ b/src/gallium/drivers/virgl/virgl_encode.c @@ -389,7 +389,7 @@ int virgl_encoder_set_vertex_buffers(struct virgl_context *ctx, int i; virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_VERTEX_BUFFERS, 0, VIRGL_SET_VERTEX_BUFFERS_SIZE(num_buffers))); for (i = 0; i < num_buffers; i++) { - struct virgl_resource *res = virgl_resource(buffers[i].buffer); + struct virgl_resource *res = virgl_resource(buffers[i].buffer.resource); virgl_encoder_write_dword(ctx->cbuf, buffers[i].stride); virgl_encoder_write_dword(ctx->cbuf, buffers[i].buffer_offset); virgl_encoder_write_res(ctx, res); |