···668668669669 // This is the format we allocate the image in, can be changed further down.
670670 VkFormat image_format = (VkFormat)info->format;
671671+672672+#ifdef XRT_GRAPHICS_BUFFER_HANDLE_IS_AHARDWAREBUFFER
673673+ /*
674674+ * Some Vulkan drivers will natively support importing and exporting
675675+ * SRGB formats (Qualcomm) even tho technically that's not intended
676676+ * by the AHardwareBuffer since they don't support sRGB formats.
677677+ * While others (Mail) does not support importing and exporting sRGB
678678+ * formats. So we need to create the image without sRGB and then create
679679+ * the image views with sRGB which is allowed by the Vulkan spec. It
680680+ * seems to be safe to do with on all drivers, so to reduce the logic
681681+ * do that instead.
682682+ */
683683+ if (image_format == VK_FORMAT_R8G8B8A8_SRGB) {
684684+ image_format = VK_FORMAT_R8G8B8A8_UNORM;
685685+ }
686686+#endif
687687+671688 VkImageUsageFlags image_usage = vk_csci_get_image_usage_flags( //
672689 vk, //
673690 image_format, //