WSLg lacks GUI, OpenGL, and Vulkan Functionality
TLDR: From #8 (comment 256525), "The short end of the stick in this entire discussion is that the lack of support is actually a "bug" - WSLg sets these symlinks up upon boot but they are overwritten (seemingly by systemd)."
WSL2 supports OpenGL and, recently, Vulkan through the d3d12
Gallium and dzn
(also known as microsoft-experimental
) Vulkan drivers in Mesa and WSLg. Ubuntu, the "default" choice for WSL supports the former without any modifications but archlinux-wsl supports neither.
I've written up a short guide at https://gist.github.com/lzlrd/0d9b757d2122f551794fd00c7f0752d6 (following https://github.com/microsoft/wslg/issues/1312#issuecomment-2741985756) on how to enable both for Arch and Ubuntu, but in short the instructions are:
- Clone https://aur.archlinux.org/packages/directx-headers-git and https://aur.archlinux.org/packages/mesa-wsl2-git.
- Build
directx-headers-git
usingmakepkg -rsi
. You may need to set up as per https://wiki.archlinux.org/title/Makepkg. -
cd
intomesa-wsl2-git
. - Edit
PKGBUILD
to remove all instances of=18.1.8
. - Build
mesa-wsl2-git
usingmakepkg -rsi
. - Run
echo "export GALLIUM_DRIVER=d3d12" | sudo tee /etc/profile.d/wslg.sh
. - Run
echo "L+ /tmp/.X11-unix - - - - /mnt/wslg/.X11-unix" | sudo tee /etc/tmpfiles.d/wslg.conf
. (Thanks to https://github.com/microsoft/wslg/issues/43#issuecomment-826039096 for this.) - Create your user account as per https://wiki.archlinux.org/title/Users_and_groups#User_management and confgure it as the default user for WSL as per https://wiki.archlinux.org/title/Install_Arch_Linux_on_WSL#Set_default_user.
-
su
into the user or open a new terminal tab/window. - Run
echo '[ -f "/etc/wsl.conf" ] && [ ! -L "/run/user/$UID/wayland-0" ] && ln -s "/mnt/wslg/runtime-dir/wayland-0" "/run/user/$UID/wayland-0"' >> .bash_profile
. - Restart WSL with
wsl --shutdown
from CMD/PowerShell
Some notable things I didn't mention in the guide:
Point 6. doesn't seem to be done by Ubuntu (a quick rg
of /etc
doesn't find a reference for GALLIUM_DRIVER
), despite having the d3d12
Gallium driver work natively.
Point 7. looks to be due to systemd overwriting /tmp
(don't quote me on this) and breaks all GUI functionality (even when using llvmpipe
for OpenGL/Vulkan). This needs to be fixed before Arch Linux WSL is released.
I think we should at least match Ubuntu in OpenGL support, though having Vulkan support through a vulkan-dzn
package would be great.