[Mesa-dev] [PATCH 12/15] anv: introduce helper to resolve vk_format from anv_format

Tapani Pälli tapani.palli at intel.com
Tue Oct 30 05:26:05 UTC 2018


Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
---
 src/intel/vulkan/anv_formats.c | 18 ++++++++++++++++++
 src/intel/vulkan/anv_private.h |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 1d3b1f67928..166b50f5a07 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -405,6 +405,24 @@ anv_get_format(VkFormat vk_format)
    return format;
 }
 
+VkFormat
+anv_get_vkformat(const struct anv_format *format)
+{
+#define LAST_FORMAT(table) table + sizeof(table) - sizeof(struct anv_format)
+
+   const struct anv_format *last_main = LAST_FORMAT(main_formats);
+   const struct anv_format *last_ycbcr = LAST_FORMAT(ycbcr_formats);
+
+#undef LAST_FORMAT
+
+   if (format >= main_formats && format <= last_main)
+      return format - main_formats;
+   else if (format >= ycbcr_formats && format <= last_ycbcr)
+      return format - ycbcr_formats;
+
+   return VK_FORMAT_UNDEFINED;
+}
+
 /**
  * Exactly one bit must be set in \a aspect.
  */
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 882de030ae0..bfdb711337e 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2634,6 +2634,9 @@ anv_plane_to_aspect(VkImageAspectFlags image_aspects,
 const struct anv_format *
 anv_get_format(VkFormat format);
 
+VkFormat
+anv_get_vkformat(const struct anv_format *format);
+
 static inline uint32_t
 anv_get_format_planes(VkFormat vk_format)
 {
-- 
2.17.2



More information about the mesa-dev mailing list