From 29908aa493cb5dab8d4285f05b146294260c19c7 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=UTF-8 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: (cherry picked from commit 5f73b8976bb21f8673c4696294c36a14534b345e) --- .pick_status.json | 2 +- src/gallium/auxiliary/util/u_threaded_context.c | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 71def7ec37b..4887b933ebc 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2641,7 +2641,7 @@ "description": "aux/tc: fix address calc for segmented texture subdata", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "51ad269198e425fae719a37f169b365a8b52e7f3" }, diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index 2a296895346..de2b92c8ee1 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -3163,10 +3163,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); @@ -3186,20 +3185,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; } }