From 5f73b8976bb21f8673c4696294c36a14534b345e Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 12 Sep 2023 08:49:52 -0400 Subject: [PATCH] aux/tc: fix address calc for segmented texture subdata MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit this fixes all dimension/array uses for the rp tracking path Fixes: 51ad269198e ("aux/tc: handle stride mismatch during rp-optimized subdata") Acked-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 8006fff..e0f0049 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -3162,10 +3162,9 @@ tc_texture_subdata(struct pipe_context *_pipe, tc->base.resource_copy_region(&tc->base, resource, level, box->x, box->y, box->z, pres, 0, &src_box); } else { /* if stride doesn't match, inline util_copy_box on the GPU and assume the driver will optimize */ - unsigned src_offset = 0; src_box.depth = 1; - for (unsigned z = 0; z < box->depth; ++z) { - unsigned dst_x = box->x, dst_y = box->y, width = box->width, height = box->height; + for (unsigned z = 0; z < box->depth; ++z, src_box.x = z * layer_stride) { + unsigned dst_x = box->x, dst_y = box->y, width = box->width, height = box->height, dst_z = box->z + z; int blocksize = util_format_get_blocksize(format); int blockwidth = util_format_get_blockwidth(format); int blockheight = util_format_get_blockheight(format); @@ -3185,20 +3184,15 @@ tc_texture_subdata(struct pipe_context *_pipe, uint64_t size = (uint64_t)height * width; assert(size <= SIZE_MAX); - src_box.x = src_offset; assert(dst_x + src_box.width < u_minify(pres->width0, level)); assert(dst_y + src_box.height < u_minify(pres->height0, level)); assert(pres->target != PIPE_TEXTURE_3D || z + src_box.depth < u_minify(pres->depth0, level)); - tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, z, pres, 0, &src_box); + tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, dst_z, pres, 0, &src_box); } else { src_box.height = 1; - for (unsigned i = 0; i < height; i++, dst_y++) { - src_box.x = src_offset; - tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, z, pres, 0, &src_box); - src_offset += stride; - } + for (unsigned i = 0; i < height; i++, dst_y++, src_box.x += stride) + tc->base.resource_copy_region(&tc->base, resource, level, dst_x, dst_y, dst_z, pres, 0, &src_box); } - src_offset += layer_stride; } } -- 2.7.4