From f97c241f9f04682fe01ac868a60bdd0b3baa0625 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Tue, 26 Aug 2025 20:16:18 +0200 Subject: [PATCH] Don't request promoted extensions --- client/application.cpp | 6 +--- client/xr/instance.cpp | 74 +++++++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/client/application.cpp b/client/application.cpp index 1ab926a2..22de1aee 100644 --- a/client/application.cpp +++ b/client/application.cpp @@ -71,7 +71,6 @@ struct interaction_profile std::string profile_name; std::vector required_extensions; XrVersion min_version = XR_MAKE_VERSION(1, 0, 0); - XrVersion max_version = XR_MAKE_VERSION(2, 0, 0); // exclusive std::vector input_sources; bool available; }; @@ -139,7 +138,6 @@ static std::vector interaction_profiles{ interaction_profile{ .profile_name = "/interaction_profiles/facebook/touch_controller_pro", .required_extensions = {XR_FB_TOUCH_CONTROLLER_PRO_EXTENSION_NAME}, - .max_version = XR_MAKE_VERSION(1, 1, 0), .input_sources = { "/user/hand/left/output/haptic", "/user/hand/left/output/haptic_trigger_fb", @@ -252,7 +250,6 @@ static std::vector interaction_profiles{ interaction_profile{ .profile_name = "/interaction_profiles/meta/touch_controller_plus", .required_extensions = {XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME}, - .max_version = XR_MAKE_VERSION(1, 1, 0), .input_sources = { "/user/hand/left/output/haptic", "/user/hand/right/output/haptic", @@ -997,8 +994,7 @@ void application::initialize_actions() for (auto & profile: interaction_profiles) { profile.available = std::ranges::all_of(profile.required_extensions, [&](auto & ext) { return xr_instance.has_extension(ext); }) and - profile.min_version <= api_version and - profile.max_version > api_version; + profile.min_version <= api_version; if (profile.profile_name.ends_with("khr/simple_controller")) { diff --git a/client/xr/instance.cpp b/client/xr/instance.cpp index 4f95679d..5522341d 100644 --- a/client/xr/instance.cpp +++ b/client/xr/instance.cpp @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include #include @@ -42,7 +44,37 @@ static XrBool32 debug_callback( return XR_FALSE; } -static std::pair create_instance(XrInstanceCreateInfo & info) +static const std::map>> promoted_extensions = { + { + XR_MAKE_VERSION(1, 1, 0), + { + XR_KHR_LOCATE_SPACES_EXTENSION_NAME, + XR_KHR_MAINTENANCE1_EXTENSION_NAME, + XR_EXT_HP_MIXED_REALITY_CONTROLLER_EXTENSION_NAME, + XR_EXT_LOCAL_FLOOR_EXTENSION_NAME, + XR_EXT_PALM_POSE_EXTENSION_NAME, + XR_EXT_SAMSUNG_ODYSSEY_CONTROLLER_EXTENSION_NAME, + XR_EXT_UUID_EXTENSION_NAME, + XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME, + XR_FB_TOUCH_CONTROLLER_PRO_EXTENSION_NAME, + XR_HTC_VIVE_COSMOS_CONTROLLER_INTERACTION_EXTENSION_NAME, + XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME, + XR_META_TOUCH_CONTROLLER_PLUS_EXTENSION_NAME, + XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME, + XR_VARJO_QUAD_VIEWS_EXTENSION_NAME, + }, + }, +}; + +static bool is_promoted(XrVersion version, const char * extension) +{ + auto it = promoted_extensions.find(XR_MAKE_VERSION(XR_VERSION_MAJOR(version), XR_VERSION_MINOR(version), 0)); + if (it == promoted_extensions.end()) + return false; + return it->second.contains(extension); +} + +static std::pair create_instance(XrInstanceCreateInfo & info, std::vector & in_extensions) { XrResult res; for (XrVersion version: { @@ -50,11 +82,21 @@ static std::pair create_instance(XrInstanceCreateInfo & i XR_API_VERSION_1_0, }) { + std::vector extensions; + std::ranges::copy_if( + in_extensions, + std::back_inserter(extensions), + [version](const char * ext) { return not is_promoted(version, ext); }); info.applicationInfo.apiVersion = version; + info.enabledExtensionNames = extensions.data(); + info.enabledExtensionCount = extensions.size(); XrInstance inst; res = xrCreateInstance(&info, &inst); if (XR_SUCCEEDED(res)) + { + std::swap(in_extensions, extensions); return {version, inst}; + } spdlog::info("Failed to create OpenXR instance version {}: {}", xr::to_string(version), xr::to_string(res)); @@ -129,20 +171,6 @@ xr::instance::instance(std::string_view application_name, std::vector