[Mesa-dev] [PATCH 12/15] anv: introduce helper to resolve vk_format from anv_format
Lionel Landwerlin
lionel.g.landwerlin at intel.com
Tue Nov 6 13:01:11 UTC 2018
We could touch the macros in anv_formats.c to include VkFormat in
anv_format if that makes your life easier.
On 30/10/2018 05:26, Tapani Pälli wrote:
> 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)
> {
More information about the mesa-dev
mailing list