使用 X11 转发的 OpenGL 渲染

Ada*_*lai 17 ssh opengl x11

我正在尝试在远程服务器上运行一个可执行文件,我通过 ssh -Y 连接到该服务器。我认为可执行文件使用 openGL

服务器运行 Ubuntu,本地系统运行 OSX。

ssh -Y 通常通过 X11 在我的本地机器上打开一个显示。这适用于其他应用程序(firefox、matlab 等)

这次我收到消息:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  35
  Current serial number in output stream:  34
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  34
  Current serial number in output stream:  35
Run Code Online (Sandbox Code Playgroud)

我还运行了 glxinfo(我正在尝试在论坛上找到的东西)并得到了这个

name of display: localhost:11.0
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  23
  Current serial number in output stream:  22
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

谢谢!

Her*_*oCC 13

编辑 2021 年 5 月 5 日:随着 XQuartz 2.8.0 的发布,配置路径似乎已从 更改org.macosforge.xquartz.X11org.xquartz.X11。相同的说明仍然适用,如果您来自未来,只需将旧路径替换为新路径即可。


虽然这里的答案已经修复,但我正在提交另一个答案,当我的工作中每隔一年出现这个问题时,我可以使用它作为将来的参考:)

当 X 转发(通过 SSH、Docker 等)时,这种情况经常发生。您需要允许 OpenGL 绘图 (iglx),默认情况下,许多 X11 服务器(例如 XQuarts 或 Ubuntu 上的标准 X11 服务器)上禁用该功能。您可能会看到与此相关的一些其他日志如下。

XRequest.155: GLXBadContext 0x500003a
XRequest.155: BadValue (integer parameter out of range for operation) 0x0
XRequest.155: GLXBadContext 0x500003b
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
../../src/xcb_io.c:259: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Run Code Online (Sandbox Code Playgroud)

修复方法是启用 iglx。首先,检查您的 XQuarts 版本是否支持此功能。截至撰写本文时的最新版本是这样,但它已被弃用,因此将来可能不会。我的版本是XQuartz 2.7.11 (xorg-server 1.18.4).

接下来,运行defaults write org.macosforge.xquartz.X11 enable_iglx -bool true. 您应该能够通过运行来确认它已设置

$ defaults read org.macosforge.xquartz.X11
{
    "app_to_run" = "/opt/X11/bin/xterm";
    "cache_fonts" = 1;
    "done_xinit_check" = 1;
    "enable_iglx" = 1; ####### this should be truthy
    "login_shell" = "/bin/sh";
    "no_auth" = 0;
    "nolisten_tcp" = 0;
    "startx_script" = "/opt/X11/bin/startx -- /opt/X11/bin/Xquartz";
}
Run Code Online (Sandbox Code Playgroud)

最后,重新启动 xquartz(或您的整个机器)。您可能需要重新运行xhost +以禁用安全性和身份验证(对于隔离的机器来说很好,对于暴露在互联网上的机器来说很危险)。您现在应该能够按预期运行 GUI 应用程序。希望这可以帮助!


小智 1

我在 Mac OS Mojave 上使用默认值得到了这种工作;在终端应用程序中编写org.macports.X11 enable_iglx -bool true,然后在同一终端中运行 Xquartz +extension GLX`。

然后我可以运行 glxgears 并进行光栅工作,但它会将显示放入外部显示器的左上角(而不是默认/视网膜显示),并且不会绘制任何帧来调整大小/移动它。

这让我想起了 1990 年代我对 Nvidia 显卡的蹩脚驱动程序支持以及尝试运行 Linux 桌面:)

我查了一下 freedesktop.org bug repo,发现 Xquartz/X11 似乎还不支持 Retina 显示屏。其中有一些技巧,但这让我想起几年前在我的 Mac 上的 XQuartz 中运行 Wireshark 是多么笨拙。我只是想让 X11 转发正常工作,不需要大约 3 到 5 分钟来重绘帧。请参阅https://gitlab.freedesktop.org/xorg/xserver/-/issues/187