Mesa (staging/20.1): ac/surface: adapt surf_size when modifying surf_pitch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 21 10:31:17 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 5ddce715337825f18311d01d407c096defb34d0f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5ddce715337825f18311d01d407c096defb34d0f

Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Date:   Thu Jul  9 14:10:51 2020 +0200

ac/surface: adapt surf_size when modifying surf_pitch

Otherwise we might get VM_L2_PROTECTION_FAULT_STATUS errors.

Fixes: 8275dc1ed57 ("ac/surface: fix epitch when modifying surf_pitch")
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5841>
(cherry picked from commit 87ecfdfbf0a8448d1475e6da15175e68bdeb933b)

---

 .pick_status.json           |  2 +-
 src/amd/common/ac_surface.c | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 96c3df2cc9a..a990da46faa 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -382,7 +382,7 @@
         "description": "ac/surface: adapt surf_size when modifying surf_pitch",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "8275dc1ed575888f46b4e54d29e56ca63b1accaf"
     },
diff --git a/src/amd/common/ac_surface.c b/src/amd/common/ac_surface.c
index 252e703d377..6336163f623 100644
--- a/src/amd/common/ac_surface.c
+++ b/src/amd/common/ac_surface.c
@@ -1307,18 +1307,27 @@ static int gfx9_compute_miptree(struct ac_addrlib *addrlib,
 
 	surf->u.gfx9.surf_slice_size = out.sliceSize;
 	surf->u.gfx9.surf_pitch = out.pitch;
+	surf->u.gfx9.surf_height = out.height;
+	surf->surf_size = out.surfSize;
+	surf->surf_alignment = out.baseAlign;
+
 	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 */
+		/* Adjust surf_pitch to be in elements units not in pixels */
 		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);
+		/* The surface is really a surf->bpe bytes per pixel surface even if we
+		 * use it as a surf->bpe bytes per element one.
+		 * Adjust surf_slice_size and surf_size to reflect the change
+		 * made to surf_pitch.
+		 */
+		surf->u.gfx9.surf_slice_size = MAX2(
+			surf->u.gfx9.surf_slice_size,
+			surf->u.gfx9.surf_pitch * out.height * surf->bpe * surf->blk_w);
+		surf->surf_size = surf->u.gfx9.surf_slice_size * in->numSlices;
 	}
-	surf->u.gfx9.surf_height = out.height;
-	surf->surf_size = out.surfSize;
-	surf->surf_alignment = out.baseAlign;
 
 	if (in->swizzleMode == ADDR_SW_LINEAR) {
 		for (unsigned i = 0; i < in->numMipLevels; i++) {



More information about the mesa-commit mailing list