From: Mike Blumenkrantz Date: Wed, 8 Mar 2023 21:42:28 +0000 (-0500) Subject: aux/tc: use renderpass tracking to optimize texture_subdata calls X-Git-Tag: upstream/23.3.3~11718 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=43facca1958d101b7e083a1c62bae985a3154ef0;p=platform%2Fupstream%2Fmesa.git aux/tc: use renderpass tracking to optimize texture_subdata calls if it's known that a renderpass is active and the driver wants to do renderpass optimizing, help out by not forcing a sync and instead doing what the driver would do: create a staging buffer and copy it to the image this requires that the driver already handles buffer -> image copies with resource_copy_region Acked-by: Marek Olšák Part-of: --- diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index f600138..bb4f849 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -3099,11 +3099,27 @@ tc_texture_subdata(struct pipe_context *_pipe, } else { struct pipe_context *pipe = tc->pipe; - tc_sync(tc); - tc_set_driver_thread(tc); - pipe->texture_subdata(pipe, resource, level, usage, box, data, - stride, layer_stride); - tc_clear_driver_thread(tc); + if (resource->usage != PIPE_USAGE_STAGING && + tc->options.parse_renderpass_info && tc->in_renderpass) { + enum pipe_format format = resource->format; + if (usage & PIPE_MAP_DEPTH_ONLY) + format = util_format_get_depth_only(format); + else if (usage & PIPE_MAP_STENCIL_ONLY) + format = PIPE_FORMAT_S8_UINT; + unsigned stride = util_format_get_stride(format, box->width); + unsigned layer_stride = util_format_get_2d_size(format, stride, box->height); + struct pipe_resource *pres = pipe_buffer_create_with_data(pipe, 0, PIPE_USAGE_STREAM, layer_stride * box->depth, data); + struct pipe_box src_box = *box; + src_box.x = src_box.y = src_box.z = 0; + tc->base.resource_copy_region(&tc->base, resource, level, box->x, box->y, box->z, pres, 0, &src_box); + pipe_resource_reference(&pres, NULL); + } else { + tc_sync(tc); + tc_set_driver_thread(tc); + pipe->texture_subdata(pipe, resource, level, usage, box, data, + stride, layer_stride); + tc_clear_driver_thread(tc); + } } }