Repository navigation
icd_shim: the binding belongs to the first commit, and the id is re-resolved when the first answer was a guess - #65
Merged
Conversation
…d is re-resolved when the first answer was a guess
Where the binding goes, and where the id that goes in it comes from, are two
different questions and they have two different answers.
The binding belongs to the first commit. gamescope keeps one override surface
per X window and a new binding retires the previous holder, so a binding sent at
`vkCreateXlibSurfaceKHR` gives the window to any surface that exists, whether
or not it ever paints: the Epic overlay 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 that throwaway
surface took the game's window; the game's later commits then 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, in that flush and before the
attach, once per swapchain. gamescope ignores a repeat from the resource that
already holds the window, so a swapchain recreated on the same surface (resize,
present-mode change) costs nothing.
`vkDestroySurfaceKHR` now sends `gamescope_swapchain.destroy` and then
`wl_surface.destroy`, both of which the client used to skip by freeing only its
proxies. The order is load-bearing: the first nulls
`wl_surface_info->x11_surface`, so the second skips
`wlserver_x11_surface_info_finish()` and the window keeps its Xwayland main
surface. Reversed, the destroy finishes the window's surface info — main_surface
null, wl_id zero — for the rest of the session.
The id is a second question. `resolve_override_target` runs at surface creation
because a surface has to answer caps and `surface_extent` reads the window's live
size. On its legitimate path that is not a guess: the named window's root-child
ancestor is a full-size window — under `wine explorer /desktop=shell`, the one
desktop window every guest window nests inside — and nothing about it changes.
On its fallback path it is a guess: the ancestor is degenerate (Dishonored
nesting under a 1x1 override-redirect helper) and the target comes from pid,
class, input focus and `_NET_ACTIVE_WINDOW`, read from a tree the guest has not
drawn into yet.
So the resolution now reports its provenance, `OverrideTarget { window,
provisional }`, `GnSurface` keeps the XID winex11 named beside the one resolved
from it, and `bind_window_at_first_commit` re-asks when the answer was
provisional — once per swapchain, at the first instant there is evidence, with
the re-resolved id replacing `window` so later caps calls and later swapchains
agree. The log names both ids when they differ. A guest on the legitimate path
pays one bool and no X round trip.
docs/13 step 4 states which decision is made when and why, and records the
destroy order.
This was referenced Nov 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One commit on top of
master. It carries the bind-at-first-commit change and the surface-destroy handling that #64 proposes, plus the part that is new here — the id in the binding. Self-contained, so it can be read or landed without waiting on #64.The binding belongs to the first commit
gamescope keeps one override surface per X window and a new binding retires the previous holder, so a binding sent at
vkCreateXlibSurfaceKHRgives the window to any surface that merely exists. The Epic overlay creates a D3D11 device and swapchain on a child of the game's window only to findPresent, never presents, and destroys it 7 ms later — the child resolves to the same top-level, so that throwaway surface took the game's window, the game's later commits sat in the pending list with their buffers locked, and the next acquire waited forever on a black screen.The binding now goes out right before a swapchain's first commit, in that flush and before the attach, once per swapchain (worker, inline and generated-frame paths). A surface that never paints never takes the window. gamescope ignores a repeat from the resource that already holds the window, so a swapchain recreated on the same surface costs nothing.
vkDestroySurfaceKHRsendsgamescope_swapchain.destroyand thenwl_surface.destroy; both used to be skipped by freeing only the client proxies. The order is load-bearing: the first nullswl_surface_info->x11_surface, so the second skipswlserver_x11_surface_info_finish()and the window keeps its Xwayland main surface. Reversed, the destroy finishes the window's surface info —main_surfacenull,wl_idzero — for the rest of the session.The id is a separate question, and it was still decided too early
resolve_override_targetruns at surface creation because a surface has to answer caps, andsurface_extentreads the window's live size. On its legitimate path that is not a guess: the named window's root-child ancestor is a full-size window — underwine explorer /desktop=shell, the one desktop window every guest window nests inside — and nothing about it can change.On its fallback path it is a guess: the ancestor is degenerate (Dishonored nesting under a 1×1 override-redirect helper) and the target comes from pid, class, input focus and
_NET_ACTIVE_WINDOW, read from a tree the guest has not drawn into yet. #64 moved the bind past that moment; the id decision should move with it.So the resolution reports its provenance —
OverrideTarget { window, provisional }—GnSurfacekeeps the XID winex11 named beside the one resolved from it, andbind_window_at_first_commitre-asks once when the answer was provisional, at the first instant there is evidence. The re-resolved id replaceswindow, so later caps calls and later swapchains agree with it, and the log names both ids when they differ. A guest on the legitimate path pays one bool and no X round trip.Change
icd_shim/src/x11.rs—OverrideTarget { window, provisional }; the rule reports whether it guessed; the host test asserts both, and that a legitimate ancestor is not marked provisional.icd_shim/src/proxy.rs— bind at first commit;GnSwapchain.window_bound;GnSurface.named_window/window_provisional; the re-ask;swapchain.destroy+wl_surface.destroyon surface destroy.icd_shim/src/wlproto.rs—swapchain_destroy,surface_destroy.docs/13step 4 — which decision is made when and why, and the destroy order.Testing
Odin 3 (8 Gen 2 / Adreno 830), Android 13, payload
20261110.1(shimdd0cf2bb, the build of this commit),wine explorer /desktop=shell,1280x720, gamescope display, Epic overlay enabled on both titles,GNDRM_LOG_VKSHIM=1.Yooka-Laylee (Epic) — two surfaces for one top-level, one owner
Two surfaces created for the same window, one bind. The second never took the window because it never painted — the case that produced a black screen before.
re-resolved: 0, because the ancestor is the full-size desktop window and the legitimate branch was taken.FINAL FANTASY VII REMAKE INTERGRADE (Epic, vkd3d/D3D12) — a surface that never binds, and a swapchain recreate
Surface
…9010never binds at all — created for the game's window, it never painted, so it never took it. The swapchain was then destroyed and recreated on the same surface: the window was not unbound (the proxy lives on the surface), the recreate re-bound, and gamescope ignored it for the resource already holding the window.Both sessions ended through Back → QuickMenu → Exit.
Build:
./tools/build-android.shclean,check-exports.shPASS, clippy-D warningsclean on--all-targets,cargo test -p adrenotools_gamescope124 passed.Not tested
A guest that destroys its Vulkan surface mid-session while its window lives — a DXVK/vkd3d device loss. That is the only path that reaches the A33 gap branch, and neither title did it here.