VR/zh: Difference between revisions

Ardenet (talk | contribs)
Created page with "通过应用 [https://github.com/Frogging-Family/community-patches/blob/a6a468420c0df18d51342ac6864ecd3f99f7011e/linux61-tkg/cap_sys_nice_begone.mypatch 此补丁],AMDGPU 内核驱动程序将忽略进程权限并允许任何应用程序创建高优先级环境(high priority contexts)。"
Ardenet (talk | contribs)
Tags: Mobile edit Mobile web edit
 
(17 intermediate revisions by 2 users not shown)
Line 54: Line 54:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
有关可用环境变量和调整的更多信息,请参阅 [https://lvra.gitlab.io/docs/fossvr/monado/ Linux VR Adventures wiki] [https://monado.freedesktop.org/getting-started.html#environment-variables Monado 文档关于环境变量的部分]
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]
</div>
 


== OpenComposite ==
== OpenComposite ==


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://gitlab.com/znixian/OpenOVR OpenComposite] 是一个兼容层,用于在 Monado 等 OpenXR 运行时上运行 OpenVR 应用程序。它与 DXVK vkd3d 等工具类似,但用于将 OpenVR 调用转换为 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.
</div>


为了在 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]] 创建此文件。
Line 162: Line 157:
在初始设置时,SteamVR 会请求提升权限,以便为其某个二进制文件设置文件能力(file capability)。这是使异步再投影技术正常工作所必需的。客户端需要拥有 <code>CAP_SYS_NICE</code> 授权来获取高优先级环境,这是异步再投影技术的必要条件。
在初始设置时,SteamVR 会请求提升权限,以便为其某个二进制文件设置文件能力(file capability)。这是使异步再投影技术正常工作所必需的。客户端需要拥有 <code>CAP_SYS_NICE</code> 授权来获取高优先级环境,这是异步再投影技术的必要条件。


