Skip to content

Instantly share code, notes, and snippets.

@fredemmott
Last active October 4, 2023 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredemmott/81d72c2250c7501ad86516895ced2ccd to your computer and use it in GitHub Desktop.
Save fredemmott/81d72c2250c7501ad86516895ced2ccd to your computer and use it in GitHub Desktop.
diff --git a/src/APILayer/APILayer_loader.cpp b/src/APILayer/APILayer_loader.cpp
index f21ecb7..1041077 100644
--- a/src/APILayer/APILayer_loader.cpp
+++ b/src/APILayer/APILayer_loader.cpp
@@ -312,17 +312,27 @@ static XrResult xrCreateApiLayerInstance(
XrInstance dummyInstance {};
{
- // Workaround UltraLeap bug: it should be possible to enumerate
- // extensions without an XrInstance, but ultraleap's API layer
- // breaks this.
+ // While the OpenXR specification says that
+ // `xrEnumerateInstanceExtensionProperties()` does not require an
+ // `XrInstance`, if there is a 'next' API layer, it will not be able to
+ // retrieve the extension list from the runtime or an n+2 API layer unless
+ // an instance has been created, as it won't have the next
+ // `xrGetInstanceProcAddr()` pointer yet.
XrInstanceCreateInfo dummyInfo {
- .type = XR_TYPE_INSTANCE_CREATE_INFO,
- .applicationInfo = {
- .applicationName = "FREDEMMOTT_HTCC ultraleap compat hack",
- .applicationVersion = 1,
- .apiVersion = XR_CURRENT_API_VERSION,
- },
- };
+ .type = XR_TYPE_INSTANCE_CREATE_INFO,
+ .applicationInfo = {
+ .applicationVersion = originalInfo->applicationInfo.applicationVersion,
+ .apiVersion = XR_CURRENT_API_VERSION,
+ },
+ };
+ {
+ auto [it, count] = std::format_to_n(
+ dummyInfo.applicationInfo.applicationName,
+ XR_MAX_APPLICATION_NAME_SIZE - 1,
+ "FREDEMMOTT_HTCC Init: {}",
+ originalInfo->applicationInfo.applicationName);
+ *it = '\0';
+ }
auto dummyLayerInfo = *layerInfo;
dummyLayerInfo.nextInfo = dummyLayerInfo.nextInfo->next;
layerInfo->nextInfo->nextCreateApiLayerInstance(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment