microsoft / wslg

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

No GPU acceleration in flatpak apps #690

Open jonaskuske opened 2 years ago

jonaskuske commented 2 years ago

Environment

Windows build number:
Microsoft Windows [Version 10.0.22000.556]

Your Distribution version:
Ubuntu 20.04 LTS

Your WSLg version:
WSL-Version: 0.56.2.0
Kernelversion: 5.10.102.1
WSLg-Version: 1.0.30
MSRDC-Version: 1.2.2924
Direct3D-Version: 1.601.0
Windows-Version: 10.0.22000.556

Steps to reproduce

# install flatpak
sudo add-apt-repository -y ppa:flatpak/stable # version in ubuntu repo doesn't have fix for https://github.com/flatpak/flatpak/issues/4372
sudo apt update
sudo apt install flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

# install and run glxinfo
sudo flatpak install -y io.github.arunsivaramanneo.GPUViewer
sudo rm /dev/shm # https://github.com/flatpak/flatpak/issues/2267, https://github.com/flatpak/flatpak/issues/4484
flatpak run \
--device=all \
--filesystem=host-os:ro \
--env=LD_LIBRARY_PATH=/run/host/usr/lib/wsl/lib \
--env=LIBGL_DEBUG=verbose \
--env=D3D12_DEBUG=all \
--command=bash io.github.arunsivaramanneo.GPUViewer -c 'glxinfo -B'

It uses llvmpipe instead of D3D12, and when run with GALLIUM_DRIVER=d3d12 you get an error:

Show/hide error ``` name of display: :99.0 libGL: MESA-LOADER: dlopen(/usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so) libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory. libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory. libGL error: failed to create dri screen libGL error: failed to load driver: swrast 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: 67 Current serial number in output stream: 68 ```

I then noticed that the d3d12 driver is missing in the freedesktop runtime's mesa, so I compiled it myself with d3d12 included:

git clone -b release/21.08 https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git
sed -ri 's/(gallium_drivers: iris,crocus)/\1,d3d12/' ./freedesktop-sdk/elements/extensions/mesa/mesa.bst
sed -ri 's|(- kind: local)|- kind: git_tag\n  directory: subprojects/DirectX-Headers\n  url: github:microsoft/DirectX-Headers.git\n  track: main\n  ref: v1.600.10-0-gf6c6c66b55fa53d5b609d41d4d3f4539cc86affd\n\1|' ./freedesktop-sdk/elements/extensions/mesa/mesa.bst
git clone https://gitlab.com/BuildStream/bst-external.git ./freedesktop-sdk/bst-external
docker run --privileged -v $(pwd)/freedesktop-sdk:/freedesktop-sdk buildstream/buildstream /bin/bash -c '\
  yum install -y make flatpak && \
  cd /freedesktop-sdk && \
  pip3 install --user -e ./bst-external && \
  make export'

sudo flatpak uninstall -y io.github.arunsivaramanneo.GPUViewer org.freedesktop.Platform org.freedesktop.Platform.GL.default
sudo flatpak remote-add --no-gpg-verify dev ./freedesktop-sdk/repo
sudo flatpak install -y dev org.freedesktop.Platform org.freedesktop.Platform.GL.default
sudo flatpak install -y flathub io.github.arunsivaramanneo.GPUViewer

flatpak run \
--device=all \
--filesystem=host-os:ro \
--env=LD_LIBRARY_PATH=/run/host/usr/lib/wsl/lib \
--env=LIBGL_DEBUG=verbose \
--env=D3D12_DEBUG=all \
--command=bash io.github.arunsivaramanneo.GPUViewer -c 'glxinfo -B'

/usr/lib/x86_64-linux-gnu/GL/default/lib/d3d12_dri.so exists now, but still not working, same error (with GALLIUM_DRIVER=d3d12, otherwise llvmpipe with no errors). :(

Show/hide error ``` name of display: :99.0 libGL: MESA-LOADER: dlopen(/usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so) libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory. libGL: Can't open configuration file /etc/drirc: No such file or directory. libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory. libGL error: failed to create dri screen libGL error: failed to load driver: swrast 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: 67 Current serial number in output stream: 68 ```

Any pointers as to what might still be missing, or how to further debug? :)

Other stuff I tried:

WSL logs:

