From ab0d6c91fdd96db288da5c0037417b1302399e9e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sun, 29 Nov 2020 01:25:01 -0500 Subject: [PATCH] gallium/u_threaded: optimize set_constant_buffer Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- .../auxiliary/util/u_threaded_context.c | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 9d6dfa77206..1c23aae60d3 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -783,17 +783,29 @@ tc_set_constant_buffer(struct pipe_context *_pipe, const struct pipe_constant_buffer *cb) { struct threaded_context *tc = threaded_context(_pipe); - struct pipe_resource *buffer = NULL; - unsigned offset; - /* 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. - */ if (cb && cb->user_buffer) { + struct pipe_resource *buffer = NULL; + unsigned offset; + + /* 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); 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->shader = shader; + p->index = index; + p->cb.buffer_size = cb->buffer_size; + p->cb.user_buffer = NULL; + p->cb.buffer_offset = offset; + p->cb.buffer = buffer; + return; } struct tc_constant_buffer *p = @@ -803,18 +815,10 @@ tc_set_constant_buffer(struct pipe_context *_pipe, p->index = index; if (cb) { - if (cb->user_buffer) { - p->cb.buffer_size = cb->buffer_size; - p->cb.user_buffer = NULL; - p->cb.buffer_offset = offset; - p->cb.buffer = buffer; - } else { - tc_set_resource_reference(&p->cb.buffer, - cb->buffer); - p->cb.user_buffer = NULL; - p->cb.buffer_offset = cb->buffer_offset; - p->cb.buffer_size = cb->buffer_size; - } + tc_set_resource_reference(&p->cb.buffer, cb->buffer); + p->cb.user_buffer = NULL; + p->cb.buffer_offset = cb->buffer_offset; + p->cb.buffer_size = cb->buffer_size; } else { memset(&p->cb, 0, sizeof(*cb)); } -- 2.34.1