| 1 | /**************************************************************************/ |
| 2 | /* openxr_vulkan_extension.cpp */ |
| 3 | /**************************************************************************/ |
| 4 | /* This file is part of: */ |
| 5 | /* GODOT ENGINE */ |
| 6 | /* https://godotengine.org */ |
| 7 | /**************************************************************************/ |
| 8 | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ |
| 9 | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ |
| 10 | /* */ |
| 11 | /* Permission is hereby granted, free of charge, to any person obtaining */ |
| 12 | /* a copy of this software and associated documentation files (the */ |
| 13 | /* "Software"), to deal in the Software without restriction, including */ |
| 14 | /* without limitation the rights to use, copy, modify, merge, publish, */ |
| 15 | /* distribute, sublicense, and/or sell copies of the Software, and to */ |
| 16 | /* permit persons to whom the Software is furnished to do so, subject to */ |
| 17 | /* the following conditions: */ |
| 18 | /* */ |
| 19 | /* The above copyright notice and this permission notice shall be */ |
| 20 | /* included in all copies or substantial portions of the Software. */ |
| 21 | /* */ |
| 22 | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ |
| 23 | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ |
| 24 | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ |
| 25 | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ |
| 26 | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ |
| 27 | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ |
| 28 | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ |
| 29 | /**************************************************************************/ |
| 30 | |
| 31 | #include "openxr_vulkan_extension.h" |
| 32 | |
| 33 | #include "../../openxr_util.h" |
| 34 | #include "../openxr_fb_foveation_extension.h" |
| 35 | |
| 36 | #include "core/string/print_string.h" |
| 37 | #include "servers/rendering/renderer_rd/effects/copy_effects.h" |
| 38 | #include "servers/rendering/renderer_rd/storage_rd/texture_storage.h" |
| 39 | #include "servers/rendering/rendering_server.h" |
| 40 | #include "servers/rendering/rendering_server_globals.h" |
| 41 | |
| 42 | HashMap<String, bool *> OpenXRVulkanExtension::get_requested_extensions(XrVersion p_version) { |
| 43 | HashMap<String, bool *> request_extensions; |
| 44 | |
| 45 | request_extensions[XR_KHR_VULKAN_ENABLE2_EXTENSION_NAME] = nullptr; // must be available |
| 46 | |
| 47 | return request_extensions; |
| 48 | } |
| 49 | |
| 50 | void OpenXRVulkanExtension::on_instance_created(const XrInstance p_instance) { |
| 51 | ERR_FAIL_NULL(OpenXRAPI::get_singleton()); |
| 52 | |
| 53 | // Obtain pointers to functions we're accessing here, they are (not yet) part of core. |
| 54 | |
| 55 | EXT_INIT_XR_FUNC(xrGetVulkanGraphicsRequirements2KHR); |
| 56 | EXT_INIT_XR_FUNC(xrCreateVulkanInstanceKHR); |
| 57 | EXT_INIT_XR_FUNC(xrGetVulkanGraphicsDevice2KHR); |
| 58 | EXT_INIT_XR_FUNC(xrCreateVulkanDeviceKHR); |
| 59 | EXT_INIT_XR_FUNC(xrEnumerateSwapchainImages); |
| 60 | } |
| 61 | |
| 62 | bool OpenXRVulkanExtension::check_graphics_api_support(XrVersion p_desired_version) { |
| 63 | ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false); |
| 64 | |
| 65 | XrGraphicsRequirementsVulkan2KHR vulkan_requirements = { |
| 66 | XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN2_KHR, // type |
| 67 | nullptr, // next |
| 68 | 0, // minApiVersionSupported |
| 69 | 0 // maxApiVersionSupported |
| 70 | }; |
| 71 | |
| 72 | XrResult result = xrGetVulkanGraphicsRequirements2KHR(OpenXRAPI::get_singleton()->get_instance(), OpenXRAPI::get_singleton()->get_system_id(), &vulkan_requirements); |
| 73 | if (XR_FAILED(result)) { |
| 74 | print_line("OpenXR: Failed to get Vulkan graphics requirements [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | // #ifdef DEBUG |
| 79 | print_line("OpenXR: XrGraphicsRequirementsVulkan2KHR:"); |
| 80 | print_line(" - minApiVersionSupported: ", OpenXRUtil::make_xr_version_string(vulkan_requirements.minApiVersionSupported)); |
| 81 | print_line(" - maxApiVersionSupported: ", OpenXRUtil::make_xr_version_string(vulkan_requirements.maxApiVersionSupported)); |
| 82 | // #endif |
| 83 | |
| 84 | if (p_desired_version < vulkan_requirements.minApiVersionSupported) { |
| 85 | print_line("OpenXR: Requested Vulkan version does not meet the minimum version this runtime supports."); |
| 86 | print_line("- desired_version ", OpenXRUtil::make_xr_version_string(p_desired_version)); |
| 87 | print_line("- minApiVersionSupported ", OpenXRUtil::make_xr_version_string(vulkan_requirements.minApiVersionSupported)); |
| 88 | print_line("- maxApiVersionSupported ", OpenXRUtil::make_xr_version_string(vulkan_requirements.maxApiVersionSupported)); |
| 89 | return false; |
| 90 | } |
| 91 | |
| 92 | if (p_desired_version > vulkan_requirements.maxApiVersionSupported) { |
| 93 | print_line("OpenXR: Requested Vulkan version exceeds the maximum version this runtime has been tested on and is known to support."); |
| 94 | print_line("- desired_version ", OpenXRUtil::make_xr_version_string(p_desired_version)); |
| 95 | print_line("- minApiVersionSupported ", OpenXRUtil::make_xr_version_string(vulkan_requirements.minApiVersionSupported)); |
| 96 | print_line("- maxApiVersionSupported ", OpenXRUtil::make_xr_version_string(vulkan_requirements.maxApiVersionSupported)); |
| 97 | } |
| 98 | |
| 99 | return true; |
| 100 | } |
| 101 | |
| 102 | bool OpenXRVulkanExtension::create_vulkan_instance(const VkInstanceCreateInfo *p_vulkan_create_info, VkInstance *r_instance) { |
| 103 | // get the vulkan version we are creating |
| 104 | uint32_t vulkan_version = p_vulkan_create_info->pApplicationInfo->apiVersion; |
| 105 | uint32_t major_version = VK_VERSION_MAJOR(vulkan_version); |
| 106 | uint32_t minor_version = VK_VERSION_MINOR(vulkan_version); |
| 107 | uint32_t patch_version = VK_VERSION_PATCH(vulkan_version); |
| 108 | XrVersion desired_version = XR_MAKE_VERSION(major_version, minor_version, patch_version); |
| 109 | |
| 110 | // check if this is supported |
| 111 | if (!check_graphics_api_support(desired_version)) { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | XrVulkanInstanceCreateInfoKHR xr_vulkan_instance_info = { |
| 116 | XR_TYPE_VULKAN_INSTANCE_CREATE_INFO_KHR, // type |
| 117 | nullptr, // next |
| 118 | OpenXRAPI::get_singleton()->get_system_id(), // systemId |
| 119 | 0, // createFlags |
| 120 | vkGetInstanceProcAddr, // pfnGetInstanceProcAddr |
| 121 | p_vulkan_create_info, // vulkanCreateInfo |
| 122 | nullptr, // vulkanAllocator |
| 123 | }; |
| 124 | |
| 125 | VkResult vk_result = VK_SUCCESS; |
| 126 | XrResult result = xrCreateVulkanInstanceKHR(OpenXRAPI::get_singleton()->get_instance(), &xr_vulkan_instance_info, &vulkan_instance, &vk_result); |
| 127 | if (XR_FAILED(result)) { |
| 128 | print_line("OpenXR: Failed to create Vulkan instance [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | ERR_FAIL_COND_V_MSG(vk_result == VK_ERROR_INCOMPATIBLE_DRIVER, false, |
| 133 | "Cannot find a compatible Vulkan installable client driver (ICD).\n\n" |
| 134 | "vkCreateInstance Failure"); |
| 135 | ERR_FAIL_COND_V_MSG(vk_result == VK_ERROR_EXTENSION_NOT_PRESENT, false, |
| 136 | "Cannot find a specified extension library.\n" |
| 137 | "Make sure your layers path is set appropriately.\n" |
| 138 | "vkCreateInstance Failure"); |
| 139 | ERR_FAIL_COND_V_MSG(vk_result, false, |
| 140 | "vkCreateInstance failed.\n\n" |
| 141 | "Do you have a compatible Vulkan installable client driver (ICD) installed?\n" |
| 142 | "Please look at the Getting Started guide for additional information.\n" |
| 143 | "vkCreateInstance Failure"); |
| 144 | |
| 145 | *r_instance = vulkan_instance; |
| 146 | |
| 147 | return true; |
| 148 | } |
| 149 | |
| 150 | bool OpenXRVulkanExtension::get_physical_device(VkPhysicalDevice *r_device) { |
| 151 | ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false); |
| 152 | |
| 153 | XrVulkanGraphicsDeviceGetInfoKHR get_info = { |
| 154 | XR_TYPE_VULKAN_GRAPHICS_DEVICE_GET_INFO_KHR, // type |
| 155 | nullptr, // next |
| 156 | OpenXRAPI::get_singleton()->get_system_id(), // systemId |
| 157 | vulkan_instance, // vulkanInstance |
| 158 | }; |
| 159 | |
| 160 | XrResult result = xrGetVulkanGraphicsDevice2KHR(OpenXRAPI::get_singleton()->get_instance(), &get_info, &vulkan_physical_device); |
| 161 | if (XR_FAILED(result)) { |
| 162 | print_line("OpenXR: Failed to obtain Vulkan physical device [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 163 | return false; |
| 164 | } |
| 165 | |
| 166 | *r_device = vulkan_physical_device; |
| 167 | |
| 168 | return true; |
| 169 | } |
| 170 | |
| 171 | bool OpenXRVulkanExtension::create_vulkan_device(const VkDeviceCreateInfo *p_device_create_info, VkDevice *r_device) { |
| 172 | ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false); |
| 173 | |
| 174 | XrVulkanDeviceCreateInfoKHR create_info = { |
| 175 | XR_TYPE_VULKAN_DEVICE_CREATE_INFO_KHR, // type |
| 176 | nullptr, // next |
| 177 | OpenXRAPI::get_singleton()->get_system_id(), // systemId |
| 178 | 0, // createFlags |
| 179 | vkGetInstanceProcAddr, // pfnGetInstanceProcAddr |
| 180 | vulkan_physical_device, // vulkanPhysicalDevice |
| 181 | p_device_create_info, // vulkanCreateInfo |
| 182 | nullptr // vulkanAllocator |
| 183 | }; |
| 184 | |
| 185 | VkResult vk_result = VK_SUCCESS; |
| 186 | XrResult result = xrCreateVulkanDeviceKHR(OpenXRAPI::get_singleton()->get_instance(), &create_info, &vulkan_device, &vk_result); |
| 187 | if (XR_FAILED(result)) { |
| 188 | print_line("OpenXR: Failed to create Vulkan device [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | if (vk_result != VK_SUCCESS) { |
| 193 | print_line("OpenXR: Failed to create Vulkan device [Vulkan error", vk_result, "]"); |
| 194 | } |
| 195 | |
| 196 | *r_device = vulkan_device; |
| 197 | |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | void OpenXRVulkanExtension::set_direct_queue_family_and_index(uint32_t p_queue_family_index, uint32_t p_queue_index) { |
| 202 | vulkan_queue_family_index = p_queue_family_index; |
| 203 | vulkan_queue_index = p_queue_index; |
| 204 | } |
| 205 | |
| 206 | bool OpenXRVulkanExtension::use_fragment_density_offsets() { |
| 207 | OpenXRFBFoveationExtension *fb_foveation = OpenXRFBFoveationExtension::get_singleton(); |
| 208 | if (fb_foveation == nullptr) { |
| 209 | return false; |
| 210 | } |
| 211 | |
| 212 | return fb_foveation->is_foveation_eye_tracked_enabled(); |
| 213 | } |
| 214 | |
| 215 | void OpenXRVulkanExtension::get_fragment_density_offsets(LocalVector<VkOffset2D> &r_vk_offsets, const Vector2i &p_granularity) { |
| 216 | OpenXRFBFoveationExtension *fb_foveation = OpenXRFBFoveationExtension::get_singleton(); |
| 217 | if (fb_foveation == nullptr) { |
| 218 | return; |
| 219 | } |
| 220 | |
| 221 | LocalVector<Vector2i> offsets; |
| 222 | fb_foveation->get_fragment_density_offsets(offsets); |
| 223 | |
| 224 | r_vk_offsets.reserve(offsets.size()); |
| 225 | for (Vector2i offset : offsets) { |
| 226 | offset = ((offset + p_granularity / 2) / p_granularity) * p_granularity; |
| 227 | |
| 228 | r_vk_offsets.push_back(VkOffset2D{ offset.x, offset.y }); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | XrGraphicsBindingVulkanKHR OpenXRVulkanExtension::graphics_binding_vulkan; |
| 233 | |
| 234 | void *OpenXRVulkanExtension::set_session_create_and_get_next_pointer(void *p_next_pointer) { |
| 235 | DEV_ASSERT(vulkan_queue_family_index < UINT32_MAX && "Direct queue family index was not specified yet."); |
| 236 | DEV_ASSERT(vulkan_queue_index < UINT32_MAX && "Direct queue index was not specified yet."); |
| 237 | |
| 238 | graphics_binding_vulkan.type = XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR; |
| 239 | graphics_binding_vulkan.next = p_next_pointer; |
| 240 | graphics_binding_vulkan.instance = vulkan_instance; |
| 241 | graphics_binding_vulkan.physicalDevice = vulkan_physical_device; |
| 242 | graphics_binding_vulkan.device = vulkan_device; |
| 243 | graphics_binding_vulkan.queueFamilyIndex = vulkan_queue_family_index; |
| 244 | graphics_binding_vulkan.queueIndex = vulkan_queue_index; |
| 245 | |
| 246 | return &graphics_binding_vulkan; |
| 247 | } |
| 248 | |
| 249 | void OpenXRVulkanExtension::get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) { |
| 250 | // We might want to do more here especially if we keep things in linear color space |
| 251 | // Possibly add in R10G10B10A2 as an option if we're using the mobile renderer. |
| 252 | p_usable_swap_chains.push_back(VK_FORMAT_R8G8B8A8_SRGB); |
| 253 | p_usable_swap_chains.push_back(VK_FORMAT_B8G8R8A8_SRGB); |
| 254 | p_usable_swap_chains.push_back(VK_FORMAT_R8G8B8A8_UINT); |
| 255 | p_usable_swap_chains.push_back(VK_FORMAT_B8G8R8A8_UINT); |
| 256 | } |
| 257 | |
| 258 | void OpenXRVulkanExtension::get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) { |
| 259 | // Note, it is very likely we do NOT support any of depth formats where we can combine our stencil support (e.g. _S8_UINT). |
| 260 | // Right now this isn't a problem but once stencil support becomes an issue, we need to check for this in the rendering engine |
| 261 | // and create a separate buffer for the stencil. |
| 262 | |
| 263 | p_usable_swap_chains.push_back(VK_FORMAT_D24_UNORM_S8_UINT); |
| 264 | p_usable_swap_chains.push_back(VK_FORMAT_D32_SFLOAT_S8_UINT); |
| 265 | p_usable_swap_chains.push_back(VK_FORMAT_D32_SFLOAT); |
| 266 | } |
| 267 | |
| 268 | bool OpenXRVulkanExtension::get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) { |
| 269 | LocalVector<XrSwapchainImageVulkanKHR> images; |
| 270 | LocalVector<XrSwapchainImageFoveationVulkanFB> density_images; |
| 271 | |
| 272 | RenderingServer *rendering_server = RenderingServer::get_singleton(); |
| 273 | ERR_FAIL_NULL_V(rendering_server, false); |
| 274 | RenderingDevice *rendering_device = rendering_server->get_rendering_device(); |
| 275 | ERR_FAIL_NULL_V(rendering_device, false); |
| 276 | |
| 277 | uint32_t swapchain_length; |
| 278 | XrResult result = xrEnumerateSwapchainImages(p_swapchain, 0, &swapchain_length, nullptr); |
| 279 | if (XR_FAILED(result)) { |
| 280 | print_line("OpenXR: Failed to get swapchain image count [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 281 | return false; |
| 282 | } |
| 283 | |
| 284 | images.resize(swapchain_length); |
| 285 | |
| 286 | for (XrSwapchainImageVulkanKHR &image : images) { |
| 287 | image.type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR; |
| 288 | image.next = nullptr; |
| 289 | image.image = VK_NULL_HANDLE; |
| 290 | } |
| 291 | |
| 292 | if (OpenXRFBFoveationExtension::get_singleton()->is_enabled()) { |
| 293 | density_images.resize(swapchain_length); |
| 294 | |
| 295 | for (uint64_t i = 0; i < swapchain_length; i++) { |
| 296 | density_images[i].type = XR_TYPE_SWAPCHAIN_IMAGE_FOVEATION_VULKAN_FB; |
| 297 | density_images[i].next = nullptr; |
| 298 | density_images[i].image = VK_NULL_HANDLE; |
| 299 | density_images[i].width = 0; |
| 300 | density_images[i].height = 0; |
| 301 | |
| 302 | images[i].next = &density_images[i]; |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | result = xrEnumerateSwapchainImages(p_swapchain, swapchain_length, &swapchain_length, (XrSwapchainImageBaseHeader *)images.ptr()); |
| 307 | if (XR_FAILED(result)) { |
| 308 | print_line("OpenXR: Failed to get swapchain images [", OpenXRAPI::get_singleton()->get_error_string(result), "]"); |
| 309 | return false; |
| 310 | } |
| 311 | |
| 312 | SwapchainGraphicsData *data = memnew(SwapchainGraphicsData); |
| 313 | if (data == nullptr) { |
| 314 | print_line("OpenXR: Failed to allocate memory for swapchain data"); |
| 315 | return false; |
| 316 | } |
| 317 | *r_swapchain_graphics_data = data; |
| 318 | data->is_multiview = (p_array_size > 1); |
| 319 | |
| 320 | RenderingDevice::DataFormat format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB; |
| 321 | RenderingDevice::TextureSamples samples = RenderingDevice::TEXTURE_SAMPLES_1; |
| 322 | uint64_t usage_flags = RenderingDevice::TEXTURE_USAGE_SAMPLING_BIT; |
| 323 | |
| 324 | switch (p_swapchain_format) { |
| 325 | case VK_FORMAT_R8G8B8A8_SRGB: |
| 326 | // Even though this is an sRGB framebuffer format we're using UNORM here. |
| 327 | // The reason here is because Godot does a linear to sRGB conversion while |
| 328 | // with the sRGB format, this conversion would be doubled by the hardware. |
| 329 | // This also means we're reading the values as is for our preview on screen. |
| 330 | // The OpenXR runtime however is still treating this as an sRGB format and |
| 331 | // will thus do an sRGB -> Linear conversion as expected. |
| 332 | //format = RenderingDevice::DATA_FORMAT_R8G8B8A8_SRGB; |
| 333 | format = RenderingDevice::DATA_FORMAT_R8G8B8A8_UNORM; |
| 334 | usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; |
| 335 | break; |
| 336 | case VK_FORMAT_B8G8R8A8_SRGB: |
| 337 | //format = RenderingDevice::DATA_FORMAT_B8G8R8A8_SRGB; |
| 338 | format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UNORM; |
| 339 | usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; |
| 340 | break; |
| 341 | case VK_FORMAT_R8G8B8A8_UINT: |
| 342 | format = RenderingDevice::DATA_FORMAT_R8G8B8A8_UINT; |
| 343 | usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; |
| 344 | break; |
| 345 | case VK_FORMAT_B8G8R8A8_UINT: |
| 346 | format = RenderingDevice::DATA_FORMAT_B8G8R8A8_UINT; |
| 347 | usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; |
| 348 | break; |
| 349 | case VK_FORMAT_R16G16B16A16_SFLOAT: |
| 350 | format = RenderingDevice::DATA_FORMAT_R16G16B16A16_SFLOAT; |
| 351 | usage_flags |= RenderingDevice::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; |
| 352 | break; |
| 353 | case VK_FORMAT_D32_SFLOAT: |
| 354 | format = RenderingDevice::DATA_FORMAT_D32_SFLOAT; |
| 355 | usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | RenderingDevice::TEXTURE_USAGE_DEPTH_RESOLVE_ATTACHMENT_BIT; |
| 356 | break; |
| 357 | case VK_FORMAT_D24_UNORM_S8_UINT: |
| 358 | format = RenderingDevice::DATA_FORMAT_D24_UNORM_S8_UINT; |
| 359 | usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | RenderingDevice::TEXTURE_USAGE_DEPTH_RESOLVE_ATTACHMENT_BIT; |
| 360 | break; |
| 361 | case VK_FORMAT_D32_SFLOAT_S8_UINT: |
| 362 | format = RenderingDevice::DATA_FORMAT_D32_SFLOAT_S8_UINT; |
| 363 | usage_flags |= RenderingDevice::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | RenderingDevice::TEXTURE_USAGE_DEPTH_RESOLVE_ATTACHMENT_BIT; |
| 364 | break; |
| 365 | default: |
| 366 | // continue with our default value |
| 367 | print_line("OpenXR: Unsupported swapchain format", p_swapchain_format); |
| 368 | break; |
| 369 | } |
| 370 | |
| 371 | switch (p_sample_count) { |
| 372 | case 1: |
| 373 | samples = RenderingDevice::TEXTURE_SAMPLES_1; |
| 374 | break; |
| 375 | case 2: |
| 376 | samples = RenderingDevice::TEXTURE_SAMPLES_2; |
| 377 | break; |
| 378 | case 4: |
| 379 | samples = RenderingDevice::TEXTURE_SAMPLES_4; |
| 380 | break; |
| 381 | case 8: |
| 382 | samples = RenderingDevice::TEXTURE_SAMPLES_8; |
| 383 | break; |
| 384 | case 16: |
| 385 | samples = RenderingDevice::TEXTURE_SAMPLES_16; |
| 386 | break; |
| 387 | case 32: |
| 388 | samples = RenderingDevice::TEXTURE_SAMPLES_32; |
| 389 | break; |
| 390 | case 64: |
| 391 | samples = RenderingDevice::TEXTURE_SAMPLES_64; |
| 392 | break; |
| 393 | default: |
| 394 | // continue with our default value |
| 395 | print_line("OpenXR: Unsupported sample count", p_sample_count); |
| 396 | break; |
| 397 | } |
| 398 | |
| 399 | Vector<RID> texture_rids; |
| 400 | Vector<RID> density_map_rids; |
| 401 | |
| 402 | // create Godot texture objects for each entry in our swapchain |
| 403 | for (uint32_t i = 0; i < swapchain_length; i++) { |
| 404 | const XrSwapchainImageVulkanKHR &swapchain_image = images[i]; |
| 405 | |
| 406 | RID image_rid = rendering_device->texture_create_from_extension( |
| 407 | p_array_size == 1 ? RenderingDevice::TEXTURE_TYPE_2D : RenderingDevice::TEXTURE_TYPE_2D_ARRAY, |
| 408 | format, |
| 409 | samples, |
| 410 | usage_flags, |
| 411 | (uint64_t)swapchain_image.image, |
| 412 | p_width, |
| 413 | p_height, |
| 414 | 1, |
| 415 | p_array_size, |
| 416 | 1); |
| 417 | |
| 418 | texture_rids.push_back(image_rid); |
| 419 | |
| 420 | if (OpenXRFBFoveationExtension::get_singleton()->is_enabled() && density_images[i].image != VK_NULL_HANDLE) { |
| 421 | RID density_map_rid = rendering_device->texture_create_from_extension( |
| 422 | p_array_size == 1 ? RenderingDevice::TEXTURE_TYPE_2D : RenderingDevice::TEXTURE_TYPE_2D_ARRAY, |
| 423 | RD::DATA_FORMAT_R8G8_UNORM, |
| 424 | RenderingDevice::TEXTURE_SAMPLES_1, |
| 425 | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT | RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_STORAGE_BIT | RD::TEXTURE_USAGE_VRS_ATTACHMENT_BIT, |
| 426 | (uint64_t)density_images[i].image, |
| 427 | density_images[i].width, |
| 428 | density_images[i].height, |
| 429 | 1, |
| 430 | p_array_size, |
| 431 | 1); |
| 432 | |
| 433 | density_map_rids.push_back(density_map_rid); |
| 434 | } else { |
| 435 | density_map_rids.push_back(RID()); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | data->texture_rids = texture_rids; |
| 440 | data->density_map_rids = density_map_rids; |
| 441 | |
| 442 | return true; |
| 443 | } |
| 444 | |
| 445 | bool OpenXRVulkanExtension::create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) { |
| 446 | OpenXRUtil::XrMatrix4x4f matrix; |
| 447 | OpenXRUtil::XrMatrix4x4f_CreateProjectionFov(&matrix, p_fov, (float)p_z_near, (float)p_z_far); |
| 448 | |
| 449 | for (int j = 0; j < 4; j++) { |
| 450 | for (int i = 0; i < 4; i++) { |
| 451 | r_camera_matrix.columns[j][i] = matrix.m[j * 4 + i]; |
| 452 | } |
| 453 | } |
| 454 | |
| 455 | return true; |
| 456 | } |
| 457 | |
| 458 | RID OpenXRVulkanExtension::get_texture(void *p_swapchain_graphics_data, int p_image_index) { |
| 459 | SwapchainGraphicsData *data = (SwapchainGraphicsData *)p_swapchain_graphics_data; |
| 460 | ERR_FAIL_NULL_V(data, RID()); |
| 461 | |
| 462 | ERR_FAIL_INDEX_V(p_image_index, data->texture_rids.size(), RID()); |
| 463 | return data->texture_rids[p_image_index]; |
| 464 | } |
| 465 | |
| 466 | RID OpenXRVulkanExtension::get_density_map(void *p_swapchain_graphics_data, int p_image_index) { |
| 467 | SwapchainGraphicsData *data = (SwapchainGraphicsData *)p_swapchain_graphics_data; |
| 468 | ERR_FAIL_NULL_V(data, RID()); |
| 469 | |
| 470 | ERR_FAIL_INDEX_V(p_image_index, data->density_map_rids.size(), RID()); |
| 471 | return data->density_map_rids[p_image_index]; |
| 472 | } |
| 473 | |
| 474 | void OpenXRVulkanExtension::cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) { |
| 475 | if (*p_swapchain_graphics_data == nullptr) { |
| 476 | return; |
| 477 | } |
| 478 | |
| 479 | SwapchainGraphicsData *data = (SwapchainGraphicsData *)*p_swapchain_graphics_data; |
| 480 | |
| 481 | RenderingServer *rendering_server = RenderingServer::get_singleton(); |
| 482 | ERR_FAIL_NULL(rendering_server); |
| 483 | RenderingDevice *rendering_device = rendering_server->get_rendering_device(); |
| 484 | ERR_FAIL_NULL(rendering_device); |
| 485 | |
| 486 | for (const RID &texture_rid : data->texture_rids) { |
| 487 | // This should clean up our RIDs and associated texture objects but shouldn't destroy the images, they are owned by our XrSwapchain. |
| 488 | rendering_device->free_rid(texture_rid); |
| 489 | } |
| 490 | data->texture_rids.clear(); |
| 491 | |
| 492 | for (int i = 0; i < data->density_map_rids.size(); i++) { |
| 493 | if (data->density_map_rids[i].is_valid()) { |
| 494 | rendering_device->free_rid(data->density_map_rids[i]); |
| 495 | } |
| 496 | } |
| 497 | data->density_map_rids.clear(); |
| 498 | |
| 499 | memdelete(data); |
| 500 | *p_swapchain_graphics_data = nullptr; |
| 501 | } |
| 502 | |
| 503 | #define ENUM_TO_STRING_CASE(e) \ |
| 504 | case e: { \ |
| 505 | return String(#e); \ |
| 506 | } break; |
| 507 | |
| 508 | String OpenXRVulkanExtension::get_swapchain_format_name(int64_t p_swapchain_format) const { |
| 509 | // This really should be in vulkan_context... |
| 510 | VkFormat format = VkFormat(p_swapchain_format); |
| 511 | switch (format) { |
| 512 | ENUM_TO_STRING_CASE(VK_FORMAT_UNDEFINED) |
| 513 | ENUM_TO_STRING_CASE(VK_FORMAT_R4G4_UNORM_PACK8) |
| 514 | ENUM_TO_STRING_CASE(VK_FORMAT_R4G4B4A4_UNORM_PACK16) |
| 515 | ENUM_TO_STRING_CASE(VK_FORMAT_B4G4R4A4_UNORM_PACK16) |
| 516 | ENUM_TO_STRING_CASE(VK_FORMAT_R5G6B5_UNORM_PACK16) |
| 517 | ENUM_TO_STRING_CASE(VK_FORMAT_B5G6R5_UNORM_PACK16) |
| 518 | ENUM_TO_STRING_CASE(VK_FORMAT_R5G5B5A1_UNORM_PACK16) |
| 519 | ENUM_TO_STRING_CASE(VK_FORMAT_B5G5R5A1_UNORM_PACK16) |
| 520 | ENUM_TO_STRING_CASE(VK_FORMAT_A1R5G5B5_UNORM_PACK16) |
| 521 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_UNORM) |
| 522 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_SNORM) |
| 523 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_USCALED) |
| 524 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_SSCALED) |
| 525 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_UINT) |
| 526 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_SINT) |
| 527 | ENUM_TO_STRING_CASE(VK_FORMAT_R8_SRGB) |
| 528 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_UNORM) |
| 529 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_SNORM) |
| 530 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_USCALED) |
| 531 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_SSCALED) |
| 532 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_UINT) |
| 533 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_SINT) |
| 534 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8_SRGB) |
| 535 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_UNORM) |
| 536 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_SNORM) |
| 537 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_USCALED) |
| 538 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_SSCALED) |
| 539 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_UINT) |
| 540 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_SINT) |
| 541 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8_SRGB) |
| 542 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_UNORM) |
| 543 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_SNORM) |
| 544 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_USCALED) |
| 545 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_SSCALED) |
| 546 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_UINT) |
| 547 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_SINT) |
| 548 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8_SRGB) |
| 549 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_UNORM) |
| 550 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_SNORM) |
| 551 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_USCALED) |
| 552 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_SSCALED) |
| 553 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_UINT) |
| 554 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_SINT) |
| 555 | ENUM_TO_STRING_CASE(VK_FORMAT_R8G8B8A8_SRGB) |
| 556 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_UNORM) |
| 557 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_SNORM) |
| 558 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_USCALED) |
| 559 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_SSCALED) |
| 560 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_UINT) |
| 561 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_SINT) |
| 562 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8A8_SRGB) |
| 563 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_UNORM_PACK32) |
| 564 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_SNORM_PACK32) |
| 565 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_USCALED_PACK32) |
| 566 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_SSCALED_PACK32) |
| 567 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_UINT_PACK32) |
| 568 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_SINT_PACK32) |
| 569 | ENUM_TO_STRING_CASE(VK_FORMAT_A8B8G8R8_SRGB_PACK32) |
| 570 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_UNORM_PACK32) |
| 571 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_SNORM_PACK32) |
| 572 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_USCALED_PACK32) |
| 573 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_SSCALED_PACK32) |
| 574 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_UINT_PACK32) |
| 575 | ENUM_TO_STRING_CASE(VK_FORMAT_A2R10G10B10_SINT_PACK32) |
| 576 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_UNORM_PACK32) |
| 577 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_SNORM_PACK32) |
| 578 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_USCALED_PACK32) |
| 579 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_SSCALED_PACK32) |
| 580 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_UINT_PACK32) |
| 581 | ENUM_TO_STRING_CASE(VK_FORMAT_A2B10G10R10_SINT_PACK32) |
| 582 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_UNORM) |
| 583 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_SNORM) |
| 584 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_USCALED) |
| 585 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_SSCALED) |
| 586 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_UINT) |
| 587 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_SINT) |
| 588 | ENUM_TO_STRING_CASE(VK_FORMAT_R16_SFLOAT) |
| 589 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_UNORM) |
| 590 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_SNORM) |
| 591 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_USCALED) |
| 592 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_SSCALED) |
| 593 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_UINT) |
| 594 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_SINT) |
| 595 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16_SFLOAT) |
| 596 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_UNORM) |
| 597 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_SNORM) |
| 598 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_USCALED) |
| 599 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_SSCALED) |
| 600 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_UINT) |
| 601 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_SINT) |
| 602 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16_SFLOAT) |
| 603 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_UNORM) |
| 604 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_SNORM) |
| 605 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_USCALED) |
| 606 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_SSCALED) |
| 607 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_UINT) |
| 608 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_SINT) |
| 609 | ENUM_TO_STRING_CASE(VK_FORMAT_R16G16B16A16_SFLOAT) |
| 610 | ENUM_TO_STRING_CASE(VK_FORMAT_R32_UINT) |
| 611 | ENUM_TO_STRING_CASE(VK_FORMAT_R32_SINT) |
| 612 | ENUM_TO_STRING_CASE(VK_FORMAT_R32_SFLOAT) |
| 613 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32_UINT) |
| 614 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32_SINT) |
| 615 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32_SFLOAT) |
| 616 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32_UINT) |
| 617 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32_SINT) |
| 618 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32_SFLOAT) |
| 619 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32A32_UINT) |
| 620 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32A32_SINT) |
| 621 | ENUM_TO_STRING_CASE(VK_FORMAT_R32G32B32A32_SFLOAT) |
| 622 | ENUM_TO_STRING_CASE(VK_FORMAT_R64_UINT) |
| 623 | ENUM_TO_STRING_CASE(VK_FORMAT_R64_SINT) |
| 624 | ENUM_TO_STRING_CASE(VK_FORMAT_R64_SFLOAT) |
| 625 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64_UINT) |
| 626 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64_SINT) |
| 627 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64_SFLOAT) |
| 628 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64_UINT) |
| 629 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64_SINT) |
| 630 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64_SFLOAT) |
| 631 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64A64_UINT) |
| 632 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64A64_SINT) |
| 633 | ENUM_TO_STRING_CASE(VK_FORMAT_R64G64B64A64_SFLOAT) |
| 634 | ENUM_TO_STRING_CASE(VK_FORMAT_B10G11R11_UFLOAT_PACK32) |
| 635 | ENUM_TO_STRING_CASE(VK_FORMAT_E5B9G9R9_UFLOAT_PACK32) |
| 636 | ENUM_TO_STRING_CASE(VK_FORMAT_D16_UNORM) |
| 637 | ENUM_TO_STRING_CASE(VK_FORMAT_X8_D24_UNORM_PACK32) |
| 638 | ENUM_TO_STRING_CASE(VK_FORMAT_D32_SFLOAT) |
| 639 | ENUM_TO_STRING_CASE(VK_FORMAT_S8_UINT) |
| 640 | ENUM_TO_STRING_CASE(VK_FORMAT_D16_UNORM_S8_UINT) |
| 641 | ENUM_TO_STRING_CASE(VK_FORMAT_D24_UNORM_S8_UINT) |
| 642 | ENUM_TO_STRING_CASE(VK_FORMAT_D32_SFLOAT_S8_UINT) |
| 643 | ENUM_TO_STRING_CASE(VK_FORMAT_BC1_RGB_UNORM_BLOCK) |
| 644 | ENUM_TO_STRING_CASE(VK_FORMAT_BC1_RGB_SRGB_BLOCK) |
| 645 | ENUM_TO_STRING_CASE(VK_FORMAT_BC1_RGBA_UNORM_BLOCK) |
| 646 | ENUM_TO_STRING_CASE(VK_FORMAT_BC1_RGBA_SRGB_BLOCK) |
| 647 | ENUM_TO_STRING_CASE(VK_FORMAT_BC2_UNORM_BLOCK) |
| 648 | ENUM_TO_STRING_CASE(VK_FORMAT_BC2_SRGB_BLOCK) |
| 649 | ENUM_TO_STRING_CASE(VK_FORMAT_BC3_UNORM_BLOCK) |
| 650 | ENUM_TO_STRING_CASE(VK_FORMAT_BC3_SRGB_BLOCK) |
| 651 | ENUM_TO_STRING_CASE(VK_FORMAT_BC4_UNORM_BLOCK) |
| 652 | ENUM_TO_STRING_CASE(VK_FORMAT_BC4_SNORM_BLOCK) |
| 653 | ENUM_TO_STRING_CASE(VK_FORMAT_BC5_UNORM_BLOCK) |
| 654 | ENUM_TO_STRING_CASE(VK_FORMAT_BC5_SNORM_BLOCK) |
| 655 | ENUM_TO_STRING_CASE(VK_FORMAT_BC6H_UFLOAT_BLOCK) |
| 656 | ENUM_TO_STRING_CASE(VK_FORMAT_BC6H_SFLOAT_BLOCK) |
| 657 | ENUM_TO_STRING_CASE(VK_FORMAT_BC7_UNORM_BLOCK) |
| 658 | ENUM_TO_STRING_CASE(VK_FORMAT_BC7_SRGB_BLOCK) |
| 659 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK) |
| 660 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK) |
| 661 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK) |
| 662 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK) |
| 663 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK) |
| 664 | ENUM_TO_STRING_CASE(VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK) |
| 665 | ENUM_TO_STRING_CASE(VK_FORMAT_EAC_R11_UNORM_BLOCK) |
| 666 | ENUM_TO_STRING_CASE(VK_FORMAT_EAC_R11_SNORM_BLOCK) |
| 667 | ENUM_TO_STRING_CASE(VK_FORMAT_EAC_R11G11_UNORM_BLOCK) |
| 668 | ENUM_TO_STRING_CASE(VK_FORMAT_EAC_R11G11_SNORM_BLOCK) |
| 669 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_4x4_UNORM_BLOCK) |
| 670 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_4x4_SRGB_BLOCK) |
| 671 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x4_UNORM_BLOCK) |
| 672 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x4_SRGB_BLOCK) |
| 673 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x5_UNORM_BLOCK) |
| 674 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x5_SRGB_BLOCK) |
| 675 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x5_UNORM_BLOCK) |
| 676 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x5_SRGB_BLOCK) |
| 677 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x6_UNORM_BLOCK) |
| 678 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x6_SRGB_BLOCK) |
| 679 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x5_UNORM_BLOCK) |
| 680 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x5_SRGB_BLOCK) |
| 681 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x6_UNORM_BLOCK) |
| 682 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x6_SRGB_BLOCK) |
| 683 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x8_UNORM_BLOCK) |
| 684 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x8_SRGB_BLOCK) |
| 685 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x5_UNORM_BLOCK) |
| 686 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x5_SRGB_BLOCK) |
| 687 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x6_UNORM_BLOCK) |
| 688 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x6_SRGB_BLOCK) |
| 689 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x8_UNORM_BLOCK) |
| 690 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x8_SRGB_BLOCK) |
| 691 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x10_UNORM_BLOCK) |
| 692 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x10_SRGB_BLOCK) |
| 693 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x10_UNORM_BLOCK) |
| 694 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x10_SRGB_BLOCK) |
| 695 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x12_UNORM_BLOCK) |
| 696 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x12_SRGB_BLOCK) |
| 697 | ENUM_TO_STRING_CASE(VK_FORMAT_G8B8G8R8_422_UNORM) |
| 698 | ENUM_TO_STRING_CASE(VK_FORMAT_B8G8R8G8_422_UNORM) |
| 699 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM) |
| 700 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8R8_2PLANE_420_UNORM) |
| 701 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM) |
| 702 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8R8_2PLANE_422_UNORM) |
| 703 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM) |
| 704 | ENUM_TO_STRING_CASE(VK_FORMAT_R10X6_UNORM_PACK16) |
| 705 | ENUM_TO_STRING_CASE(VK_FORMAT_R10X6G10X6_UNORM_2PACK16) |
| 706 | ENUM_TO_STRING_CASE(VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16) |
| 707 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16) |
| 708 | ENUM_TO_STRING_CASE(VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16) |
| 709 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16) |
| 710 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16) |
| 711 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16) |
| 712 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16) |
| 713 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16) |
| 714 | ENUM_TO_STRING_CASE(VK_FORMAT_R12X4_UNORM_PACK16) |
| 715 | ENUM_TO_STRING_CASE(VK_FORMAT_R12X4G12X4_UNORM_2PACK16) |
| 716 | ENUM_TO_STRING_CASE(VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16) |
| 717 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16) |
| 718 | ENUM_TO_STRING_CASE(VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16) |
| 719 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16) |
| 720 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16) |
| 721 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16) |
| 722 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16) |
| 723 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16) |
| 724 | ENUM_TO_STRING_CASE(VK_FORMAT_G16B16G16R16_422_UNORM) |
| 725 | ENUM_TO_STRING_CASE(VK_FORMAT_B16G16R16G16_422_UNORM) |
| 726 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM) |
| 727 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16R16_2PLANE_420_UNORM) |
| 728 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM) |
| 729 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16R16_2PLANE_422_UNORM) |
| 730 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM) |
| 731 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG) |
| 732 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG) |
| 733 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG) |
| 734 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG) |
| 735 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG) |
| 736 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG) |
| 737 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG) |
| 738 | ENUM_TO_STRING_CASE(VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG) |
| 739 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT) |
| 740 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT) |
| 741 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT) |
| 742 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT) |
| 743 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT) |
| 744 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT) |
| 745 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT) |
| 746 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT) |
| 747 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT) |
| 748 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT) |
| 749 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT) |
| 750 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT) |
| 751 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT) |
| 752 | ENUM_TO_STRING_CASE(VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT) |
| 753 | ENUM_TO_STRING_CASE(VK_FORMAT_G8_B8R8_2PLANE_444_UNORM_EXT) |
| 754 | ENUM_TO_STRING_CASE(VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT) |
| 755 | ENUM_TO_STRING_CASE(VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT) |
| 756 | ENUM_TO_STRING_CASE(VK_FORMAT_G16_B16R16_2PLANE_444_UNORM_EXT) |
| 757 | ENUM_TO_STRING_CASE(VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT) |
| 758 | ENUM_TO_STRING_CASE(VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT) |
| 759 | ENUM_TO_STRING_CASE(VK_FORMAT_MAX_ENUM) |
| 760 | default: { |
| 761 | return String("Swapchain format ") + String::num_int64(int64_t(p_swapchain_format)); |
| 762 | } break; |
| 763 | } |
| 764 | } |