amd/surface: fix base_mip_width of subsampled formats

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 <bas@basnieuwenhuizen.nl>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21253>
This commit is contained in:
Pierre-Eric Pelloux-Prayer 2023-02-10 19:38:33 -05:00 committed by Marek Olšák
parent 28d0ddead0
commit affa8a9fb2

View file

@ -1784,9 +1784,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) {