Skip to content

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:

  1. Clone https://aur.archlinux.org/packages/directx-headers-git and https://aur.archlinux.org/packages/mesa-wsl2-git.
  2. Build directx-headers-git using makepkg -rsi. You may need to set up as per https://wiki.archlinux.org/title/Makepkg.
  3. cd into mesa-wsl2-git.
  4. Edit PKGBUILD to remove all instances of =18.1.8.
  5. Build mesa-wsl2-git using makepkg -rsi.
  6. Run echo "export GALLIUM_DRIVER=d3d12" | sudo tee /etc/profile.d/wslg.sh.
  7. 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.)
  8. 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.
  9. su into the user or open a new terminal tab/window.
  10. 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.
  11. 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.

Edited by Diab Neiroukh
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information