Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 937851 - media-libs/mesa: unable to initialise D3D12 GPU in WSL
Summary: media-libs/mesa: unable to initialise D3D12 GPU in WSL
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo X packagers
URL: https://github.com/microsoft/wslg/iss...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-13 07:15 UTC by Matt Jolly
Modified: 2024-10-03 07:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
glxinfo -B ; emerge --info (file_937851.txt,7.72 KB, text/plain)
2024-08-13 07:15 UTC, Matt Jolly
Details
gentoo glxinfo strace (glxinfo.strace.zstd,27.30 KB, application/zstd)
2024-09-09 05:19 UTC, Matt Jolly
Details
ubuntu glxinfo strace (glxinfo.strace.ubuntu.zstd,23.44 KB, application/zstd)
2024-09-09 05:20 UTC, Matt Jolly
Details
gentoo glxinfo strace USE=-zink (glxinfo-nozink.strace.zstd,14.50 KB, application/zstd)
2024-09-10 01:15 UTC, Matt Jolly
Details
gentoo glxinfo strace USE=-zink moved dzn lib (glxinfo-nozink-mvdzn.strace.zstd,14.46 KB, application/zstd)
2024-09-10 01:16 UTC, Matt Jolly
Details
gentoo glxinfo strace USE=-video_cards_zink -vulkan (glxinfo-nozink-novulkan.strace.zstd,14.59 KB, application/zstd)
2024-09-10 01:16 UTC, Matt Jolly
Details
gentoo mesa 24.2.2 glxinfo strace force d3d12 (glxinfo-newmesa-forced3d12.strace,79.04 KB, text/plain)
2024-09-16 00:31 UTC, Matt Jolly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Jolly gentoo-dev 2024-08-13 07:15:53 UTC
Created attachment 900028 [details]
glxinfo -B ; emerge --info

I'm attempting to get WSL-g up and running however I've discovered that despite `/dev/dxg` existing and USE=`video_cards_d3d12` enabled on media-libs/mesa-24.1.3 that the only available renderer is `llvmpipe`.

This is obviously undesirable. I'm using an Intel iGPU, and https://bugs.gentoo.org/845213 suggests that this may have never worked under this configuration - Has anybody had success?

The only insight I have at this stage is the following whenever anything using OpenGL is launched (e.g. glxinfo, glxgears, firefox):

```
kangie@wsl2-hostname ~ $ glxinfo -B
name of display: :0
WARNING: dzn is not a conformant Vulkan implementation, testing use only.
MESA: error: ID3D12DeviceFactory::CreateDevice failed
. . .
```

I'm not much of a Mesa/OpenGL buff, but WSL appears to be correctly passing in `/dev/dxg` from the Linux VM:

```
kangie@wsl2-hostname ~ $ ls -la /dev/dxg
crw-rw-rw- 1 root root 10, 127 Aug 12 09:58 /dev/dxg
```

I'm a bit stumped for now bit will try and see if I can work out what the Mesa code is doing sometime in the next month.

Available to try suggestions if anyone has them.
Comment 1 Matt Jolly gentoo-dev 2024-08-13 10:36:42 UTC
I can confirm that Ubuntu in WSL-g does not have this issue:

```
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (Intel(R) Iris(R) Xe Graphics) (0xffffffff)
    Version: 23.2.1
    Accelerated: yes
    Video memory: 8162MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.1
    Max compat profile version: 4.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (Intel(R) Iris(R) Xe Graphics)
OpenGL core profile version string: 4.1 (Core Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2
OpenGL core profile shading language version string: 4.10
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.1 (Compatibility Profile) Mesa 23.2.1-1ubuntu3.1~22.04.2
OpenGL shading language version string: 4.10
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 23.2.1-1ubuntu3.1~22.04.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
```
Comment 2 Matt Jolly gentoo-dev 2024-09-09 05:19:46 UTC
Created attachment 902436 [details]
gentoo glxinfo strace
Comment 3 Matt Jolly gentoo-dev 2024-09-09 05:20:04 UTC
Created attachment 902437 [details]
ubuntu glxinfo strace
Comment 4 Matt Jolly gentoo-dev 2024-09-09 05:25:05 UTC
It appears that I'm getting proper libraries and devices into WSL from MS:

```
$ ls /usr/lib/wsl/lib/ -av
.  ..  libd3d12.so  libd3d12core.so  libdxcore.so
```

Nothing jumping out at me in the straces, which is sad - I'd hoped there would be something obvious.
Comment 5 Matt Jolly gentoo-dev 2024-09-09 05:29:11 UTC
My current Mesa build config

