Prefer OpenXR for desktop XR policy
This commit is contained in:
@@ -23,6 +23,34 @@ PlatformFamily current_platform_family() noexcept
|
||||
#endif
|
||||
}
|
||||
|
||||
const char* xr_runtime_backend_name(XrRuntimeBackend backend) noexcept
|
||||
{
|
||||
switch (backend)
|
||||
{
|
||||
case XrRuntimeBackend::openxr:
|
||||
return "openxr";
|
||||
case XrRuntimeBackend::openvr:
|
||||
return "openvr";
|
||||
case XrRuntimeBackend::none:
|
||||
default:
|
||||
return "none";
|
||||
}
|
||||
}
|
||||
|
||||
XrRuntimeSelection select_desktop_xr_runtime(
|
||||
bool openxr_available,
|
||||
bool openvr_available,
|
||||
bool allow_legacy_openvr_fallback) noexcept
|
||||
{
|
||||
if (openxr_available)
|
||||
return { XrRuntimeBackend::openxr, false };
|
||||
|
||||
if (allow_legacy_openvr_fallback && openvr_available)
|
||||
return { XrRuntimeBackend::openvr, true };
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool platform_deletes_recorded_files_on_clear(PlatformFamily family) noexcept
|
||||
{
|
||||
return family == PlatformFamily::ios || family == PlatformFamily::macos;
|
||||
|
||||
@@ -17,8 +17,25 @@ enum class PlatformFamily {
|
||||
webgl,
|
||||
};
|
||||
|
||||
enum class XrRuntimeBackend {
|
||||
none,
|
||||
openxr,
|
||||
openvr,
|
||||
};
|
||||
|
||||
struct XrRuntimeSelection {
|
||||
XrRuntimeBackend backend = XrRuntimeBackend::none;
|
||||
bool uses_legacy_openvr_fallback = false;
|
||||
};
|
||||
|
||||
[[nodiscard]] PlatformFamily current_platform_family() noexcept;
|
||||
|
||||
[[nodiscard]] const char* xr_runtime_backend_name(XrRuntimeBackend backend) noexcept;
|
||||
[[nodiscard]] XrRuntimeSelection select_desktop_xr_runtime(
|
||||
bool openxr_available,
|
||||
bool openvr_available,
|
||||
bool allow_legacy_openvr_fallback) noexcept;
|
||||
|
||||
[[nodiscard]] bool platform_deletes_recorded_files_on_clear(PlatformFamily family) noexcept;
|
||||
[[nodiscard]] bool platform_publishes_exported_images(PlatformFamily family) noexcept;
|
||||
[[nodiscard]] bool platform_flushes_persistent_storage(PlatformFamily family) noexcept;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user