Skip to content

Commit

Permalink
hello_xr: add debug output for Vulkan extensions from runtime vs. app
Browse files Browse the repository at this point in the history
Adding some extra debug output when "--verbose --graphics Vulkan(2)" is
specified, to list which Vulkan instance and Vulkan device extensions
were requested by the XR runtime and which were requested by the
application.

I found this quite useful to have to get the current wineopenxr
implementation running without Steam. Steam uses Windows
registry keys at the moment to relay Vulkan extensions needed by the XR
runtime to DXVK. Without Steam I need to populate the registry keys
manually at the moment.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Reviewed-by: Rylie Pavlik <rylie.pavlik@collabora.com>
  • Loading branch information
T-X authored and rpavlik committed Sep 23, 2024
1 parent d795b97 commit 2c9b058
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions changes/sdk/pr.403.gh.OpenXR-SDK-Source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Addition: hello_xr: Log Vulkan extensions requested by runtime and by app, visible when running with `--verbose`.
19 changes: 19 additions & 0 deletions src/tests/hello_xr/graphicsplugin_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>& 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;
Expand All @@ -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<const char*> 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));
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 2c9b058

Please sign in to comment.