VR: Difference between revisions
m Fix path of "warning about Proton failing to launch with OpenComposite" |
|||
Line 53: | Line 53: | ||
If this file is not set to read-only, SteamVR will add its runtime path back, hence the use for Home Manager. | If this file is not set to read-only, SteamVR will add its runtime path back, hence the use for Home Manager. | ||
{{Warning|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/ | {{Warning|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.}} | ||
An example configuration for enabling OpenComposite may look like this: | An example configuration for enabling OpenComposite may look like this: |
Revision as of 16:19, 7 September 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
xdg.configFile."openxr/1/active_runtime.json".text = ''
{
"file_format_version": "1.0.0",
"runtime": {
"name": "Monado",
"library_path": "${pkgs.monado}/lib/libopenxr_monado.so"
}
}
'';
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.
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