From 127de27015756ce1dff063689186eb3024c5510a Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 27 Oct 2025 11:15:50 -0400 Subject: [PATCH] vulkan/util: Add a vk_format_srgb_to_linear() helper Reviewed-by: Mel Henning Part-of: --- src/vulkan/util/vk_format.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vulkan/util/vk_format.h b/src/vulkan/util/vk_format.h index ca44c9c413c..2f26d2d539e 100644 --- a/src/vulkan/util/vk_format.h +++ b/src/vulkan/util/vk_format.h @@ -196,6 +196,16 @@ vk_format_is_srgb(VkFormat format) return util_format_is_srgb(vk_format_to_pipe_format(format)); } +static inline VkFormat +vk_format_srgb_to_linear(VkFormat format) +{ + if (!vk_format_is_srgb(format)) + return format; + + return vk_format_from_pipe_format( + util_format_linear(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));