[zink] Sync issue causes graphical glitches in Valheim
Description
When launching the game with OpenGL using Zink, there are flickering vertex explosions and other graphical glitches starting from the title screen and onwards. The glitches are easier to reproduce with a slower GPU or with more graphical effects enabled.
I did not see this issue when I tested it on the Deck (Main OS, Mesa 23.3.0).
Screenshots/video files
The glitches don't appear in screenshots taken via the Steam overlay, in RenderDoc captures, or when replaying a GFXReconstruct capture frame by frame, so I was only able to get screenshots via ScreenGrab.
This texture is briefly rendered in place of the Valheim logo when rapidly switching from character screen to main menu:
In the normal RenderDoc captures I got, this texture belongs to the preceding indexed draw.
Steps to reproduce
Start the game with Zink
Sometimes there are vertex explosions immediately in the title screen, but it depends on GPU load
Choose "start game" and then go back to the main menu, and the title logo will briefly render using the wrong texture
The logo glitch is a good symptom to look for since it appears more easily than the other glitches.
System information
System information
System:
Host: ryzen-runar Kernel: 6.6.9-arch1-1 arch: x86_64 bits: 64 compiler: gcc
v: 13.2.1 Desktop: KDE Plasma v: 5.27.10 tk: Qt v: 5.15.11 wm: kwin_x11
dm: SDDM Distro: Arch Linux
CPU:
Info: 12-core model: AMD Ryzen 9 7900 bits: 64 type: MT MCP arch: Zen 4
rev: 2 cache: L1: 768 KiB L2: 12 MiB L3: 64 MiB
Speed (MHz): avg: 1340 high: 3901 min/max: 400/5482 cores: 1: 3589 2: 400
3: 3901 4: 3496 5: 400 6: 400 7: 400 8: 3827 9: 3516 10: 3554 11: 400
12: 400 13: 400 14: 3496 15: 400 16: 400 17: 400 18: 400 19: 400 20: 400
21: 400 22: 400 23: 400 24: 400 bogomips: 177692
Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
Graphics:
Device-1: AMD Navi 10 [Radeon RX 5600 OEM/5600 XT / 5700/5700 XT]
driver: amdgpu v: kernel arch: RDNA-1 pcie: speed: 16 GT/s lanes: 16 ports:
active: none empty: DP-1, DP-2, DP-3, HDMI-A-1 bus-ID: 03:00.0
chip-ID: 1002:731f
Device-2: AMD Raphael vendor: ASUSTeK driver: amdgpu v: kernel
arch: RDNA-2 pcie: speed: 16 GT/s lanes: 16 ports: active: DP-4,HDMI-A-2
empty: none bus-ID: 0d:00.0 chip-ID: 1002:164e temp: 41.0 C
Device-3: Logitech Webcam C310 driver: snd-usb-audio,uvcvideo type: USB
rev: 2.0 speed: 480 Mb/s lanes: 1 bus-ID: 7-1:2 chip-ID: 046d:081b
Display: x11 server: X.Org v: 21.1.10 with: Xwayland v: 23.2.3
compositor: kwin_x11 driver: X: loaded: modesetting unloaded: vesa
alternate: fbdev dri: radeonsi gpu: amdgpu display-ID: :0 screens: 1
Screen-1: 0 s-res: 4480x1440 s-dpi: 96
Monitor-1: DP-4 pos: primary,right model: Dell U2515H res: 2560x1440
dpi: 118 diag: 634mm (25")
Monitor-2: HDMI-A-2 mapped: HDMI-2 pos: left model: Samsung S24E391
res: 1920x1080 dpi: 94 diag: 598mm (23.5")
API: EGL v: 1.5 platforms: device: 0 drv: radeonsi device: 1 drv: radeonsi
device: 2 drv: swrast surfaceless: drv: radeonsi x11: drv: radeonsi
inactive: gbm,wayland
API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 23.3.2-arch1.2
glx-v: 1.4 direct-render: yes renderer: AMD Radeon Graphics (radeonsi
raphael_mendocino LLVM 16.0.6 DRM 3.54 6.6.9-arch1-1) device-ID: 1002:164e
API: Vulkan v: 1.3.274 surfaces: xcb,xlib device: 0 type: integrated-gpu
driver: mesa radv device-ID: 1002:164e device: 1 type: discrete-gpu
driver: mesa radv device-ID: 1002:731f device: 2 type: cpu
driver: mesa llvmpipe device-ID: 10005:0000
Regression
Initially I thought it was a regression since it appears in 23.0 (896db04e) and onwards (91ec3cc7), and I could not reproduce any glitches with RX 5700 XT or RX 7600 when using 22.3 (4ee0a7e7). However, when I ran it on the iGPU instead, all the glitches appeared immediately regardless of Mesa version.
API captures (if applicable, optional)
I got a GFXReconstruct capture with the RX 5700 XT and 23.3.2. The captures I got with the RX 7600 would crash on replay.
Further information (optional)
RADV_DEBUG=syncshaders
doesn't affect the issue, but RADV_DEBUG=hang
fixes it.