VR: Difference between revisions
imported>Scrumplex Document Monado and OpenComposite |
Haruki7049 (talk | contribs) Marked this version for translation |
||
(24 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
== Monado == | <translate> | ||
== Monado == <!--T:1--> | |||
<!--T:2--> | |||
[https://monado.freedesktop.org/ Monado] is an open source OpenXR runtime. It offers support for a variety of hardware using its built-in drivers and can be used to run any OpenXR and, with the help of OpenComposite, most OpenVR applications. | [https://monado.freedesktop.org/ Monado] is an open source OpenXR runtime. It offers support for a variety of hardware using its built-in drivers and can be used to run any OpenXR and, with the help of OpenComposite, most OpenVR applications. | ||
<!--T:3--> | |||
Monado can be configured using its NixOS options since 24.05: | Monado can be configured using its NixOS options since 24.05: | ||
</translate> | |||
{{file|/etc/nixos/configuration.nix|nix| | {{file|/etc/nixos/configuration.nix|nix|3=services.monado = { | ||
services.monado = { | |||
enable = true; | enable = true; | ||
defaultRuntime = true; # Register as default OpenXR runtime | defaultRuntime = true; # Register as default OpenXR runtime | ||
}; | };}} | ||
<translate> | |||
<!--T:4--> | |||
In order to configure Monado, you might want to add additional environment variables: | In order to configure Monado, you might want to add additional environment variables: | ||
</translate> | |||
{{file|/etc/nixos/configuration.nix|nix| | {{file|/etc/nixos/configuration.nix|nix|3=systemd.user.services.monado.environment = { | ||
systemd.user.services.monado.environment = { | |||
STEAMVR_LH_ENABLE = "1"; | STEAMVR_LH_ENABLE = "1"; | ||
XRT_COMPOSITOR_COMPUTE = "1"; | XRT_COMPOSITOR_COMPUTE = "1"; | ||
}; | };}} | ||
<translate> | |||
=== Hand Tracking === <!--T:5--> | |||
<!--T:6--> | |||
You may notice that running <code>monado-services</code> will fail due to the lack of hand tracking data. There are 2 ways to remedy this, either disable hand tracking altogether, or download the hand tracking data. | |||
<!--T:7--> | |||
To disable hand tracking, modify the environment variable to include <code>WMR_HANDTRACKING = "0";</code>, so that it will look like this. | |||
</translate> | |||
{{file|/etc/nixos/configuration.nix|nix|3=systemd.user.services.monado.environment = { | |||
STEAMVR_LH_ENABLE = "1"; | |||
XRT_COMPOSITOR_COMPUTE = "1"; | |||
WMR_HANDTRACKING = "0"; | |||
};}} | |||
<translate> | |||
<!--T:8--> | |||
To get hand tracking to work, you require <code>git-lfs</code> to be enabled. The standard way of enabling <code>git-lfs</code> is through the configuration below | |||
</translate> | |||
{{file|/etc/nixos/configuration.nix|nix|3=programs.git = { | |||
enable = true; | |||
lfs.enable = true; | |||
};}} | |||
<translate> | |||
<!--T:9--> | |||
After making sure <code>git-lfs</code> is enabled, run these commands and restart <code>monado-service</code> | |||
</translate> | |||
{{Commands| | |||
$ mkdir -p ~/.local/share/monado | |||
$ cd ~/.local/share/monado | |||
$ git clone https://gitlab.freedesktop.org/monado/utilities/hand-tracking-models | |||
}} | |||
<translate> | |||
<!--T:10--> | |||
For further information about available environment variables and tweaks, read the [https://lvra.gitlab.io/docs/fossvr/monado/ Linux VR Adventures wiki] and the [https://monado.freedesktop.org/getting-started.html#environment-variables Monado documentation about environment variables] | For further information about available environment variables and tweaks, read the [https://lvra.gitlab.io/docs/fossvr/monado/ Linux VR Adventures wiki] and the [https://monado.freedesktop.org/getting-started.html#environment-variables Monado documentation about environment variables] | ||
</translate> | |||
== OpenComposite == | <translate> | ||
== OpenComposite == <!--T:11--> | |||
<!--T:12--> | |||
[https://gitlab.com/znixian/OpenOVR 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. | [https://gitlab.com/znixian/OpenOVR 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. | ||
<!--T:13--> | |||
In order to run OpenVR games on anything other than SteamVR, you need to configure the OpenVR runtime path defined in <code>~/.config/openvr/openvrpaths.vrpath</code>. A reliable way to do this is to use [[Home Manager]] to create this file. | In order to run OpenVR games on anything other than SteamVR, you need to configure the OpenVR runtime path defined in <code>~/.config/openvr/openvrpaths.vrpath</code>. A reliable way to do this is to use [[Home Manager]] to create this file. | ||
<!--T:14--> | |||
{{Warning|Older versions of Proton will always query the current OpenVR and OpenXR runtime. If you use OpenComposite, and it fails to initialize an OpenXR context, Proton will fail to launch. A workaround is to delete the ~/.config/openvr/openvrpaths.vrpath file and then retry launching the game.}} | |||
<!--T:15--> | |||
If this file is not set to read-only, SteamVR will add its runtime path back, hence the use for Home Manager. | |||
<!--T:16--> | |||
An example configuration for enabling OpenComposite may look like this: | An example configuration for enabling OpenComposite may look like this: | ||
</translate> | |||
{{file|~/.config/home-manager/home.nix|nix|3=# For Monado: | |||
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json"; | |||
# For WiVRn: | |||
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.wivrn}/share/openxr/1/openxr_wivrn.json"; | |||
xdg.configFile."openvr/openvrpaths.vrpath".text = '' | xdg.configFile."openvr/openvrpaths.vrpath".text = '' | ||
{ | { | ||
Line 50: | Line 109: | ||
"version" : 1 | "version" : 1 | ||
} | } | ||
''; | '';}} | ||
<translate> | |||
<!--T:17--> | |||
If you are planning to play any OpenVR game on Steam or OpenXR games through Proton, you will have to use OpenComposite in this manner. In most cases you also have to allow access to the socket path of your OpenXR runtime to Steam's runtime, by using the following launch options for XR applications on Steam: <code>env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%</code>. This example is for Monado, while other XR runtimes might differ. | If you are planning to play any OpenVR game on Steam or OpenXR games through Proton, you will have to use OpenComposite in this manner. In most cases you also have to allow access to the socket path of your OpenXR runtime to Steam's runtime, by using the following launch options for XR applications on Steam: <code>env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%</code>. This example is for Monado, while other XR runtimes might differ. | ||
</translate> | |||
<translate> | |||
== WiVRn == <!--T:18--> | |||
<!--T:35--> | |||
WiVRn is an OpenXR streaming application built around Monado. It wirelessly connects a standalone VR headset to a Linux computer. If your headset is not wireless, look at [[VR#Monado|Monado]] instead. | |||
Example usage of the WiVRn module: | |||
</translate> | |||
{{File|/etc/nixos/configuration.nix|nix|3=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; | |||
} | |||
]; | |||
}; | |||
}; | |||
};}} | |||
<translate> | |||
<!--T:19--> | |||
Like Monado, you will also have to add the launch argument for WiVRn to allow access to the socket: <code>PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/wivrn/comp_ipc %command%</code> | |||
</translate> | |||
<translate> | |||
== Envision == <!--T:20--> | |||
<!--T:36--> | |||
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: | |||
</translate> | |||
{{File|/etc/nixos/configuration.nix|nix|3=programs.envision = { | |||
enable = true; | |||
openFirewall = true; # This is set true by default | |||
};}} | |||
<translate> | |||
== SteamVR == <!--T:21--> | |||
<!--T:37--> | |||
[https://store.steampowered.com/app/250820/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. | |||
<!--T:22--> | |||
After installing SteamVR through Steam and plugging in a SteamVR-compatible headset, SteamVR should work for the most part. | |||
<!--T:23--> | |||
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 <code>CAP_SYS_NICE</code> capability to acquire a high-priority context, which is a requirement for asynchronous reprojection. | |||
<!--T:24--> | |||
{{Note|Steam is run in a bubblewrap-based FHS environment. This environment runs Steam in a user namespace, which prevents it from using any capabilities or setuid binaries. This means that asynchronous reprojection can not be used on NixOS, without patching the kernel to remove these restrictions completely. See this [https://github.com/NixOS/nixpkgs/issues/217119 Nixpkgs issue]}} | |||
</translate> | |||
<translate> | |||
=== Patching AMDGPU to allow high priority queues === <!--T:25--> | |||
<!--T:26--> | |||
By applying [https://github.com/Frogging-Family/community-patches/blob/a6a468420c0df18d51342ac6864ecd3f99f7011e/linux61-tkg/cap_sys_nice_begone.mypatch this patch], the AMDGPU kernel driver will ignore process privileges and allow any application to create high priority contexts. | |||
<!--T:27--> | |||
{{Warning|This removes intentional restrictions from the kernel, and it could cause scheduling issues. While it has not been reported that it does cause issues, this should be considered an unsupported configuration.}} | |||
</translate> | |||
<translate> | |||
==== Applying as a NixOS kernel patch ==== <!--T:28--> | |||
<!--T:29--> | |||
To workaround the <code>CAP_SYS_NICE</code> requirement, we can apply a kernel patch using the following NixOS configuration snippet: | |||
</translate> | |||
{{file|/etc/nixos/configuration.nix|nix|3=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="; | |||
}; | |||
} | |||
]; | |||
}} | |||
<translate> | |||
<!--T:30--> | |||
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]] | |||
</translate> | |||
<translate> | |||
== wlx-overlay-s == <!--T:31--> | |||
<!--T:38--> | |||
[https://github.com/galister/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. | |||
</translate> | |||
<translate> | |||
==== SteamVR autostart ==== <!--T:32--> | |||
<!--T:39--> | |||
When launching wlx-overlay-s in SteamVR (or any OpenVR compositor) it will register an autostart manifest. Currently, this manifest will reference a Nix store path of wlx-overlay-s, which might get garbage collected after rebuilds of your NixOS/Nix profile. A workaround is to regularly run the following command to update the manifest's store path:{{Commands| | |||
# Run wlx-overlay-s and replace any running instance | |||
$ wlx-overlay-s --replace}} | |||
</translate> | |||
== See also == | <translate> | ||
== See also == <!--T:33--> | |||
<!--T:34--> | |||
* [https://lvra.gitlab.io Linux VR Adventures Wiki] | * [https://lvra.gitlab.io Linux VR Adventures Wiki] | ||
[[Category:Video]] | |||
[[Category:Hardware]] | |||
[[Category:Desktop]] | |||
[[Category:Gaming]] | |||
</translate> |
Latest revision as of 07:00, 4 November 2024
Monado
Monado is an open source OpenXR runtime. It offers support for a variety of hardware using its built-in drivers and can be used to run any OpenXR and, with the help of OpenComposite, most OpenVR applications.
Monado can be configured using its NixOS options since 24.05:
/etc/nixos/configuration.nix
services.monado = {
enable = true;
defaultRuntime = true; # Register as default OpenXR runtime
};
In order to configure Monado, you might want to add additional environment variables:
/etc/nixos/configuration.nix
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
};
Hand Tracking
You may notice that running monado-services
will fail due to the lack of hand tracking data. There are 2 ways to remedy this, either disable hand tracking altogether, or download the hand tracking data.
To disable hand tracking, modify the environment variable to include WMR_HANDTRACKING = "0";
, so that it will look like this.
/etc/nixos/configuration.nix
systemd.user.services.monado.environment = {
STEAMVR_LH_ENABLE = "1";
XRT_COMPOSITOR_COMPUTE = "1";
WMR_HANDTRACKING = "0";
};
To get hand tracking to work, you require git-lfs
to be enabled. The standard way of enabling git-lfs
is through the configuration below
/etc/nixos/configuration.nix
programs.git = {
enable = true;
lfs.enable = true;
};
After making sure git-lfs
is enabled, run these commands and restart 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.
In order to run OpenVR games on anything other than SteamVR, you need to configure the OpenVR runtime path defined in ~/.config/openvr/openvrpaths.vrpath
. A reliable way to do this is to use Home Manager to create this file.
If this file is not set to read-only, SteamVR will add its runtime path back, hence the use for Home Manager.
An example configuration for enabling OpenComposite may look like this:
~/.config/home-manager/home.nix
# For Monado:
xdg.configFile."openxr/1/active_runtime.json".source = "${pkgs.monado}/share/openxr/1/openxr_monado.json";
# For WiVRn:
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
}
'';
If you are planning to play any OpenVR game on Steam or OpenXR games through Proton, you will have to use OpenComposite in this manner. In most cases you also have to allow access to the socket path of your OpenXR runtime to Steam's runtime, by using the following launch options for XR applications on Steam: env PRESSURE_VESSEL_FILESYSTEMS_RW=$XDG_RUNTIME_DIR/monado_comp_ipc %command%
. This example is for Monado, while other XR runtimes might differ.
WiVRn
WiVRn is an OpenXR streaming application built around Monado. It wirelessly connects a standalone VR headset to a Linux computer. If your headset is not wireless, look at Monado instead. Example usage of the WiVRn module:
/etc/nixos/configuration.nix
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:
/etc/nixos/configuration.nix
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.
Patching AMDGPU to allow high priority queues
By applying this patch, the AMDGPU kernel driver will ignore process privileges and allow any application to create high priority contexts.
Applying as a NixOS kernel patch
To workaround the CAP_SYS_NICE
requirement, we can apply a kernel patch using the following NixOS configuration snippet:
/etc/nixos/configuration.nix
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 autostart
When launching wlx-overlay-s in SteamVR (or any OpenVR compositor) it will register an autostart manifest. Currently, this manifest will reference a Nix store path of wlx-overlay-s, which might get garbage collected after rebuilds of your NixOS/Nix profile. A workaround is to regularly run the following command to update the manifest's store path:
# Run wlx-overlay-s and replace any running instance $ wlx-overlay-s --replace