pulseaudio.log (show/hide) ``` W: [pulseaudio] authkey.c: Failed to open cookie file '/home/wslg/.config/pulse/cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to load authentication key '/home/wslg/.config/pulse/cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to open cookie file '/home/wslg/.pulse-cookie': No such file or directory W: [pulseaudio] authkey.c: Failed to load authentication key '/home/wslg/.pulse-cookie': No such file or directory E: [pulseaudio] module-console-kit.c: GetSessionsForUnixUser() call failed: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.ConsoleKit was not provided by any .service files E: [pulseaudio] module.c: Failed to load module "module-console-kit" (argument: ""): initialization failed. E: [rdp-sink] module-rdp-sink.c: RDP Sink - Trying to connect to /mnt/wslg/PulseAudioRDPSink E: [rdp-sink] module-rdp-sink.c: Connected failed E: [rdp-sink] module-rdp-sink.c: RDP Sink - Trying to connect to /mnt/wslg/PulseAudioRDPSink E: [rdp-sink] module-rdp-sink.c: RDP Sink - Connected to fd 12 ```
weston.log (show/hide) ``` Date: 2022-03-20 CET [18:40:25.273] weston 9.0.0 https://wayland.freedesktop.org Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/ Build: 9.0.0-62-g6a3f1f66 [18:40:25.273] Command line: /usr/bin/weston --backend=rdp-backend.so --xwayland --socket=wayland-0 --shell=rdprail-shell.so --logger-scopes=log,rdp-backend,rdprail-shell --log=/mnt/wslg/weston.log [18:40:25.274] OS: Linux, 5.10.102.1-microsoft-standard-WSL2, #1 SMP Wed Mar 2 00:30:59 UTC 2022, x86_64 [18:40:25.274] Using config file '/home/wslg/.config/weston.ini' [18:40:25.274] Output repaint window is 7 ms maximum. [18:40:25.274] Loading module '/usr/lib/libweston-9/rdp-backend.so' [18:40:25.286] using FreeRDP version 2.4.0 Date: 2022-03-20 CET [18:40:25.286] RDP backend: WESTON_RDP_DEBUG_LEVEL: 3 [18:40:25.286] RDP backend: WESTON_RDP_MONITOR_REFRESH_RATE: 60000 [18:40:25.286] RDP backend: timer resolution tv_sec:0 tv_nsec:1 [18:40:25.286] RDP backend: Environment dump - start [18:40:25.286] WSL_DISTRO_NAME= [18:40:25.286] WSL2_USER_PROFILE=C:\Users\jonaskuske [18:40:25.286] WSL2_SHARED_MEMORY_OB_DIRECTORY=WSL\C49CEF65-EE4D-4B8F-9F61-66CFB0F923BE\wslg [18:40:25.286] PWD=/ [18:40:25.286] NAME=Surface-Jonas [18:40:25.286] WSL_FEATURE_FLAGS=7 [18:40:25.286] WSL2_INSTALL_PATH=C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.56.2.0_x64__8wekyb3d8bbwe [18:40:25.286] SHLVL=1 [18:40:25.286] WSL2_GUI_APPS_ENABLED=1 [18:40:25.286] WSL2_DISTRO_NAME=Ubuntu20.04LTS [18:40:25.286] WSL2_VM_ID=C49CEF65-EE4D-4B8F-9F61-66CFB0F923BE [18:40:25.286] _=/usr/bin/WSLGd [18:40:25.286] HOME=/home/wslg [18:40:25.286] USER=wslg [18:40:25.286] LOGNAME=wslg [18:40:25.286] SHELL=/bin/bash [18:40:25.286] PATH=/usr/sbin:/usr/bin:/sbin:/bin:/usr/games [18:40:25.286] XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir [18:40:25.286] WAYLAND_DISPLAY=wayland-0 [18:40:25.286] DISPLAY=:0 [18:40:25.286] XCURSOR_PATH=/usr/share/icons [18:40:25.286] XCURSOR_THEME=whiteglass [18:40:25.286] XCURSOR_SIZE=16 [18:40:25.286] PULSE_AUDIO_RDP_SINK=/mnt/wslg/PulseAudioRDPSink [18:40:25.286] PULSE_AUDIO_RDP_SOURCE=/mnt/wslg/PulseAudioRDPSource [18:40:25.286] USE_VSOCK=3 [18:40:25.286] WSL2_DEFAULT_APP_ICON=/usr/share/icons/wsl/linux.png [18:40:25.286] WSL2_DEFAULT_APP_OVERLAY_ICON=/usr/share/icons/wsl/linux.png [18:40:25.286] WESTON_DISABLE_ABSTRACT_FD=1 [18:40:25.286] WSL2_SHARED_MEMORY_MOUNT_POINT=/mnt/shared_memory [18:40:25.286] WESTON_CONFIG_FILE=/home/wslg/.config/weston.ini [18:40:25.286] RDP backend: Environment dump - end [18:40:25.286] RDP backend: FreeRDP version: 2.4.0 [18:40:25.286] Using external fd for incoming connections: 3 [18:40:25.286] Default head is being added [18:40:25.286] Registered plugin API 'weston_rdprail_api_v1' of size 56 [18:40:25.286] RDPAPPLIST_MODULEDIR is set to /usr/lib/rdpapplist [18:40:25.287] RDP backend: use_rdpapplist = 1 [18:40:25.287] rdp_allocate_shared_memory: Failed to open "/mnt/shared_memory/{14e5b396-c791-4dcf-89dd-050c82fe4ef8}" with error: Input/output error [18:40:25.287] RDP backend: use_gfxredir = 0 [18:40:25.287] RDP backend: enable_hi_dpi_support = 1 [18:40:25.287] RDP backend: enable_fractional_hi_dpi_support = 0 [18:40:25.287] RDP backend: enable_fractional_hi_dpi_roundup = 1 [18:40:25.287] RDP backend: debug_desktop_scaling_factor = 0 [18:40:25.287] RDP backend: enable_window_zorder_sync = 1 [18:40:25.287] RDP backend: keep_display_power_by_screenupdate = 0 [18:40:25.287] RDP backend: enable_distro_name_title = 1 [18:40:25.287] RDP backend: enable_copy_warning_title = 1 [18:40:25.287] Using VSOCK for incoming connections: 3 [18:40:25.288] Registered plugin API 'weston_rdp_output_api_v1' of size 16 [18:40:25.288] Head attaching: rdp-0, index:0, is_primary: 1 [18:40:25.288] get_config: attached head [0]: make:(null), mode:(null), name:rdp-0, (0x55718cd45ab0) [18:40:25.288] get_config: attached head [0]: x:0, y:0, width:0, height:0 [18:40:25.288] set_size: attached head [0]: make:weston, mode:rdp, name:rdp-0, (0x55718cd45ab0) [18:40:25.288] set_size: attached head [0]: x:0, y:0, width:0, height:0 [18:40:25.288] Output 'rdp-0' enabled with head(s) rdp-0 [18:40:25.288] Compositor capabilities: arbitrary surface rotation: yes screen capture uses y-flip: no presentation clock: CLOCK_MONOTONIC_RAW, id 4 presentation clock resolution: 0.000000001 s [18:40:25.288] Loading module '/usr/lib/weston/rdprail-shell.so' [18:40:25.289] RDPRAIL-shell: WESTON_RDPRAIL_SHELL_DEBUG_LEVEL: 3. Date: 2022-03-20 CET [18:40:25.289] wet_shell_init: distro name Ubuntu20.04LTS (14) [18:40:25.289] WESTON_RDPRAIL_SHELL_DISABLE_APPEND_DISTRONAME_STARTMEN:1 [18:40:25.290] WSL2_DEFAULT_APP_ICON:/usr/share/icons/wsl/linux.png [18:40:25.291] WSL2_DEFAULT_APP_OVERLAY_ICON:/usr/share/icons/wsl/linux.png [18:40:25.291] WESTON_RDPRAIL_SHELL_DISABLE_BLEND_OVERLAY_ICON_TASKBAR:1 [18:40:25.291] WESTON_RDPRAIL_SHELL_DISABLE_BLEND_OVERLAY_ICON_APPLIST:1 [18:40:25.291] rdp_rail_shell_initialize_notify: shell: distro name: Ubuntu20.04LTS [18:40:25.293] app_list_monitor_thread: running in system-distro with user-distro: Ubuntu20.04LTS [18:40:25.293] Loading module '/usr/lib/libweston-9/xwayland.so' [18:40:25.293] app_list_monitor_thread: open(/proc/self/ns/mnt) [18:40:25.293] app_list_monitor_thread: open(/proc/2/ns/mnt) [18:40:25.295] app_list_monitor_thread: inotify_add_watch(/usr/share/applications) [18:40:25.297] Registered plugin API 'weston_xwayland_v1' of size 32 [18:40:25.298] Registered plugin API 'weston_xwayland_surface_v1' of size 48 [18:40:25.299] Not using abstract fd for Xwayland [18:40:25.299] xserver listening on display :0 [18:40:25.299] launching '/usr/libexec/weston-rdprail-shell' [18:40:25.299] app_list_monitor_thread: /usr/local/share/applications doesn't exist, skipping. [18:40:25.299] app list folder[0]: /usr/share/applications [18:40:25.301] desktop file: /usr/share/applications/htop.desktop is terminal based app [18:40:25.301] app list entry failed to update: Key:htop [18:40:25.301] free_app_entry(): (null): /usr/share/applications/htop.desktop [18:40:25.301] desktop file: /usr/share/applications/info.desktop is terminal based app [18:40:25.301] app list entry failed to update: Key:info [18:40:25.301] free_app_entry(): (null): /usr/share/applications/info.desktop [18:40:25.302] desktop file: /usr/share/applications/snap-handle-link.desktop has NoDisplay specified [18:40:25.302] app list entry failed to update: Key:snap-handle-link [18:40:25.302] free_app_entry(): (null): /usr/share/applications/snap-handle-link.desktop [18:40:25.303] desktop file: /usr/share/applications/byobu.desktop is terminal based app [18:40:25.303] app list entry failed to update: Key:byobu [18:40:25.303] free_app_entry(): (null): /usr/share/applications/byobu.desktop [18:40:25.303] desktop file: /usr/share/applications/vim.desktop is terminal based app [18:40:25.303] app list entry failed to update: Key:vim [18:40:25.303] free_app_entry(): (null): /usr/share/applications/vim.desktop [18:40:25.304] desktop file: /usr/share/applications/io.snapcraft.SessionAgent.desktop has NoDisplay specified [18:40:25.304] app list entry failed to update: Key:io.snapcraft.SessionAgent [18:40:25.304] free_app_entry(): (null): /usr/share/applications/io.snapcraft.SessionAgent.desktop [18:40:25.304] desktop file: /usr/share/applications/python3.8.desktop has NoDisplay specified [18:40:25.304] app list entry failed to update: Key:python3.8 [18:40:25.304] free_app_entry(): (null): /usr/share/applications/python3.8.desktop [18:40:25.306] desktop file: /usr/share/applications/xdg-desktop-portal-gtk.desktop has NoDisplay specified [18:40:25.306] app list entry failed to update: Key:xdg-desktop-portal-gtk [18:40:25.306] free_app_entry(): (null): /usr/share/applications/xdg-desktop-portal-gtk.desktop [18:40:25.306] app list folder[1]: /usr/local/share/applications [18:40:25.324] CreateWndow(): rdp_peer is not initalized [18:40:26.057] Client: ClientStatus:0x3f5 [18:40:26.057] - TS_RAIL_CLIENTSTATUS_ALLOWLOCALMOVESIZE [18:40:26.057] - TS_RAIL_CLIENTSTATUS_ZORDER_SYNC [18:40:26.057] - TS_RAIL_CLIENTSTATUS_WINDOW_RESIZE_MARGIN_SUPPORTED [18:40:26.057] - TS_RAIL_CLIENTSTATUS_HIGH_DPI_ICONS_SUPPORTED [18:40:26.057] - TS_RAIL_CLIENTSTATUS_APPBAR_REMOTING_SUPPORTED [18:40:26.057] - TS_RAIL_CLIENTSTATUS_POWER_DISPLAY_REQUEST_SUPPORTED [18:40:26.057] - TS_RAIL_CLIENTSTATUS_GET_APPID_RESPONSE_EX_SUPPORTED [18:40:26.057] - TS_RAIL_CLIENTSTATUS_BIDIRECTIONAL_CLOAK_SUPPORTED [18:40:26.057] Client HandShake buildNumber:22000 [18:40:26.092] Server AppList caps version:3 [18:40:26.124] Client: GrfxCaps count:0x8 [18:40:26.124] Client: GrfxCaps[0] version:0x80004 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_8 [18:40:26.124] Client: GrfxCaps[1] version:0x80105 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_81 [18:40:26.124] Client: GrfxCaps[2] version:0xa0002 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_10 [18:40:26.124] Client: GrfxCaps[3] version:0xa0200 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_102 [18:40:26.124] Client: GrfxCaps[4] version:0xa0301 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_103 [18:40:26.124] Client: GrfxCaps[5] version:0xa0400 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_104 [18:40:26.124] Client: GrfxCaps[6] version:0xa0502 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_105 [18:40:26.124] Client: GrfxCaps[7] version:0xa0600 length:4 flags:0x0 [18:40:26.124] Version : RDPGFX_CAPVERSION_106 [18:40:26.135] Pulse Audio source listener socket on /mnt/wslg/PulseAudioRDPSource [18:40:26.135] xf_peer_adjust_monitor_layout: [18:40:26.135] DesktopWidth:3240, DesktopHeight:2160 [18:40:26.135] UseMultimon:0 [18:40:26.135] ForceMultimon:0 [18:40:26.135] MonitorCount:0 [18:40:26.135] HasMonitorAttributes:0 [18:40:26.135] HiDefRemoteApp:1 [18:40:26.135] disp_monitor_validate_and_compute_layout:---INPUT--- [18:40:26.135] rdpMonitor[0]: x:0, y:0, width:3240, height:2160, is_primary:1 [18:40:26.135] rdpMonitor[0]: physicalWidth:317, physicalHeight:211, orientation:0 [18:40:26.135] AudioIn source_thread: Listening for audio in connection. [18:40:26.135] rdpMonitor[0]: desktopScaleFactor:200, deviceScaleFactor:180 [18:40:26.135] rdpMonitor[0]: scale:2, client scale :2.00 [18:40:26.135] Client desktop upper left coordinate (0,0) [18:40:26.135] disp_monitor_validate_and_compute_layout:---OUTPUT--- [18:40:26.135] rdpMonitor[0]: x:0, y:0, width:3240, height:2160, is_primary:1 [18:40:26.135] rdpMonitor[0]: weston x:0, y:0, width:1620, height:1080 [18:40:26.135] rdpMonitor[0]: physicalWidth:317, physicalHeight:211, orientation:0 [18:40:26.135] rdpMonitor[0]: desktopScaleFactor:200, deviceScaleFactor:180 [18:40:26.135] rdpMonitor[0]: scale:2, clientScale:2.00 [18:40:26.136] Head mode change:rdp-0 OLD width:0, height:0, scale:1, clientScale:1.000000 [18:40:26.136] Head mode change:rdp-0 NEW width:3240, height:2160, scale:2, clientScale:2.000000 [18:40:26.136] move head/output rdp-0 (0,0) -> (0,0) [18:40:26.136] Output 'rdp-0' enabled with head(s) rdp-0 [18:40:26.136] move head/output rdp-0 (0,0) -> (0,0) [18:40:26.136] client origin (0,0) is (0,0) in Weston space [18:40:26.136] client virtual desktop is (0,0) - (3240,2160) [18:40:26.136] weston virtual desktop is (0,0) - (1620,1080) [18:40:26.136] kbd_layout:0x407 kbd_type:0x8 kbd_subType:0x0 kbd_functionKeys:0xc [18:40:26.136] convert_rdp_keyboard_to_xkb_rule_names: matching model=pc102 layout=de variant=(null) options=(null) [18:40:26.145] Detected a monitor change on head 'rdp-0', not bothering to do anything about it. [18:40:26.145] Client ExecOrder:0x00000008, Program:dummy-entry, WorkingDir:(null), RemoteApplicationArguments:(null) [18:40:26.145] Client ExecOrder launching dummy-entry [18:40:26.145] launching 'dummy-entry' [18:40:26.147] Client: ClientSysparam: filterKeys [18:40:26.147] Client: ClientSysparam: toggleKeys:62 [18:40:26.147] Client: ClientSysparam: stickyKeys:506 [18:40:26.147] Client: ClientSysparam: caretWidth:1 [18:40:26.147] Client: ClientSysparam: highContrast [18:40:26.147] Client: ClientSysparam: taskbarPos:(left:0, top:2064, right:3240, bottom:2160) [18:40:26.147] Client: ClientSysparam: mouseButtonSwap:0 [18:40:26.147] Client: ClientSysparam: keyboardPref:0 [18:40:26.147] Client: ClientSysparam: dragFullWindows:1 [18:40:26.148] Client: ClientSysparam: keyboardCues:0 [18:40:26.148] Client: ClientSysparam: workArea:(left:0, top:0, right:3240, bottom:2064) [18:40:26.148] Translated workarea:(0,0)-(1620,1032) at rdp-0:(0,0)-(1620,1080) [18:40:26.148] Client AppList caps version:3 [18:40:26.148] Client AppList client language id: de_DE [18:40:26.148] compositor: executing 'dummy-entry' failed: No such file or directory [18:40:26.148] app_list_monitor_thread: startRdpNotifyEvent is signalled. 0 - de_DE [18:40:26.148] app_list_start_rdp_notify(): client language is changed from en_US to de_DE [18:40:26.148] app list folder[0]: /usr/share/applications [18:40:26.149] desktop file: /usr/share/applications/htop.desktop is terminal based app [18:40:26.149] app list entry failed to update: Key:htop [18:40:26.149] Client: ClientSysparam: filterKeys [18:40:26.149] free_app_entry(): (null): /usr/share/applications/htop.desktop [18:40:26.149] Client: ClientSysparam: toggleKeys:62 [18:40:26.149] Client: ClientSysparam: stickyKeys:506 [18:40:26.149] Client: ClientSysparam: caretWidth:1 [18:40:26.149] desktop file: /usr/share/applications/info.desktop is terminal based app [18:40:26.149] app list entry failed to update: Key:info [18:40:26.149] Client: ClientSysparam: highContrast [18:40:26.149] free_app_entry(): (null): /usr/share/applications/info.desktop [18:40:26.149] desktop file: /usr/share/applications/snap-handle-link.desktop has NoDisplay specified [18:40:26.149] app list entry failed to update: Key:snap-handle-link [18:40:26.149] free_app_entry(): (null): /usr/share/applications/snap-handle-link.desktop [18:40:26.149] desktop file: /usr/share/applications/byobu.desktop is terminal based app [18:40:26.149] app list entry failed to update: Key:byobu [18:40:26.149] free_app_entry(): (null): /usr/share/applications/byobu.desktop [18:40:26.149] Client ExecOrder program terminated [18:40:26.149] desktop file: /usr/share/applications/vim.desktop is terminal based app [18:40:26.149] dummy-entry exited with status 255 [18:40:26.149] app list entry failed to update: Key:vim [18:40:26.149] free_app_entry(): (null): /usr/share/applications/vim.desktop [18:40:26.149] desktop file: /usr/share/applications/io.snapcraft.SessionAgent.desktop has NoDisplay specified [18:40:26.149] app list entry failed to update: Key:io.snapcraft.SessionAgent [18:40:26.149] free_app_entry(): (null): /usr/share/applications/io.snapcraft.SessionAgent.desktop [18:40:26.149] desktop file: /usr/share/applications/python3.8.desktop has NoDisplay specified [18:40:26.149] app list entry failed to update: Key:python3.8 [18:40:26.149] free_app_entry(): (null): /usr/share/applications/python3.8.desktop [18:40:26.150] desktop file: /usr/share/applications/xdg-desktop-portal-gtk.desktop has NoDisplay specified [18:40:26.150] app list entry failed to update: Key:xdg-desktop-portal-gtk [18:40:26.150] free_app_entry(): (null): /usr/share/applications/xdg-desktop-portal-gtk.desktop [18:40:26.150] app list folder[1]: /usr/local/share/applications [18:40:26.439] rdp_audio_server_activated: 1 audio formats supported. [18:40:26.439] [0] - Format(WAVE_FORMAT_PCM) - Bits(16), Channels(2), Frequency(44100) [18:40:26.439] RDPAudio - Agreed on format 0. [18:40:26.439] rdp_audio_server_activated: bytesPerFrame:4, latency:5 [18:40:26.439] Pulse Audio Sink listener socket on /mnt/wslg/PulseAudioRDPSink [18:40:26.439] Audio sink thread: Listening for audio connection. [18:40:26.441] Client: ClientSysparam: taskbarPos:(left:0, top:2064, right:3240, bottom:2160) [18:40:26.441] Client: ClientSysparam: mouseButtonSwap:0 [18:40:26.441] Client: ClientSysparam: keyboardPref:0 [18:40:26.441] Client: ClientSysparam: dragFullWindows:1 [18:40:26.441] Client: ClientSysparam: keyboardCues:0 [18:40:26.441] Client: ClientSysparam: workArea:(left:0, top:0, right:3240, bottom:2064) [18:40:26.441] Translated workarea:(0,0)-(1620,1032) at rdp-0:(0,0)-(1620,1080) [18:40:30.333] Audio sink thread: connection successful on socket (62). [18:40:30.333] RDP Sink version (1 - 1) [18:41:14.113] Spawned Xwayland server, pid 226 [18:41:18.366] xfixes version: 5.0 [18:41:18.374] created wm, root 575 [18:41:18.374] xfixes selection notify event: owner 2097153 [18:41:18.374] our window, skipping ```
stderr.log (show/hide) ``` dbus[13]: Unknown username "pulse" in message bus configuration file could not load cursor 'grabbing' could not load cursor 'dnd-move' could not load cursor 'dnd-copy' glamor: 'wl_drm' not supported Missing Wayland requirements for glamor GBM backend Failed to initialize glamor, falling back to sw The XKEYBOARD keymap compiler (xkbcomp) reports: > Internal error: Could not resolve keysym XF86FullScreen Errors from xkbcomp are not fatal to the X server The XKEYBOARD keymap compiler (xkbcomp) reports: > Warning: Unsupported maximum keycode 569, clipping. > X11 cannot support keycodes above 255. > Internal error: Could not resolve keysym XF86FullScreen Errors from xkbcomp are not fatal to the X server ```
versions.txt (show/hide) ``` WSLg ( x86_64 ): 1.0.30+Branch.main.Sha.18884f996f5e851af4842010b434db17d3caa7aa Mariner: VERSION="1.0.20210224" FreeRDP: 81cfc08b9c745c941be23bd8dd43b9ffeb5b6991 weston: 6a3f1f669f6e53c0db3057d4f62da3a473c07c71 pulseaudio: 2f0f0b8c3872780f15e275fc12899f4564f01bd5 mesa: ```