```
[ebuild   R    ] media-libs/mesa-24.1.6::gentoo  USE="X llvm (opengl) proprietary-codecs vulkan wayland zstd -d3d9 -debug -lm-sensors -opencl -osmesa (-selinux) -test -unwind -vaapi -valgrind -vdpau -vulkan-overlay -xa" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse2" LLVM_SLOT="18 -15 -16 -17" VIDEO_CARDS="d3d12 zink (-freedreno) -intel -lavapipe (-lima) -nouveau -nvk (-panfrost) -r300 -r600 -radeon -radeonsi (-v3d) (-vc4) -virgl (-vivante) -vmware" 0 KiB
```
Comment 6 Paul Zander 2024-09-09 18:26:09 UTC
Three things to try after each do the strace -e file glxinfo -B again
- media-libs/mesa VIDEO_CARDS: -zink
- mv /usr/share/vulkan/icd.d/dzn_icd.x86_64.json{,.old}
- undo the move, and set USE=-vulkan for mesa
Comment 7 Matt Jolly gentoo-dev 2024-09-10 01:08:40 UTC
Done, I'll upload the straces.

Nothing special to report. Still llvmpipe in Gentoo.

The `WARNING: dzn is not a conformant Vulkan implementation, testing use only.` warning disappears with USE=-zink, so I guess dozen (dzn) is a directx zink thing?

Had to install Ubuntu 24.04 LTS for testing/doco. It seems to work as well, I get glxgears. Some interesting warnings that don't seem to impact anything.


```Ubuntu24.04
name of display: :0
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (Intel(R) Iris(R) Xe Graphics) (0xffffffff)
    Version: 24.0.9
    Accelerated: yes
    Video memory: 8162MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.1
    Max compat profile version: 4.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (Intel(R) Iris(R) Xe Graphics)
OpenGL core profile version string: 4.1 (Core Profile) Mesa 24.0.9-0ubuntu0.1
```
Comment 8 Matt Jolly gentoo-dev 2024-09-10 01:15:21 UTC
Dozen (dzn) is Vulkan on D3D12. We can ignore that until/unless we get the mesa d3d12 driver working.
Comment 9 Matt Jolly gentoo-dev 2024-09-10 01:15:53 UTC
Created attachment 902499 [details]
gentoo glxinfo strace USE=-zink
Comment 10 Matt Jolly gentoo-dev 2024-09-10 01:16:20 UTC
Created attachment 902500 [details]
gentoo glxinfo strace USE=-zink moved dzn lib
Comment 11 Matt Jolly gentoo-dev 2024-09-10 01:16:53 UTC
Created attachment 902501 [details]
gentoo glxinfo strace USE=-video_cards_zink -vulkan
Comment 12 Matt Jolly gentoo-dev 2024-09-16 00:28:23 UTC
New mesa (~arch - 24.2.2) makes no difference.

Found some discussion involving envvar `GALLIUM_DRIVER`; if set to d3d12 we now get a clear failure rather than a fallback to llvmpipe.

```
name of display: :0
glx: failed to create drisw screen
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  148 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  38
  Current serial number in output stream:  39
```

Will upload strace. Still no idea what's going on; might have to ask upstream.
Comment 13 Matt Jolly gentoo-dev 2024-09-16 00:31:44 UTC
Created attachment 903096 [details]
gentoo mesa 24.2.2 glxinfo strace force d3d12
Comment 14 Matt Jolly gentoo-dev 2024-09-16 00:40:32 UTC
OK, we have a missing dependency on dev-libs/libedit.

It's a little annoying as it explicitly wants libedit.so.2 but we only provide .0 and .7. A quick symlink solves that problem.

What's the actual solution here desktop team?

Current status:


```
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (Intel(R) Iris(R) Xe Graphics) (0xffffffff)
    Version: 24.2.2
    Accelerated: yes
    Video memory: 8162MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.1
    Max compat profile version: 4.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (Intel(R) Iris(R) Xe Graphics)
OpenGL core profile version string: 4.1 (Core Profile) Mesa 24.2.2
OpenGL core profile shading language version string: 4.10
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.1 (Compatibility Profile) Mesa 24.2.2
OpenGL shading language version string: 4.10
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 24.2.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
```
Comment 15 Matt Turner gentoo-dev 2024-09-16 01:19:51 UTC
Looks like this is reported upstream (to WSL) as https://github.com/microsoft/wslg/issues/996
Comment 16 Matt Jolly gentoo-dev 2024-09-16 02:34:53 UTC
For any users that stumble across this issue and just need working Graphics in WSL2, the TL;DR is:

Intel (or MS?) build the drivers against a Debian or Ubuntu-based distribution.

Debian use `libedit2`, a package that differs from `libedit` only in that the soname is `.2` instead of `.0`.

It is inappropriate for us to package a fix for this issue, however enterprising users can make the Mesa D3D12 Gallium drivers for intel to work by:

- Building mesa with `VIDEO_CARDS_D3D12`
- Installing dev-libs/libedit
- Symlinking `libedit.so` to `libedit.so.2`
- Cursing Microsoft/Intel/Debian/Ubuntu/Deity of choice.

The end result is that the D3D12 Intel GPU should work transparently and continue working until this is resolved upstream and flows into the Gentoo WSL container through a WSL store update.