OS: Windows 10
Device: Oculus Quest 2
Runtime: SteamVR
OpenXR version: 1.0.22
OpenXR-SDK-Source version built: 1.0.26 (because, I don’t need eye tracking, and Oculus Quest 2 dosn’t has it)
Hi.
I create my own application to interact with VR and can you help me with it, pls? When I try to get system id, I get error code -2. I know that error code from xrGetSystemProperties, but I don’t use that function nowhere in code listed below, and this error code appiarances only after xrGetSystemId.
Maybe, somebody knows how to fix it?
Thx, in advance!
Some logs:
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader trampoline
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::FindManifestFiles - using registry-specified runtime file C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::CreateIfValid - attempting to load C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : RuntimeInterface::LoadRuntime succeeded loading runtime defined in manifest file C:\My\Steam\steamapps\common\SteamVR\steamxr_win64.json using interface version 1 and OpenXR API version 1.0
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : ApiLayerInterface::LoadApiLayers succeeded loading layer XR_APILAYER_MBUCCHIA_toolkit using interface version 1 and OpenXR API version 1.0
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : ApiLayerInterface::LoadApiLayers succeeded loading layer XR_APILAYER_LUNARG_core_validation using interface version 1 and OpenXR API version 1.0
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering LoaderInstance::CreateInstance
Core Validation output type: text, first time = true
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader terminator
Verbose [GENERAL | xrDestroyInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrDestroyInstance | OpenXR-Loader] : Completed loader terminator
Core Validation output type: text, first time = false
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Entering loader terminator
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader terminator
Info [GENERAL | xrCreateInstance | OpenXR-Loader] : LoaderInstance::CreateInstance succeeded with 2 layers enabled and runtime interface - created instance = 0x00000296268fa580
Verbose [GENERAL | xrCreateInstance | OpenXR-Loader] : Completed loader trampoline
[VALID_ERROR | VUID-XrSystemProperties-next-next | xrGetSystemProperties]: Invalid structure(s) in "next" chain for XrSystemProperties struct "next"
Objects:
[0] - XrInstance (0x00000296268fa580)
[VALID_ERROR | VUID-xrGetSystemProperties-properties-parameter | xrGetSystemProperties]: Command xrGetSystemProperties param properties is invalid
Objects:
[0] - XrInstance (0x00000296268fa580)
Error: Failed to get system: -2
Application code:
#include <vulkan/vulkan.h>
#define XR_USE_GRAPHICS_API_VULKAN
#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>
#include <iostream>
#include <cstring>
using namespace std;
XrInstance createInstance()
{
XrInstance instance;
static const char* const applicationName = "OpenXR Example";
static const unsigned int majorVersion = 0;
static const unsigned int minorVersion = 1;
static const unsigned int patchVersion = 0;
static const char* const layerNames[] = { "XR_APILAYER_LUNARG_core_validation" };
static const char* const extensionNames[] = {
"XR_KHR_vulkan_enable",
"XR_KHR_vulkan_enable2",
"XR_EXT_debug_utils"
};
XrInstanceCreateInfo instanceCreateInfo{};
instanceCreateInfo.type = XR_TYPE_INSTANCE_CREATE_INFO;
instanceCreateInfo.createFlags = 0;
strcpy(instanceCreateInfo.applicationInfo.applicationName, applicationName);
instanceCreateInfo.applicationInfo.applicationVersion = XR_MAKE_VERSION(majorVersion, minorVersion, patchVersion);
strcpy(instanceCreateInfo.applicationInfo.engineName, applicationName);
instanceCreateInfo.applicationInfo.engineVersion = XR_MAKE_VERSION(majorVersion, minorVersion, patchVersion);
instanceCreateInfo.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
instanceCreateInfo.enabledApiLayerCount = 1;
instanceCreateInfo.enabledApiLayerNames = layerNames;
instanceCreateInfo.enabledExtensionCount = sizeof(extensionNames) / sizeof(const char*);
instanceCreateInfo.enabledExtensionNames = extensionNames;
XrResult result = xrCreateInstance(&instanceCreateInfo, &instance);
if (result != XR_SUCCESS)
{
cerr << "Failed to create OpenXR instance: " << result << endl;
return XR_NULL_HANDLE;
}
return instance;
}
void destroyInstance(XrInstance instance)
{
xrDestroyInstance(instance);
}
XrSystemId getSystem(XrInstance instance)
{
XrSystemId systemID;
XrSystemGetInfo systemGetInfo{};
systemGetInfo.type = XR_TYPE_SYSTEM_GET_INFO;
systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
XrResult result = xrGetSystem(instance, &systemGetInfo, &systemID);
if (result != XR_SUCCESS)
{
cerr << "Failed to get system: " << result << endl;
return XR_NULL_SYSTEM_ID;
}
return systemID;
}
int main(int, char**)
{
XrInstance instance = createInstance();
XrSystemId system = getSystem(instance);
destroyInstance(instance);
return 0;
}