要旨
WSLgのOpenGLの動作モードについて、わかりやすくまとまった情報がなかったので、実際に動作させて整理しました。
ディストリビューションはDebian12とし、mesa関係はbackportsの新しいバージョン(Mesa 25.0.4-1~bpo12+1)にアップデートしています。
1. マイクロソフトの見解
WSLgは、OpenGLアクセラレーションの有無にかかわらず、シンプルな2Dアプリケーションに最適です。しかし、BlenderやGazeboなどのより複雑な3Dアプリケーションを実行する場合は、WDDMv3.0をサポートするGPUを搭載したシステムで実行することで、はるかに優れたエクスペリエンスが得られます。WDDMv3.0はWSL vGPUサポートを標準で提供しており、Mesaを介してOpenGLアクセラレーションを自動的に有効化します。
これはGeeks3D GpuTestでpianoを実行し、Windowsのネイティブ環境よりは下がるが、ソフトウェアレンダリングよりもはるかに優れたパフォーマンスが得られます。
ハードウェアアクセラレーションOpenGL
2. Geeks3D GpuTestによるフレームレートの確認
解像度は1024x640(起動用pythonコードのデフォルト)としました。
2.1 起動用pythonコードの編集
2014年のpython2のコードなので、python3でも動くように一部を修正しました。
# 変更部分の付近のみ記載
import os
#from subprocess import call
#import Tkinter as tk # original
import tkinter as tk
...
seltext = ""
cs = listbox1.curselection()
if cs:
index = cs[0]
seltext = listbox1.get(index)
else:
# print "\nPlease select a test (FurMark is the default test)."
print ("\nPlease select a test (FurMark is the default test).")
index = 0
seltext = listbox1.get(index)
2.2 WSLgの動作モードの設定
ハードウェアとソフトウェアレンダリング
export GALLIUM_DRIVER=d3d12 # ハードウェア D3D12
export GALLIUM_DRIVER=llvmpipe # Mesa最速のソフトウェア LLVMpipe
パッケージ "mesa-utils"をインストールすると、"glxinfo -B"コマンドにより現在の環境が表示されます。
複数のGPUの選択(nvidiaとintel:ノートパソコン)
export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA or INTEL
2.3 デスクトップパソコン
Core i7-12700K, NVIDIA Geforce RTX 3060
PixMark Pianoでは、マイクロソフトの結果と同様に、D3D12(RTX3060)のフレームレートが高くなりました。
しかし、Julia FP64のようにD3D12とllvmpipeのフレームレートが同等の場合もありました。
数値はFPS | D3D12(RTX3060) | llvmpipe | Windows |
---|---|---|---|
PixMark Piano (OpenGL2.1/3.0) | 170 | 9 | 218 |
TessMark X64 (OpenGL 4.0) | 408 | 動作せず(黒塗り) | 683 |
PixMark Julia FP64 (OpenGL 4.0) | 145 | 146 | 171 |
PixMark Piano- D3D12 (NVIDIA)
168FPS、GPUの使用率が78%まで上がっており、NVIDIAのGPUに負荷がかかっていることがわかります。
PixMark Piano - llvmpipe(ソフトウェア)
9FPSしか出ていませんが、CPUの負荷が60%まで上がり、CPUファンがうるさいです。GPUの使用率は10%と低いです。
TessMark X64
PixMark Julia FP64
2.4 ノートパソコン
core i7-10750H, NVIDIA Geforce RTX 2060
デスクトップパソコンと同様にPixMark PianoではGPUの効果が大く、Julia FP64では効果がない結果になりました。
D3D12を省略、数値はFPS | RTX 2060 | Intel | llvmpipe |
---|---|---|---|
PixMark Piano (OpenGL2.1/3.0) | 64 | 8 | 4 |
TessMark X64 (OpenGL 4.0) | 212 | 48 | 動作せず(黒塗り) |
PixMark Julia FP64 (OpenGL 4.0) | 64 | 51 | 80 |
参考情報
Debian-Backportsのリポジトリ追加
新しいユーザーは、editorとしてnanoを推奨 Backports:debian-wiki
$ sudo apt edit-sources # 今のところ、sudo nano /etc/apt/sources.listと同じ。
# Debian 13からの新しいsourcesの表記方法への対応?
[sudo] password for elmeruser:
Select an editor. To change later, run 'select-editor'.
1. /bin/nano <---- easiest
2. /usr/bin/vim.tiny
Choose 1-2 [1]:1
# 以下の行を追加
deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
backportsからインストールしたmesa関係のパッケージ
sudo apt install -t bookworm-backports libd3dadapter9-mesa libegl-mesa0 libgl1-mesa-dri libglx-mesa0 libosmesa6 libwayland-egl1 mesa-drm-shim mesa-libgallium mesa-va-drivers mesa-vdpau-drivers mesa-vulkan-drivers libvkd3d-shader1 libvkd3d-utils1 libvkd3d1
Mesaのバージョン情報
$ glxinfo -B
name of display: :0
display: :0 screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Microsoft Corporation (0xffffffff)
Device: D3D12 (NVIDIA GeForce RTX 3060) (0xffffffff)
Version: 25.0.4
Accelerated: yes
Video memory: 77538MB
Unified memory: no
Preferred profile: core (0x1)
Max core profile version: 4.6
Max compat profile version: 4.6
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.1
...
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 3060)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 25.0.4-1~bpo12+1
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL version string: 4.6 (Compatibility Profile) Mesa 25.0.4-1~bpo12+1
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 25.0.4-1~bpo12+1
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10