cso_context,u_vbuf: add take_ownership param into set_vertex_buffers
st/mesa will use this to skip atomic ops for reference counting. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8298>
This commit is contained in:
parent
27dcb46629
commit
a4a21b6104
|
@ -1027,7 +1027,7 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
|
|||
return;
|
||||
|
||||
if (vbuf) {
|
||||
u_vbuf_set_vertex_buffers(vbuf, start_slot, count, 0, buffers);
|
||||
u_vbuf_set_vertex_buffers(vbuf, start_slot, count, 0, false, buffers);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1052,6 +1052,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
|
|||
const struct cso_velems_state *velems,
|
||||
unsigned vb_count,
|
||||
unsigned unbind_trailing_vb_count,
|
||||
bool take_ownership,
|
||||
bool uses_user_vertex_buffers,
|
||||
const struct pipe_vertex_buffer *vbuffers)
|
||||
{
|
||||
|
@ -1073,7 +1074,8 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
|
|||
|
||||
if (vb_count || unbind_trailing_vb_count) {
|
||||
u_vbuf_set_vertex_buffers(vbuf, 0, vb_count,
|
||||
unbind_trailing_vb_count, vbuffers);
|
||||
unbind_trailing_vb_count,
|
||||
take_ownership, vbuffers);
|
||||
}
|
||||
u_vbuf_set_vertex_elements(vbuf, velems);
|
||||
return;
|
||||
|
@ -1083,7 +1085,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
|
|||
/* Unbind all buffers in u_vbuf, because we'll use cso_context. */
|
||||
unsigned unbind_vb_count = vb_count + unbind_trailing_vb_count;
|
||||
if (unbind_vb_count)
|
||||
u_vbuf_set_vertex_buffers(vbuf, 0, 0, unbind_vb_count, NULL);
|
||||
u_vbuf_set_vertex_buffers(vbuf, 0, 0, unbind_vb_count, false, NULL);
|
||||
|
||||
/* Unset this to make sure the CSO is re-bound on the next use. */
|
||||
u_vbuf_unset_vertex_elements(vbuf);
|
||||
|
@ -1093,7 +1095,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
|
|||
|
||||
if (vb_count || unbind_trailing_vb_count) {
|
||||
pipe->set_vertex_buffers(pipe, 0, vb_count, unbind_trailing_vb_count,
|
||||
false, vbuffers);
|
||||
take_ownership, vbuffers);
|
||||
}
|
||||
cso_set_vertex_elements_direct(ctx, velems);
|
||||
}
|
||||
|
|
|
@ -169,6 +169,7 @@ cso_set_vertex_buffers_and_elements(struct cso_context *ctx,
|
|||
const struct cso_velems_state *velems,
|
||||
unsigned vb_count,
|
||||
unsigned unbind_trailing_vb_count,
|
||||
bool take_ownership,
|
||||
bool uses_user_vertex_buffers,
|
||||
const struct pipe_vertex_buffer *vbuffers);
|
||||
|
||||
|
|
|
@ -878,6 +878,7 @@ static void u_vbuf_delete_vertex_elements(void *ctx, void *state,
|
|||
void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
|
||||
unsigned start_slot, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
const struct pipe_vertex_buffer *bufs)
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -928,7 +929,12 @@ void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
|
|||
continue;
|
||||
}
|
||||
|
||||
pipe_vertex_buffer_reference(orig_vb, vb);
|
||||
if (take_ownership) {
|
||||
pipe_vertex_buffer_unreference(orig_vb);
|
||||
memcpy(orig_vb, vb, sizeof(*vb));
|
||||
} else {
|
||||
pipe_vertex_buffer_reference(orig_vb, vb);
|
||||
}
|
||||
|
||||
if (vb->stride) {
|
||||
nonzero_stride_vb_mask |= 1 << dst_index;
|
||||
|
|
|
@ -77,6 +77,7 @@ void u_vbuf_unset_vertex_elements(struct u_vbuf *mgr);
|
|||
void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
|
||||
unsigned start_slot, unsigned count,
|
||||
unsigned unbind_num_trailing_slots,
|
||||
bool take_ownership,
|
||||
const struct pipe_vertex_buffer *bufs);
|
||||
void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info,
|
||||
const struct pipe_draw_indirect_info *indirect,
|
||||
|
|
|
@ -354,6 +354,7 @@ st_update_array(struct st_context *st)
|
|||
cso_set_vertex_buffers_and_elements(cso, &velements,
|
||||
num_vbuffers,
|
||||
unbind_trailing_vbuffers,
|
||||
false,
|
||||
uses_user_vertex_buffers,
|
||||
vbuffer);
|
||||
st->last_num_vbuffers = num_vbuffers;
|
||||
|
|
Loading…
Reference in New Issue