util/format: translate 422_UNORM and 420_UNORM vulkan formats
authorJonathan Marek <jonathan@marek.ca>
Wed, 8 Apr 2020 03:40:37 +0000 (23:40 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 20 May 2020 13:22:12 +0000 (13:22 +0000)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4590>

src/vulkan/util/vk_format.c

index f23575958b332821fd245e078fda782684ccd134..9afe89f7f20b9d9417bb0110c1854aa6b9bcac43 100644 (file)
@@ -244,8 +244,20 @@ static const enum pipe_format vk_format_map[] = {
 enum pipe_format
 vk_format_to_pipe_format(enum VkFormat vkformat)
 {
-   if (vkformat >= ARRAY_SIZE(vk_format_map))
-      return PIPE_FORMAT_NONE;
+   if (vkformat >= ARRAY_SIZE(vk_format_map)) {
+      switch (vkformat) {
+      case VK_FORMAT_G8B8G8R8_422_UNORM:
+         return PIPE_FORMAT_YUYV;
+      case VK_FORMAT_B8G8R8G8_422_UNORM:
+         return PIPE_FORMAT_UYVY;
+      case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
+         return PIPE_FORMAT_YV12;
+      case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
+         return PIPE_FORMAT_NV12;
+      default:
+         return PIPE_FORMAT_NONE;
+      }
+   }
 
    /* Unpopulated entries in the table must be PIPE_FORMAT_NONE */
    STATIC_ASSERT(PIPE_FORMAT_NONE == 0);