The open source OpenXR runtime
0
fork

Configure Feed

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

a/vk: Fix validation error in Android

Mutable format and Android external format are mutually exclusive.

Co-authored-by: Robbie Bridgewater <ebridgewater@magicleap.com>
Co-authored-by: Julian Petrov <jpetrov@magicleap.com>
Co-authored-by: Korcan Hussein <korcan.hussein@collabora.com>
Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2325>

+15 -6
+15 -6
src/xrt/auxiliary/vk/vk_image_allocator.c
··· 184 184 .sType = VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID, 185 185 .externalFormat = a_buffer_format_props.externalFormat, 186 186 }; 187 - CHAIN(format_android); 188 187 189 188 if (image_format == VK_FORMAT_R8G8B8A8_SRGB) { 190 189 // Some versions of Android can't allocate native sRGB, use UNORM and correct gamma later. ··· 192 191 193 192 // https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-VkImageViewCreateInfo-image-01019 194 193 image_create_flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; 195 - 196 - // https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkImageCreateInfo.html#VUID-VkImageCreateInfo-pNext-02396 197 - format_android.externalFormat = 0; 198 - assert(a_buffer_format_props.format != VK_FORMAT_UNDEFINED); // Make sure there is a Vulkan format. 199 - assert(format_android.externalFormat == 0); 194 + has_mutable_usage = true; 200 195 201 196 add_format_non_dup(&flh, VK_FORMAT_R8G8B8A8_UNORM); 202 197 add_format_non_dup(&flh, VK_FORMAT_R8G8B8A8_SRGB); 198 + } 199 + 200 + // https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/VkImageCreateInfo.html#VUID-VkImageCreateInfo-pNext-02396 201 + if (has_mutable_usage) { 202 + format_android.externalFormat = 0; 203 + // Make sure there is a Vulkan format. 204 + if (a_buffer_format_props.format == VK_FORMAT_UNDEFINED) { 205 + VK_WARN(vk, 206 + "vkGetAndroidHardwareBufferPropertiesANDROID: AHB has no Vulkan-mappable format. " 207 + "External format chain required, but external formats cannot be mutable. Swapchain " 208 + "creation may fail!"); 209 + assert(false); 210 + } 203 211 } 204 212 205 213 if (vk_csci_is_format_supported(vk, image_format, info->bits)) { ··· 256 264 // VUID-VkImageCreateInfo-pNext-01974 257 265 if (format_android.externalFormat != 0) { 258 266 create_info.format = VK_FORMAT_UNDEFINED; 267 + CHAIN(format_android); 259 268 } 260 269 #endif 261 270