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 <samuel.pitoiset@gmail.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30899>
This commit is contained in:
Valentine Burley
2024-08-28 16:22:20 +02:00
committed by Marge Bot
parent 7d0a631f20
commit b37e06fd58
2 changed files with 20 additions and 12 deletions

View File

@@ -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);

View File

@@ -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);