From 7ac76d4e91e1fd4a449495a87c9513535ff7fda0 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 5 Sep 2025 16:58:33 +0200 Subject: [PATCH] panvk: Initialize panvk_image::plane_count early We are about to use it at initialization time, so let's make sure it's initialized as early as possible. We defer the initialization to a helper because we will extend it to support planar Z24S8. Signed-off-by: Boris Brezillon Reviewed-by: Eric R. Smith Reviewed-by: Christoph Pillmayer Part-of: --- src/panfrost/vulkan/panvk_image.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/panfrost/vulkan/panvk_image.c b/src/panfrost/vulkan/panvk_image.c index 230cf60d905..294545fe2fc 100644 --- a/src/panfrost/vulkan/panvk_image.c +++ b/src/panfrost/vulkan/panvk_image.c @@ -128,6 +128,19 @@ get_iusage(struct panvk_image *image, const VkImageCreateInfo *create_info) return iusage; } +static unsigned +get_plane_count(struct panvk_image *image) +{ + /* Z32_S8X24 is not supported on v9+, and we don't want to use it + * on v7- anyway, because it's less efficient than the multiplanar + * alternative. + */ + if (image->vk.format == VK_FORMAT_D32_SFLOAT_S8_UINT) + return 2; + + return vk_format_get_plane_count(image->vk.format); +} + static bool panvk_image_can_use_mod(struct panvk_image *image, const struct pan_image_usage *iusage, uint64_t mod, @@ -469,6 +482,9 @@ VkResult panvk_image_init(struct panvk_image *image, const VkImageCreateInfo *pCreateInfo) { + /* Needs to happen early for some panvk_image_ helpers to work. */ + image->plane_count = get_plane_count(image); + /* Add any create/usage flags that might be needed for meta operations. * This is run before the modifier selection because some * usage/create_flags influence the modifier selection logic. */