turnip: Add tu6_rb_fmt_to_ifmt.
authorBas Nieuwenhuizen <basni@chromium.org>
Mon, 4 Feb 2019 13:52:34 +0000 (14:52 +0100)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 11 Mar 2019 17:02:13 +0000 (10:02 -0700)
src/freedreno/vulkan/tu_formats.c
src/freedreno/vulkan/tu_private.h

index 1dbb6de..ce013e6 100644 (file)
@@ -328,6 +328,75 @@ tu6_get_native_format(VkFormat format)
    return (fmt && fmt->present) ? fmt : NULL;
 }
 
+enum a6xx_2d_ifmt
+tu6_rb_fmt_to_ifmt(enum a6xx_color_fmt fmt)
+{
+   switch (fmt) {
+   case RB6_A8_UNORM:
+   case RB6_R8_UNORM:
+   case RB6_R8_SNORM:
+   case RB6_R8G8_UNORM:
+   case RB6_R8G8_SNORM:
+   case RB6_R8G8B8A8_UNORM:
+   case RB6_R8G8B8_UNORM:
+   case RB6_R8G8B8A8_SNORM:
+      return R2D_UNORM8;
+
+   case RB6_R32_UINT:
+   case RB6_R32_SINT:
+   case RB6_R32G32_UINT:
+   case RB6_R32G32_SINT:
+   case RB6_R32G32B32A32_UINT:
+   case RB6_R32G32B32A32_SINT:
+      return R2D_INT32;
+
+   case RB6_R16_UINT:
+   case RB6_R16_SINT:
+   case RB6_R16G16_UINT:
+   case RB6_R16G16_SINT:
+   case RB6_R16G16B16A16_UINT:
+   case RB6_R16G16B16A16_SINT:
+      return R2D_INT16;
+
+   case RB6_R8_UINT:
+   case RB6_R8_SINT:
+   case RB6_R8G8_UINT:
+   case RB6_R8G8_SINT:
+   case RB6_R8G8B8A8_UINT:
+   case RB6_R8G8B8A8_SINT:
+      return R2D_INT8;
+
+   case RB6_R16_UNORM:
+   case RB6_R16_SNORM:
+   case RB6_R16G16_UNORM:
+   case RB6_R16G16_SNORM:
+   case RB6_R16G16B16A16_UNORM:
+   case RB6_R16G16B16A16_SNORM:
+   case RB6_R32_FLOAT:
+   case RB6_R32G32_FLOAT:
+   case RB6_R32G32B32A32_FLOAT:
+      return R2D_FLOAT32;
+
+   case RB6_R16_FLOAT:
+   case RB6_R16G16_FLOAT:
+   case RB6_R16G16B16A16_FLOAT:
+      return R2D_FLOAT16;
+
+   case RB6_R4G4B4A4_UNORM:
+   case RB6_R5G5B5A1_UNORM:
+   case RB6_R5G6B5_UNORM:
+   case RB6_R10G10B10A2_UNORM:
+   case RB6_R10G10B10A2_UINT:
+   case RB6_R11G11B10_FLOAT:
+   case RB6_X8Z24_UNORM:
+      // ???
+      return 0;
+   default:
+      unreachable("bad format");
+      return 0;
+   }
+}
+
 static uint32_t
 tu_pack_mask(int bits)
 {
index f9af103..2f46134 100644 (file)
 #include "vk_debug_report.h"
 
 #include "drm/msm_drm.h"
+
+#include "adreno_common.xml.h"
+#include "adreno_pm4.xml.h"
+#include "a6xx.xml.h"
+
 #include "tu_descriptor_set.h"
 #include "tu_extensions.h"
 
@@ -1027,6 +1032,7 @@ int
 tu_pack_clear_value(const VkClearValue *val,
                     VkFormat format,
                     uint32_t buf[4]);
+enum a6xx_2d_ifmt tu6_rb_fmt_to_ifmt(enum a6xx_color_fmt fmt);
 
 struct tu_image_level
 {