From b972c025fec33e9a11d4fc0749ad65e5c803d951 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 10 Feb 2023 19:38:33 -0500 Subject: [PATCH] amd/surface: fix base_mip_width of subsampled formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit base_mip_width is used in si_compute_copy_image when the SI_IMAGE_ACCESS_BLOCK_FORMAT_AS_UINT flag is used. width = tex->surface.u.gfx9.base_mip_width; This will be incorrect if we don't adjust it. For instance, with a 260x256 image, surf_pitch and base_mip_width are 320 before surf_pitch is updated to be 192. Both need to match, or computing the width from base_mip_width leads to incorrect result. Cc: mesa-stable Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Pierre-Eric Pelloux-Prayer Reviewed-by: Marek Olšák Part-of: (cherry picked from commit affa8a9fb2f3ed02ab812bf8f991783683fd408d) --- .pick_status.json | 2 +- src/amd/common/ac_surface.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 71b7b109abf..a1201dec6a9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -220,7 +220,7 @@ "description": "amd/surface: fix base_mip_width of subsampled formats", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null }, diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c index 0b03de9b3ac..e8f6f612628 100644 --- a/src/amd/common/ac_surface.c +++ b/src/amd/common/ac_surface.c @@ -1788,9 +1788,11 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib, const struct radeon_ /* Adjust pitch like we did for surf_pitch */ surf->u.gfx9.pitch[i] = align(mip_info[i].pitch / surf->blk_w, alignment); } + surf->u.gfx9.base_mip_width = surf->u.gfx9.surf_pitch; + } else { + surf->u.gfx9.base_mip_width = mip_info[0].pitch; } - surf->u.gfx9.base_mip_width = mip_info[0].pitch; surf->u.gfx9.base_mip_height = mip_info[0].height; if (in->flags.depth) {