mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
gallium/u_threaded: unify user and non-user codepaths in set_constant_buffer
We can do this cleanup thanks to take_ownership. Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> 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
dcc94af6b1
commit
cf82b3dc74
1 changed files with 13 additions and 20 deletions
|
|
@ -805,29 +805,22 @@ tc_set_constant_buffer(struct pipe_context *_pipe,
|
|||
return;
|
||||
}
|
||||
|
||||
if (cb->user_buffer) {
|
||||
struct pipe_resource *buffer = NULL;
|
||||
unsigned offset;
|
||||
struct pipe_resource *buffer;
|
||||
unsigned offset;
|
||||
|
||||
if (cb->user_buffer) {
|
||||
/* This must be done before adding set_constant_buffer, because it could
|
||||
* generate e.g. transfer_unmap and flush partially-uninitialized
|
||||
* set_constant_buffer to the driver if it was done afterwards.
|
||||
*/
|
||||
u_upload_data(tc->base.const_uploader, 0, cb->buffer_size, tc->ubo_alignment,
|
||||
cb->user_buffer, &offset, &buffer);
|
||||
buffer = NULL;
|
||||
u_upload_data(tc->base.const_uploader, 0, cb->buffer_size,
|
||||
tc->ubo_alignment, cb->user_buffer, &offset, &buffer);
|
||||
u_upload_unmap(tc->base.const_uploader);
|
||||
|
||||
struct tc_constant_buffer *p =
|
||||
tc_add_struct_typed_call(tc, TC_CALL_set_constant_buffer,
|
||||
tc_constant_buffer);
|
||||
p->info.shader = shader;
|
||||
p->info.index = index;
|
||||
p->info.is_null = false;
|
||||
p->cb.buffer_size = cb->buffer_size;
|
||||
p->cb.user_buffer = NULL;
|
||||
p->cb.buffer_offset = offset;
|
||||
p->cb.buffer = buffer;
|
||||
return;
|
||||
take_ownership = true;
|
||||
} else {
|
||||
buffer = cb->buffer;
|
||||
offset = cb->buffer_offset;
|
||||
}
|
||||
|
||||
struct tc_constant_buffer *p =
|
||||
|
|
@ -837,13 +830,13 @@ tc_set_constant_buffer(struct pipe_context *_pipe,
|
|||
p->info.index = index;
|
||||
p->info.is_null = false;
|
||||
p->cb.user_buffer = NULL;
|
||||
p->cb.buffer_offset = cb->buffer_offset;
|
||||
p->cb.buffer_offset = offset;
|
||||
p->cb.buffer_size = cb->buffer_size;
|
||||
|
||||
if (take_ownership)
|
||||
p->cb.buffer = cb->buffer;
|
||||
p->cb.buffer = buffer;
|
||||
else
|
||||
tc_set_resource_reference(&p->cb.buffer, cb->buffer);
|
||||
tc_set_resource_reference(&p->cb.buffer, buffer);
|
||||
}
|
||||
|
||||
struct tc_inlinable_constants {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue