From a09b4c298ceed529ffc6dc5f48b1721aeb1d08a0 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Fri, 4 Dec 2015 16:18:35 -0800 Subject: [PATCH] anv: Add func anv_get_isl_format() --- src/vulkan/anv_formats.c | 23 +++++++++++++++++++++++ src/vulkan/anv_private.h | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/vulkan/anv_formats.c b/src/vulkan/anv_formats.c index abbf667a079..19de40b52c2 100644 --- a/src/vulkan/anv_formats.c +++ b/src/vulkan/anv_formats.c @@ -221,6 +221,29 @@ anv_format_for_vk_format(VkFormat format) return &anv_formats[format]; } +/** + * Exactly one bit must be set in \a aspect. + */ +enum isl_format +anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect) +{ + const struct anv_format *anv_fmt = &anv_formats[format]; + + switch (aspect) { + case VK_IMAGE_ASPECT_COLOR_BIT: + return anv_fmt->surface_format; + case VK_IMAGE_ASPECT_DEPTH_BIT: + assert(anv_fmt->depth_format != 0); + return anv_fmt->surface_format; + case VK_IMAGE_ASPECT_STENCIL_BIT: + assert(anv_fmt->has_stencil); + return ISL_FORMAT_R8_UINT; + default: + unreachable("bad VkImageAspect"); + return ISL_FORMAT_UNSUPPORTED; + } +} + // Format capabilities void anv_validate_GetPhysicalDeviceFormatProperties( diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index c1b777e5973..156905ffa5d 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1385,6 +1385,9 @@ extern const struct anv_format *const anv_format_s8_uint; const struct anv_format * anv_format_for_vk_format(VkFormat format); +enum isl_format +anv_get_isl_format(VkFormat format, VkImageAspectFlags aspect); + static inline bool anv_format_is_color(const struct anv_format *format) { -- 2.30.2