Mesa (master): ac/surface: fix epitch when modifying surf_pitch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 10 09:27:47 UTC 2020


Module: Mesa
Branch: master
Commit: 8275dc1ed575888f46b4e54d29e56ca63b1accaf
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8275dc1ed575888f46b4e54d29e56ca63b1accaf

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Wed Jun  3 18:20:15 2020 +0200

ac/surface: fix epitch when modifying surf_pitch

This is needed otherwise it can cause bad rendering of UYVY files.
The align(..., 256 / surf->bpe) constraint comes from addrlib.

Fixes: 69aadc49331 ("radeonsi: fix surf_pitch for subsampled surface")
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5314>

---

 src/amd/common/ac_surface.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index 54bf476a213..d316216fd88 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -1163,10 +1163,14 @@ static int gfx9_compute_miptree(ADDR_HANDLE addrlib,
 
 	surf->u.gfx9.surf_slice_size = out.sliceSize;
 	surf->u.gfx9.surf_pitch = out.pitch;
-	if (!compressed && surf->blk_w > 1 && out.pitch == out.pixelPitch) {
+	if (!compressed && surf->blk_w > 1 && out.pitch == out.pixelPitch &&
+	    surf->u.gfx9.surf.swizzle_mode == ADDR_SW_LINEAR) {
 		/* Adjust surf_pitch to be in elements units,
 		 * not in pixels */
-		surf->u.gfx9.surf_pitch /= surf->blk_w;
+		surf->u.gfx9.surf_pitch =
+			align(surf->u.gfx9.surf_pitch / surf->blk_w, 256 / surf->bpe);
+		surf->u.gfx9.surf.epitch = MAX2(surf->u.gfx9.surf.epitch,
+						surf->u.gfx9.surf_pitch * surf->blk_w - 1);
 	}
 	surf->u.gfx9.surf_height = out.height;
 	surf->surf_size = out.surfSize;



More information about the mesa-commit mailing list