Mesa (master): freedreno: fix layout pitchalign field not being set for imported buffers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 11 18:41:59 UTC 2020


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

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Sat Jul 11 13:49:51 2020 -0400

freedreno: fix layout pitchalign field not being set for imported buffers

The pitchalign value was being left to 0 and then wrapping around when
the base offset was subtracted in texture state.

Fixes: 979e7e3680792 ("freedreno/layout: layout simplifications and pitch from level 0 pitch")

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5864>

---

 src/gallium/drivers/freedreno/freedreno_resource.c | 23 ++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index fb5bb532e57..07baa7d293b 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -1027,16 +1027,23 @@ fd_resource_from_handle(struct pipe_screen *pscreen,
 	slice->offset = handle->offset;
 	slice->size0 = handle->stride * prsc->height0;
 
-	uint32_t pitchalign = fd_screen(pscreen)->gmem_alignw * rsc->layout.cpp;
-
-	/* pitchalign is 64-bytes for linear formats on a6xx
-	 * layout_resource_for_modifier will validate tiled pitch
+	/* use a pitchalign of gmem_alignw pixels, because GMEM resolve for
+	 * lower alignments is not implemented (but possible for a6xx at least)
+	 *
+	 * for UBWC-enabled resources, layout_resource_for_modifier will further
+	 * validate the pitch and set the right pitchalign
 	 */
-	if (is_a6xx(screen))
-		pitchalign = 64;
+	rsc->layout.pitchalign =
+		fdl_cpp_shift(&rsc->layout) + util_logbase2(screen->gmem_alignw);
+
+	/* apply the minimum pitchalign (note: actually 4 for a3xx but doesn't matter) */
+	if (is_a6xx(screen) || is_a5xx(screen))
+		rsc->layout.pitchalign = MAX2(rsc->layout.pitchalign, 6);
+	else
+		rsc->layout.pitchalign = MAX2(rsc->layout.pitchalign, 5);
 
-	if ((rsc->layout.pitch0 < align(prsc->width0 * rsc->layout.cpp, pitchalign)) ||
-			(rsc->layout.pitch0 & (pitchalign - 1)))
+	if (rsc->layout.pitch0 < (prsc->width0 * rsc->layout.cpp) ||
+		fd_resource_pitch(rsc, 0) != rsc->layout.pitch0)
 		goto fail;
 
 	assert(rsc->layout.cpp);



More information about the mesa-commit mailing list