Prefer OpenXR for desktop XR policy

This commit is contained in:
2026-06-05 16:06:52 +02:00
parent 308fb13075
commit bdd7a32ff5
8 changed files with 149 additions and 20 deletions

View File

@@ -209,6 +209,15 @@ void ensure_directory(const std::string& path)
CreateDirectoryA(path.c_str(), NULL);
}
[[nodiscard]] pp::platform::XrRuntimeSelection select_windows_xr_runtime() noexcept
{
// DEBT-0061: OpenXR is the target backend; Windows only exposes the retained OpenVR bridge today.
return pp::platform::select_desktop_xr_runtime(
false,
true,
true);
}
std::string build_supported_files_filter(const std::vector<std::string>& types)
{
std::string filter = "Supported Files (";
@@ -442,12 +451,33 @@ public:
[[nodiscard]] bool start_vr_mode() override
{
return win32_vr_start();
const auto runtime = select_windows_xr_runtime();
if (runtime.backend == pp::platform::XrRuntimeBackend::openvr)
{
active_xr_runtime_backend_ = pp::platform::XrRuntimeBackend::none;
if (win32_vr_start())
active_xr_runtime_backend_ = runtime.backend;
return active_xr_runtime_backend_ == runtime.backend;
}
if (runtime.backend == pp::platform::XrRuntimeBackend::openxr)
LOG("OpenXR runtime selected but the Windows OpenXR backend is not wired yet");
return false;
}
void stop_vr_mode() override
{
win32_vr_stop();
auto runtime = active_xr_runtime_backend_;
if (runtime == pp::platform::XrRuntimeBackend::none)
runtime = select_windows_xr_runtime().backend;
if (runtime == pp::platform::XrRuntimeBackend::openvr)
win32_vr_stop();
else if (runtime == pp::platform::XrRuntimeBackend::openxr)
LOG("OpenXR runtime selected but the Windows OpenXR stop path is not wired yet");
active_xr_runtime_backend_ = pp::platform::XrRuntimeBackend::none;
}
void pick_image(pp::platform::PickedPathCallback callback) override
@@ -572,6 +602,9 @@ public:
(void)suggested_name;
callback(std::string(path), false);
}
private:
pp::platform::XrRuntimeBackend active_xr_runtime_backend_ = pp::platform::XrRuntimeBackend::none;
};
}