From 25a0a4463892aa3824c2218319ddcd8847aef0c4 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Thu, 7 Dec 2023 14:55:30 +0100 Subject: [PATCH] libandroid: xr: remove XR_KHR_android_create_instance from extension list --- src/libandroid/native_window.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/libandroid/native_window.c b/src/libandroid/native_window.c index 72d4cfa0..e35c8376 100644 --- a/src/libandroid/native_window.c +++ b/src/libandroid/native_window.c @@ -606,14 +606,19 @@ XrResult bionic_xrGetInstanceProperties(XrInstance instance, XrInstancePropertie XrResult bionic_xrCreateInstance(XrInstanceCreateInfo *createInfo, XrInstance *instance) { + /* so that we can use simpler (and faster) code, we replace extensions which we + * want to remove with this extension rather than delete them and copy the following + * extensions over + */ + const char *harmless_extension = "XR_KHR_opengl_es_enable"; + const char* extra_exts[] = { - "XR_KHR_opengl_es_enable", "XR_MNDX_egl_enable", "XR_EXT_local_floor", }; char **old_names = createInfo->enabledExtensionNames, **new_names; - int i, new_count = createInfo->enabledExtensionCount + ARRRAY_SIZE(extra_exts); + int new_count = createInfo->enabledExtensionCount + ARRRAY_SIZE(extra_exts); printf("eee xrCreateInstance\n"); @@ -621,14 +626,19 @@ XrResult bionic_xrCreateInstance(XrInstanceCreateInfo *createInfo, XrInstance *i new_names = malloc(sizeof(*new_names) * new_count); memcpy(new_names, old_names, createInfo->enabledExtensionCount * sizeof(*old_names)); - for (i = 0; i < ARRRAY_SIZE(extra_exts); ++i) + for(int i = 0; i < createInfo->enabledExtensionCount; i++) { + if(!strcmp(new_names[i], "XR_KHR_android_create_instance")) + new_names[i] = harmless_extension; + } + + for (int i = 0; i < ARRRAY_SIZE(extra_exts); ++i) new_names[createInfo->enabledExtensionCount + i] = extra_exts[i]; createInfo->enabledExtensionCount = new_count; createInfo->enabledExtensionNames = new_names; fprintf(stderr, "## xrCreateInstance: Enabled extensions:\n"); - for (i = 0; i < createInfo->enabledExtensionCount; ++i) + for (int i = 0; i < createInfo->enabledExtensionCount; ++i) fprintf(stderr, "## ---- %s\n", createInfo->enabledExtensionNames[i]); return xr_lazy_call("xrCreateInstance", createInfo, instance);