diff --git a/app/src/main/cpp/questxr/quest_xr.cpp b/app/src/main/cpp/questxr/quest_xr.cpp index 26acbcb18..3dbfc5e67 100644 --- a/app/src/main/cpp/questxr/quest_xr.cpp +++ b/app/src/main/cpp/questxr/quest_xr.cpp @@ -104,6 +104,8 @@ private: DroidDeckXrHand inputs_[2]{}; PFN_xrConvertTimeToTimespecTimeKHR convertTime_ = nullptr; bool timespecSupported_ = false; + PFN_xrPerfSettingsSetPerformanceLevelEXT setPerformance_ = nullptr; + bool performanceSupported_ = false; XrPath hands_[2]{}; XrSpace handSpaces_[2]{}; XrSpaceLocation head_{XR_TYPE_SPACE_LOCATION}; @@ -252,9 +254,12 @@ private: for (const auto &extension : extensions) { if (!std::strcmp(extension.extensionName, XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME)) timespecSupported_ = true; + if (!std::strcmp(extension.extensionName, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME)) + performanceSupported_ = true; } std::vector enabled{XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME, XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME}; if (timespecSupported_) enabled.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME); + if (performanceSupported_) enabled.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); XrInstanceCreateInfoAndroidKHR androidInfo{XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; androidInfo.applicationVM = app_->activity->vm; androidInfo.applicationActivity = app_->activity->clazz; @@ -266,6 +271,11 @@ private: create.enabledExtensionCount = enabled.size(); create.enabledExtensionNames = enabled.data(); check(xrCreateInstance(&create, &instance_), "xrCreateInstance"); + if (performanceSupported_) { + XrResult result = xrGetInstanceProcAddr(instance_, "xrPerfSettingsSetPerformanceLevelEXT", + reinterpret_cast(&setPerformance_)); + if (XR_FAILED(result)) setPerformance_ = nullptr; + } if (timespecSupported_) check(xrGetInstanceProcAddr(instance_, "xrConvertTimeToTimespecTimeKHR", reinterpret_cast(&convertTime_)), "time conversion entrypoint"); XrSystemGetInfo systemInfo{XR_TYPE_SYSTEM_GET_INFO}; @@ -590,12 +600,23 @@ private: XrSessionBeginInfo begin{XR_TYPE_SESSION_BEGIN_INFO}; begin.primaryViewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO; check(xrBeginSession(session_, &begin), "xrBeginSession"); running_ = true; + if (setPerformance_) { + for (auto domain : {XR_PERF_SETTINGS_DOMAIN_CPU_EXT, XR_PERF_SETTINGS_DOMAIN_GPU_EXT}) { + XrResult request = setPerformance_(session_, domain, XR_PERF_SETTINGS_LEVEL_SUSTAINED_HIGH_EXT); + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "sustained performance domain=%d result=%d", domain, request); + } + } } else if (state_ == XR_SESSION_STATE_STOPPING) { check(xrEndSession(session_), "xrEndSession"); running_ = false; if (quitRequested_) exit_ = true; } else if (state_ == XR_SESSION_STATE_EXITING || state_ == XR_SESSION_STATE_LOSS_PENDING) exit_ = true; health(); } else if (event.type == XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING) exit_ = true; + else if (event.type == XR_TYPE_EVENT_DATA_PERF_SETTINGS_EXT) { + const auto &performance = *reinterpret_cast(&event); + __android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "performance domain=%d subdomain=%d level=%d->%d", + performance.domain, performance.subDomain, performance.fromLevel, performance.toLevel); + } event = {XR_TYPE_EVENT_DATA_BUFFER}; } check(result, "xrPollEvent"); diff --git a/docs/quest.md b/docs/quest.md index 86d420cdc..8d4b2f4cd 100644 --- a/docs/quest.md +++ b/docs/quest.md @@ -155,6 +155,11 @@ the previous sRGB source upload darkened them to approximately 13, 55, 134 and 190. The transport remains 8-bit SDR; this correction does not add HDR or higher precision gradients. +When available, `XR_EXT_performance_settings` requests sustained-high CPU and GPU +performance for the running OpenXR session. These are runtime-managed hints; +device power and thermal policies remain authoritative. Unsupported or rejected +requests do not prevent startup. This does not change render resolution. + ### Experimental flat games in SteamVR Start SteamVR first, then add `droiddeck-steamvr-game %command%` to a flat