cancel
Showing results for 
Search instead for 
Did you mean: 

OpenXR 32bit runtime issues

morgg
Level 3
Hello,

I am trying to implement OpenXR support in a VR mod for an old game (X-Wing Alliance).
When I do the first call to xrEnumerateInstanceExtensionProperties(), it never returns.

Oculus loader indicates that the runtime was loaded correctly, but never completes the "trampoline" like it usually does.
Verbose [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : Entering loader trampoline
Warning [GENERAL | | OpenXR-Loader] : ReadLayerDataFilesInRegistry - failed to read registry location \ApiLayers\Implicit in either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::FindManifestFiles - using environment variable override runtime file F:\Oculus\Support\oculus-runtime\oculus_openxr_32.json
Info [GENERAL | | OpenXR-Loader] : RuntimeManifestFile::CreateIfValid - attempting to load F:\Oculus\Support\oculus-runtime\oculus_openxr_32.json
Info [GENERAL | xrEnumerateInstanceExtensionProperties | OpenXR-Loader] : RuntimeInterface::LoadRuntime succeeded loading runtime defined in manifest file F:\Oculus\Support\oculus-runtime\oculus_openxr_32.json using interface version 1 and OpenXR API version 1.0
Output captured from Oculus runtime show no specific error:
22/02 01:49:20.051 {INFO}    [CAPI] OVRInterface plugin library location: F:\Oculus\Support\oculus-runtime\client-plugins\x86
22/02 01:49:20.051 {INFO} [CAPI] OVRInterface plugin libraries:
<none>

22/02 01:49:20.051 {INFO} [CAPI] OVRInterface classes and interfaces:
Class Id: 0xb00b00067332ab1, class Name: OVRExtensionAddition
Interface Id: 0xb00b00053345520

22/02 01:49:20.057 {INFO} [CAPI] LibOVR module is located at F:\Oculus\Support\oculus-runtime\LibOVRRT32_1.dll
Procmon indicates that the last event from the process is a CreateFile for Oculus\Support\oculus-runtime\client-plugins\x86 that fails with PATH NOT FOUND, because it does not exist.

To try to bypass this issue and troubleshoot, if I try to xrCreateInstance() with a hardcoded array of extension names (only XR_KHR_D3D11_enable), without calling xrEnumerateInstanceExtensionProperties() first, it's successful with a warning:
22/02 02:02:21.196 {WARNING} [OXR] OXRInstanceData::CreateSession detected graphics device query was not called for XR_TYPE_GRAPHICS_BINDING_D3D11_KHR

But the subsequent call to xrCreateSession() fails, and returns an error code of -50, which even though missing in my version of the headers, it seems to be XR_ERROR_GRAPHICS_REQUIREMENTS_CALL_MISSING in the latest version of OpenXR.

The xrGetGraphicsRequirements* call was not made before calling xrCreateSession.


Unfortunately, , I could not find any documentation about the allegedly required xrGetGraphicsRequirements() call.

Any ideas of what is causing these issues, or to put me in the right direction?

My environment:
Oculus runtime: 26.0.0.39.502
OpenXR Loader 1.0.10 (from Nuget package)

Note: I have successfully run some examples compiled 32bit mode and with Oculus runtime, so that should not be the issue. I assume it's something in the specific app context which is a bit special because it's a dll wrapping DirectDraw (ddraw.dll) to hook a 20 year old game engine and use Direct3D.

Thanks in advance!
1 ACCEPTED SOLUTION

Accepted Solutions

johnkearney
Level 3

@morgg - looking at your callstack, it seems like xrEnumerateInstanceExtensionProperties is being called from DLLMain. This will result in undefined behavior (at least) with Windows. There are restrictions of what can be called from DLLMain: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices

Is there so other place you can call this code from?

Thanks,
John

View solution in original post

4 REPLIES 4

johnkearney
Level 3

Hi @morgg ,

This issue does not look like it is specific to 32 bit or specific to Oculus.
Generally before calling xrCreateSession you'll need to call an xrGetGraphicsRequirement function. (There was an different less specific error for this case before OpenXR 1.0.12 but this has always been a requirement.)

For your case, I'd suggest looking at a Sample OpenXR application. Here is one example - d3d11 in hello_xr: https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/src/tests/hello_xr/graphicsplugin_d3d1...

Hope that helps,
John

morgg
Level 3

Thanks for the reply John.

 

Indeed, the second issue I explained (missing xrGetGraphicsRequirements call) was my code's fault, and I realized what I was missing. I also proposed some clarification to the specification so it may be easer to understand for other newbies like me 🙂

But the first issue I was reporting (xrEnumerateInstanceExtensionProperties() never returning) is still happening.

If I just skip this part and hardcode the extensions requested, the Instance can be created without issues.

 

AFAIK, there is not much to do before the call to xrEnumerateInstanceExtensionProperties where I could have screwed up... This is the relevant excerpt of code dealing with OpenXR before the problem:

 

#define XR_USE_PLATFORM_WIN32
#define XR_USE_GRAPHICS_API_D3D11

#include <openxr/openxr.h>
#include <openxr/openxr_platform.h>

uint32_t ext_count = 0;
XrResult xrResult = XR_ERROR_RUNTIME_FAILURE;
xrResult = xrEnumerateInstanceExtensionProperties(nullptr, 0, &ext_count, nullptr);

 

I am able to run the SingleFileExample I am using as a guideline with the Oculus 32bit runtime, but for some reason in my "app" (a wrapper to run an old DirectDraw game in Direct3D11), with the same steps (related to OpenXR) it does not work.

 

Is there any other more verbose log that I could check, or some debugging symbols for the runtime so that I can see where it gets stuck??

 

This is the call stack when I pause it:

 	ntdll.dll!_NtWaitForMultipleObjects@20()	Unknown
 	KernelBase.dll!WaitForMultipleObjectsEx()	Unknown
 	KernelBase.dll!_WaitForMultipleObjects@16()	Unknown
>	LibOVRRT32_1.dll!07f8b177()	Unknown
 	LibOVRRT32_1.dll![Frames below may be incorrect and/or missing, no symbols loaded for LibOVRRT32_1.dll]	Unknown
 	LibOVRRT32_1.dll!07f88d93()	Unknown
 	LibOVRRT32_1.dll!07ef0a71()	Unknown
 	LibOVRRT32_1.dll!07ef1daf()	Unknown
 	LibOVRRT32_1.dll!07e7ed25()	Unknown
 	ntdll.dll!_bsearch()	Unknown
 	LibOVRRT32_1.dll!07fa7c14()	Unknown
 	LibOVRRT32_1.dll!07fa7b20()	Unknown
 	LibOVRRT32_1.dll!07e735c2()	Unknown
 	openxr_loader.dll!7a357dbd()	Unknown
 	openxr_loader.dll!7a358ec1()	Unknown
 	openxr_loader.dll!7a340a0c()	Unknown
 	ddraw.dll!VRRendererOpenXR::is_available() Line 36	C++
 	ddraw.dll!DllMain(HINSTANCE__ * hModule, unsigned long ul_reason_for_call, void * lpReserved) Line 1149	C++
 	ddraw.dll!dllmain_dispatch(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 200	C++
 	ddraw.dll!_DllMainCRTStartup(HINSTANCE__ * const instance, const unsigned long reason, void * const reserved) Line 253	C++
 	ntdll.dll!_LdrxCallInitRoutine@16()	Unknown
 	ntdll.dll!LdrpCallInitRoutine()	Unknown
 	ntdll.dll!LdrpInitializeNode()	Unknown
 	ntdll.dll!LdrpInitializeGraphRecurse()	Unknown
 	ntdll.dll!LdrpInitializeGraphRecurse()	Unknown
 	ntdll.dll!_LdrpInitializeProcess@8()	Unknown
 	ntdll.dll!_LdrpInitialize()	Unknown
 	ntdll.dll!LdrInitializeThunk()	Unknown

 

Any ideas?

Thanks!

 

johnkearney
Level 3

@morgg - looking at your callstack, it seems like xrEnumerateInstanceExtensionProperties is being called from DLLMain. This will result in undefined behavior (at least) with Windows. There are restrictions of what can be called from DLLMain: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-best-practices

Is there so other place you can call this code from?

Thanks,
John

View solution in original post

morgg
Level 3

I am hacking someone else's code, so I will see what I can do 🙂

Thanks for the help @johnkearney !