microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.9k stars 296 forks source link

d3d12 driver fails to initialize on Arch with AMD Radeon RX 6600 #1177

Closed parkovski closed 4 months ago

parkovski commented 5 months ago

Windows build number:

10.0.22631.0

Your Distribution version:

Arch fully updated

Your WSL versions:

WSL version: 2.0.14.0 Kernel version: 5.15.133.1-1 WSLg version: 1.0.59 MSRDC version: 1.2.4677 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22631.2861

Steps to reproduce:

sudo LIBVA_DRIVER_NAME=d3d12 vainfo --display drm --device /dev/dri/card0

I've also tried turning on hardware acceleration in Firefox and this causes it to crash on startup. It runs ok with software rendering.

WSL logs:

stderr.log weston.log pulseaudio.log

WSL dumps:

No response

Expected behavior:

Vainfo runs as intended. I've tried several different ways of running it with/without sudo and with different command flags and it never gets further than vaInitialize failed.

Actual behavior:

Trying display: drm
libva error: /usr/lib/dri/d3d12_drv_video.so init failed
vaInitialize failed with error code 2 (resource allocation failed),exit
kiocosta commented 5 months ago

Try adding export LIBGL_ALWAYS_INDIRECT=1 to ~/.zshrc (or ~/.bashrc if you use bash) and then running source ~/.zshrc. Does this help?

elsaco commented 5 months ago

@parkovski what version of the mesa-va-drivers are you using on arch? On ubuntu it seems to work with version 23.2.1:

elsaco@texas:~$ LIBVA_DRIVER_NAME=d3d12 vainfo --display drm --device /dev/dri/card0
libva info: VA-API version 1.19.0
Xlib:  extension "DRI2" missing on display ":0".
libva info: User environment variable requested driver 'd3d12'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/d3d12_drv_video.so
libva info: Found init function __vaDriverInit_1_19
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.19 (libva 2.12.0)
vainfo: Driver version: Mesa Gallium driver 23.2.1-1ubuntu3.1 for D3D12 (Intel(R) Arc(TM) A750 Graphics)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

After running the command check dmesg output for more clues. Also ldd -v /usr/bin/vainfo will tell you if any library dependencies are missing.

parkovski commented 5 months ago

Tried adding LIBGL_ALWAYS_INDIRECT=1, that didn't help though I remember using that flag with VcXSrv before WSLg was a thing.

Also tried downgrading my libva-mesa-driver package to 23.2.1 (was on 23.3.2), still getting the same error.

In dmesg I see a lot of this:

[58771.188957] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[58771.189895] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[58771.190730] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -22
[58771.191590] misc dxg: dxgk: dxgkio_query_adapter_info: Ioctl failed: -2

Running ldd -v /usr/bin/vainfo didn't tell me anything suspicious.

Assuming those ioctl values are -errno, they are 22 (EINVAL) and 2 (ENOENT) so maybe a device file is missing?

Just installed Ubuntu and it works as intended there so maybe I can do some digging and find what's different.

Just tried building mesa from source, but I get the same error.

viruscamp commented 4 months ago
  1. check environment variables

    $ env | grep DISPLAY
    WAYLAND_DISPLAY=wayland-0
    DISPLAY=:0
  2. check dev files

    $ ls -l /dev/dri
    crw-rw---- 1 root video  226,   0  3月 5日 18:32 card0
    crw-rw-rw- 1 root render 226, 128  3月 5日 18:32 renderD128
  3. check display socket files

    $ ls -ld /tmp/.X11-unix /tmp/.X11-unix/X0 $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY
    lrwxrwxrwx 1 user1 user1 31  3月 5日 18:32 /run/user/1000//wayland-0 -> /mnt/wslg/runtime-dir/wayland-0
    lrwxrwxrwx 1 root      root      19  3月 5日 18:32 /tmp/.X11-unix -> /mnt/wslg/.X11-unix
    srwxrwxrwx 1 user1 user1  0  3月 5日 18:32 /tmp/.X11-unix/X0
  4. check the current user is in group video, if not then add the user to group video:

    $ groups
    video wheel user1
    $ sudo usermod --append --groups video user1
  5. if you have two or more distros installed in WSL2, try to run ls -l /dev/dri/card0 and paste the outputs. 5.1. stop all distros by run wsl.exe --shutdown 5.2. start 1st distro, run ls -l /dev/dri/card0 5.3. start 2nd distro, run ls -l /dev/dri/card0 5.4. switch back to 1st distro, run ls -l /dev/dri/card0

parkovski commented 4 months ago

This seems to be fixed after updating today, closing.