Skip to content

fix(vk): the presenter thread is off by default again - #2544

Merged
hckrman101 merged 1 commit into
NotRexed:mainfrom
hckrman101:fix/present-thread-off
Nov 11, 2026
Merged

hckrman101 merged 1 commit into
NotRexed:mainfrom
hckrman101:fix/present-thread-off

Conversation

@hckrman101

Copy link
Copy Markdown
Collaborator

A review of the presenter thread merged in #2325 found two problems that make it unsafe as a default, so this turns it off again until they are fixed.

  • The swapchain is used from two threads with no lock between them. The game thread's vkAcquireNextImageKHR runs while the presenter thread calls vkQueuePresentKHR and vkWaitForPresentKHR on the same swapchain. All three need the swapchain externally synchronized. The overlap happens every frame, by design.
  • The drain before a swapchain remake gives up after 5 s. Its callers then destroy the swapchain and semaphores the presenter may still be using. The presenter's own worst case (the copy's fence for 5 s, then the present) is longer than that. The same limit in present_out lets two presents go out of order.

What changes

The fixes (one lock or an idle wait around the swapchain's acquire and present, a drain that never gives up and leaves the swapchain alone, and the smaller findings) follow in their own PR. That PR turns the default back on only if every fix holds and is tested.

Tested: tests/test_present_thread.py, tests/test_fps_stats.py and tests/test_present_semaphores.py pass, and the Vulkan back end builds.

A review of the presenter thread (NotRexed#2325) found two problems that make it
unsafe as a default:
- The game thread's vkAcquireNextImageKHR runs on the swapchain while the
  presenter thread calls vkQueuePresentKHR and vkWaitForPresentKHR on it,
  with no lock shared between them. All three need the swapchain externally
  synchronized, and this overlap happens every frame.
- The drain before a swapchain is made again gives up after 5 s, and its
  callers then destroy the swapchain and semaphores the presenter may still
  be using. The presenter's own worst case is over 5 s.

RX_VK_PRESENT_THREAD=1 still turns it on. Off, the device makes no queue
for it, as before NotRexed#2325. Fixes follow in their own change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hckrman101
hckrman101 merged commit b520d51 into NotRexed:main Nov 11, 2026
8 of 10 checks passed
@hckrman101
hckrman101 deleted the fix/present-thread-off branch November 11, 2026 22:49
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.

1 participant