Expected behavior

glxinfo -B in flatpak uses the GPU just like it does when run on the host or in a docker container, instead of llvmpipe software rendering.

Actual behavior

It always uses llvmpipe, and breaks when run via GALLIUM_DRIVER=d3d12

jonaskuske commented 2 years ago

And here's whats logged for my actual usecase, using the Epiphany browser (to debug sites in WebKit):

> flatpak run --device=all --filesystem=host-os:ro --env=LD_LIBRARY_PATH=/run/host/usr/lib/wsl/lib --env=LIBGL_DEBUG=verbose --env=D3D12_DEBUG=all --env=MESA_DEBUG=1 --env=GALLIUM_PRINT_OPTIONS=1 --env=GALLIUM_DRIVER=d3d12 org.gnome.Epiphany

(epiphany:2): Gdk-WARNING **: 20:29:52.752: Settings portal not found: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libEGL warning: DRI2: failed to create dri screen
EGLDisplay Initialization failed: EGL_NOT_INITIALIZED

(epiphany:2): libsecret-WARNING **: 20:29:52.897: couldn't get session bus: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id

(epiphany:2): epiphany-WARNING **: 20:29:52.907: Failed to search secrets in password schema: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id

(WebKitWebProcess:37): Gdk-WARNING **: 20:29:53.071: Settings portal not found: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libEGL warning: DRI2: failed to create dri screen
EGLDisplay Initialization failed: EGL_NOT_INITIALIZED
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libEGL warning: DRI2: failed to create dri screen
EGLDisplay Initialization failed: EGL_NOT_INITIALIZED
Cannot create EGL context: invalid display (last error: EGL_SUCCESS)

