From b37e06fd5889d4c2711b9f840c593ffe0eba9ab3 Mon Sep 17 00:00:00 2001 From: Valentine Burley Date: Wed, 28 Aug 2024 16:22:20 +0200 Subject: [PATCH] vulkan, radv: Add new common vk_format_get_plane_width/height helpers Add new vk_format_get_plane_width/height helpers using ycbcr_info and use it to replace RADV's ones which relied on util_format_get_plane_width/height. We already have this data in the YCbCr table, so this avoids having the maintain the list of pipe formats in util_format_get_plane_width/height. Reviewed-by: Samuel Pitoiset Reviewed-by: Faith Ekstrand Signed-off-by: Valentine Burley Part-of: --- src/amd/vulkan/radv_formats.h | 12 ------------ src/vulkan/util/vk_format.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/amd/vulkan/radv_formats.h b/src/amd/vulkan/radv_formats.h index 012220aae7c..a83430e90cc 100644 --- a/src/amd/vulkan/radv_formats.h +++ b/src/amd/vulkan/radv_formats.h @@ -104,18 +104,6 @@ vk_format_no_srgb(VkFormat format) } } -static inline unsigned -vk_format_get_plane_width(VkFormat format, unsigned plane, unsigned width) -{ - return util_format_get_plane_width(vk_format_to_pipe_format(format), plane, width); -} - -static inline unsigned -vk_format_get_plane_height(VkFormat format, unsigned plane, unsigned height) -{ - return util_format_get_plane_height(vk_format_to_pipe_format(format), plane, height); -} - struct radv_physical_device; uint32_t radv_translate_buffer_numformat(const struct util_format_description *desc, int first_non_void); diff --git a/src/vulkan/util/vk_format.h b/src/vulkan/util/vk_format.h index 4fb3a85198f..720c5c185d7 100644 --- a/src/vulkan/util/vk_format.h +++ b/src/vulkan/util/vk_format.h @@ -260,6 +260,26 @@ vk_format_get_plane_count(VkFormat format) return ycbcr_info ? ycbcr_info->n_planes : 1; } +static inline unsigned +vk_format_get_plane_width(VkFormat format, unsigned plane, unsigned width) +{ + const struct vk_format_ycbcr_info *ycbcr_info = + vk_format_get_ycbcr_info(format); + const uint8_t width_scale = ycbcr_info ? + ycbcr_info->planes[plane].denominator_scales[0] : 1; + return width / width_scale; +} + +static inline unsigned +vk_format_get_plane_height(VkFormat format, unsigned plane, unsigned height) +{ + const struct vk_format_ycbcr_info *ycbcr_info = + vk_format_get_ycbcr_info(format); + const uint8_t height_scale = ycbcr_info ? + ycbcr_info->planes[plane].denominator_scales[1] : 1; + return height / height_scale; +} + VkClearColorValue vk_swizzle_color_value(VkClearColorValue color, VkComponentMapping swizzle, bool is_int);