Skip to content

fix(vulkan): reuse unchanged swapchains across rebuilds and game joins - #156

Merged
CoderDayton merged 1 commit into
mainfrom
fix/swapchain-reuse
Dec 1, 2026
Merged

CoderDayton merged 1 commit into
mainfrom
fix/swapchain-reuse

Conversation

@CoderDayton

Copy link
Copy Markdown
Owner

On NVIDIA with PRIME on X11, every swapchain destroy or retiring create blocks Roblox's main thread for about 22 s, so each game join froze for about 44 s. Moving the destroy to the background (#148/#151) didn't help because the create itself blocks.

Roblox rebuilds an identical swapchain after each view change, and on every join it destroys the swapchain and surface, then makes the same swapchain again on a new surface. Now:

  • An identical create gets the current swapchain back (refcounted), or the last destroyed one at a join.
  • Any acquired image, or a SUBOPTIMAL, OUT_OF_DATE or SURFACE_LOST result, stops reuse, so real resizes still get a new swapchain.
  • Since every surface is the same SDL window, a held swapchain can retire into or serve any surface. A surface the game destroys stays alive until no swapchain uses it.

Tested on Wayland (RTX 4090): three joins in a row reused the kept swapchain with no driver create or destroy, and the join to swapchain-ready time was about 50–75 ms. On X11, real resizes still made new swapchains. The unit tests and full suite pass. Not tested on an actual PRIME laptop, AMD, Intel or vr.

NVIDIA with PRIME on X11 blocks ~22 s in every swapchain destroy or
retiring create, and Roblox rebuilds an identical swapchain after each
view change and on every join. Identical creates now get the current or
last destroyed swapchain back, and a surface the game destroys stays
alive until no swapchain uses it.
@CoderDayton
CoderDayton merged commit b311f93 into main Dec 1, 2026
6 checks passed
@CoderDayton
CoderDayton deleted the fix/swapchain-reuse branch December 1, 2026 23:58
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