}
struct pipe_context *pipe = ctx->pipe;
- pipe->set_vertex_buffers(pipe, start_slot, count, 0, buffers);
+ pipe->set_vertex_buffers(pipe, start_slot, count, 0, false, buffers);
}
/**
/* Unbind all buffers in cso_context, because we'll use u_vbuf. */
unsigned unbind_vb_count = vb_count + unbind_trailing_vb_count;
if (unbind_vb_count)
- pipe->set_vertex_buffers(pipe, 0, 0, unbind_vb_count, NULL);
+ pipe->set_vertex_buffers(pipe, 0, 0, unbind_vb_count, false, NULL);
/* Unset this to make sure the CSO is re-bound on the next use. */
ctx->velements = NULL;
if (vb_count || unbind_trailing_vb_count) {
pipe->set_vertex_buffers(pipe, 0, vb_count, unbind_trailing_vb_count,
- vbuffers);
+ false, vbuffers);
}
cso_set_vertex_elements_direct(ctx, velems);
}
util_set_vertex_buffers_count(draw->pt.vertex_buffer,
&draw->pt.nr_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots, false);
}
dd_context_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start, unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct dd_context *dctx = dd_context(_pipe);
safe_memcpy(&dctx->draw_state.vertex_buffers[start + num_buffers], NULL,
sizeof(buffers[0]) * unbind_num_trailing_slots);
pipe->set_vertex_buffers(pipe, start, num_buffers,
- unbind_num_trailing_slots, buffers);
+ unbind_num_trailing_slots, take_ownership,
+ buffers);
}
static void
static void noop_set_vertex_buffers(struct pipe_context *ctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
}
rbug_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start_slot, unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *_buffers)
{
struct rbug_context *rb_pipe = rbug_context(_pipe);
pipe->set_vertex_buffers(pipe, start_slot,
num_buffers, unbind_num_trailing_slots,
- buffers);
+ take_ownership, buffers);
mtx_unlock(&rb_pipe->call_mutex);
}
trace_context_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start_slot, unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct trace_context *tr_ctx = trace_context(_pipe);
trace_dump_arg(uint, start_slot);
trace_dump_arg(uint, num_buffers);
trace_dump_arg(uint, unbind_num_trailing_slots);
+ trace_dump_arg(bool, take_ownership);
trace_dump_arg_begin("buffers");
trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
trace_dump_arg_end();
pipe->set_vertex_buffers(pipe, start_slot, num_buffers,
- unbind_num_trailing_slots, buffers);
+ unbind_num_trailing_slots, take_ownership,
+ buffers);
trace_dump_call_end();
}
/* Unbind resources that we have bound. */
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
- pipe->set_vertex_buffers(pipe, 0, 0, 1, NULL);
+ pipe->set_vertex_buffers(pipe, 0, 0, 1, false, NULL);
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, 1, NULL);
/* restore states not restored by cso */
struct pipe_context *pipe = ppq->p->pipe;
pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, false, NULL);
pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, false, NULL);
- pipe->set_vertex_buffers(pipe, 0, 0, 1, NULL);
+ pipe->set_vertex_buffers(pipe, 0, 0, 1, false, NULL);
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, 3, NULL);
/* restore states not restored by cso */
/* Vertex buffer. */
if (ctx->base.saved_vertex_buffer.buffer.resource) {
- pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0,
+ pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, true,
&ctx->base.saved_vertex_buffer);
- pipe_vertex_buffer_unreference(&ctx->base.saved_vertex_buffer);
+ ctx->base.saved_vertex_buffer.buffer.resource = NULL;
}
/* Vertex elements. */
return;
u_upload_unmap(pipe->stream_uploader);
- pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, &vb);
+ pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, false, &vb);
pipe->bind_vertex_elements_state(pipe, vertex_elements_cso);
pipe->bind_vs_state(pipe, get_vs(&ctx->base));
vb.buffer_offset = srcx;
vb.stride = 4;
- pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, &vb);
+ pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, false, &vb);
pipe->bind_vertex_elements_state(pipe, ctx->velem_state_readbuf[0]);
bind_vs_pos_only(ctx, 1);
if (ctx->has_geometry_shader)
blitter_check_saved_vertex_states(ctx);
blitter_disable_render_cond(ctx);
- pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, &vb);
+ pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, 0, false, &vb);
pipe->bind_vertex_elements_state(pipe,
ctx->velem_state_readbuf[num_channels-1]);
bind_vs_pos_only(ctx, num_channels);
cso_set_vertex_buffers(cso, vbuf_slot, 1, &vbuffer);
cso_draw_arrays(cso, prim_type, 0, num_verts);
} else {
- pipe->set_vertex_buffers(pipe, vbuf_slot, 1, 0, &vbuffer);
+ pipe->set_vertex_buffers(pipe, vbuf_slot, 1, 0, false, &vbuffer);
util_draw_arrays(pipe, prim_type, 0, num_verts);
}
}
uint32_t *enabled_buffers,
const struct pipe_vertex_buffer *src,
unsigned start_slot, unsigned count,
- unsigned unbind_num_trailing_slots)
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership)
{
unsigned i;
uint32_t bitmask = 0;
pipe_vertex_buffer_unreference(&dst[i]);
- if (!src[i].is_user_buffer)
+ if (!take_ownership && !src[i].is_user_buffer)
pipe_resource_reference(&dst[i].buffer.resource, src[i].buffer.resource);
}
unsigned *dst_count,
const struct pipe_vertex_buffer *src,
unsigned start_slot, unsigned count,
- unsigned unbind_num_trailing_slots)
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership)
{
unsigned i;
uint32_t enabled_buffers = 0;
}
util_set_vertex_buffers_mask(dst, &enabled_buffers, src, start_slot,
- count, unbind_num_trailing_slots);
+ count, unbind_num_trailing_slots,
+ take_ownership);
*dst_count = util_last_bit(enabled_buffers);
}
uint32_t *enabled_buffers,
const struct pipe_vertex_buffer *src,
unsigned start_slot, unsigned count,
- unsigned unbind_num_trailing_slots);
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership);
void util_set_vertex_buffers_count(struct pipe_vertex_buffer *dst,
unsigned *dst_count,
const struct pipe_vertex_buffer *src,
unsigned start_slot, unsigned count,
- unsigned unbind_num_trailing_slots);
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership);
void util_set_shader_buffers_mask(struct pipe_shader_buffer *dst,
uint32_t *enabled_buffers,
if (!count) {
pipe->set_vertex_buffers(pipe, p->start, 0,
- p->unbind_num_trailing_slots, NULL);
+ p->unbind_num_trailing_slots, false, NULL);
return;
}
tc_assert(!p->slot[i].is_user_buffer);
pipe->set_vertex_buffers(pipe, p->start, count,
- p->unbind_num_trailing_slots, p->slot);
- for (unsigned i = 0; i < count; i++)
- pipe_resource_reference(&p->slot[i].buffer.resource, NULL);
+ p->unbind_num_trailing_slots, true, p->slot);
}
static void
tc_set_vertex_buffers(struct pipe_context *_pipe,
unsigned start, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct threaded_context *tc = threaded_context(_pipe);
p->count = count;
p->unbind_num_trailing_slots = unbind_num_trailing_slots;
- for (unsigned i = 0; i < count; i++) {
- struct pipe_vertex_buffer *dst = &p->slot[i];
- const struct pipe_vertex_buffer *src = buffers + i;
-
- tc_assert(!src->is_user_buffer);
- dst->stride = src->stride;
- dst->is_user_buffer = false;
- tc_set_resource_reference(&dst->buffer.resource,
- src->buffer.resource);
- dst->buffer_offset = src->buffer_offset;
+ if (take_ownership) {
+ memcpy(p->slot, buffers, count * sizeof(struct pipe_vertex_buffer));
+ } else {
+ for (unsigned i = 0; i < count; i++) {
+ struct pipe_vertex_buffer *dst = &p->slot[i];
+ const struct pipe_vertex_buffer *src = buffers + i;
+
+ tc_assert(!src->is_user_buffer);
+ dst->stride = src->stride;
+ dst->is_user_buffer = false;
+ tc_set_resource_reference(&dst->buffer.resource,
+ src->buffer.resource);
+ dst->buffer_offset = src->buffer_offset;
+ }
}
} else {
struct tc_vertex_buffers *p =
const unsigned num_vb = screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
PIPE_SHADER_CAP_MAX_INPUTS);
- mgr->pipe->set_vertex_buffers(mgr->pipe, 0, 0, num_vb, NULL);
+ mgr->pipe->set_vertex_buffers(mgr->pipe, 0, 0, num_vb, false, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; i++)
pipe_vertex_buffer_unreference(&mgr->vertex_buffer[i]);
}
pipe->set_vertex_buffers(pipe, start_slot, count,
- unbind_num_trailing_slots, NULL);
+ unbind_num_trailing_slots, false, NULL);
return;
}
start_slot = ffs(mgr->dirty_real_vb_mask) - 1;
count = util_last_bit(mgr->dirty_real_vb_mask >> start_slot);
- pipe->set_vertex_buffers(pipe, start_slot, count, 0,
+ pipe->set_vertex_buffers(pipe, start_slot, count, 0, false,
mgr->real_vertex_buffer + start_slot);
mgr->dirty_real_vb_mask = 0;
}
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
filter->pipe->set_viewport_states(filter->pipe, 0, 1, &viewport);
- filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, &filter->quad);
+ filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, false, &filter->quad);
filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves);
util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4);
c->pipe->set_framebuffer_state(c->pipe, &c->fb_state);
c->pipe->bind_vs_state(c->pipe, c->vs);
- c->pipe->set_vertex_buffers(c->pipe, 0, 1, 0, &c->vertex_buf);
+ c->pipe->set_vertex_buffers(c->pipe, 0, 1, 0, false, &c->vertex_buf);
c->pipe->bind_vertex_elements_state(c->pipe, c->vertex_elems_state);
pipe_set_constant_buffer(c->pipe, PIPE_SHADER_FRAGMENT, 0, s->shader_params);
c->pipe->bind_rasterizer_state(c->pipe, c->rast);
/* set up pipe state */
filter->pipe->bind_rasterizer_state(filter->pipe, filter->rs_state);
- filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, &filter->quad);
+ filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, false, &filter->quad);
filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves);
filter->pipe->bind_vs_state(filter->pipe, filter->vs);
filter->pipe->bind_sampler_states(filter->pipe, PIPE_SHADER_FRAGMENT,
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
filter->pipe->set_viewport_states(filter->pipe, 0, 1, &viewport);
- filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, &filter->quad);
+ filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, false, &filter->quad);
filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves);
util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4);
filter->pipe->bind_fs_state(filter->pipe, filter->fs);
filter->pipe->set_framebuffer_state(filter->pipe, &fb_state);
filter->pipe->set_viewport_states(filter->pipe, 0, 1, &viewport);
- filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, &filter->quad);
+ filter->pipe->set_vertex_buffers(filter->pipe, 0, 1, 0, false, &filter->quad);
filter->pipe->bind_vertex_elements_state(filter->pipe, filter->ves);
util_draw_arrays(filter->pipe, PIPE_PRIM_QUADS, 0, 4);
if (!ref_frames[j] || !ref_frames[j][i]) continue;
vb[2] = vl_vb_get_mv(&buf->vertex_stream, j);
- dec->context->set_vertex_buffers(dec->context, 0, 3, 0, vb);
+ dec->context->set_vertex_buffers(dec->context, 0, 3, 0, false, vb);
vl_mc_render_ref(i ? &dec->mc_c : &dec->mc_y, &buf->mc[i], ref_frames[j][i]);
}
if (!buf->num_ycbcr_blocks[i]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, i);
- dec->context->set_vertex_buffers(dec->context, 0, 2, 0, vb);
+ dec->context->set_vertex_buffers(dec->context, 0, 2, 0, false, vb);
vl_zscan_render(i ? &dec->zscan_c : & dec->zscan_y, &buf->zscan[i] , buf->num_ycbcr_blocks[i]);
if (!buf->num_ycbcr_blocks[plane]) continue;
vb[1] = vl_vb_get_ycbcr(&buf->vertex_stream, plane);
- dec->context->set_vertex_buffers(dec->context, 0, 2, 0, vb);
+ dec->context->set_vertex_buffers(dec->context, 0, 2, 0, false, vb);
if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)
vl_idct_prepare_stage2(i ? &dec->idct_c : &dec->idct_y, &buf->idct[plane]);
unsigned start_slot,
unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct d3d12_context *ctx = d3d12_context(pctx);
util_set_vertex_buffers_count(ctx->vbs, &ctx->num_vbs,
buffers, start_slot, num_buffers,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
for (unsigned i = 0; i < ctx->num_vbs; ++i) {
const struct pipe_vertex_buffer* buf = ctx->vbs + i;
static void
etna_set_vertex_buffers(struct pipe_context *pctx, unsigned start_slot,
- unsigned num_buffers, unsigned unbind_num_trailing_slots,
+ unsigned num_buffers, unsigned unbind_num_trailing_slots, bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct etna_context *ctx = etna_context(pctx);
struct etna_vertexbuf_state *so = &ctx->vertex_buffer;
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, vb, start_slot,
- num_buffers, unbind_num_trailing_slots);
+ num_buffers, unbind_num_trailing_slots,
+ take_ownership);
so->count = util_last_bit(so->enabled_mask);
for (unsigned idx = start_slot; idx < start_slot + num_buffers; ++idx) {
pctx->set_viewport_states(pctx, 0, 1, &vp);
pctx->bind_vertex_elements_state(pctx, ctx->solid_vbuf_state.vtx);
- pctx->set_vertex_buffers(pctx, blitter->vb_slot, 1, 0,
+ pctx->set_vertex_buffers(pctx, blitter->vb_slot, 1, 0, false,
&ctx->solid_vbuf_state.vertexbuf.vb[0]);
pctx->set_stream_output_targets(pctx, 0, NULL, NULL);
fd_set_vertex_buffers(struct pipe_context *pctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct fd_context *ctx = fd_context(pctx);
}
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, vb, start_slot,
- count, unbind_num_trailing_slots);
+ count, unbind_num_trailing_slots,
+ take_ownership);
so->count = util_last_bit(so->enabled_mask);
if (!vb)
static void i915_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct i915_context *i915 = i915_context(pipe);
util_set_vertex_buffers_count(i915->vertex_buffers,
&i915->nr_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
/* pass-through to draw module */
draw_set_vertex_buffers(draw, start_slot, count,
iris_set_vertex_buffers(struct pipe_context *ctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct iris_context *ice = (struct iris_context *) ctx;
/* We may see user buffers that are NULL bindings. */
assert(!(buffer->is_user_buffer && buffer->buffer.user != NULL));
- pipe_resource_reference(&state->resource, buffer->buffer.resource);
+ if (take_ownership) {
+ pipe_resource_reference(&state->resource, NULL);
+ state->resource = buffer->buffer.resource;
+ } else {
+ pipe_resource_reference(&state->resource, buffer->buffer.resource);
+ }
struct iris_resource *res = (void *) state->resource;
state->offset = (int) buffer->buffer_offset;
lima_set_vertex_buffers(struct pipe_context *pctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct lima_context *ctx = lima_context(pctx);
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask,
vb, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
so->count = util_last_bit(so->enabled_mask);
ctx->dirty |= LIMA_CONTEXT_DIRTY_VERTEX_BUFF;
struct lima_context_vertex_buffer *so = &ctx->vertex_buffers;
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, NULL,
- 0, 0, ARRAY_SIZE(so->vb));
+ 0, 0, ARRAY_SIZE(so->vb), false);
pipe_surface_reference(&ctx->framebuffer.base.cbufs[0], NULL);
pipe_surface_reference(&ctx->framebuffer.base.zsbuf, NULL);
llvmpipe_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
util_set_vertex_buffers_count(llvmpipe->vertex_buffer,
&llvmpipe->num_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
llvmpipe->dirty |= LP_NEW_VERTEX;
nv30_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct nv30_context *nv30 = nv30_context(pipe);
util_set_vertex_buffers_count(nv30->vtxbuf, &nv30->num_vtxbufs,
vb, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
nv30->dirty |= NV30_NEW_ARRAYS;
}
nv50_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct nv50_context *nv50 = nv50_context(pipe);
util_set_vertex_buffers_count(nv50->vtxbuf, &nv50->num_vtxbufs, vb,
start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
if (!vb) {
nv50->vbo_user &= ~(((1ull << count) - 1) << start_slot);
nvc0_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct nvc0_context *nvc0 = nvc0_context(pipe);
util_set_vertex_buffers_count(nvc0->vtxbuf, &nvc0->num_vtxbufs, vb,
start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
if (!vb) {
nvc0->vbo_user &= ~(((1ull << count) - 1) << start_slot);
unsigned start_slot,
unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct panfrost_context *ctx = pan_context(pctx);
util_set_vertex_buffers_mask(ctx->vertex_buffers, &ctx->vb_mask, buffers,
- start_slot, num_buffers, unbind_num_trailing_slots);
+ start_slot, num_buffers, unbind_num_trailing_slots,
+ take_ownership);
}
static void
vb.depth0 = 1;
r300->dummy_vb.buffer.resource = screen->resource_create(screen, &vb);
- r300->context.set_vertex_buffers(&r300->context, 0, 1, 0, &r300->dummy_vb);
+ r300->context.set_vertex_buffers(&r300->context, 0, 1, 0, false, &r300->dummy_vb);
}
{
static void r300_set_vertex_buffers_hwtcl(struct pipe_context* pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
util_set_vertex_buffers_count(r300->vertex_buffer,
&r300->nr_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots, take_ownership);
/* There must be at least one vertex buffer set, otherwise it locks up. */
if (!r300->nr_vertex_buffers) {
util_set_vertex_buffers_count(r300->vertex_buffer,
&r300->nr_vertex_buffers,
- &r300->dummy_vb, 0, 1, 0);
+ &r300->dummy_vb, 0, 1, 0, false);
}
r300->vertex_arrays_dirty = TRUE;
static void r300_set_vertex_buffers_swtcl(struct pipe_context* pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
util_set_vertex_buffers_count(r300->vertex_buffer,
&r300->nr_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots, take_ownership);
draw_set_vertex_buffers(r300->draw, start_slot, count,
unbind_num_trailing_slots, buffers);
vbuffer.stride = 2 * 4 * sizeof(float); /* vertex size */
vbuffer.buffer_offset = offset;
- rctx->b.set_vertex_buffers(&rctx->b, blitter->vb_slot, 1, 0, &vbuffer);
+ rctx->b.set_vertex_buffers(&rctx->b, blitter->vb_slot, 1, 0, false, &vbuffer);
util_draw_arrays_instanced(&rctx->b, R600_PRIM_RECTANGLE_LIST, 0, 3,
0, num_instances);
pipe_resource_reference(&buf, NULL);
static void r600_set_vertex_buffers(struct pipe_context *ctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *input)
{
struct r600_context *rctx = (struct r600_context *)ctx;
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.resource, input[i].buffer.resource);
+ if (take_ownership) {
+ pipe_resource_reference(&vb[i].buffer.resource, NULL);
+ vb[i].buffer.resource = input[i].buffer.resource;
+ } else {
+ 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.resource);
} else {
}
static void si_set_vertex_buffers(struct pipe_context *ctx, unsigned start_slot, unsigned count,
- unsigned unbind_num_trailing_slots,
+ unsigned unbind_num_trailing_slots, bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct si_context *sctx = (struct si_context *)ctx;
assert(start_slot + count + unbind_num_trailing_slots <= ARRAY_SIZE(sctx->vertex_buffer));
if (buffers) {
- for (i = 0; i < count; i++) {
- const struct pipe_vertex_buffer *src = buffers + i;
- struct pipe_vertex_buffer *dsti = dst + i;
- struct pipe_resource *buf = src->buffer.resource;
- unsigned slot_bit = 1 << (start_slot + i);
-
- pipe_resource_reference(&dsti->buffer.resource, buf);
- dsti->buffer_offset = src->buffer_offset;
- dsti->stride = src->stride;
-
- if (dsti->buffer_offset & 3 || dsti->stride & 3)
- unaligned |= slot_bit;
-
- si_context_add_resource_size(sctx, buf);
- if (buf)
- si_resource(buf)->bind_history |= PIPE_BIND_VERTEX_BUFFER;
+ if (take_ownership) {
+ for (i = 0; i < count; i++) {
+ const struct pipe_vertex_buffer *src = buffers + i;
+ struct pipe_vertex_buffer *dsti = dst + i;
+ struct pipe_resource *buf = src->buffer.resource;
+ unsigned slot_bit = 1 << (start_slot + i);
+
+ /* Only unreference bound vertex buffers. (take_ownership) */
+ pipe_resource_reference(&dsti->buffer.resource, NULL);
+
+ if (src->buffer_offset & 3 || src->stride & 3)
+ unaligned |= slot_bit;
+
+ si_context_add_resource_size(sctx, buf);
+ if (buf)
+ si_resource(buf)->bind_history |= PIPE_BIND_VERTEX_BUFFER;
+ }
+ /* take_ownership allows us to copy pipe_resource pointers without refcounting. */
+ memcpy(dst, buffers, count * sizeof(struct pipe_vertex_buffer));
+ } else {
+ for (i = 0; i < count; i++) {
+ const struct pipe_vertex_buffer *src = buffers + i;
+ struct pipe_vertex_buffer *dsti = dst + i;
+ struct pipe_resource *buf = src->buffer.resource;
+ unsigned slot_bit = 1 << (start_slot + i);
+
+ pipe_resource_reference(&dsti->buffer.resource, buf);
+ dsti->buffer_offset = src->buffer_offset;
+ dsti->stride = src->stride;
+
+ if (dsti->buffer_offset & 3 || dsti->stride & 3)
+ unaligned |= slot_bit;
+
+ si_context_add_resource_size(sctx, buf);
+ if (buf)
+ si_resource(buf)->bind_history |= PIPE_BIND_VERTEX_BUFFER;
+ }
}
} else {
for (i = 0; i < count; i++)
softpipe_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
util_set_vertex_buffers_count(softpipe->vertex_buffer,
&softpipe->num_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
softpipe->dirty |= SP_NEW_VERTEX;
svga_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct svga_context *svga = svga_context(pipe);
util_set_vertex_buffers_count(svga->curr.vb,
&svga->curr.num_vertex_buffers,
buffers, start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
svga->dirty |= SVGA_NEW_VBUFFER;
}
unsigned start_slot,
unsigned num_elements,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct swr_context *ctx = swr_context(pipe);
buffers,
start_slot,
num_elements,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
ctx->dirty |= SWR_NEW_VERTEX;
}
static void
tegra_set_vertex_buffers(struct pipe_context *pcontext, unsigned start_slot,
unsigned num_buffers, unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct tegra_context *context = to_tegra_context(pcontext);
}
context->gpu->set_vertex_buffers(context->gpu, start_slot, num_buffers,
- unbind_num_trailing_slots, buffers);
+ unbind_num_trailing_slots,
+ take_ownership, buffers);
}
static struct pipe_stream_output_target *
v3d_set_vertex_buffers(struct pipe_context *pctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct v3d_context *v3d = v3d_context(pctx);
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, vb,
start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
so->count = util_last_bit(so->enabled_mask);
v3d->dirty |= VC5_DIRTY_VTXBUF;
vc4_set_vertex_buffers(struct pipe_context *pctx,
unsigned start_slot, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *vb)
{
struct vc4_context *vc4 = vc4_context(pctx);
util_set_vertex_buffers_mask(so->vb, &so->enabled_mask, vb,
start_slot, count,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
so->count = util_last_bit(so->enabled_mask);
vc4->dirty |= VC4_DIRTY_VTXBUF;
unsigned start_slot,
unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct virgl_context *vctx = virgl_context(ctx);
util_set_vertex_buffers_count(vctx->vertex_buffer,
&vctx->num_vertex_buffers,
buffers, start_slot, num_buffers,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots,
+ take_ownership);
if (buffers) {
for (unsigned i = 0; i < num_buffers; i++) {
unsigned start_slot,
unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct zink_context *ctx = zink_context(pctx);
util_set_vertex_buffers_mask(ctx->buffers, &ctx->buffers_enabled_mask,
buffers, start_slot, num_buffers,
- unbind_num_trailing_slots);
+ unbind_num_trailing_slots, take_ownership);
}
static void
if (state->vb_dirty) {
state->pctx->set_vertex_buffers(state->pctx, state->start_vb,
- state->num_vb, 0, state->vb);
+ state->num_vb, 0, false, state->vb);
state->vb_dirty = false;
}
}
state.start_vb = -1;
state.num_vb = 0;
- state.pctx->set_vertex_buffers(state.pctx, 0, 0, PIPE_MAX_ATTRIBS, NULL);
+ state.pctx->set_vertex_buffers(state.pctx, 0, 0, PIPE_MAX_ATTRIBS, false, NULL);
state.pctx->bind_vertex_elements_state(state.pctx, NULL);
state.pctx->bind_vs_state(state.pctx, NULL);
state.pctx->bind_fs_state(state.pctx, NULL);
dummy_vtxbuf.is_user_buffer = false;
dummy_vtxbuf.buffer_offset = 0;
pipe->set_vertex_buffers(pipe, context->dummy_vbo_bound_at,
- 1, 0, &dummy_vtxbuf);
+ 1, 0, false, &dummy_vtxbuf);
context->vbo_bound_done = TRUE;
}
mask &= ~(1 << context->dummy_vbo_bound_at);
for (i = 0; mask; mask >>= 1, ++i) {
if (mask & 1) {
if (context->vtxbuf[i].buffer.resource)
- pipe->set_vertex_buffers(pipe, i, 1, 0, &context->vtxbuf[i]);
+ pipe->set_vertex_buffers(pipe, i, 1, 0, false, &context->vtxbuf[i]);
else
- pipe->set_vertex_buffers(pipe, i, 0, 1, NULL);
+ pipe->set_vertex_buffers(pipe, i, 0, 1, false, NULL);
}
}
info.max_index = draw.count - 1;
info.index.resource = NULL;
- context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, vtxbuf);
+ context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, false, vtxbuf);
context->pipe->draw_vbo(context->pipe, &info, NULL, &draw, 1);
}
else
info.index.user = user_ibuf;
- context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, vbuf);
+ context->pipe->set_vertex_buffers(context->pipe, 0, 1, 0, false, vbuf);
context->pipe->draw_vbo(context->pipe, &info, NULL, &draw, 1);
}
pipe->set_sampler_views(pipe, PIPE_SHADER_VERTEX, 0, 0, NINE_MAX_SAMPLERS_VS, NULL);
pipe->set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0, 0, NINE_MAX_SAMPLERS_PS, NULL);
- pipe->set_vertex_buffers(pipe, 0, 0, device->caps.MaxStreams, NULL);
+ pipe->set_vertex_buffers(pipe, 0, 0, device->caps.MaxStreams, false, NULL);
for (i = 0; i < ARRAY_SIZE(context->rt); ++i)
nine_bind(&context->rt[i], NULL);
&(vtxbuf.buffer.resource));
u_upload_unmap(device->pipe_sw->stream_uploader);
}
- pipe_sw->set_vertex_buffers(pipe_sw, i, 1, 0, &vtxbuf);
+ pipe_sw->set_vertex_buffers(pipe_sw, i, 1, 0, false, &vtxbuf);
pipe_vertex_buffer_unreference(&vtxbuf);
} else
- pipe_sw->set_vertex_buffers(pipe_sw, i, 0, 1, NULL);
+ pipe_sw->set_vertex_buffers(pipe_sw, i, 0, 1, false, NULL);
}
}
nine_context_get_pipe_release(device);
int i;
for (i = 0; i < 4; i++) {
- pipe_sw->set_vertex_buffers(pipe_sw, i, 0, 1, NULL);
+ pipe_sw->set_vertex_buffers(pipe_sw, i, 0, 1, false, NULL);
if (sw_internal->transfers_so[i])
pipe->transfer_unmap(pipe, sw_internal->transfers_so[i]);
sw_internal->transfers_so[i] = NULL;
unsigned unbind_num_trailing_slots,
const struct pipe_image_view *images);
+ /**
+ * Bind an array of vertex buffers to the specified slots.
+ *
+ * \param start_slot first vertex buffer slot
+ * \param count number of consecutive vertex buffers to bind.
+ * \param unbind_num_trailing_slots unbind slots after the bound slots
+ * \param take_ownership the caller holds buffer references and they
+ * should be taken over by the callee. This means
+ * that drivers shouldn't increment reference counts.
+ * \param buffers array of the buffers to bind
+ */
void (*set_vertex_buffers)( struct pipe_context *,
unsigned start_slot,
unsigned num_buffers,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer * );
/*@}*/
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
sizeof(vertices),
vertices);
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
vertices);
}
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
bytes,
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
sizeof(vertices),
vertices);
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
sizeof(vertices),
vertices);
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
num_verts * sizeof(struct vertex),
verts);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader(void)
sizeof(vertices),
vertices);
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )
sizeof(inst_data),
inst_data);
- ctx->set_vertex_buffers(ctx, 0, 2, 0, vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 2, 0, false, vbuf);
}
static void set_vertex_shader( void )
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
sizeof(vertices),
vertices);
- info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, &vbuf);
+ info.ctx->set_vertex_buffers(info.ctx, 0, 1, 0, false, &vbuf);
}
sizeof(vertices),
vertices);
- ctx->set_vertex_buffers(ctx, 0, 1, 0, &vbuf);
+ ctx->set_vertex_buffers(ctx, 0, 1, 0, false, &vbuf);
}
static void set_vertex_shader( void )