using X11 instead of Wayland:

> flatpak run --device=all --filesystem=host-os:ro --env=LD_LIBRARY_PATH=/run/host/usr/lib/wsl/lib --nosocket=wayland --nosocket=fallback-x11 --socket=x11 --env=LIBGL_DEBUG=verbose --env=D3D12_DEBUG=all --env=MESA_DEBUG=1 --env=GALLIUM_PRINT_OPTIONS=1 --env=GALLIUM_DRIVER=d3d12 org.gnome.Epiphany

(epiphany:2): libsecret-WARNING **: 20:36:21.748: couldn't get session bus: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id

(epiphany:2): epiphany-WARNING **: 20:36:21.759: Failed to search secrets in password schema: Cannot spawn a message bus without a machine-id: Invalid machine ID in /var/lib/dbus/machine-id or /etc/machine-id
libGL: MESA-LOADER: dlopen(/usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so)
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/jonaskuske/.drirc: No such file or directory.
libGL error: failed to create dri screen
libGL error: failed to load driver: swrast

(epiphany:2): Gdk-WARNING **: 20:36:22.315: The program 'epiphany' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 9847 error_code 2 request_code 148 (GLX) minor_code 34)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
elsaco commented 2 years ago

@jonaskuske there's a bug tracking GPU acceleration issues at https://github.com/microsoft/WSL/issues/8145 that might be of interest to you.

