The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/vk: Create image with mutable format if a sRGB on Android

+28
+28
src/xrt/auxiliary/vk/vk_image_allocator.c
··· 47 47 { 48 48 // This is the format we allocate the image in, can be changed further down. 49 49 VkFormat image_format = (VkFormat)info->format; 50 + VkImageCreateFlags image_create_flags = 0; 50 51 51 52 VkImageUsageFlags image_usage = vk_csci_get_image_usage_flags( // 52 53 vk, // ··· 125 126 }; 126 127 CHAIN(format_android); 127 128 129 + #ifdef VK_KHR_image_format_list 130 + VkImageFormatListCreateInfoKHR image_format_list_create_info = { 131 + .sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR, 132 + .pNext = NULL, 133 + .viewFormatCount = 2, 134 + .pViewFormats = 135 + (VkFormat[2]){ 136 + VK_FORMAT_R8G8B8A8_UNORM, 137 + VK_FORMAT_R8G8B8A8_SRGB, 138 + }, 139 + }; 140 + #endif 128 141 // Android can't allocate native sRGB. 129 142 // Use UNORM and correct gamma later. 130 143 if (image_format == VK_FORMAT_R8G8B8A8_SRGB) { 131 144 image_format = VK_FORMAT_R8G8B8A8_UNORM; 145 + 146 + // https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01019 147 + image_create_flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; 148 + 149 + // https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkImageCreateInfo.html#VUID-VkImageCreateInfo-pNext-02396 150 + format_android.externalFormat = 0; 151 + assert(a_buffer_format_props.format != VK_FORMAT_UNDEFINED); // Make sure there is a Vulkan format. 152 + assert(format_android.externalFormat == 0); 153 + 154 + #ifdef VK_KHR_image_format_list 155 + if (vk->has_KHR_image_format_list) { 156 + CHAIN(image_format_list_create_info); 157 + } 158 + #endif 132 159 } 133 160 #endif 134 161 135 162 VkImageCreateInfo create_info = { 136 163 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, 137 164 .pNext = next_chain, 165 + .flags = image_create_flags, 138 166 .imageType = VK_IMAGE_TYPE_2D, 139 167 .format = image_format, 140 168 .extent = {.width = info->width, .height = info->height, .depth = 1},