From d6eb5b40393205bebeb6ebc78022434bd08dd57d Mon Sep 17 00:00:00 2001 From: Utku Iseri Date: Wed, 8 Oct 2025 16:57:01 +0200 Subject: [PATCH] panvk: explicit fallback to linear for legacy scanout images If there isn't any modifier info coming from the compositor, we go through our internal image path and pick the best modifier that supports the image. This causes problems on X11, as it actually expects the image to be in a linear layout. Explicitly set the modifier to linear for legacy scanout images, which specifically indicates that the image doesn't have an explicit DRM modifier and we should do the safe thing by using linear. The naming becomes confusing for scanout with this change, so the flag is now split into two separate flags, one for controlling the AFBC optimalness called wsi, the other more directly called legacy_scanout, which is used for enforcing the linear mod. Reviewed-by: Boris Brezillon Reviewed-by: Yiwei Zhang Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/lib/pan_image.h | 7 +++++-- src/panfrost/lib/pan_mod.c | 4 ++-- src/panfrost/vulkan/panvk_image.c | 8 +++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/panfrost/lib/pan_image.h b/src/panfrost/lib/pan_image.h index e1a8add2aba..236e2c4d5a5 100644 --- a/src/panfrost/lib/pan_image.h +++ b/src/panfrost/lib/pan_image.h @@ -262,8 +262,11 @@ struct pan_image_usage { /* Image frequently updated with host data. */ bool frequent_host_updates; - /* Scanout image. */ - bool scanout; + /* Legacy scanout image. */ + bool legacy_scanout; + + /* Image created by WSI. */ + bool wsi; }; static inline enum pan_mod_support diff --git a/src/panfrost/lib/pan_mod.c b/src/panfrost/lib/pan_mod.c index bd3fc9cb651..a6ebf26415e 100644 --- a/src/panfrost/lib/pan_mod.c +++ b/src/panfrost/lib/pan_mod.c @@ -247,8 +247,8 @@ pan_mod_afbc_test_props(const struct pan_kmod_dev_props *dprops, if (iprops->extent_px.width <= 16 && iprops->extent_px.height <= 16) return PAN_MOD_NOT_OPTIMAL; - /* Reserve 32x8 tiles for scanout buffers. */ - if (iusage && !iusage->scanout && + /* Reserve 32x8 tiles for WSI images. */ + if (iusage && !iusage->wsi && pan_afbc_superblock_width(iprops->modifier) != 16) return PAN_MOD_NOT_OPTIMAL; diff --git a/src/panfrost/vulkan/panvk_image.c b/src/panfrost/vulkan/panvk_image.c index 2b157aa75bb..a23bb1dd5fd 100644 --- a/src/panfrost/vulkan/panvk_image.c +++ b/src/panfrost/vulkan/panvk_image.c @@ -124,7 +124,8 @@ get_iusage(struct panvk_image *image, const VkImageCreateInfo *create_info) iusage.host_copy = !!(image->vk.usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT); - iusage.scanout = wsi_info && wsi_info->scanout; + iusage.legacy_scanout = wsi_info && wsi_info->scanout; + iusage.wsi = wsi_info != NULL; return iusage; } @@ -373,6 +374,11 @@ panvk_image_get_mod(struct panvk_image *image, assert(!"Missing modifier info"); } + /* legacy scanout (images without any external modifier info) should default to LINEAR. */ + if (iusage.legacy_scanout) + return DRM_FORMAT_MOD_LINEAR; + + /* Without external dependencies, pick the best modifier that supports the image. */ return panvk_image_get_mod_from_list(image, &iusage, NULL, 0); }