hideyukn88 commented 2 years ago

@jonaskuske, thanks for reporting the issue, assuming you are on the latest WSL (which addresses the issue mentioned by @elsaco), is the issue specific under flatpak? does glxinfo found GPU under non-flatpak environment? Thanks!

jonaskuske commented 2 years ago

@hideyukn88 Yeah, this is specifically about flatpak. GPU works im general (apart from the Nvidia segfault described in https://github.com/microsoft/WSL/issues/8145), but I'm not sure how to get it to work in sandboxed flatpak apps. I followed the docker sample https://github.com/microsoft/wslg/blob/732705fc9a49981ffc8aa3c551a2a565cf9d2a8e/samples/container/Containers.md, the d3d12 driver is there, /wsl/lib is in LD_LIBRARY_PATH but it isn't working so I'm wondering what else might be missing.

tiagoshibata commented 2 years ago

As a hacky and invasive workaround, using --usr-path=/usr to override the entirety of flatpak's /usr with the host's /usr works:

flatpak run --device=all --env=LD_LIBRARY_PATH=/usr/lib/wsl/lib --usr-path=/usr --command=/app/bin/glxinfo io.github.arunsivaramanneo.GPUViewer -B
name of display: :99.0
display: :99  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (NVIDIA Quadro P400) (0xffffffff)
    Version: 21.2.6
    Accelerated: yes
    Video memory: 18157MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA Quadro P400)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 21.2.6
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 21.2.6
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 21.2.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

