Repository navigation
fix(vk): let a catch-up go on only past met waits, not every stopped queue - #449
Conversation
…queue wait_queue_empty in sync mode (a queue finish, an invalidate that reads back what the GPU wrote, a pool's mapping changing) called sync_drain(2), which forces every queue stopped at an event wait past it. The work those waits are for is mostly not submitted yet: the thread waiting is the one that submits it (holding the waiter 20 ms let only 32 of ~3600 go on by themselves). Forced past, the stopped submission's lit passes read what that work makes before it was made, and the scene came out black, grey or blown out for a frame (HUD and Navi on top), every other frame for seconds in Kokiri Forest. At low frame rates the other queue's work had always arrived first, so this shows once the game runs at speed. A frame probe (RX_VK_PROBE=2) of the dark frames: the same ~120 draws into the 1536x864 scene target came out 0, with the 512x512 compute dispatches recorded before the passes instead of after them. Now a catch-up only schedules what can go on; the rest goes on with its own queue's later work, a present, or sync_watch's hold_ms, as before. RX_VK_CATCHUP_FORCE=1: forced, as before. Complements NotRexed#430, which does the same for releases (drain 1). Measured over 70 s of Kokiri gameplay (frame log, RX 7800 XT, RADV, foliage-linux-updater release + this): before: 10,000-40,000 waits gone past, 600-2,900 forced by "waits for the replay", 250-1,100 frames flashing after: 264-378 waits gone past, 0 forced by catch-ups, 65-113 frames flashing (3 runs); 60 fps, no hangs or device loss The flashes left line up with the presents' drain(0) (114-362 a run); NotRexed#430's readback refresh may be what remains. Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested on Intel Arc B390 (Core Ultra X7 358H iGPU), Linux, Mesa 26.2.5 ANV, kernel 7.2.15, Hyprland (Wayland). This fixes the flashing here. Setup: release
Thanks for the fix! |
|
Tested on an RTX 4080 / Windows 11 / Ryzen 9 7900X:
No regression in fps, no white frames or device lost; 0 flashes in this run. Plain |
What this fixes
One-frame flashes in Kokiri Forest once the game runs at speed. The scene goes black, grey or blown out for a frame, with the HUD and Navi still drawn on top. It often alternates with normal frames for several seconds. This may be what #145, #305 and #307 describe.
Why
In sync mode,
wait_queue_empty()callssync_drain(2), which forces every queue stopped at an event wait past its wait. The callers are a queue finish, an invalidate that reads back GPU-written data, and a pool's mapping changing.The work those waits are for is mostly not submitted yet, because the thread that's waiting is the one that would submit it. As a test, holding the waiter for up to 20 ms let only 32 of about 3,600 stopped queues go on by themselves. Forced past its wait, the stopped submission's lit passes read results before they're made.
A frame probe (
RX_VK_PROBE=2) of the dark frames showed:At low frame rates the other queue's work had always arrived first, so this only shows once the game runs fast. For us that was after the udmabuf change.
Change
gpu/vk/vk_replay.cpp: in sync mode, a catch-up now onlyschedule()s what can go on, meaning waits that are met. Stopped work still goes on, as before, with:sync_watch'shold_ms.RX_VK_CATCHUP_FORCE=1forces, as before.This complements #430, which does the same for releases (drain 1).
Tested
RX_VK_FRAMELOG) of 70 s of Kokiri gameplay, counting frames that differ from both neighbours but match the frame two back.finish()that needs stopped work waits on the timeline untilsync_watchmoves it, but that never showed up as lost frames.drain(0), 114-362 per run. AMD (RX 6600) fixes for Ocarina of Time: GPU hang, fog flicker, exposure #430's readback refresh may cover what remains.foliage-linux-updaterrelease with this patch.main: rebased onto currentmain, wherehookshot_vkbuilds. I have not run a fullmainbuild.Analysis and patch made with Claude (Anthropic); I ran every test on my machine.
🤖 Generated with Claude Code