Skip to content

fix(vk): recover presentation after surface loss - #1995

Merged
hckrman101 merged 4 commits into
NotRexed:mainfrom
Arkex-ai:fix/vulkan-surface-loss
Nov 11, 2026
Merged

hckrman101 merged 4 commits into
NotRexed:mainfrom
Arkex-ai:fix/vulkan-surface-loss

Conversation

@Arkex-ai

@Arkex-ai Arkex-ai commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

After Vulkan reported a lost window surface, the picture could stop indefinitely. The renderer now retires the old swapchain and retries with a replacement surface after loss during acquire, present or swapchain setup.

Closes #1977.

Technical changes

  • Drain pending GPU work and retire the old swapchain, views and semaphores before destroying the surface.
  • Reuse the startup surface factory on retry. Wait for a drawable window, limit surface creation attempts, recheck presentation support and keep startup error messages out of repeated recovery attempts.
  • Track swapchain generation with deferred frames so an old frame cannot reach a replacement chain even if the driver reuses its handle.
  • Recheck spare-image capacity after replacement so a 2× deferred pair cannot acquire on a chain that only has room for ordinary presentation. Deferred out-of-date presents also no longer count as shown frames in the overlay or pacing history.

Validation

Current head: b52079d5, rebased onto main 49f75dc8 (recorder test ordering fix). All authored commits are unchanged by range-diff. Fresh hosted checks run on this head; the local and native results below remain tied to their earlier tested heads.

Earlier local and native evidence:

Earlier head: 8c6b593d, rebased onto main ebbba2ea. Focused Windows checks: 4 passed / 1 failed. Swapchain recovery, presentation semaphores, Anti-Lag and the new FPS statistics pass. The recorder check fails its existing destructor negative control on both this head and the exact clean base. Earlier native evidence remains labeled below.

  • At cda37c2, the upstream source suite passed with 323 passed / 0 failed / 24 skipped on Windows and 337 / 0 / 10 on Linux. Windows includes the temporary bake skips from test: log_batch "off" takes the fastest of three; bake tests skip on Windows CI (600 s limit) #2013.
  • The Windows and Linux regression fixtures inject surface loss during acquire, present and swapchain creation. They verify resource destruction order, reject deferred frames when the replacement swapchain reuses the old handle, and check recovery with a smaller replacement chain.
  • Native driver surface loss and Linux gameplay remain untested.
Earlier native smoke test and Linux surface probe
  • At cc80fde (API 14), a Windows RTX 5070 Ti run logged 6,688 presents at 2× frame generation with pacing off. The Kokiri scene returned after maximize, restore and minimize, and the game exited normally.
  • The standalone WSLg probe recreated Vulkan surfaces 8 times on X11 and 8 times on Wayland using SDL2 and lavapipe. Each replacement supported presentation and returned valid capabilities. The probe did not exercise SDL3 or swapchain presentation.
Current-head workflow Result
Linux AppImage Needs attention
Game-free source regressions Passed
PR title Passed
Windows builder Passed

@Arkex-ai
Arkex-ai force-pushed the fix/vulkan-surface-loss branch from d526a52 to c5aec41 Compare November 10, 2026 23:28
@Arkex-ai

Copy link
Copy Markdown
Contributor Author

Thanks for the review. c5aec41 keeps both surface startup diagnostics at startup only, so a failed 250 ms retry won't print them repeatedly. The existing capped surface-loss message remains. I also rewrote the opening, noted the deferred OUT_OF_DATE accounting, and clarified that the native resize smoke test exercised ordinary window transitions. Surface loss itself was injected. Linux gameplay and driver-reported native loss are still untested.

The previous Windows source run matched the exact upstream base: 322 passed, 2 failed, 21 skipped, with the same log timing failure and skeleton bake timeout. The three new fork workflows are linked in the Validation table for c5aec41.

@Arkex-ai
Arkex-ai force-pushed the fix/vulkan-surface-loss branch from c5aec41 to cda37c2 Compare November 11, 2026 00:13
@Arkex-ai
Arkex-ai marked this pull request as ready for review November 11, 2026 00:35
@Arkex-ai
Arkex-ai force-pushed the fix/vulkan-surface-loss branch 2 times, most recently from 01147b2 to 8c6b593 Compare November 11, 2026 11:39
@Arkex-ai
Arkex-ai force-pushed the fix/vulkan-surface-loss branch from 8c6b593 to b52079d Compare November 11, 2026 12:43
@hckrman101
hckrman101 merged commit edcb8a1 into NotRexed:main Nov 11, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vulkan presentation stalls after the window surface is lost

1 participant