vulkan/util: Use ycbcr_info for multiplane helpers in vk_format.c

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Acked-by: Alejandro Piñeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24096>
This commit is contained in:
Mohamed Ahmed
2023-07-11 20:23:59 +03:00
committed by Marge Bot
parent d5b6edec0f
commit c4c258e19e
2 changed files with 14 additions and 25 deletions
+6 -19
View File
@@ -366,25 +366,12 @@ VkFormat
vk_format_get_plane_format(VkFormat format, unsigned plane_id)
{
assert(plane_id < vk_format_get_plane_count(format));
switch (format) {
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
case VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM:
case VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM:
return VK_FORMAT_R8_UNORM;
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_422_UNORM:
return plane_id ? VK_FORMAT_R8G8_UNORM : VK_FORMAT_R8_UNORM;
case VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM:
case VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM:
case VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM:
return VK_FORMAT_R16_UNORM;
case VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16:
return plane_id ? VK_FORMAT_R10X6G10X6_UNORM_2PACK16 : VK_FORMAT_R10X6_UNORM_PACK16;
case VK_FORMAT_G16_B16R16_2PLANE_420_UNORM:
case VK_FORMAT_G16_B16R16_2PLANE_422_UNORM:
return plane_id ? VK_FORMAT_R16G16_UNORM : VK_FORMAT_R16_UNORM;
default:
const struct vk_format_ycbcr_info *ycbcr_info =
vk_format_get_ycbcr_info(format);
if (ycbcr_info && ycbcr_info->n_planes > 1) {
const struct vk_format_ycbcr_plane *plane_info = &ycbcr_info->planes[plane_id];
return plane_info->format;
} else {
assert(vk_format_get_plane_count(format) == 1);
return format;
}
+8 -6
View File
@@ -200,12 +200,6 @@ vk_format_get_blocksizebits(VkFormat format)
return util_format_get_blocksizebits(vk_format_to_pipe_format(format));
}
static inline unsigned
vk_format_get_plane_count(VkFormat format)
{
return util_format_get_num_planes(vk_format_to_pipe_format(format));
}
VkFormat
vk_format_get_plane_format(VkFormat format, unsigned plane_id);
@@ -236,6 +230,14 @@ struct vk_format_ycbcr_info {
const struct vk_format_ycbcr_info *vk_format_get_ycbcr_info(VkFormat format);
static inline unsigned
vk_format_get_plane_count(VkFormat format)
{
const struct vk_format_ycbcr_info *ycbcr_info =
vk_format_get_ycbcr_info(format);
return ycbcr_info ? ycbcr_info->n_planes : 1;
}
#ifdef __cplusplus
}
#endif