Repository navigation
shim: a swapchain takes its window at its first present, not at surface creation - #64
utkarshdalal wants to merge 1 commit into
Conversation
…urface creation gamescope keeps one override surface per X window, and a new override_window_content retires the previous binding. The shim sent it as soon as the surface was created, so any surface made for the game's window took the window, whether or not it ever presented. The Epic overlay does exactly that: it creates a D3D11 device and swapchain on a child of the game's window only to find Present, destroys it 7 ms later, and never presents. The child resolves to the same top-level, so the throwaway surface stole the game's binding; the game's later commits sat in gamescope's pending list with their buffers locked, all five images stayed in flight, and the next acquire waited forever on a black screen. The binding now goes out right before a swapchain's first commit (worker, inline and generated-frame paths), once per swapchain; gamescope ignores a repeat from the surface that already holds the window, so a recreated swapchain on the same surface costs nothing. vkDestroySurfaceKHR now sends gamescope_swapchain.destroy and wl_surface.destroy instead of only freeing the client proxies, so the compositor drops the binding and the surface instead of keeping both alive for the rest of the session.
|
Reviewed #64 and ran it on device with an Epic-overlay title (Alex Kidd's failure mode). The binding placement is right and I'm not arguing with it — two things suggested on top, in #65: keep defaulting the id to the first commit, and it is worth stating why the destroy order is load-bearing. What #64 gets right, and now measured. With the overlay on, Yooka-Laylee creates two surfaces for the same top-level ( FINAL FANTASY VII REMAKE INTERGRADE (vkd3d/D3D12) goes further: one of its surfaces, Suggestion 1 — the id is decided too early, the binding is not. On the fallback path it is a guess: a degenerate ancestor (Dishonored under a 1×1 override-redirect helper) selects by pid, class, input focus and Suggestion 2 — the destroy order deserves a comment in the code. It is correct as written, but the reason is not obvious and the failure is silent-ish: Reverse the two and Cross-repo consequence worth linking. #64's teardown makes A33's "override is gone" state reachable mid-session, where it was exit-only before. That arm blanks the panel on absence alone, so a surface recreate now flashes black. gamescope #36 changes it to blank only once something else has painted after the gap; the two should land together. Not covered by my run: a guest that destroys its Vulkan surface while its window lives (a DXVK/vkd3d device loss), which is the only path that exercises the gap. Swapchain recreates are fine — measured, Device evidence, both titles, payload |
One commit on top of
master.The failure
Alex Kidd in Miracle World DX (Epic) freezes on a black screen about 10 s after start under gamescope when the Epic overlay is on. It runs with the overlay off, and on the X11 display server.
gamescope keeps one override surface per X window:
handle_override_window_contentdrops the previous binding (sendsretired) when a new one arrives, and the old surface's later commits sit ing_PendingCommitswith their buffers locked. The shim sentoverride_window_contentas soon as the Vulkan surface was created. The overlay DLL creates a D3D11 device and swapchain on a child of the game's window only to findPresent, destroys it 7 ms later and never presents. The child resolves to the same top-level, so that throwaway surface took the game's window. From then on the window was bound to a surface with no content (black), none of the game's five images came back (in_flight=5), and the next acquire waited forever.The shim also never told gamescope a surface was gone:
vkDestroySurfaceKHRonly freed the client proxies, so the binding and the server-side surface stayed alive for the rest of the session.The change
override_window_contentgoes out right before a swapchain's first commit (bind_window_at_first_commit, on the worker, inline and generated-frame commit paths), once per swapchain. A swapchain that never presents never takes the window. A recreated swapchain on the same surface (resize, present-mode change) re-sends it, which gamescope ignores for the surface that already holds the window. Server-side the order is unchanged: bind, then the first attach + commit in the same flush.vkDestroySurfaceKHRsendsgamescope_swapchain.destroyand thenwl_surface.destroy(both opcode 0, no args). Swapchain first, so gamescope drops the content override without finishing the window's X11 surface info.docs/13step 4 describes when the binding is made.Not in this PR: a
gamescope_swapchain.retiredlistener. A swapchain whose window is taken by another one that really presents still stalls in acquire if it keeps presenting, as before. Handling it needs a listener with all three events, a wake of the acquire wait, andVK_ERROR_OUT_OF_DATE_KHRfrom acquire/present, which is more than this fix.What the deferral changes in gamescope's A33 session blind: the binding is stamped at the first paint that sees it, which is now at most one frame later. A surface destroyed while its window lives on now leaves the window unbound, so A33 holds it black until the next swapchain's first commit, where before it kept the last frame.
How to test
aarch64-linux-android(release, NDK 27.3) at 341d3d0, export set unchanged, clippy-D warningsclean foradrenotools_gamescope(all targets). Merges cleanly with Shim waits for the panel to release a buffer before the guest renders into it #60 and shim: at a cap at the display's rate, a self-paced guest keeps the container's mode with the vblank-grid gate #61. Lib tests not run.libadrenotools_gamescope.soreplaced, Alex Kidd in Miracle World DX, gamescope, Epic overlay on,GNDRM_LOG_VKSHIM=1:override: swapchain 0x...ae50 binds surface 0x...4500 to XID 0x600004 at its first commit;acq=30 pres=29 rel=28 in_flight=1right after the probe,acq=6477 pres=6476 rel=6475 in_flight=1110 s later. Before the fix the same point stuck atrel=28 in_flight=5.