VR/zh: Difference between revisions
Created page with "为了在 SteamVR 以外的任何平台上运行 OpenVR 游戏,您需要配置 <code>~/.config/openvr/openvrpaths.vrpath</code> 中定义的 OpenVR 运行时路径。一个可靠的方法是使用 Home Manager 创建此文件。" Tags: Mobile edit Mobile web edit |
Created page with "WiVRn 是一款基于 Monado 构建的 OpenXR 流媒体应用程序。它能够将独立的 VR 头戴设备无线连接到 Linux 计算机。如果您的头戴设备不是无线的,请查阅 Monado。 WiVRn 模块的示例用法:" |
||
Line 67: | Line 67: | ||
为了在 SteamVR 以外的任何平台上运行 OpenVR 游戏,您需要配置 <code>~/.config/openvr/openvrpaths.vrpath</code> 中定义的 OpenVR 运行时路径。一个可靠的方法是使用 [[Special:MyLanguage/Home Manager|Home Manager]] 创建此文件。 | 为了在 SteamVR 以外的任何平台上运行 OpenVR 游戏,您需要配置 <code>~/.config/openvr/openvrpaths.vrpath</code> 中定义的 OpenVR 运行时路径。一个可靠的方法是使用 [[Special:MyLanguage/Home Manager|Home Manager]] 创建此文件。 | ||
{{Warning|旧版本的 Proton 将始终查询当前的 OpenVR 和 OpenXR 运行时。如果您使用 OpenComposite,并且它无法初始化 OpenXR 环境,Proton 将无法启动。解决方法是删除 ~/.config/openvr/openvrpaths.vrpath 文件,然后重试启动游戏。}} | |||
{{Warning| | |||
如果此文件未设置为只读,SteamVR 将添加其运行时路径,因此可以使用 Home Manager。 | |||
启用 OpenComposite 的示例配置可能如下所示: | |||
{{file|~/.config/home-manager/home.nix|nix|3=# For Monado: | {{file|~/.config/home-manager/home.nix|nix|3=# For Monado: | ||
Line 105: | Line 99: | ||
'';}} | '';}} | ||
如果您计划在 Steam 上玩任何 OpenVR 游戏或通过 Proton 游玩 OpenXR 游戏,则必须以这种方式使用 OpenComposite。在大多数情况下,您还必须允许 Steam 运行时访问您的 OpenXR 运行时的 Socket 路径,方法是使用以下 Steam 上 XR 应用程序的启动选项:<code>env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%</code>。此示例适用于 Monado,其他 XR 运行时可能有所不同。 | |||
== WiVRn == | == WiVRn == | ||
WiVRn 是一款基于 Monado 构建的 OpenXR 流媒体应用程序。它能够将独立的 VR 头戴设备无线连接到 Linux 计算机。如果您的头戴设备不是无线的,请查阅 [[Special:MyLanguage/VR#Monado|Monado]]。 | |||
WiVRn | WiVRn 模块的示例用法: | ||
<div lang="en" dir="ltr" class="mw-content-ltr"> | <div lang="en" dir="ltr" class="mw-content-ltr"> |
Revision as of 10:38, 8 October 2025
Monado
Monado 是一个开源的 OpenXR 运行时。它使用内置驱动程序支持各种硬件,使其可以运行任何 OpenXR 程序,并且在 OpenComposite 的帮助下,还可以运行大多数 OpenVR 应用程序。
可以使用其 NixOS 选项 services.monado.enable
配置 Monado:
services.monado = {
enable = true;
defaultRuntime = true; # Register as default OpenXR runtime
};
为了配置 Monado,您可能需要添加其他环境变量:
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
};
配置完成后,Monado 可以在 systemd 用户会话中启动和停止。
例如,以下命令将启动 Monado,然后打印其日志输出:
$ systemctl --user start monado.service
$ journalctl --user --follow --unit monado.service
手部追踪
您可能会注意到,由于缺少手部追踪数据,运行 monado-services
会失败。有两种方法可以解决这个问题:完全禁用手部追踪,或下载手部追踪数据。
要禁用手部追踪,请修改环境变量以包含 WMR_HANDTRACKING = "0";
,使其如下所示。
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
WMR_HANDTRACKING = "0";
};
要使手部追踪功能正常工作,您需要启用 git-lfs
。启用 git-lfs
的标准方法是通过以下配置
programs.git = {
enable = true;
lfs.enable = true;
};
确保 git-lfs
功能启用后,运行以下命令并重新启动 monado-service
$ mkdir -p ~/.local/share/monado
$ cd ~/.local/share/monado
$ git clone https://gitlab.freedesktop.org/monado/utilities/hand-tracking-models
For further information about available environment variables and tweaks, read the Linux VR Adventures wiki and the Monado documentation about environment variables
OpenComposite
OpenComposite is a compatibility layer for running OpenVR applications on an OpenXR runtime like Monado. It is comparable to tools like DXVK or vkd3d, but for translating OpenVR calls to OpenXR.
为了在 SteamVR 以外的任何平台上运行 OpenVR 游戏,您需要配置 ~/.config/openvr/openvrpaths.vrpath
中定义的 OpenVR 运行时路径。一个可靠的方法是使用 Home Manager 创建此文件。
如果此文件未设置为只读,SteamVR 将添加其运行时路径,因此可以使用 Home Manager。
启用 OpenComposite 的示例配置可能如下所示:
# For Monado:
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json";
# For WiVRn v0.22 and below:
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.wivrn}/share/openxr/1/openxr_wivrn.json";
xdg.configFile."openvr/openvrpaths.vrpath".text = ''
{
"config" :
[
"${config.xdg.dataHome}/Steam/config"
],
"external_drivers" : null,
"jsonid" : "vrpathreg",
"log" :
[
"${config.xdg.dataHome}/Steam/logs"
],
"runtime" :
[
"${pkgs.opencomposite}/lib/opencomposite"
],
"version" : 1
}
'';
如果您计划在 Steam 上玩任何 OpenVR 游戏或通过 Proton 游玩 OpenXR 游戏,则必须以这种方式使用 OpenComposite。在大多数情况下,您还必须允许 Steam 运行时访问您的 OpenXR 运行时的 Socket 路径,方法是使用以下 Steam 上 XR 应用程序的启动选项:env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%
。此示例适用于 Monado,其他 XR 运行时可能有所不同。
WiVRn
WiVRn 是一款基于 Monado 构建的 OpenXR 流媒体应用程序。它能够将独立的 VR 头戴设备无线连接到 Linux 计算机。如果您的头戴设备不是无线的,请查阅 Monado。 WiVRn 模块的示例用法:
services.wivrn = {
enable = true;
openFirewall = true;
# Write information to /etc/xdg/openxr/1/active_runtime.json, VR applications
# will automatically read this and work with WiVRn (Note: This does not currently
# apply for games run in Valve's Proton)
defaultRuntime = true;
# Run WiVRn as a systemd service on startup
autoStart = true;
# Config for WiVRn (https://github.com/WiVRn/WiVRn/blob/master/docs/configuration.md)
config = {
enable = true;
json = {
# 1.0x foveation scaling
scale = 1.0;
# 100 Mb/s
bitrate = 100000000;
encoders = [
{
encoder = "vaapi";
codec = "h265";
# 1.0 x 1.0 scaling
width = 1.0;
height = 1.0;
offset_x = 0.0;
offset_y = 0.0;
}
];
};
};
};
Like Monado, you will also have to add the launch argument for WiVRn to allow access to the socket: PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/wivrn/comp_ipc %command%
Envision
Envision is an orchestrator for the FOSS VR stack. It handles the building and configuration of Monado, WiVRn, OpenComposite, and other utilities of the FOSS VR stack such as the Lighthouse driver, OpenHMD, Survive, and WMR. You can enable it with the Envision module:
programs.envision = {
enable = true;
openFirewall = true; # This is set true by default
};
SteamVR
SteamVR is a proprietary OpenVR runtime with compatibility for OpenXR. It is part of Steam and doesn't need any additional setup on NixOS apart from enabling Steam.
After installing SteamVR through Steam and plugging in a SteamVR-compatible headset, SteamVR should work for the most part.
On initial setup, SteamVR will ask for elevated permissions, to set up a file capability for one of its binaries. This is needed to allow asynchronous reprojection to work. Clients need the CAP_SYS_NICE
capability to acquire a high-priority context, which is a requirement for asynchronous reprojection.
修补 AMDGPU 以允许高优先级队列
By applying this patch, the AMDGPU kernel driver will ignore process privileges and allow any application to create high priority contexts.
作为 NixOS 内核补丁进行应用
To workaround the CAP_SYS_NICE
requirement, we can apply a kernel patch using the following NixOS configuration snippet:
boot.kernelPatches = [
{
name = "amdgpu-ignore-ctx-privileges";
patch = pkgs.fetchpatch {
name = "cap_sys_nice_begone.patch";
url = "https://github.com/Frogging-Family/community-patches/raw/master/linux61-tkg/cap_sys_nice_begone.mypatch";
hash = "sha256-Y3a0+x2xvHsfLax/uwycdJf3xLxvVfkfDVqjkxNaYEo=";
};
}
];
It is also possible to just patch amdgpu and build it as an out-of-tree module, as described in Linux_kernel#Patching_a_single_In-tree_kernel_module
wlx-overlay-s
wlx-overlay-s is a lightweight OpenXR/OpenVR overlay for Wayland and X11 desktops. It works with SteamVR as well as Monado/WiVRn natively.
SteamVR 自动启动
# Run wlx-overlay-s and replace any running instance
$ wlx-overlay-s --replace