Mesa (main): vulkan,radv: Move vk_format_get_plane_format to common code
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 7 18:25:03 UTC 2022
Module: Mesa
Branch: main
Commit: 69e4d39d188b2c30fc8cd06b4abcfa619595f840
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=69e4d39d188b2c30fc8cd06b4abcfa619595f840
Author: Jason Ekstrand <jason.ekstrand at collabora.com>
Date: Mon Jun 6 11:25:45 2022 -0500
vulkan,radv: Move vk_format_get_plane_format to common code
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16873>
---
src/amd/vulkan/vk_format.h | 32 --------------------------------
src/vulkan/util/vk_format.c | 26 ++++++++++++++++++++++++++
src/vulkan/util/vk_format.h | 9 +++++++++
3 files changed, 35 insertions(+), 32 deletions(-)
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
More information about the mesa-commit
mailing list