I'm working on a cleaner fix.

RushingAlien commented 9 months ago

I'm guessing a good solution is for Microsoft to package WSL's GL drivers for flatpak there are already:

This is how GL drivers are provided to Flatpak, via GL runtime extensions. So we would need to have Microsoft package an org.freedesktop.Platform.GL.wsl

I would like to make this a reality, where are the sources to these driver bits?

You guys should communicate with the FreeDesktop/Flatpak guys about it, they are interested on supporting WSL.

e-t-l commented 9 months ago

@tiagoshibata:

As a hacky and invasive workaround, using --usr-path=/usr to override the entirety of flatpak's /usr with the host's /usr works

Is there any security risk in, if I understand this correctly, breaking out of the flatpak sandbox to give access to the whole /usr dir?

UPDATE: This doesn't actually work, at least for me on a fresh WSL (2.0.14) install of Ubuntu 22.04. Running flatpak run --usr-path=/usr org.gnome.Epiphany produced a ton of errors about missing dependencies, which I had to download one-by-one (because it only showed one error at a time)...

epiphany: error while loading shared libraries: libgtk-4.so.1: cannot open shared object file: No such file or directory
epiphany: error while loading shared libraries: libadwaita-1.so.0: cannot open shared object file: No such file or directory
epiphany: error while loading shared libraries: libsoup-3.0.so.0: cannot open shared object file: No such file or directory
epiphany: error while loading shared libraries: libwebkitgtk-6.0.so.4: cannot open shared object file: No such file or directory
epiphany: error while loading shared libraries: libgcr-4.so.4: cannot open shared object file: No such file or directory
dpkg: dependency problems prevent configuration of libgcr-4-4:amd64:
 libgcr-4-4:amd64 depends on libgck-2-2 (= 4.1.0-2+b1); however:
  Package libgck-2-2 is not installed.
 libgcr-4-4:amd64 depends on libgcrypt20 (>= 1.10.0); however:
  Version of libgcrypt20:amd64 on system is 1.9.4-3ubuntu3.
 libgcr-4-4:amd64 depends on libglib2.0-0 (>= 2.75.3); however:
  Version of libglib2.0-0:amd64 on system is 2.72.4-0ubuntu2.2.
 libgcr-4-4:amd64 depends on libp11-kit0 (>= 0.25.0); however:
  Version of libp11-kit0:amd64 on system is 0.24.0-6build1.
epiphany: error while loading shared libraries: libgee-0.8.so.2: cannot open shared object file: No such file or directory
epiphany: symbol lookup error: /app/lib/epiphany/libephymisc.so: undefined symbol: gtk_file_dialog_set_filters

It was this final error, "undefined symbol," that I couldn't figure out how to fix. So I still cannot run Gnome Web with hardware acceleration on WSL :(

RushingAlien commented 1 month ago

Are there documentation on how to package WSL's GL drivers? Been meaning to package org.freedesktop.Platform.GL.wsl