Ralith / openxrs

OpenXR bindings for Rust
Apache License 2.0
282 stars 59 forks source link

Dynamically loading a runtime does not work per spec #90

Closed nwessing closed 3 years ago

nwessing commented 3 years ago

The Entry::load_from function seems to be loading function pointers in a non spec compliant way. Looking at this code: https://github.com/Ralith/openxrs/blob/master/openxr/src/entry.rs#L67

Take a look at the documentation for runtime loading: https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/specification/loader/runtime.adoc#loaderruntime-interface-negotiation

It looks to me like an openxr implementation should only export a single function XrNegotiateRuntimeRequest and then this function will provide a function pointer to load the remaining symbols.

I ran into this when trying to manually load Steam's OpenXR implementation. Running dumpbin on vrclient_x64.dll reveals that xrNegotiateLoaderRuntimeInterface is the only exported OpenXR function.

Ralith commented 3 years ago

Thanks for the issue! I believe there is some confusion here. An OpenXR implementation is software that conforms with the OpenXR specification. A runtime as defined in https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/specification/loader/runtime.adoc is not, strictly speaking, an OpenXR implementation; it is a component of the OpenXR implementation provided by the OpenXR loader. The document you linked is not part of the normative specification at all. As, indeed, it states explicitly:

This command is not a part of the OpenXR API itself, only a private interface between the loader and runtimes for version 1 and higher interfaces

(emphasis added)

nwessing commented 3 years ago

Sorry about the confusion, I am new to OpenXR trying to learn more about it and clearly did not understand it as well as I had thought! In the context of this crate, what would be the correct way to choose the OpenXR implementation (or am I looking for a runtime?) at runtime.

Ralith commented 3 years ago

OpenXR does not define a mechanism for applications to select between multiple runtimes. In environments where multiple runtimes may be available, it's the OpenXR loader's responsibility to select the appropriate one, which it does according to the procedures documented at https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/master/specification/loader/runtime.adoc#runtime-discovery. If a user wants a specific runtime, it's their responsibility to configure their system such that it is the active runtime.