【问题标题】:Hot to run OpenGL application on Windows Subsystem for Linux [closed]在适用于 Linux 的 Windows 子系统上热运行 OpenGL 应用程序 [关闭]
【发布时间】:2019-07-31 11:00:35
【问题描述】:

我有两张视频卡:

Intel(R) HD Graphics 630,驱动程序版本:25.20.100.6472

NVIDIA Quadro M1200,驱动程序版本:26.21.14.3102

在 Windows 10 上,这两种卡都可以很好地与 OpenGL/OpenGl ES 应用程序配合使用。

我尝试使用Xming 6.9.0.31 X Server 在适用于 Linux 的 Windows 子系统上运行 OpenGL ES 应用程序(基于 Java/LibGDX/LWJGL3),但出现以下错误:

“需要GLX 1.3版”

我已经安装了mesa-utils 包。

当我尝试运行glmark2 基准时,我收到以下错误:

错误:需要 GLX 版本 >= 1.3

错误:错误:无法获取 GL 视觉配置!

错误:主要:无法初始化画布

当我尝试运行glxgears -info 基准测试时,应用程序启动,显示齿轮但不旋转。似乎应用程序只呈现第一帧。在终端上,我们有一些有趣的信息:

GL_RENDERER = Quadro M1200/PCIe/SSE2

GL_VERSION = 1.2 (4.6.0 NVIDIA 431.02)

GL_VENDOR = NVIDIA 公司

GL_EXTENSIONS = GL_ARB_depth_texture GL_ARB_imaging GL_ARB_multitexture GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_texture_border_clamp GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_mirrored_repeat GL_ARB_transpose_matrix GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_edge_clamp GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_object GL_EXT_vertex_array GL_ATI_texture_mirror_once GL_IBM_texture_mirrored_repeat GL_NV_blend_square GL_NV_point_sprite GL_NV_texgen_reflection GL_NV_texture_rectangle GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow VisualID 54, 0x36

35.0 秒内 5493 帧 = 156.996 FPS

34.7 秒内 2085 帧 = 60.154 FPS

34.7 秒内 2085 帧 = 60.146 FPS

35.0 秒内 2085 帧 = 59.567 FPS

34.7 秒内 2085 帧 = 60.089 FPS

日志表明帧已渲染,但应用程序窗口中没有任何反应。

glxinfo | grep -i "version" -A 2 -B 2的结果:

直接渲染:否(如果您想找出原因,请尝试设置 LIBGL_DEBUG=详细)

服务器 glx 供应商字符串:SGI

服务器 glx 版本字符串:1.2

(...)

客户端 glx 供应商字符串:NVIDIA Corporation

客户端 glx 版本字符串:1.4

(...)

GLX 版本:1.2

(...)

OpenGL 供应商字符串:NVIDIA Corporation

OpenGL 渲染器字符串:Quadro M1200/PCIe/SSE2

OpenGL 版本字符串:1.2 (4.6.0 NVIDIA 431.02)

(...)

看了上面的清单我不明白为什么没有直接渲染,为什么服务器GLX版本是1.2(不是1.4),供应商是SGI,为什么OpenGL版本字符串是1.2(不是更高)?

我应该怎么做才能在 WSL 中正确运行 OpenGL 应用程序?

编辑

nvidia-setting 命令显示以下输出:

ERROR: NVIDIA driver is not loaded
ERROR: Unable to load info from any available system

为什么?前面的命令显示我已经为 WSL 安装了 Nvidia 驱动程序。

编辑 2

从存储库安装 Nvidia 驱动程序后:

sudo apt install nvidia-driver-390

我有以下nvidia-setting的错误:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

ERROR: NVIDIA driver is not loaded


ERROR: Error querying enabled displays on GPU 0 (Missing Extension).


ERROR: Error querying connected displays on GPU 0 (Missing Extension).

** Message: 11:40:41.535: PRIME: No offloading required. Abort
** Message: 11:40:41.537: PRIME: is it supported? no

ERROR: nvidia-settings could not find the registry key file. This file should have been installed along with this driver at /usr/share/nvidia/nvidia-application-profiles-key-documentation. The application profiles will continue to work,
       but values cannot be prepopulated or validated, and will not be listed in the help text. Please see the README for possible values and descriptions.

更新

Xming 6好像支持很老的OpenGL版本,所以我决定用Cygwin/X作为X Server。

我使用以下命令启动它:

startx -- -listen tcp

基于 Cygwin 和 WSL 的终端输出,使用Mesa3D 驱动程序。在 WSL 上,glxgearsglmark2 可以正常工作。他们表明使用了以下渲染器(来自Mesa3d):

OpenGL Information
GL_VENDOR:     VMware, Inc.
GL_RENDERER:   llvmpipe (LLVM 8.0, 256 bits)
GL_VERSION:    3.1 Mesa 19.0.2

但是我的 Java 应用程序崩溃了:

shared memfd open() failed: Function not implemented
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  42 (X_SetInputFocus)
  Serial number of failed request:  159
  Current serial number in output stream:  176

另一方面,当我使用以下命令启动 Cygwin/X 时:

startxwin -- -listen tcp

似乎是从加速渲染开始的,因为屏幕上有以下信息:

