From d5405c16084da1c2e64b04536be880302dee98cd Mon Sep 17 00:00:00 2001 From: Rajnesh Kanwal Date: Wed, 30 Mar 2022 19:42:20 +0100 Subject: [PATCH] vulkan: Move common format function to vulkan/util/vk_format.h Moving duplicate vk_format helper functions to common vulkan/util/vk_format.h and also renaming vk_format_get_component_size_in_bits to match how amd and freedreno name the same function. Not moving this function to common code as freedreno's implementation is a bit different. Signed-off-by: Rajnesh Kanwal Reviewed-by: Jason Ekstrand Part-of: --- src/amd/vulkan/vk_format.h | 9 --------- src/freedreno/vulkan/vk_format.h | 6 ------ src/imagination/vulkan/pvr_job_common.c | 12 ++++++------ src/imagination/vulkan/vk_format.h | 18 +++--------------- src/vulkan/util/vk_format.h | 12 ++++++++++++ 5 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/amd/vulkan/vk_format.h b/src/amd/vulkan/vk_format.h index 9f90941bf93..3cb035eb3cc 100644 --- a/src/amd/vulkan/vk_format.h +++ b/src/amd/vulkan/vk_format.h @@ -32,15 +32,6 @@ #include #include -/** - * Return total bits needed for the pixel format per block. - */ -static inline unsigned -vk_format_get_blocksizebits(VkFormat format) -{ - return util_format_get_blocksizebits(vk_format_to_pipe_format(format)); -} - /** * Return the index of the first non-void channel * -1 if no non-void channels diff --git a/src/freedreno/vulkan/vk_format.h b/src/freedreno/vulkan/vk_format.h index 8aca5fef8e2..c335a12ae9b 100644 --- a/src/freedreno/vulkan/vk_format.h +++ b/src/freedreno/vulkan/vk_format.h @@ -34,12 +34,6 @@ #include -static inline bool -vk_format_has_alpha(VkFormat format) -{ - return util_format_has_alpha(vk_format_to_pipe_format(format)); -} - static inline unsigned vk_format_get_component_bits(VkFormat format, enum util_format_colorspace colorspace, diff --git a/src/imagination/vulkan/pvr_job_common.c b/src/imagination/vulkan/pvr_job_common.c index 747434e8c19..4ca0b5c484d 100644 --- a/src/imagination/vulkan/pvr_job_common.c +++ b/src/imagination/vulkan/pvr_job_common.c @@ -84,14 +84,14 @@ void pvr_pbe_get_src_format_and_gamma(VkFormat vk_format, /* F16 source for gamma'd formats. */ *src_format_out = PVRX(PBESTATE_SOURCE_FORMAT_F16_PER_CHANNEL); } else if (vk_format_has_depth(vk_format) && - vk_format_get_component_size_in_bits(vk_format, - UTIL_FORMAT_COLORSPACE_ZS, - 0) > 16) { + vk_format_get_component_bits(vk_format, + UTIL_FORMAT_COLORSPACE_ZS, + 0) > 16) { *src_format_out = PVRX(PBESTATE_SOURCE_FORMAT_8_PER_CHANNEL); } else if (vk_format_has_stencil(vk_format) && - vk_format_get_component_size_in_bits(vk_format, - UTIL_FORMAT_COLORSPACE_ZS, - 1) > 0) { + vk_format_get_component_bits(vk_format, + UTIL_FORMAT_COLORSPACE_ZS, + 1) > 0) { *src_format_out = PVRX(PBESTATE_SOURCE_FORMAT_8_PER_CHANNEL); } else if (chan_0_width > 16) { *src_format_out = PVRX(PBESTATE_SOURCE_FORMAT_8_PER_CHANNEL); diff --git a/src/imagination/vulkan/vk_format.h b/src/imagination/vulkan/vk_format.h index 627dc867877..e4350cdee40 100644 --- a/src/imagination/vulkan/vk_format.h +++ b/src/imagination/vulkan/vk_format.h @@ -54,24 +54,12 @@ vk_format_is_alpha_on_msb(VkFormat vk_format) #endif } -static inline boolean -vk_format_has_alpha(VkFormat vk_format) -{ - return util_format_has_alpha(vk_format_to_pipe_format(vk_format)); -} - static inline boolean vk_format_is_pure_integer(VkFormat vk_format) { return util_format_is_pure_integer(vk_format_to_pipe_format(vk_format)); } -static inline uint -vk_format_get_blocksizebits(VkFormat vk_format) -{ - return util_format_get_blocksizebits(vk_format_to_pipe_format(vk_format)); -} - static inline uint vk_format_get_channel_width(VkFormat vk_format, uint32_t channel) { @@ -96,9 +84,9 @@ vk_format_has_32bit_component(VkFormat vk_format) } static inline uint -vk_format_get_component_size_in_bits(VkFormat vk_format, - enum util_format_colorspace colorspace, - uint32_t component) +vk_format_get_component_bits(VkFormat vk_format, + enum util_format_colorspace colorspace, + uint32_t component) { return util_format_get_component_bits(vk_format_to_pipe_format(vk_format), colorspace, diff --git a/src/vulkan/util/vk_format.h b/src/vulkan/util/vk_format.h index 72b416c6f6e..630cfbe5929 100644 --- a/src/vulkan/util/vk_format.h +++ b/src/vulkan/util/vk_format.h @@ -170,6 +170,18 @@ vk_format_get_nr_components(VkFormat format) return util_format_get_nr_components(vk_format_to_pipe_format(format)); } +static inline bool +vk_format_has_alpha(VkFormat format) +{ + return util_format_has_alpha(vk_format_to_pipe_format(format)); +} + +static inline unsigned +vk_format_get_blocksizebits(VkFormat format) +{ + return util_format_get_blocksizebits(vk_format_to_pipe_format(format)); +} + #ifdef __cplusplus } #endif