From aceabab18f608d4a07e76bc9269c8cf569a79276 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 15 May 2025 17:22:06 +0200 Subject: [PATCH] panfrost: Add a debug flag to enforce WSI row pitch at import time So far we assumed tile rows would be tightly packed, so changing the behavior without introducing a new set of AFBC modifiers is likely to break some cases where the exported got the stride wrong. That's still something we would like to enforce in the long run, so let's start by adding a "PAN_MESA_DEBUG=strict_afbc" flag to exercise the code supposed to force this behavior. Signed-off-by: Boris Brezillon Tested-by: Eric R. Smith Reviewed-by: Eric R. Smith Reviewed-by: Mary Guillemard Part-of: --- src/gallium/drivers/panfrost/pan_resource.c | 1 + src/gallium/drivers/panfrost/pan_screen.c | 1 + src/panfrost/lib/pan_util.h | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index c07f1d501ca..f05530d5a4d 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -134,6 +134,7 @@ panfrost_resource_from_handle(struct pipe_screen *pscreen, struct pan_image_wsi_layout explicit_layout = { .offset_B = whandle->offset, .row_pitch_B = whandle->stride, + .strict = dev->debug & PAN_DBG_STRICT_IMPORT, }; rsc->modifier = mod; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 649ac58fc33..ac3d685a47f 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -72,6 +72,7 @@ static const struct debug_named_value panfrost_debug_options[] = { {"nocrc", PAN_DBG_NO_CRC, "Disable transaction elimination"}, {"msaa16", PAN_DBG_MSAA16, "Enable MSAA 8x and 16x support"}, {"linear", PAN_DBG_LINEAR, "Force linear textures"}, + {"strict_import", PAN_DBG_STRICT_IMPORT, "Use the explicit WSI stride and fail if it's not properly aligned"}, {"nocache", PAN_DBG_NO_CACHE, "Disable BO cache"}, {"dump", PAN_DBG_DUMP, "Dump all graphics memory"}, #ifdef PAN_DBG_OVERFLOW diff --git a/src/panfrost/lib/pan_util.h b/src/panfrost/lib/pan_util.h index 854c59ac03d..4f87d6e7eb6 100644 --- a/src/panfrost/lib/pan_util.h +++ b/src/panfrost/lib/pan_util.h @@ -43,7 +43,7 @@ #define PAN_DBG_GL3 0x0100 #define PAN_DBG_NO_AFBC 0x0200 #define PAN_DBG_MSAA16 0x0400 -/* 0x800 unused */ +#define PAN_DBG_STRICT_IMPORT 0x0800 #define PAN_DBG_LINEAR 0x1000 #define PAN_DBG_NO_CACHE 0x2000 #define PAN_DBG_DUMP 0x4000