From c5d180a0bb53002fccdc6593f4e30758948b10ee Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Sun, 1 Sep 2024 13:01:32 +0000 Subject: [PATCH] tu: Streamline setting YCbCr feature bits Use ycbcr_info instead of checking the layout or the format directly. Swap the order of the if statement for clarity. These should make the code significanntly easier to read. Also document Chia-I's findings on SEPARATE_RECONSTRUCTION_FILTER_BIT. Signed-off-by: Valentine Burley Part-of: --- src/freedreno/common/freedreno_dev_info.h | 5 +++++ src/freedreno/vulkan/tu_formats.cc | 19 ++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/freedreno/common/freedreno_dev_info.h b/src/freedreno/common/freedreno_dev_info.h index 942bd1e6d8e..6de3d4eff77 100644 --- a/src/freedreno/common/freedreno_dev_info.h +++ b/src/freedreno/common/freedreno_dev_info.h @@ -94,6 +94,11 @@ struct fd_dev_info { bool depth_bounds_require_depth_test_quirk; bool has_tex_filter_cubic; + + /* The blob driver does not support SEPARATE_RECONSTRUCTION_FILTER_BIT + * before a6xx_gen3. It still sets CHROMA_LINEAR bit according to + * chromaFilter, but the bit has no effect before a6xx_gen3. + */ bool has_separate_chroma_filter; bool has_sample_locations; diff --git a/src/freedreno/vulkan/tu_formats.cc b/src/freedreno/vulkan/tu_formats.cc index 7d092dd28d4..f21ebf0a1ba 100644 --- a/src/freedreno/vulkan/tu_formats.cc +++ b/src/freedreno/vulkan/tu_formats.cc @@ -112,6 +112,7 @@ tu_physical_device_get_format_properties( VkFormatFeatureFlags2 linear = 0, optimal = 0, buffer = 0; enum pipe_format format = vk_format_to_pipe_format(vk_format); const struct util_format_description *desc = util_format_description(format); + const struct vk_format_ycbcr_info *ycbcr_info = vk_format_get_ycbcr_info(vk_format); bool supported_vtx = tu6_format_vtx_supported(format); bool supported_color = tu6_format_color_supported(format); @@ -143,20 +144,19 @@ tu_physical_device_get_format_properties( VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT; - /* no blit src bit for YUYV/NV12/I420 formats */ - if (desc->layout != UTIL_FORMAT_LAYOUT_SUBSAMPLED && - desc->layout != UTIL_FORMAT_LAYOUT_PLANAR2 && - desc->layout != UTIL_FORMAT_LAYOUT_PLANAR3) { - optimal |= VK_FORMAT_FEATURE_BLIT_SRC_BIT; - } else { + if (ycbcr_info) { + /* This is supported on all YCbCr formats */ optimal |= VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT; - if (desc->layout != UTIL_FORMAT_LAYOUT_SUBSAMPLED) { + if (ycbcr_info->n_planes > 1) { optimal |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT; if (physical_device->info->a6xx.has_separate_chroma_filter) optimal |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT; } + } else { + /* BLIT_SRC_BIT isn't allowed for YCbCr formats */ + optimal |= VK_FORMAT_FEATURE_BLIT_SRC_BIT; } if (!vk_format_is_int(vk_format)) { @@ -223,10 +223,7 @@ tu_physical_device_get_format_properties( optimal = 0; } - if (vk_format == VK_FORMAT_G8B8G8R8_422_UNORM || - vk_format == VK_FORMAT_B8G8R8G8_422_UNORM || - vk_format == VK_FORMAT_G8_B8R8_2PLANE_420_UNORM || - vk_format == VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM) { + if (ycbcr_info) { /* Disable buffer texturing of subsampled (422) and planar YUV textures. * The subsampling requirement comes from "If format is a block-compressed * format, then bufferFeatures must not support any features for the