GL_VERSION:     4.6.0 NVIDIA 431.70
GL_VENDOR:      NVIDIA Corporation
GL_RENDERER:    Quadro M1200/PCIe/SSE2
(II) GLX: enabled GLX_SGI_make_current_read
(II) GLX: enabled GLX_SGI_swap_control
(II) GLX: enabled GLX_MESA_swap_control
(II) GLX: enabled GLX_SGIX_pbuffer
(II) GLX: enabled GLX_ARB_multisample
(II) GLX: enabled GLX_SGIS_multisample
(II) GLX: enabled GLX_ARB_fbconfig_float
(II) GLX: enabled GLX_EXT_fbconfig_packed_float
(II) GLX: enabled GLX_ARB_create_context
(II) GLX: enabled GLX_ARB_create_context_profile
(II) GLX: enabled GLX_ARB_create_context_robustness
(II) GLX: enabled GLX_EXT_create_context_es2_profile
(II) AIGLX: enabled GLX_MESA_copy_sub_buffer
(II) 894 pixel formats reported by wglGetPixelFormatAttribivARB
(II) 858 fbConfigs
(II) ignored pixel formats: 0 not OpenGL, 0 unknown pixel type, 36 unaccelerated
(II) GLX: Initialized Win32 native WGL GL provider for screen 0

但是 OpenGL 应用程序(glxgearsglmark2 和我自己的)无法在 WSL 上运行,产生类似于以下的错误:

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:  148 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  32
  Current serial number in output stream:  31

当我尝试为我的卡安装最新的 Nvidia 驱动程序时:NVIDIA-Linux-x86_64-430.40.run,出现以下错误:

警告:文件“/proc/sys/kernel/modprobe”不可用; X 服务器将使用/sbin/modprobe 作为modprobe 的路径 效用。这条路径不同于由 nvidia-installer,/bin/kmod。请确认/sbin/modprobe 工作正常或挂载 /proc 文件系统并验证 '/proc/sys/kernel/modprobe' 报告正确的路径。 -> 使用 CC="/usr/bin/cc" 执行 CC 完整性检查。

错误:无法找到当前运行的内核源代码树 核心。请确保您已安装内核源文件 对于您的内核并且它们已正确配置;在红帽上 例如,Linux 系统,请确保您拥有“内核源”或 'kernel-devel' RPM 已安装。如果您知道正确的内核源 文件已安装,您可以使用 '--kernel-source-path' 命令行选项。

总结:

如何在 WSL 上成功运行 OpenGL 硬件加速应用程序?如何在 WSL 上安装最新/可用的 NVidia 驱动程序?

【问题讨论】:

    标签: opengl windows-10 nvidia windows-subsystem-for-linux


    【解决方案1】:

    我认为齿轮没有旋转是因为您的 OpenGL 版本 (1.2) 太旧了。 在这个site 上,你可以看到它是 1998 年(21 岁)的。 可能是 glxgears 没有用这么旧的 OpenGL 版本进行测试。

    当我运行 glxgears 时,我得到了这个版本: GL_VERSION = 4.6.0 英伟达 418.74

    【讨论】:

    • 问题是我有最新的 NVIDIA 驱动程序(NVIDIA 431.02,nvidia.com/Download/driverResults.aspx/148432/en-us),但 GL_VERSION 非常低。为什么?
    • 也许 Xming 必须正确配置。我读过你需要 -wgl 选项。但是我对Xming并不熟悉。如果它是 Java 应用程序,我想知道为什么它不能直接在 Windows 上运行。另一种选择是运行 linux 的虚拟机。
    • 我的 Java 应用程序使用了一些使用 JNR 加载的本机库,它们分别为 Windows 和 Linux 提供。我需要测试应用程序是否在两个系统上都能正常工作。实际上,也尝试在运行 Hyper-V 环境的 Ubuntu VM 上对其进行测试,但我遇到了另一个问题:stackoverflow.com/questions/57295844/…
    • 我还想知道您为什么在桌面应用程序中使用 OpenGL ES。它是为移动设备制作的。另一种选择是直接在您的计算机上安装 Linux。
    • 我使用 OpenGL ES 是因为相同的代码库(基于 LibGDX,跨平台库)用于在桌面、Web 和移动等不同平台上编译和运行 App。
    【解决方案2】:

    可能需要导出您的显示。 通过键入默认 xming 设置为我工作

    export DISPLAY=:0 
    

    在 xming 服务器运行时在您的 linux 终端中。旧的 openGL 应该很好,但我建议更新版本,因为它们应该更可能与各种新硬件兼容。如果您想测试问题是否出在您的应用程序上,这里有一个名为 gource 的应用程序的快速示例,该应用程序在导出显示后在 WSL ubuntu 上的 xming 窗口中运行。我下载并安装了一个新的xming副本,运行一次并没有碰任何东西,我克隆了GLM的github,然后在目录中运行了gource

    【讨论】:

    • Xming 6 支持 GLX 1.2,因此如果应用程序不使用涉及使用高于 1.2 的 GLX 版本的 OpenGL 功能,它们将可以运行。我的应用需要 GLX 1.3 或更高版本,因此它不适用于 Xming,但它适用于 Cygwin/X(存在其他问题)。
    • 有趣的是,gource 正是我无法运行的软件。
    猜你喜欢
    • 2021-01-23
    • 2019-06-07
    • 2018-06-09
    • 1970-01-01
    • 2017-12-14
    • 2021-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多