turnip: add format_is_uint/format_is_sint
authorJonathan Marek <jonathan@marek.ca>
Sat, 5 Oct 2019 16:05:52 +0000 (12:05 -0400)
committerJonathan Marek <jonathan@marek.ca>
Tue, 15 Oct 2019 11:56:19 +0000 (07:56 -0400)
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
src/freedreno/vulkan/vk_format.h

index 4e13bc9c02d18798d599e40c3bc4a2d89cfd0f84..bbf7a5d81b9ee3590490edc41b69459171ea2cd7 100644 (file)
@@ -448,6 +448,28 @@ vk_format_is_int(VkFormat format)
    return channel >= 0 && desc->channel[channel].pure_integer;
 }
 
+static inline bool
+vk_format_is_uint(VkFormat format)
+{
+   const struct vk_format_description *desc = vk_format_description(format);
+   int channel = vk_format_get_first_non_void_channel(format);
+
+   return channel >= 0 &&
+          desc->channel[channel].pure_integer &&
+          desc->channel[channel].type != VK_FORMAT_TYPE_SIGNED;
+}
+
+static inline bool
+vk_format_is_sint(VkFormat format)
+{
+   const struct vk_format_description *desc = vk_format_description(format);
+   int channel = vk_format_get_first_non_void_channel(format);
+
+   return channel >= 0 &&
+          desc->channel[channel].pure_integer &&
+          desc->channel[channel].type == VK_FORMAT_TYPE_SIGNED;
+}
+
 static inline bool
 vk_format_is_srgb(VkFormat format)
 {