{{Note|Steam 在基于 bubblewrap 的 FHS 环境中运行。此环境在用户命名空间中运行 Steam,这阻止它使用任何能力(capabilities)或为二进制文件 setuid。这意味着除非修补内核以完全消除这些限制,否则异步再投影技术无法在 NixOS 上使用。请参阅此 [https://github.com/NixOS/nixpkgs/issues/217119 Nixpkgs 问题]}}
{{Note|Steam 在基于 bubblewrap 的 FHS 环境中运行。此环境在用户命名空间中运行 Steam,这阻止它使用任何能力(capabilities)或为二进制文件 setuid。这意味着除非修补内核以完全消除这些限制或修改用于运行 Steam 的 bubblewrap 二进制文件以消除这些功能保护,否则异步再投影技术无法在 NixOS 上使用。这两种解决方法都有各自的安全隐患。请参阅此 [https://github.com/NixOS/nixpkgs/issues/217119 Nixpkgs 问题]}}


<span id="Patching_AMDGPU_to_allow_high_priority_queues"></span>
<span id="Patching_AMDGPU_to_allow_high_priority_queues"></span>
Line 169: Line 164:
通过应用 [https://github.com/Frogging-Family/community-patches/blob/a6a468420c0df18d51342ac6864ecd3f99f7011e/linux61-tkg/cap_sys_nice_begone.mypatch 此补丁],AMDGPU 内核驱动程序将忽略进程权限并允许任何应用程序创建高优先级环境(high priority contexts)。
通过应用 [https://github.com/Frogging-Family/community-patches/blob/a6a468420c0df18d51342ac6864ecd3f99f7011e/linux61-tkg/cap_sys_nice_begone.mypatch 此补丁],AMDGPU 内核驱动程序将忽略进程权限并允许任何应用程序创建高优先级环境(high priority contexts)。


<div lang="en" dir="ltr" class="mw-content-ltr">
{{Warning|这将移除内核中特意设置的限制,并可能导致调度问题。虽然目前尚未收到导致问题的报告,但这应被视为不受支持的配置。}}
{{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.}}
</div>


<span id="Applying_as_a_NixOS_kernel_patch"></span>
<span id="Applying_as_a_NixOS_kernel_patch"></span>
==== 作为 NixOS 内核补丁进行应用 ====
==== 作为 NixOS 内核补丁进行应用 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
为了解决 <code>CAP_SYS_NICE</code> 要求,我们可以使用以下 NixOS 配置片段应用内核补丁:
To workaround the <code>CAP_SYS_NICE</code> requirement, we can apply a kernel patch using the following NixOS configuration snippet:
</div>


{{file|/etc/nixos/configuration.nix|nix|3=boot.kernelPatches = [
{{file|/etc/nixos/configuration.nix|nix|3=boot.kernelPatches = [
Line 192: Line 183:
}}
}}


<div lang="en" dir="ltr" class="mw-content-ltr">
也可以只修补 amdgpu 并将其构建为树外模块(out-of-tree module),如 [[Special:MyLanguage/Linux_kernel#Patching_a_single_In-tree_kernel_module|Pacthing a single In-tree Kernel Module]] 中所述
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]]
 
</div>
<span id="Patching_bubblewrap_to_allow_capabilities"></span>
=== 修补 bubblewrap 以允许启用能力(capabilities) ===
 
通过修改用于运行 Steam 的 bubblewrap 二进制文件,您可以允许该 FHS 环境中的进程获取能力。这样就无需直接修补内核了。
 
{{Warning|这绕过了 bubblewrap 中预设的安全机制,并允许所有其他由 steam 启动或通过 steam-run 运行的软件也获得这些能力。}}
 
{{file|/etc/nixos/configuration.nix|nix|3=programs.steam = let
  patchedBwrap = pkgs.bubblewrap.overrideAttrs (o: {
    patches = (o.patches or []) ++ [
      ./bwrap.patch
    ];
  });
in {
  enable = true;
  package = pkgs.steam.override {
    buildFHSEnv = (args: ((pkgs.buildFHSEnv.override {
      bubblewrap = patchedBwrap;
    }) (args // {
      extraBwrapArgs = (args.extraBwrapArgs or []) ++ [ "--cap-add ALL" ];
    })));
  };
};
}}
{{file|/etc/nixos/bwrap.patch|diff|3=diff --git a/bubblewrap.c b/bubblewrap.c
index 8322ea0..4e20262 100644
--- a/bubblewrap.c
+++ b/bubblewrap.c
@@ -868,13 +868,6 @@ acquire_privs (void)
      /* Keep only the required capabilities for setup */
      set_required_caps ();
    }
-  else if (real_uid != 0 && has_caps ())
-    {
-      /* We have some capabilities in the non-setuid case, which should not happen.
-         Probably caused by the binary being setcap instead of setuid which we
-         don't support anymore */
-      die ("Unexpected capabilities but not setuid, old file caps config?");
-   }
  else if (real_uid == 0)
    {
      /* If our uid is 0, default to inheriting all caps; the caller
}}
 
作为额外的更改,您可能还需要用指向修改后的 bwrap 二进制文件的符号链接替换 ​​Steam 自己的 bwrap 二进制文件,该链接位于 <code>~/.local/share/Steam/ubuntu12_32/steam-runtime/usr/libexec/steam-runtime-tools-0/srt-bwrap</code>
 
当 steam-runtime 更新时,Steam 会定期用自己的二进制文件替换此修改,因此您可能需要在功能异常时,重新应用此修改。


== wlx-overlay-s ==
== wlx-overlay-s ==


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://github.com/galister/wlx-overlay-s wlx-overlay-s] 是一个轻量级的 OpenXR/OpenVR 覆盖层,适用于 Wayland X11 桌面。它原生兼容 SteamVR 以及 Monado/WiVRn
[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.
</div>


<span id="SteamVR_autostart"></span>
<span id="SteamVR_autostart"></span>
==== SteamVR 自动启动 ====
==== SteamVR 自动启动 ====


<div lang="en" dir="ltr" class="mw-content-ltr">
在 SteamVR(或任何 OpenVR 合成器)中启动 wlx-overlay-s 时,它会注册一个自动启动清单。目前,此清单将引用 wlx-overlay-s 的 Nix 存储路径,该路径可能会在重建 NixOS/Nix 配置文件后被垃圾回收。一种解决方法是定期运行以下命令来更新清单的存储路径:
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
{{Commands|
# 运行 wlx-overlay-s 并替换任何正在运行的实例
$ wlx-overlay-s --replace}}
$ wlx-overlay-s --replace}}
</div>


<span id="See_also"></span>
<span id="See_also"></span>
== 另见 ==
== 另见 ==


<div lang="en" dir="ltr" class="mw-content-ltr">
* [https://lvra.gitlab.io Linux VR Adventures Wiki]
* [https://lvra.gitlab.io Linux VR Adventures Wiki]
[[Category:Video]]
 
[[Category:Hardware]]
[[Category:Video/zh|分类:视频]]
[[Category:Desktop]]
[[Category:Hardware/zh|分类:硬件]]
[[Category:Gaming]]
[[Category:Desktop/zh|分类:桌面]]
</div>
[[Category:Gaming/zh|分类:游戏]]