From 29d1cd6e8bd77580b6d9288355555d7663ee7546 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Wed, 28 Aug 2024 16:36:19 +0200 Subject: [PATCH] tu: Use vk_format_get_plane_width/height to get the plane dimensions This change simplifies the code by avoiding special casing, making it easier to add support for formats like P010 with minimal changes. Signed-off-by: Valentine Burley Part-of: --- src/freedreno/vulkan/tu_image.cc | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/freedreno/vulkan/tu_image.cc b/src/freedreno/vulkan/tu_image.cc index 024aeff6853..1de55186206 100644 --- a/src/freedreno/vulkan/tu_image.cc +++ b/src/freedreno/vulkan/tu_image.cc @@ -499,25 +499,12 @@ tu_image_update_layout(struct tu_device *device, struct tu_image *image, for (uint32_t i = 0; i < tu6_plane_count(image->vk.format); i++) { struct fdl_layout *layout = &image->layout[i]; enum pipe_format format = tu6_plane_format(image->vk.format, i); - uint32_t width0 = image->vk.extent.width; - uint32_t height0 = image->vk.extent.height; + uint32_t width0 = vk_format_get_plane_width(image->vk.format, i, image->vk.extent.width); + uint32_t height0 = vk_format_get_plane_height(image->vk.format, i, image->vk.extent.height); - if (i > 0) { - switch (image->vk.format) { - case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: - case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: - /* half width/height on chroma planes */ - width0 = (width0 + 1) >> 1; - height0 = (height0 + 1) >> 1; - break; - case VK_FORMAT_D32_SFLOAT_S8_UINT: - /* no UBWC for separate stencil */ - image->ubwc_enabled = false; - break; - default: - break; - } - } + if (i == 1 && image->vk.format == VK_FORMAT_D32_SFLOAT_S8_UINT) + /* no UBWC for separate stencil */ + image->ubwc_enabled = false; struct fdl_explicit_layout plane_layout;