diff --git a/src/amd/vulkan/vk_format.h b/src/amd/vulkan/vk_format.h index 3cb035eb3cc..d5ce9ed5d90 100644 --- a/src/amd/vulkan/vk_format.h +++ b/src/amd/vulkan/vk_format.h @@ -151,12 +151,6 @@ vk_to_non_srgb_format(VkFormat format) } } -static inline unsigned -vk_format_get_plane_count(VkFormat format) -{ - return util_format_get_num_planes(vk_format_to_pipe_format(format)); -} - static inline unsigned vk_format_get_plane_width(VkFormat format, unsigned plane, unsigned width) { @@ -169,30 +163,4 @@ 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); } -static inline 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_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: - assert(vk_format_get_plane_count(format) == 1); - return format; - } -} - #endif /* VK_FORMAT_H */ diff --git a/src/vulkan/util/vk_format.c b/src/vulkan/util/vk_format.c index f5da22bac88..039e629d0d9 100644 --- a/src/vulkan/util/vk_format.c +++ b/src/vulkan/util/vk_format.c @@ -340,6 +340,32 @@ vk_format_aspects(VkFormat format) } } +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_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: + assert(vk_format_get_plane_count(format) == 1); + return format; + } +} + void vk_component_mapping_to_pipe_swizzle(VkComponentMapping mapping, unsigned char out_swizzle[4]) diff --git a/src/vulkan/util/vk_format.h b/src/vulkan/util/vk_format.h index 630cfbe5929..b83c2d03d44 100644 --- a/src/vulkan/util/vk_format.h +++ b/src/vulkan/util/vk_format.h @@ -182,6 +182,15 @@ 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); + #ifdef __cplusplus } #endif