diff --git a/changes/sdk/pr.403.gh.OpenXR-SDK-Source.md b/changes/sdk/pr.403.gh.OpenXR-SDK-Source.md new file mode 100644 index 000000000..416f9c1b0 --- /dev/null +++ b/changes/sdk/pr.403.gh.OpenXR-SDK-Source.md @@ -0,0 +1 @@ +- Addition: hello_xr: Log Vulkan extensions requested by runtime and by app, visible when running with `--verbose`. diff --git a/src/tests/hello_xr/graphicsplugin_vulkan.cpp b/src/tests/hello_xr/graphicsplugin_vulkan.cpp index 753579316..f7707722f 100644 --- a/src/tests/hello_xr/graphicsplugin_vulkan.cpp +++ b/src/tests/hello_xr/graphicsplugin_vulkan.cpp @@ -1854,6 +1854,19 @@ struct VulkanGraphicsPluginLegacy : public VulkanGraphicsPlugin { virtual XrStructureType GetGraphicsBindingType() const override { return XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR; } virtual XrStructureType GetSwapchainImageType() const override { return XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR; } + static void LogVulkanExtensions(const std::string title, const std::vector& extensions, unsigned int start = 0) { + const std::string indentStr(1, ' '); + + Log::Write(Log::Level::Verbose, Fmt("%s: (%d)", title.c_str(), extensions.size() - start)); + for (auto ext : extensions) { + if (start) { + start--; + continue; + } + Log::Write(Log::Level::Verbose, Fmt("%s Name=%s", indentStr.c_str(), ext)); + } + } + virtual XrResult CreateVulkanInstanceKHR(XrInstance instance, const XrVulkanInstanceCreateInfoKHR* createInfo, VkInstance* vulkanInstance, VkResult* vulkanResult) override { PFN_xrGetVulkanInstanceExtensionsKHR pfnGetVulkanInstanceExtensionsKHR = nullptr; @@ -1869,11 +1882,14 @@ struct VulkanGraphicsPluginLegacy : public VulkanGraphicsPlugin { { // Note: This cannot outlive the extensionNames above, since it's just a collection of views into that string! std::vector extensions = ParseExtensionString(&extensionNames[0]); + LogVulkanExtensions("Vulkan Instance Extensions, requested by runtime", extensions); // Merge the runtime's request with the applications requests for (uint32_t i = 0; i < createInfo->vulkanCreateInfo->enabledExtensionCount; ++i) { extensions.push_back(createInfo->vulkanCreateInfo->ppEnabledExtensionNames[i]); } + LogVulkanExtensions("Vulkan Instance Extensions, requested by application", extensions, + extensions.size() - createInfo->vulkanCreateInfo->enabledExtensionCount); VkInstanceCreateInfo instInfo{VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO}; memcpy(&instInfo, createInfo->vulkanCreateInfo, sizeof(instInfo)); @@ -1907,11 +1923,14 @@ struct VulkanGraphicsPluginLegacy : public VulkanGraphicsPlugin { if (deviceExtensionNamesSize > 0) { extensions = ParseExtensionString(&deviceExtensionNames[0]); } + LogVulkanExtensions("Vulkan Device Extensions, requested by runtime", extensions); // Merge the runtime's request with the applications requests for (uint32_t i = 0; i < createInfo->vulkanCreateInfo->enabledExtensionCount; ++i) { extensions.push_back(createInfo->vulkanCreateInfo->ppEnabledExtensionNames[i]); } + LogVulkanExtensions("Vulkan Device Extensions, requested by application", extensions, + extensions.size() - createInfo->vulkanCreateInfo->enabledExtensionCount); VkPhysicalDeviceFeatures features{}; memcpy(&features, createInfo->vulkanCreateInfo->pEnabledFeatures, sizeof(features));