Segfault in SDL2 game when using environment variables: `SDL_VIDEODRIVER=wayland DRI_PRIME=1`
System information
The system is a Zephyrus G14 (GA402RK) with Radeon 6800S GPU.
System:
Host: proton Kernel: 6.3.9-arch1-1 arch: x86_64 bits: 64 compiler: gcc
v: 13.1.1 Desktop: KDE Plasma v: 5.27.6 tk: Qt v: 5.15.10 wm: kwin_wayland
dm: SDDM Distro: Arch Linux
CPU:
Info: 8-core model: AMD Ryzen 9 6900HS with Radeon Graphics bits: 64
type: MT MCP arch: Zen 3+ rev: 1 cache: L1: 512 KiB L2: 4 MiB L3: 16 MiB
Speed (MHz): avg: 2173 high: 4691 min/max: 1600/4934 boost: enabled cores:
1: 1798 2: 1600 3: 1504 4: 3300 5: 1334 6: 1600 7: 1600 8: 1478 9: 4691
10: 4691 11: 1462 12: 1600 13: 1706 14: 1600 15: 1514 16: 3300
bogomips: 105453
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
Device-1: AMD Navi 23 [Radeon RX 6650 XT / 6700S 6800S] vendor: ASUSTeK
driver: amdgpu v: kernel arch: RDNA-2 pcie: speed: 16 GT/s lanes: 16 ports:
active: DP-10,DP-12 empty: DP-1, DP-11, DP-13, HDMI-A-1, eDP-1
bus-ID: 03:00.0 chip-ID: 1002:73ef
Device-2: AMD Rembrandt [Radeon 680M] vendor: ASUSTeK driver: amdgpu
v: kernel arch: RDNA-2 pcie: speed: 16 GT/s lanes: 16 ports: active: eDP-2
empty: DP-2, DP-3, DP-4, DP-5, DP-6, DP-7, DP-8, DP-9 bus-ID: 07:00.0
chip-ID: 1002:1681 temp: 55.0 C
Device-3: Quanta USB2.0 HD UVC WebCam driver: uvcvideo type: USB rev: 2.0
speed: 480 Mb/s lanes: 1 bus-ID: 3-3:2 chip-ID: 0408:30c3
Display: wayland server: X.org v: 1.21.1.8 with: Xwayland v: 23.1.2
compositor: kwin_wayland driver: X: loaded: modesetting
alternate: fbdev,vesa dri: radeonsi gpu: amdgpu display-ID: 0
Monitor-1: DP-10 model: Dell U2515H res: 2560x1440 dpi: 118
diag: 634mm (25")
Monitor-2: DP-12 model: Dell U2518D res: 2560x1440 dpi: 118
diag: 634mm (25")
Monitor-3: eDP-2 model: BOE Display 0x0a1d res: 2560x1600 dpi: 215
diag: 356mm (14")
API: OpenGL v: 4.6 Mesa 23.1.3 renderer: AMD Radeon Graphics (rembrandt
LLVM 15.0.7 DRM 3.52 6.3.9-arch1-1) direct-render: Yes
Describe the issue
When forcing an SDL2 game to run on the dedicated GPU and in native Wayland mode, the game will segfault every time.
Using the following environment variables: DRI_PRIME=1 SDL_VIDEODRIVER=wayland
- the game will launch with one or the other, but never both.
Regression
This worked properly around 9 months ago with no graphical issues. Around 6 months ago I started seeing graphical artifacts in any game run with these variables. Since around 2 months, games have not launched. The last known working date of this working was on 4th March 2023 when I recorded the following video demonstrating the artifacting: https://p.mort.coffee/Y16.mp4 (the game shown here is Unvanquished which was also compiled on this system)
Backtrace
The relevant backtrace follows. The game tried here was dhewm3 which was compiled from source on this system.
Thread 1 "dhewm3" received signal SIGSEGV, Segmentation fault.
wl_proxy_get_version (proxy=0x0) at ../wayland-1.22.0/src/wayland-client.c:2248
Downloading source file /usr/src/debug/wayland/build/../wayland-1.22.0/src/wayland-client.c
2248 return proxy->version;
(gdb) bt
#0 wl_proxy_get_version (proxy=0x0) at ../wayland-1.22.0/src/wayland-client.c:2248
#1 0x00007ffff15af3e6 in wl_drm_create_prime_buffer () at src/egl/wayland/wayland-drm/wayland-drm-client-protocol.h:303
#2 create_wl_buffer () at ../mesa-23.1.3/src/egl/drivers/dri2/platform_wayland.c:1548
#3 0x00007ffff15b2e04 in dri2_wl_swap_buffers_with_damage () at ../mesa-23.1.3/src/egl/drivers/dri2/platform_wayland.c:1638
#4 0x00007ffff15a31e8 in dri2_swap_buffers () at ../mesa-23.1.3/src/egl/drivers/dri2/egl_dri2.c:1880
#5 0x00007ffff159b04d in eglSwapBuffers () at ../mesa-23.1.3/src/egl/main/eglapi.c:1468
#6 0x00007ffff7c82d37 in Wayland_GLES_SwapWindow (_this=<optimized out>, window=<optimized out>) at /usr/src/debug/sdl2/SDL2-2.28.0/src/video/wayland/SDL_waylandopengles.c:166
Screenshots/video files (if applicable)
See regressions section.