From 49f6270e7de9962d3cf874c2d32ceaee47dcf304 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Thu, 29 Feb 2024 04:43:37 +0800 Subject: [PATCH] vulkan: Move vk_format_is_alpha and vk_format_is_alpha_on_msb into vk_format.h from pvr The vk_format_description moved to front because it's referenced by vk_format_is_alpha_on_msb Signed-off-by: Yonggang Luo Reviewed-by: Samuel Pitoiset Reviewed-by: Matt Coster Part-of: --- src/imagination/vulkan/vk_format.h | 18 ----------------- src/vulkan/util/vk_format.h | 31 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/imagination/vulkan/vk_format.h b/src/imagination/vulkan/vk_format.h index 4b846ce145e..cca2c2d79fc 100644 --- a/src/imagination/vulkan/vk_format.h +++ b/src/imagination/vulkan/vk_format.h @@ -39,19 +39,6 @@ #include "util/u_endian.h" -static inline bool vk_format_is_alpha_on_msb(VkFormat vk_format) -{ - const struct util_format_description *desc = - vk_format_description(vk_format); - - return (desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB || - desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) && -#if UTIL_ARCH_BIG_ENDIAN - desc->swizzle[3] == PIPE_SWIZZLE_X; -#else - desc->swizzle[3] == PIPE_SWIZZLE_W; -#endif -} static inline uint vk_format_get_channel_width(VkFormat vk_format, uint32_t channel) @@ -124,9 +111,4 @@ vk_format_get_common_color_channel_count(VkFormat src_format, return count; } -static inline bool vk_format_is_alpha(VkFormat format) -{ - return util_format_is_alpha(vk_format_to_pipe_format(format)); -} - #endif /* VK_FORMAT_H */ diff --git a/src/vulkan/util/vk_format.h b/src/vulkan/util/vk_format.h index d133f8ce798..e8bb2d56190 100644 --- a/src/vulkan/util/vk_format.h +++ b/src/vulkan/util/vk_format.h @@ -44,6 +44,12 @@ vk_format_from_pipe_format(enum pipe_format format); VkImageAspectFlags vk_format_aspects(VkFormat format); +static inline const struct util_format_description * +vk_format_description(VkFormat format) +{ + return util_format_description(vk_format_to_pipe_format(format)); +} + static inline bool vk_format_is_color(VkFormat format) { @@ -139,6 +145,25 @@ vk_format_is_srgb(VkFormat format) return util_format_is_srgb(vk_format_to_pipe_format(format)); } +static inline bool vk_format_is_alpha(VkFormat format) +{ + return util_format_is_alpha(vk_format_to_pipe_format(format)); +} + +static inline bool vk_format_is_alpha_on_msb(VkFormat vk_format) +{ + const struct util_format_description *desc = + vk_format_description(vk_format); + + return (desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB || + desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) && +#if UTIL_ARCH_BIG_ENDIAN + desc->swizzle[3] == PIPE_SWIZZLE_X; +#else + desc->swizzle[3] == PIPE_SWIZZLE_W; +#endif +} + static inline unsigned vk_format_get_blocksize(VkFormat format) { @@ -170,12 +195,6 @@ vk_format_is_block_compressed(VkFormat format) return util_format_is_compressed(vk_format_to_pipe_format(format)); } -static inline const struct util_format_description * -vk_format_description(VkFormat format) -{ - return util_format_description(vk_format_to_pipe_format(format)); -} - static inline unsigned vk_format_get_component_bits(VkFormat format, enum util_format_colorspace colorspace, unsigned component)