feat(ui): a mod window can be popped out of the game's picture into a window of its own #3175

Merged
HumanBean merged 16 commits from neotoxic/Longshot:feat/ui-popout into main 2026-12-04 18:10:35 +00:00
Contributor

Summary

A mod window (a Window mounted by a mod: the Progress window, a mod's debug or settings window) can now leave the game's picture and become a real window of the system's: a second box in its title bar, left of the close box, pops it out; the same box (now a pop-in icon) puts it back where it was, in the state it was in. A popped-out window can be moved to a second screen and used there while the game plays full screen on the first: its own pointer, wheel, keys and typed text, its own title in the taskbar, its place kept for the run. The game window never sees its input, and closing it never ends the game.

  • The UI side (game/crates/ui): Core::pop_sync lays a popped-out root out at its system window's scale with its top-left at 0, 0, routes the pointer and the keys of its system window to it (Input::pointer_in, focus_in), and puts it back on a pop-in, when its host closes its system window, or when the host can no longer show one. The output asks the host for each window wanted (Output::popouts: key, title, size and draggable title bar in its own virtual px). The frame gives a popped-out root a group of its own kind, root::POPOUT, never drawn over the game.
  • The contract: MKW_UI_VERSION 12 (gpu/vk/ui_draw.h, docs/dev/reference/ui-draw-list.md) and MKWVK_API_VERSION 94 (popouts_able, popouts, popout_show last on MkwVkHost).
  • The renderer (gpu/vk/vk_ui.cpp, vk_paint.cpp): asks the host once a present, draws each popped-out root into its own list at its system window's pixels, and reads its picture back (BGRA, premultiplied) when its frame or size changes. Readbacks are collected when their GPU fences signal; if no buffer is free, the draw is retried.
  • Windows (host/display.c): layered windows on the game window's thread (UpdateLayeredWindow, so the rounded corners are see-through), no frame, moved by the title bar UI names (WM_NCHITTEST), their own mouse, keys and text.
  • Linux, SDL (host/posix/display_sdl.c, host/hos_sdl.c): plain borderless SDL windows, the picture put on their surface opaque over the menu theme's dark, moved by SDL's hit test. None under gamescope (one window only) or headless; HOS_NO_POPOUTS=1 turns the box off everywhere.
  • The close box of a popped-out window brings it back (and so does Back, Escape or B, in it): its system window has no frame, so this box is its only close, and pressing it used to close the mod's window outright. Once back in the picture, the close box closes it as before. A mod's own close key (closeOn) still closes it.

Read first: Core::pop_sync, Core::toggle_pop, Core::close_box (game/crates/ui/src/core.rs), ui_tick and draw_popout (gpu/vk/vk_ui.cpp), then the two hosts' hos_display_popouts.

Testing

Tested:

  • Windows 11, in the game, an earlier head merged with #2957 and #3174 (no conflict): popped the Progress window out and pressed its close box: it came back in the game's picture, still open, where it was; popped it out again and pressed Escape in it: the same; pressed the close box once back: it closed.
  • Windows 11, in the game, on an earlier head of this branch (before the merge of main and the close box fix): popped the Progress window out onto a second screen; moved it by its title, clicked, scrolled with the wheel, walked it with the arrows; a quick single click is taken; the pop-in box put it back at its place and in its state; the close box and the pop-out box are one size and weight.
  • Linux laptop, Wayland native, the same head: the whole protocol works, no offset at 125% scaling.
  • An earlier head, game-free, on Windows 11:
    • cargo test -p game-ui -p longshot-game: 188 and 212 (+2, +1, +1) passed, 0 failed. New: the_close_box_or_back_of_a_popped_out_window_brings_it_back_open_and_closes_it_once_back fails on the previous head for each path (close box, Back), and a_popped_out_windows_picture_holds_its_own_lists_alone_never_a_hud_roots.
    • cargo clippy --no-deps -p game-ui -p longshot-game --all-targets -- -D warnings: clean. cargo fmt --all --check: clean. ffi-gen --check: current.
    • tests/run_all.py --changed origin/main (g++): 124 passed, 2 failed, 32 skipped (clang, glslang, Vulkan headers or Linux only). The two failures read no file this branch changes: test_tex_desc_memo (g++ -Werror=class-memaccess in its own test.cpp) and test_native_zstd.
    • dev.py rt (llvm-mingw): longshot-game.exe and longshot_vk.dll built and linked.
  • An earlier head, game-free, on Linux (CachyOS, x86_64, clang):
    • dev.py base and dev.py rt build (the SDL host's pop-out code included); cargo test -p game-ui -p longshot-game: 188 and 222 passed, 0 failed.
    • mise run test in full, before eab4e75e: 876 passed, 10 failed, 13 skipped. Two were this branch's, Linux-only checks reading the code it changes: test_key_press_queue (its cut of the event loop's key-down case met popout_event's first) and test_ui_record (its fixture had no popouts_); eab4e75e updates both, and the fixture now checks a popped-out window's picture is drawn before the overlays' pass, in their Colour vision mode, once: both pass. Of the rest, 5 fail the same way on main (d6e819e0) there (test_check_third_party, test_ci_source_times, test_dev_vcs, test_run_all_output, test_run_all_reap), test_run_all_junit passes alone here and on main, and test_lifter and test_lifter_semantics stopped at 600 s under the load of the full run.

Still to test:

  • Linux, this head, in the game: the same steps as on Windows (by hand).
  • Linux under Xwayland: the real mouse in a popped-out window (an emulated mouse moved nothing there, in the window or in the game, so the input tool is in doubt), and an arrow press that once went missing (by hand).
  • Steam Deck or another gamescope session: no pop-out box at all, every window stays in the picture (@Beanstalk on a Deck, or by hand).

Measurements

Nothing to measure: with no window popped out, the only added work is one popouts call a present that returns at once; a popped-out window's picture is drawn and read back when its frame or size changes.

Risks

  • Switches: HOS_NO_POPOUTS (new) ships unset, so the pop-out box shows wherever the host can open a window; set to 1 it takes the box away and every window stays in the picture, as on main. HOS_HEADLESS is not new: the hosts only read it, since a headless run has no screen to open a window on.
  • A popped-out window costs one more draw and read-back of its root when its contents or size change, read-back buffers, and one system window.
  • A host that cannot show a window (headless, gamescope, HOS_NO_POPOUTS=1) gives no box; the windows stay in the picture as on main. Reverting the branch is enough to undo it; nothing is saved (a popped-out window's place is kept for the run only).
  • On Windows the popped-out window keeps the picture's alpha (its rounded corners are see-through), so a window whose card is not fully opaque shows a little of what is behind it; on Linux it is laid on the theme's dark.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Screenshots of the same spot on main and here, for a change that shows on screen. (#issuecomment-102831)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

## Summary A mod window (a `Window` mounted by a mod: the Progress window, a mod's debug or settings window) can now leave the game's picture and become a real window of the system's: a second box in its title bar, left of the close box, pops it out; the same box (now a pop-in icon) puts it back where it was, in the state it was in. A popped-out window can be moved to a second screen and used there while the game plays full screen on the first: its own pointer, wheel, keys and typed text, its own title in the taskbar, its place kept for the run. The game window never sees its input, and closing it never ends the game. - **The UI side** (`game/crates/ui`): `Core::pop_sync` lays a popped-out root out at its system window's scale with its top-left at 0, 0, routes the pointer and the keys of its system window to it (`Input::pointer_in`, `focus_in`), and puts it back on a pop-in, when its host closes its system window, or when the host can no longer show one. The output asks the host for each window wanted (`Output::popouts`: key, title, size and draggable title bar in its own virtual px). The frame gives a popped-out root a group of its own kind, `root::POPOUT`, never drawn over the game. - **The contract**: `MKW_UI_VERSION` 12 (`gpu/vk/ui_draw.h`, `docs/dev/reference/ui-draw-list.md`) and `MKWVK_API_VERSION` 94 (`popouts_able`, `popouts`, `popout_show` last on `MkwVkHost`). - **The renderer** (`gpu/vk/vk_ui.cpp`, `vk_paint.cpp`): asks the host once a present, draws each popped-out root into its own list at its system window's pixels, and reads its picture back (BGRA, premultiplied) when its frame or size changes. Readbacks are collected when their GPU fences signal; if no buffer is free, the draw is retried. - **Windows** (`host/display.c`): layered windows on the game window's thread (`UpdateLayeredWindow`, so the rounded corners are see-through), no frame, moved by the title bar UI names (`WM_NCHITTEST`), their own mouse, keys and text. - **Linux, SDL** (`host/posix/display_sdl.c`, `host/hos_sdl.c`): plain borderless SDL windows, the picture put on their surface opaque over the menu theme's dark, moved by SDL's hit test. None under gamescope (one window only) or headless; `HOS_NO_POPOUTS=1` turns the box off everywhere. - **The close box of a popped-out window brings it back** (and so does Back, Escape or B, in it): its system window has no frame, so this box is its only close, and pressing it used to close the mod's window outright. Once back in the picture, the close box closes it as before. A mod's own close key (`closeOn`) still closes it. Read first: `Core::pop_sync`, `Core::toggle_pop`, `Core::close_box` (`game/crates/ui/src/core.rs`), `ui_tick` and `draw_popout` (`gpu/vk/vk_ui.cpp`), then the two hosts' `hos_display_popouts`. ## Testing **Tested:** - Windows 11, in the game, an earlier head merged with #2957 and #3174 (no conflict): popped the Progress window out and pressed its close box: it came back in the game's picture, still open, where it was; popped it out again and pressed Escape in it: the same; pressed the close box once back: it closed. - Windows 11, in the game, on an earlier head of this branch (before the merge of `main` and the close box fix): popped the Progress window out onto a second screen; moved it by its title, clicked, scrolled with the wheel, walked it with the arrows; a quick single click is taken; the pop-in box put it back at its place and in its state; the close box and the pop-out box are one size and weight. - Linux laptop, Wayland native, the same head: the whole protocol works, no offset at 125% scaling. - An earlier head, game-free, on Windows 11: - `cargo test -p game-ui -p longshot-game`: 188 and 212 (+2, +1, +1) passed, 0 failed. New: `the_close_box_or_back_of_a_popped_out_window_brings_it_back_open_and_closes_it_once_back` fails on the previous head for each path (close box, Back), and `a_popped_out_windows_picture_holds_its_own_lists_alone_never_a_hud_roots`. - `cargo clippy --no-deps -p game-ui -p longshot-game --all-targets -- -D warnings`: clean. `cargo fmt --all --check`: clean. `ffi-gen --check`: current. - `tests/run_all.py --changed origin/main` (g++): 124 passed, 2 failed, 32 skipped (clang, glslang, Vulkan headers or Linux only). The two failures read no file this branch changes: `test_tex_desc_memo` (g++ `-Werror=class-memaccess` in its own `test.cpp`) and `test_native_zstd`. - `dev.py rt` (llvm-mingw): `longshot-game.exe` and `longshot_vk.dll` built and linked. - An earlier head, game-free, on Linux (CachyOS, x86_64, clang): - `dev.py base` and `dev.py rt` build (the SDL host's pop-out code included); `cargo test -p game-ui -p longshot-game`: 188 and 222 passed, 0 failed. - `mise run test` in full, before eab4e75e: 876 passed, 10 failed, 13 skipped. Two were this branch's, Linux-only checks reading the code it changes: `test_key_press_queue` (its cut of the event loop's key-down case met `popout_event`'s first) and `test_ui_record` (its fixture had no `popouts_`); eab4e75e updates both, and the fixture now checks a popped-out window's picture is drawn before the overlays' pass, in their Colour vision mode, once: both pass. Of the rest, 5 fail the same way on `main` (d6e819e0) there (`test_check_third_party`, `test_ci_source_times`, `test_dev_vcs`, `test_run_all_output`, `test_run_all_reap`), `test_run_all_junit` passes alone here and on `main`, and `test_lifter` and `test_lifter_semantics` stopped at 600 s under the load of the full run. **Still to test:** - Linux, this head, in the game: the same steps as on Windows (by hand). - Linux under Xwayland: the real mouse in a popped-out window (an emulated mouse moved nothing there, in the window or in the game, so the input tool is in doubt), and an arrow press that once went missing (by hand). - Steam Deck or another gamescope session: no pop-out box at all, every window stays in the picture (`@Beanstalk` on a Deck, or by hand). ## Measurements Nothing to measure: with no window popped out, the only added work is one `popouts` call a present that returns at once; a popped-out window's picture is drawn and read back when its frame or size changes. ## Risks - Switches: `HOS_NO_POPOUTS` (new) ships unset, so the pop-out box shows wherever the host can open a window; set to 1 it takes the box away and every window stays in the picture, as on `main`. `HOS_HEADLESS` is not new: the hosts only read it, since a headless run has no screen to open a window on. - A popped-out window costs one more draw and read-back of its root when its contents or size change, read-back buffers, and one system window. - A host that cannot show a window (headless, gamescope, `HOS_NO_POPOUTS=1`) gives no box; the windows stay in the picture as on `main`. Reverting the branch is enough to undo it; nothing is saved (a popped-out window's place is kept for the run only). - On Windows the popped-out window keeps the picture's alpha (its rounded corners are see-through), so a window whose card is not fully opaque shows a little of what is behind it; on Linux it is laid on the theme's dark. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Screenshots of the same spot on `main` and here, for a change that shows on screen. (#issuecomment-102831) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A player with a second monitor wants a mod window (Progress, F2) beside the
game instead of over it. This is the UI's half: a host that can show a
window in a system window of its own says so (flag::POPOUTS), and each
window's title bar then has a pop-out box left of its close box.

Pressed, the window is asked of the host (Output::popouts: key, title, size
and the title bar to move it by, in its own virtual px). Once the host
shows it (Input::popouts, at that system window's scale) the window is laid
out and painted with its top-left at 0, 0 at that scale, in a root group of
its own kind (root::POPOUT, never drawn over the picture). The pointer in
its system window (Input::pointer_in) reaches it alone, in its pixels; the
game picture's pointer never does. Its keys are its own while its system
window has the system's focus (Input::focus_in), the game's once it is
gone. The pop-in box, the system window closed (Popout::close) or a host
that can no longer bring it back where it was in the picture.

No host sets the flag yet (MkwUiInput has no place for it): nothing
changes in the game until the host and renderer parts land.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The renderer and its host need to say which windows they show popped out,
and the UI which ones it wants shown, before any system window can open.

MkwUiInput grows popouts (MkwUiPopoutIn: key, scale, close), pointer_in and
focus_in; MkwUiOutput grows popouts (MkwUiPopoutAsk: key, size and title
bar in virtual px, title); MKW_UI_IN_POPOUTS says the host can. The game
side reads them from version 12 and keeps the asks' C views with the
presents, their titles pointing into the output it keeps. The Rust twins
and ui_draw.h assert the same layout; test_ui_renderer.py checks version 12.

Nothing sets the flag yet: the renderer and host parts come next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A mod window popped out of the game's picture now gets a window of its own.
The UI asks for its pop-outs each frame (MkwUiPopoutAsk: key, size, drag
areas, title); the renderer draws each into an offscreen image, reads it back
and hands the premultiplied BGRA pixels to the host, which shows them:

- Windows: a layered popup window (UpdateLayeredWindow), dragged by the areas
  the UI gives (WM_NCHITTEST), its mouse, keys and text sent back to the UI.
- Linux (SDL3 and SDL2, X11 and Wayland): an SDL window whose surface gets the
  pixels, dragged through SDL_SetWindowHitTest. Wayland keeps the size, not the
  position. Under gamescope (Steam Deck's Game Mode) there is no pop-out: one
  window only, the button is not offered.

MkwVkHost 90 adds popouts_able, popouts and popout_show at the end of the
table. HOS_NO_POPOUTS turns the feature off; the headless and offscreen modes
never offer it.

Known limits: no user resize of a pop-out, its position kept only for the run,
HDR output may give the pop-out's colours a slight shift.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seen in game: side by side, the close box (a "×" in the title font) and the
pop-out box (an icon) differed in size, stroke and height. The close box is now
an icon of the engine's own too (icons::CLOSE, two strokes of the pop-out
box's weight), drawn like it: a third of the title bar high, in the middle of
its square. Every window's close box changes with it, so the title bar looks
the same whether or not the host can pop windows out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tested in game on Windows: the first click on a pop-out window's pop-in box
often did nothing. The click reached the window (WM_LBUTTONDOWN, then
WM_LBUTTONUP), but the WM_MOUSELEAVE that Windows posts as the click's
capture ends came after it and cleared pointer_in before the renderer's next
report. The renderer then took the pointer from the game picture, and the
press went nowhere.

Now a report carries pointer_in for a window that had a button pressed or let
go since the last one, whatever came after, on Windows and on SDL (a leave
queued behind a quick click there too). On Windows the leave also checks the
cursor: still over the window, it stays in, and the next move tracks it again.
The check runs before the pop-out lock, since WindowFromPoint hit-tests this
thread's windows and WM_NCHITTEST takes that lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Measured on Linux at 125 %: the pop-out box drew 10 px wide, the close
cross 8 px, and the cross read paler. The pop-out frame spans 4 to 20 of
the icon's 24, the cross only 5 to 19.

The cross now spans 4 to 20 too: side by side, the two boxes are one size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main moved 51 commits since the branch's base (9a1f19b4 to d6e819e0), among them
the ReShade presets on MkwVkHost (version 90), the controls' bindings moved to the
game (91) and Skip Upscaler Wait (92), the themes' text scale and Modern dark key,
and held list keys repeating in the UI.

- MkwVkHost: the pop-out members (popouts_able, popouts, popout_show) move from
  version 90 to 93, after main's game_reshade_* members; the renderer asks a host of
  93 or later. Every pop-out comment, tests/test_program_hooks.py's member order and
  tests/test_ui_renderer.py's pop-out check follow.
- gpu/vk/vk_ui.cpp: main's nav_of, repeat_keys and keys_taken kept; the branch's
  ui_hears and put_key (the keys of a focused pop-out window go through them too)
  now use nav_of, and take_keys marks keys_taken as on main.
  tests/test_ui_debug_key.py compiles all four.
- ui: Output carries both popouts and main's theme_resets; the window's title bar
  keeps the branch's close and pop-out icons with main's text scale on the title;
  both sets of new tests kept. MKW_UI_VERSION stays 12 (main still has 11).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A mod window popped out (the Progress window, say) is shown in a borderless
system window: the only close it has is the UI's own close box in its title
bar. Pressing it closed the mod's window outright (its onClose ran, the mod
unmounted it), where the player only meant to put it back. Back (Escape, the
controller's B) in a popped-out window that has the system's focus did the
same.

Now the close box and Back of a popped-out window pop it back in, as its pop-in
box does: it is back where it was in the game's picture, still open, in the
state it was in, and its host closes the system window. Once it is back, the
close box and Back close it as before. A mod's own close key (closeOn) still
closes it, popped out or not.

Test: the close box and Back of a popped-out window bring it back, open and
not closed; the close box closes it once it is back (each path failed before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Seen on the laptop: the Progress mod's corner panel showed through the Progress
window. The panel is a HUD root, which the game's picture draws under the
windows, and the window's card is 90% opaque (the theme's card): the mod's own
cause, which its branch fixes by taking the panel away while its window is open.

A popped-out window is not part of it: its picture is its own root's lists
alone (the SDL host also lays it opaque over the theme's dark). This check keeps
it so: a HUD panel of the same mod stays in the game's picture and none of its
batches are in the popped-out window's group.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(ui): HOS_NO_POPOUTS has its switch row, and four checks follow the pop-out code
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
7d0f797507
tests/run_all.py --changed failed four checks on the branch:

- test_switch_table: HOS_NO_POPOUTS, read by both hosts' popouts_able, had no
  row in gpu/vk/switches.def. It has one now (kill: no pop-out box, every mod
  window stays in the game's picture).
- test_menu_hit and test_pause_background read the first HOS_SDL_EV_MOUSE_DOWN
  and HOS_SDL_EV_FOCUS_* cases of host/posix/display_sdl.c, which are now the
  pop-out windows' own (popout_event); they read hos_display_loop's, the game
  window's, as they meant to.
- test_ui_stale_keys (new on main) compiles take_keys without what it calls on
  this branch: ui_hears and put_key are compiled with it when vk_ui.cpp has them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: on Windows on 03/12 (an earlier head): the window pops out onto a second screen, moves by its title, takes clicks, arrows and the wheel, and comes back to its place and state. This head (merged with main, the close box bringing a popped-out window back) is not run in the game yet.

Tested in game: on Windows on 03/12 (an earlier head): the window pops out onto a second screen, moves by its title, takes clicks, arrows and the wheel, and comes back to its place and state. This head (merged with main, the close box bringing a popped-out window back) is not run in the game yet.
Member

Possibly related, for context:

  • PR #2957 feat(progress): a Progress window, a corner panel and marks in the world, and the save's progress for the launcher — Progress mod window is a direct user of this pop-out support
Possibly related, for context: - PR #2957 feat(progress): a Progress window, a corner panel and marks in the world, and the save's progress for the launcher — Progress mod window is a direct user of this pop-out support
test(ui): the key and overlay checks follow the pop-out code on Linux
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
eab4e75ead
Two Linux checks read source the pop-out work changed, and failed there
(Windows skips both):

- test_key_press_queue cut the event loop's key-down case by its first
  line, and popout_event has a key-down case of its own above it: the cut
  now starts at hos_display_loop.
- test_ui_record builds record() alone, which now draws the popped-out
  windows' pictures: the fixture stands in for popouts_ and draw_popout,
  and checks a picture asked is drawn before the overlays' pass, in their
  Colour vision mode, once, and asked again when not drawn.

Both pass on Linux (CachyOS, clang).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Screenshots, Windows 11, this head merged with #2957 and #3174, the Progress window in Hyrule Field:

  1. HOS_NO_POPOUTS=1, as on main: the title bar has the close box alone.
  2. This branch: the pop-out box left of the close box.
  3. After a press on it: the same window popped out as a window of its own, its title in the taskbar, its pop-in box in the title bar.

The game runs in HDR here; Windows' capture of the HDR screen shows the game's picture (1, 2) in other colours than the popped-out window (3), which is a plain SDR window.

capture-1-sans-bouton-1920.png

capture-2-bouton-1920.png

capture-3-sortie-1920.png

Screenshots, Windows 11, this head merged with #2957 and #3174, the Progress window in Hyrule Field: 1. `HOS_NO_POPOUTS=1`, as on `main`: the title bar has the close box alone. 2. This branch: the pop-out box left of the close box. 3. After a press on it: the same window popped out as a window of its own, its title in the taskbar, its pop-in box in the title bar. The game runs in HDR here; Windows' capture of the HDR screen shows the game's picture (1, 2) in other colours than the popped-out window (3), which is a plain SDR window. ![capture-1-sans-bouton-1920.png](https://git.magicbean.dev/attachments/39cee1a2-ae87-4bab-aafe-458aec0e87c2) ![capture-2-bouton-1920.png](https://git.magicbean.dev/attachments/a905bc52-73b2-484a-bc27-84aa16d13f7e) ![capture-3-sortie-1920.png](https://git.magicbean.dev/attachments/43f03560-5bf2-4422-b33c-cbe0a34b0ee7)
neotoxic changed title from WIP: feat(ui): a mod window can be popped out of the game's picture into a window of its own to feat(ui): a mod window can be popped out of the game's picture into a window of its own 2026-12-04 14:24:35 +00:00
Owner
@review
BeanBot requested changes 2026-12-04 16:00:33 +00:00
Dismissed
BeanBot left a comment

Recommendation: Request changes. On Linux, focusing a pop-out can pause the game instead of letting it continue, and text fields lose paste support. The readback design also adds at least nine presents of display latency and limits continuously changing pop-outs to about 13 updates per second at 60 FPS.

This adds separate system windows for mod windows, with their own input and a way back into the game picture. It makes mod information available on another screen, at the cost of additional GPU rendering, readback, memory and host-side copying.

Blocking (3): must change before merging.

  1. L1 host/posix/display_sdl.c:752: A focused pop-out is not reflected in the Linux foreground state used by Pause in background. (more on the line) Do: Track whether either the game window or a pop-out has focus in the Linux foreground state, and test transitions between them and to another application.
  2. L2 gpu/vk/vk_paint.cpp:1246: Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate. (more on the line) Do: Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game.
  3. L3 host/display.c:1298: The pop-out text-input path omits the clipboard paste handling provided by the game window; the SDL pop-out path omits it too. (more on the line) Do: Route paste shortcuts and their clipboard text to the focused pop-out's text queue on both hosts, and cover the behavior with a text-field test.

Should fix (1): not blocking, but worth doing before merging.

  • L4 host/posix/display_sdl.c:867: The first picture is marked shown and no longer fresh even when its temporary allocation fails. (more on the line) Do: Only clear fresh and mark the window shown after a successful copy and presentation; retain or report the failure so the UI can return the root to the game picture.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The active pop-out's impact on frame pacing and memory is not measured. When: An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. Do: Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks. (@fix does its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)

@fix can do L1, L2, L3, L4 and L5.

Checks: Still running: 11 checks.

More: does it help, other systems, switches, what was read

Does it help: Unproven as a complete feature: the reported Windows run shows the Progress window working, but this head was tested with sibling changes and the Linux in-game, Xwayland and gamescope runs remain outstanding. No before-and-after frame-time or memory measurements are provided for the added rendering and readback.

Other systems: The change affects Vulkan overlay rendering, GPU memory and timing, Windows layered windows, SDL2/SDL3 on Linux, focus and background pause, keyboard and text input, and gamescope. The reported Windows and Wayland runs cover part of this; Xwayland, Steam Deck, other Tier 1 GPUs and the cost of active pop-outs remain untested.

Switches: HOS_NO_POPOUTS is new and unset by default; setting it to 1 hides the pop-out control. Its switch-table row is present, but the enabled default has not been validated on all affected platforms or against the added timing and memory costs. HOS_HEADLESS is read but unchanged.

Reviewed: eab4e75ead against d6e819e084: Read the repository rules, PR template, commit history, main UI, renderer and host changes, their relevant focus, layout and input callers, and the changed test diffs. Skimmed the remaining interface, documentation and test changes; the large changed code files and all surrounding code were not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review).

Checked and fine:

  • MKWVK_API_VERSION is bumped to 93 and the new host members are appended.
  • The new switch has a switches.def row.
  • The supplied commit history records AI assistance.
  • The changed-file list contains no game-derived output or third_party changes.

Testing: No code or tests were run, as requested. The PR reports Windows and Wayland feature runs and game-free checks; CI is still running.

Overlaps and merge order: The reported Windows head was tested merged with #2957 and #3174; their independent overlap and merge order were not established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** On Linux, focusing a pop-out can pause the game instead of letting it continue, and text fields lose paste support. The readback design also adds at least nine presents of display latency and limits continuously changing pop-outs to about 13 updates per second at 60 FPS. This adds separate system windows for mod windows, with their own input and a way back into the game picture. It makes mod information available on another screen, at the cost of additional GPU rendering, readback, memory and host-side copying. **Blocking (3)**: must change before merging. 1. **L1** `host/posix/display_sdl.c:752`: A focused pop-out is not reflected in the Linux foreground state used by Pause in background. (more on the line) **Do:** Track whether either the game window or a pop-out has focus in the Linux foreground state, and test transitions between them and to another application. 2. **L2** `gpu/vk/vk_paint.cpp:1246`: Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate. (more on the line) **Do:** Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game. 3. **L3** `host/display.c:1298`: The pop-out text-input path omits the clipboard paste handling provided by the game window; the SDL pop-out path omits it too. (more on the line) **Do:** Route paste shortcuts and their clipboard text to the focused pop-out's text queue on both hosts, and cover the behavior with a text-field test. **Should fix (1)**: not blocking, but worth doing before merging. - **L4** `host/posix/display_sdl.c:867`: The first picture is marked shown and no longer fresh even when its temporary allocation fails. (more on the line) **Do:** Only clear fresh and mark the window shown after a successful copy and presentation; retain or report the failure so the UI can return the root to the game picture. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The active pop-out's impact on frame pacing and memory is not measured. *When:* An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. **Do:** Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks. *(`@fix` does its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)* `@fix` can do L1, L2, L3, L4 and L5. **Checks:** Still running: 11 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven as a complete feature: the reported Windows run shows the Progress window working, but this head was tested with sibling changes and the Linux in-game, Xwayland and gamescope runs remain outstanding. No before-and-after frame-time or memory measurements are provided for the added rendering and readback. **Other systems:** The change affects Vulkan overlay rendering, GPU memory and timing, Windows layered windows, SDL2/SDL3 on Linux, focus and background pause, keyboard and text input, and gamescope. The reported Windows and Wayland runs cover part of this; Xwayland, Steam Deck, other Tier 1 GPUs and the cost of active pop-outs remain untested. **Switches:** HOS_NO_POPOUTS is new and unset by default; setting it to 1 hides the pop-out control. Its switch-table row is present, but the enabled default has not been validated on all affected platforms or against the added timing and memory costs. HOS_HEADLESS is read but unchanged. **Reviewed:** eab4e75ead5b against d6e819e08433: Read the repository rules, PR template, commit history, main UI, renderer and host changes, their relevant focus, layout and input callers, and the changed test diffs. Skimmed the remaining interface, documentation and test changes; the large changed code files and all surrounding code were not read in full. docs/review-checklist.md and the adjacent Tooling checkout were absent.; nothing run (a code review). **Checked and fine:** - MKWVK_API_VERSION is bumped to 93 and the new host members are appended. - The new switch has a switches.def row. - The supplied commit history records AI assistance. - The changed-file list contains no game-derived output or third_party changes. **Testing:** No code or tests were run, as requested. The PR reports Windows and Wayland feature runs and game-free checks; CI is still running. **Overlaps and merge order:** The reported Windows head was tested merged with #2957 and #3174; their independent overlap and merge order were not established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -1227,0 +1243,4 @@
uint64_t size = 0;
int64_t at = -1; // (the present it was copied at; -1 free)
uint32_t w = 0, h = 0;
} reads[2];
Member

L2 (blocking): Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate.

When: At 60 game presents per second, a copied picture cannot be collected for at least nine presents, about 150 ms. If its contents change continuously, both buffers fill in two presents and no further picture can be copied until one becomes eligible, yielding at most about 13 updates per second.

Do: Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game.

**L2** (blocking): Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate. *When:* At 60 game presents per second, a copied picture cannot be collected for at least nine presents, about 150 ms. If its contents change continuously, both buffers fill in two presents and no further picture can be copied until one becomes eligible, yielding at most about 13 updates per second. **Do:** Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game.
@ -1043,0 +1295,4 @@
if (msg == WM_SYSKEYDOWN && wp != VK_F10) break; /* (Alt+F4 and the rest: Windows') */
const int first = !(lp & (1 << 30));
const int edit = wp == VK_LEFT || wp == VK_RIGHT || wp == VK_HOME || wp == VK_END || wp == VK_BACK || wp == VK_DELETE ||
wp == VK_RETURN || wp == VK_ESCAPE || ((wp == 'A' || wp == 'C' || wp == 'X') && GetKeyState(VK_CONTROL) < 0);
Member

L3 (blocking): The pop-out text-input path omits the clipboard paste handling provided by the game window; the SDL pop-out path omits it too.

When: With a text field focused in a popped-out mod window, Ctrl+V or Shift+Insert is neither added to the pop-out text queue nor sent through the existing clipboard paste path, so the field receives no pasted text on Windows or Linux.

Do: Route paste shortcuts and their clipboard text to the focused pop-out's text queue on both hosts, and cover the behavior with a text-field test.

**L3** (blocking): The pop-out text-input path omits the clipboard paste handling provided by the game window; the SDL pop-out path omits it too. *When:* With a text field focused in a popped-out mod window, Ctrl+V or Shift+Insert is neither added to the pop-out text queue nor sent through the existing clipboard paste path, so the field receives no pasted text on Windows or Linux. **Do:** Route paste shortcuts and their clipboard text to the focused pop-out's text queue on both hosts, and cover the behavior with a text-field test.
@ -605,0 +749,4 @@
const float d = p->density > 0 ? p->density : 1.0f; /* (the mouse in window units: its pixels) */
switch (e->type) {
case HOS_SDL_EV_CLOSE: p->close = 1, p->focused = 0, p->pointer_in = 0, p->held = 0; break;
case HOS_SDL_EV_FOCUS_GAINED: p->focused = 1, text = 1; break;
Member

L1 (blocking): A focused pop-out is not reflected in the Linux foreground state used by Pause in background.

When: With Pause in background enabled, moving focus from the game window to a pop-out sets hos_posix_window[0] to zero on the game window's focus loss. The pop-out focus handler wakes the pause logic but never sets an equivalent foreground state, so GetForegroundWindow still reports no foreground window and the game is held while the player uses the pop-out.

Do: Track whether either the game window or a pop-out has focus in the Linux foreground state, and test transitions between them and to another application.

**L1** (blocking): A focused pop-out is not reflected in the Linux foreground state used by Pause in background. *When:* With Pause in background enabled, moving focus from the game window to a pop-out sets hos_posix_window[0] to zero on the game window's focus loss. The pop-out focus handler wakes the pause logic but never sets an equivalent foreground state, so GetForegroundWindow still reports no foreground window and the game is held while the player uses the pop-out. **Do:** Track whether either the game window or a pop-out has focus in the Linux foreground state, and test transitions between them and to another application.
@ -605,0 +864,4 @@
if (p->fresh && p->pix) { /* (copied out: the blit runs without the lock) */
pix = (uint8_t *)malloc((size_t)p->pw * p->ph * 4);
if (pix) memcpy(pix, p->pix, (size_t)p->pw * p->ph * 4), pw = p->pw, ph = p->ph;
p->fresh = 0;
Member

L4 (should fix): The first picture is marked shown and no longer fresh even when its temporary allocation fails.

When: If malloc fails while copying the first readback, pix stays null, but fresh is cleared and shown is set. A static window receives no further picture, remains hidden, and its root has already left the game picture.

Do: Only clear fresh and mark the window shown after a successful copy and presentation; retain or report the failure so the UI can return the root to the game picture.

**L4** (should fix): The first picture is marked shown and no longer fresh even when its temporary allocation fails. *When:* If malloc fails while copying the first readback, pix stays null, but fresh is cleared and shown is set. A static window receives no further picture, remains hidden, and its root has already left the game picture. **Do:** Only clear fresh and mark the window shown after a successful copy and presentation; retain or report the failure so the UI can return the root to the game picture.
Author
Contributor

Thanks. Pushed ff345342 (merge of main e345b3ca), daa991b1 (the fixes below) and e185922e (merge of main e57f7793, with #3099), nothing rewritten.

Version. main took MkwVkHost version 93 for texture packs (game_texture_replacements_generation), so the pop-out windows are now version 94, their three members after it; the version line, the comments, the renderer's host->version >= 94 gate and the checks in tests/test_ui_renderer.py and tests/test_program_hooks.py follow.

L1 (fixed in daa991b1). Right: the pop-out's focus never reached the Linux foreground state. A focused pop-out is now its own entry, hos_posix_window[4], written under the pop-out lock at focus gained, focus lost, close and when a window goes, before the pause logic is woken; win32_posix.c's GetForegroundWindow answers for either entry, as Windows does for the process's own windows. The game window's own focus ([0]: its keys, its cursor, the mouse capture) stays its alone, so typing in a pop-out still moves nothing in the game.

L2 (fixed in daa991b1). present_image waits for a frame slot's last copy before it records into it again, so while the slot count stays the same (present_slots_now, 3 without frame generation's sets) a copy is done once that many presents have been recorded after it. A picture is now read at the (slots + 2)th present after its copy, about 83 ms at 60 fps, instead of always waiting the worst case, kFramesLater (9). Where the count changed since the copy, kFramesLater still applies. Five buffers a window, so a picture changing at every frame goes out at every present with 3 slots. I did not poll the present fences from the UI's side: present_image resets them on its own thread, and reading them from elsewhere would race that reset.

L3 (fixed in daa991b1). Ctrl+V and Shift+Insert in a pop-out's text field now put the clipboard's first line in that window's text, read before the lock. On Windows this goes through clipboard_line, shared with the game window's paste; on Linux through pop_text_utf8, shared with typed text. MKW_VK_POPOUT_TEXT is now 256, the size of the game window's own queue (TEXT_QUEUE), so a paste fits there as it does in the game window.

L4 (fixed in daa991b1). The picture is marked shown, and no longer fresh, only once its copy was made. If the allocation fails it stays fresh and is tried again at the next turn.

L5. Not measured yet. The frame-time, RAM and VRAM comparison against main with an updating pop-out is still open, and so are Xwayland and gamescope.

Checks at e185922e:

  • Windows, run_all.py --changed origin/main: 280 passed, 3 failed. The three failures are test_dlssg, test_sync_watch_event and test_turf_budget, which fail on main itself too.
  • Linux (CachyOS, laptop), at daa991b1: 255 passed, the same 3 failed.
  • dev.py rt and dev.py smoke pass on both Windows and Linux.
  • The focus and paste changes have not been tried by hand in the game yet.
Thanks. Pushed `ff345342` (merge of `main` e345b3ca), `daa991b1` (the fixes below) and `e185922e` (merge of `main` e57f7793, with #3099), nothing rewritten. **Version.** `main` took MkwVkHost version 93 for texture packs (`game_texture_replacements_generation`), so the pop-out windows are now version 94, their three members after it; the version line, the comments, the renderer's `host->version >= 94` gate and the checks in `tests/test_ui_renderer.py` and `tests/test_program_hooks.py` follow. **L1 (fixed in daa991b1).** Right: the pop-out's focus never reached the Linux foreground state. A focused pop-out is now its own entry, `hos_posix_window[4]`, written under the pop-out lock at focus gained, focus lost, close and when a window goes, before the pause logic is woken; `win32_posix.c`'s `GetForegroundWindow` answers for either entry, as Windows does for the process's own windows. The game window's own focus (`[0]`: its keys, its cursor, the mouse capture) stays its alone, so typing in a pop-out still moves nothing in the game. **L2 (fixed in daa991b1).** `present_image` waits for a frame slot's last copy before it records into it again, so while the slot count stays the same (`present_slots_now`, 3 without frame generation's sets) a copy is done once that many presents have been recorded after it. A picture is now read at the (slots + 2)th present after its copy, about 83 ms at 60 fps, instead of always waiting the worst case, `kFramesLater` (9). Where the count changed since the copy, `kFramesLater` still applies. Five buffers a window, so a picture changing at every frame goes out at every present with 3 slots. I did not poll the present fences from the UI's side: `present_image` resets them on its own thread, and reading them from elsewhere would race that reset. **L3 (fixed in daa991b1).** Ctrl+V and Shift+Insert in a pop-out's text field now put the clipboard's first line in that window's text, read before the lock. On Windows this goes through `clipboard_line`, shared with the game window's paste; on Linux through `pop_text_utf8`, shared with typed text. `MKW_VK_POPOUT_TEXT` is now 256, the size of the game window's own queue (`TEXT_QUEUE`), so a paste fits there as it does in the game window. **L4 (fixed in daa991b1).** The picture is marked shown, and no longer fresh, only once its copy was made. If the allocation fails it stays fresh and is tried again at the next turn. **L5.** Not measured yet. The frame-time, RAM and VRAM comparison against `main` with an updating pop-out is still open, and so are Xwayland and gamescope. Checks at e185922e: - Windows, `run_all.py --changed origin/main`: 280 passed, 3 failed. The three failures are `test_dlssg`, `test_sync_watch_event` and `test_turf_budget`, which fail on `main` itself too. - Linux (CachyOS, laptop), at daa991b1: 255 passed, the same 3 failed. - `dev.py rt` and `dev.py smoke` pass on both Windows and Linux. - The focus and paste changes have not been tried by hand in the game yet.
main took version 93 for texture packs while the game runs (game_texture_replacements_generation). The pop-out
windows' three members (popouts_able, popouts, popout_show) now come after it as version 94: the version line, the
member comments, the renderer's host->version >= 94 gate and the checks in tests/test_ui_renderer.py and
tests/test_program_hooks.py follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From BeanBot's review of eab4e75e:

L1. On Linux, with Pause in background on, moving the focus from the game window to a pop-out cleared the
game window's focus (hos_posix_window[0]) and nothing set it back: GetForegroundWindow said no window and the
game was held while the player used the pop-out. A focused pop-out is now its own entry, hos_posix_window[4],
published under the pop-out lock at focus gained, lost or closed and when a window goes, before the pause logic
is woken; win32_posix.c's GetForegroundWindow answers for either, as Windows does for the process's own
windows. The game window's own focus ([0]: its keys, its cursor, the mouse capture) stays its alone.

L2. A pop-out's picture was read kFramesLater (9) presents after its copy, from two buffers: about 150 ms late
and at most about 13 pictures a second. present_image waits for a frame slot's last copy before it records
into it again, so with the slot count unchanged since (present_slots_now, 3 without frame generation's sets) a
copy is done once that many presents have been recorded after it; kFramesLater stays where the count changed.
Five buffers a window: a picture changing at every frame goes out at every present.

L3. Ctrl+V and Shift+Insert in a pop-out's text field pasted nothing: the clipboard's first line now goes to
the pop-out's text, read before the lock (Windows: clipboard_line, shared with the game window's paste; Linux:
pop_text_utf8, shared with typed text). MKW_VK_POPOUT_TEXT is 256, the game window's own queue's size, so a
paste fits as it does there.

L4. On Linux the first picture was marked shown and no longer fresh even when its copy's allocation failed: a
still window then never showed. It is marked only once copied; otherwise it is tried again at the next turn.

Checks: tests/test_ui_renderer.py's pop-out check reads each; tests/test_text_keyboard_policy.py takes
clipboard_line with paste_clipboard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Merge main (e57f7793) into feat/ui-popout
Some checks failed
PR description / Title and description (pull_request_target) Has been cancelled
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
e185922e98
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner
@review
BeanBot left a comment

Recommendation: Request changes. The readback change improves pop-out responsiveness with three present slots, but configurations using more slots can still exhaust the five buffers and throttle updates. The active pop-out’s frame-pacing and memory costs also remain unmeasured.

Mod windows can be moved into separate system windows, with their own input and a way to return them to the game. The fixes add Linux foreground tracking, clipboard paste and allocation retry handling, at the cost of additional readback buffers and platform-specific code.

Blocking (1): must change before merging.

  1. L2 gpu/vk/vk_paint.cpp:1246: Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate. When: At 60 game presents per second, a copied picture cannot be collected for at least nine presents, about 150 ms. If its contents change continuously, both buffers fill in two presents and no further picture can be copied until one becomes eligible, yielding at most about 13 updates per second. Do: Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The active pop-out's impact on frame pacing and memory is not measured. When: An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. Do: Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks. (@fix does its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)

@fix can do L2 and L5.

Since the last review (on eab4e75ead)
Resolved: L1 (A focused pop-out is not reflected in the Linux foreground state used by Pause in backgrou…); L3 (The pop-out text-input path omits the clipboard paste handling provided by the game window…); L4 (The first picture is marked shown and no longer fresh even when its temporary allocation f…)
Still open: L2 (Two readback buffers held for nine presents make an interactive pop-out visibly delayed an…); L5 (The active pop-out's impact on frame pacing and memory is not measured.)

Checks: Still running: 11 checks.

Also noticed (2; not asked for, not blocking)
  • The pull request description still names host API version 93, while the current code uses version 94.
  • The added readback checks inspect source text rather than exercising buffer completion and reuse.
More: does it help, other systems, switches, what was read

Does it help: Unproven for the readback latency and update-rate fix: the code reduces the three-slot wait from nine presents to five, but no before-and-after interactive measurements are reported. The window feature was demonstrated in game on Windows and on an earlier Linux Wayland head.

Other systems: The foreground and paste changes affect Windows and Linux input; the author reports builds on both but no in-game check of those fixes. Xwayland, gamescope and frame-generation configurations remain unverified.

Switches: HOS_NO_POPOUTS is new and unset by default, enabling pop-outs on supported desktops; setting it to 1 disables them. Its row is in switches.def. HOS_HEADLESS is read but not added or changed.

Reviewed: e185922e98 against 9f76a4379c: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the ledger, comments, commit list, the relevant portions of the changes since the ledger, and the focus, paste and readback paths. The full pull request diff and all changed files were not read in full; the review checklist file was absent.; nothing run (a code review).

Checked and fine:

  • The renderer gates the new host callbacks on API version 94.
  • The SDL allocation failure leaves the picture fresh for a later retry.
  • Clipboard reads occur outside the pop-out lock on both hosts.

Testing: No commands from the project or tests were run. The author reports Windows and Linux builds and game-free checks; CI is still running. In-game focus and paste checks, Xwayland, gamescope, and the active pop-out performance comparison remain outstanding.

Overlaps and merge order: The reported Windows in-game test used this head merged with #2957 and #3174; no merge order was established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The readback change improves pop-out responsiveness with three present slots, but configurations using more slots can still exhaust the five buffers and throttle updates. The active pop-out’s frame-pacing and memory costs also remain unmeasured. Mod windows can be moved into separate system windows, with their own input and a way to return them to the game. The fixes add Linux foreground tracking, clipboard paste and allocation retry handling, at the cost of additional readback buffers and platform-specific code. **Blocking (1)**: must change before merging. 1. **L2** `gpu/vk/vk_paint.cpp:1246`: Two readback buffers held for nine presents make an interactive pop-out visibly delayed and severely limit its update rate. *When:* At 60 game presents per second, a copied picture cannot be collected for at least nine presents, about 150 ms. If its contents change continuously, both buffers fill in two presents and no further picture can be copied until one becomes eligible, yielding at most about 13 updates per second. **Do:** Use completion tracking to collect readbacks as soon as the GPU finishes and provision or schedule enough buffers for responsive updates; verify interaction latency and update rate in game. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The active pop-out's impact on frame pacing and memory is not measured. *When:* An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. **Do:** Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks. *(`@fix` does its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)* `@fix` can do L2 and L5. **Since the last review** (on eab4e75ead5b) Resolved: L1 (A focused pop-out is not reflected in the Linux foreground state used by Pause in backgrou…); L3 (The pop-out text-input path omits the clipboard paste handling provided by the game window…); L4 (The first picture is marked shown and no longer fresh even when its temporary allocation f…) Still open: L2 (Two readback buffers held for nine presents make an interactive pop-out visibly delayed an…); L5 (The active pop-out's impact on frame pacing and memory is not measured.) **Checks:** Still running: 11 checks. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The pull request description still names host API version 93, while the current code uses version 94. - The added readback checks inspect source text rather than exercising buffer completion and reuse. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven for the readback latency and update-rate fix: the code reduces the three-slot wait from nine presents to five, but no before-and-after interactive measurements are reported. The window feature was demonstrated in game on Windows and on an earlier Linux Wayland head. **Other systems:** The foreground and paste changes affect Windows and Linux input; the author reports builds on both but no in-game check of those fixes. Xwayland, gamescope and frame-generation configurations remain unverified. **Switches:** HOS_NO_POPOUTS is new and unset by default, enabling pop-outs on supported desktops; setting it to 1 disables them. Its row is in switches.def. HOS_HEADLESS is read but not added or changed. **Reviewed:** e185922e9894 against 9f76a4379cea: Read AGENTS.md, CONTRIBUTING.md, the pull request template, the ledger, comments, commit list, the relevant portions of the changes since the ledger, and the focus, paste and readback paths. The full pull request diff and all changed files were not read in full; the review checklist file was absent.; nothing run (a code review). **Checked and fine:** - The renderer gates the new host callbacks on API version 94. - The SDL allocation failure leaves the picture fresh for a later retry. - Clipboard reads occur outside the pop-out lock on both hosts. **Testing:** No commands from the project or tests were run. The author reports Windows and Linux builds and game-free checks; CI is still running. In-game focus and paste checks, Xwayland, gamescope, and the active pop-out performance comparison remain outstanding. **Overlaps and merge order:** The reported Windows in-game test used this head merged with #2957 and #3174; no merge order was established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
Owner
@fix
fix(vk): collect pop-out readbacks on GPU completion
Some checks failed
PR description / Title and description (pull_request_target) Failing after 6s
CI / What the change needs (pull_request) Successful in 8s
CI / Third-party parts and guide screenshots (pull_request) Successful in 13s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 18s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m17s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 10m14s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 9m40s
CI / Website build and checks (pull_request) Failing after 38s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 12m16s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 15m9s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 47m40s
9420da52d4
As the review on #3175 asked.
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The pop-out feature has been demonstrated on earlier heads, but its frame-pacing and memory cost with an updating window remains unmeasured. The new fence-based readback also needs in-game verification. Recommend approval; not approved on the forge.

What @fix changed
I changed this pull request: the new head is 9420da52d4. I merged main (921e6cbea8) into it, as it has merge commits. I edited its description to match the change.

Changed in part (the rest is for the author)

  • Pop-out readback latency and buffer capacity: gpu/vk/vk_paint.cpp:1241 tracks present fences and provisions nine readback buffers; gpu/vk/vk_replay.cpp:7353 preserves completion before fence reuse. The author must verify interaction latency and update rate in game. Nothing was run.
  • Pop-out frame pacing and memory: gpu/vk/vk_paint.cpp:1369 collects completed pictures without waiting and discards superseded completed reads; unchanged UI frames already skip copies in gpu/vk/vk_ui.cpp:1096. The author must compare frame pacing, RAM and VRAM against main with an updating pop-out.

Nothing was built or run: the checks run again on the new head.

Mod windows can move into separate desktop windows while retaining their state and input. The fix collects completed pictures without blocking and avoids showing older completed copies, at the cost of readback buffers and GPU work for changing windows.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L5: The active pop-out's impact on frame pacing and memory is not measured. When: An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. Do: Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks.

Checks: they run again on this head; a failure shows on the pull request.

Also noticed (2; not asked for, not blocking)
  • The author reports that the latest focus and paste changes have not yet been tried in the game.
  • The latest readback fix has not yet been tested in the game.
More: does it help, other systems, switches, what was read

Does it help: Unproven as a performance change: no comparison of frame pacing, RAM or VRAM against main with an updating pop-out is supplied. Earlier Windows and Linux runs demonstrate the feature, but predate the fence-based fix.

Other systems: The readback path affects Vulkan presentation and frame generation on Windows and Linux. Xwayland input and gamescope behavior remain unverified; the fence change has not been tested in game.

Switches: HOS_NO_POPOUTS is new and defaults to unset, enabling pop-outs where supported; setting it to 1 disables them. Its default has not been supported by cost measurements.

Reviewed: 9420da52d4 against 921e6cbea8: Read the repository rules and pull request template, the fix diff, the changed readback implementation and its presentation and UI call sites. Skimmed the overall change summary and commit log; the remaining changed files were not read in full.; nothing run (a code review).

Checked and fine:

  • Completed reads are marked before a reused present fence is reset, and older completed pictures are not shown after newer ones.
  • The fix retains pop-out drawing and readback; it does not remove the feature.

Testing: No commands that execute project code were run. The author reports successful builds and changed-file checks on both platforms, with three failures also present on main; the current fence fix has not been run.

Overlaps and merge order: #2957 and #3174 were used in earlier Windows testing; no merge dependency is established.


Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The pop-out feature has been demonstrated on earlier heads, but its frame-pacing and memory cost with an updating window remains unmeasured. The new fence-based readback also needs in-game verification. Recommend approval; not approved on the forge. **What `@fix` changed** I changed this pull request: the new head is 9420da52d426. I merged `main` (921e6cbea831) into it, as it has merge commits. I edited its description to match the change. **Changed in part (the rest is for the author)** - **Pop-out readback latency and buffer capacity**: gpu/vk/vk_paint.cpp:1241 tracks present fences and provisions nine readback buffers; gpu/vk/vk_replay.cpp:7353 preserves completion before fence reuse. The author must verify interaction latency and update rate in game. Nothing was run. - **Pop-out frame pacing and memory**: gpu/vk/vk_paint.cpp:1369 collects completed pictures without waiting and discards superseded completed reads; unchanged UI frames already skip copies in gpu/vk/vk_ui.cpp:1096. The author must compare frame pacing, RAM and VRAM against main with an updating pop-out. Nothing was built or run: the checks run again on the new head. Mod windows can move into separate desktop windows while retaining their state and input. The fix collects completed pictures without blocking and avoids showing older completed copies, at the cost of readback buffers and GPU work for changing windows. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L5**: The active pop-out's impact on frame pacing and memory is not measured. *When:* An updating pop-out adds an offscreen render, GPU-to-CPU copies and host pixel copies while the game is presenting; their cost on Tier 1 Windows and Linux systems is unknown. **Do:** Compare repeated runs against the base in the same scene and settings, including average FPS, 1% lows, frame times, RAM and VRAM, with an updating pop-out; complete the stated Xwayland and gamescope checks. **Checks:** they run again on this head; a failure shows on the pull request. <details> <summary>Also noticed (2; not asked for, not blocking)</summary> - The author reports that the latest focus and paste changes have not yet been tried in the game. - The latest readback fix has not yet been tested in the game. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven as a performance change: no comparison of frame pacing, RAM or VRAM against main with an updating pop-out is supplied. Earlier Windows and Linux runs demonstrate the feature, but predate the fence-based fix. **Other systems:** The readback path affects Vulkan presentation and frame generation on Windows and Linux. Xwayland input and gamescope behavior remain unverified; the fence change has not been tested in game. **Switches:** HOS_NO_POPOUTS is new and defaults to unset, enabling pop-outs where supported; setting it to 1 disables them. Its default has not been supported by cost measurements. **Reviewed:** 9420da52d426 against 921e6cbea831: Read the repository rules and pull request template, the fix diff, the changed readback implementation and its presentation and UI call sites. Skimmed the overall change summary and commit log; the remaining changed files were not read in full.; nothing run (a code review). **Checked and fine:** - Completed reads are marked before a reused present fence is reset, and older completed pictures are not shown after newer ones. - The fix retains pop-out drawing and readback; it does not remove the feature. **Testing:** No commands that execute project code were run. The author reports successful builds and changed-file checks on both platforms, with three failures also present on main; the current fence fix has not been run. **Overlaps and merge order:** #2957 and #3174 were used in earlier Windows testing; no merge dependency is established. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch feat/ui-popout 2026-12-04 18:10:36 +00:00
Author
Contributor

L5, measured at e185922e: dev.py ab, Hyrule Field, uncapped (HOS_FPS_MAX=1000), 3 interleaved runs of 60 s per side, 67 % render resolution.

The window is a worst case. A measurement-only patch, not pushed, puts the FPS counter at its Graph level in a mod Window, which redraws at every frame, and pops every window out at start (LS_MESURE_POP). I confirmed the system window was there during the runs: FPS counter: FPS counter, 720 x 278.

  • A = HOS_NO_POPOUTS=1: the same window drawn in the game's picture, as on main.
  • B = the window popped out.
fps median p99 1 % low VRAM working set private
Windows 11, RTX 5080 — A 173.5 (173.1–174.0) 5.75 ms 6.88 ms 145.4 7857 MB 10510 MB 19477 MB
Windows 11, RTX 5080 — B 164.9 (164.9–164.9) 6.05 ms 7.35 ms 136.1 7709 MB 10451 MB 19379 MB
Linux (CachyOS, Wayland), RTX 3060 Laptop — A 81.1 (81.0–81.3) 12.27 ms 16.22 ms 62.1 4376 MB 8214 MB 2315 MB
Linux (CachyOS, Wayland), RTX 3060 Laptop — B 75.1 (74.7–75.7) 13.22 ms 17.87 ms 56.2 4269 MB 8451 MB 2348 MB

(VRAM: the log's last VRAM: ... used; working set and private: its last vk: memory: line.)

What it costs:

  • Time: about 0.3 ms a frame on Windows (−5 % fps) and about 0.95 ms a frame on Linux (−7 % fps). That is for a window whose picture changes at every frame, so it is drawn, copied back and handed to the host at every present.
  • Memory: no difference that stands out from the run-to-run spread, in VRAM or in RAM.
  • At a 60 fps cap the same work would be about 2 to 6 % of a 16.7 ms frame. I did not measure that case.

When it costs nothing: the renderer redraws a popped-out window only when the UI's frame changed (draw_popout: a same frame keeps the last picture), so a still window, a Progress page left open for example, costs nothing between changes.

Why Linux costs more: the larger share there is likely the host side. The picture is copied once more under the lock and put on an SDL surface. I have not profiled where the time goes.

Xwayland and gamescope are still untested: no such session here.

**L5, measured** at e185922e: `dev.py ab`, Hyrule Field, uncapped (`HOS_FPS_MAX=1000`), 3 interleaved runs of 60 s per side, 67 % render resolution. The window is a worst case. A measurement-only patch, not pushed, puts the FPS counter at its Graph level in a mod `Window`, which redraws at every frame, and pops every window out at start (`LS_MESURE_POP`). I confirmed the system window was there during the runs: `FPS counter: FPS counter`, 720 x 278. - **A** = `HOS_NO_POPOUTS=1`: the same window drawn in the game's picture, as on `main`. - **B** = the window popped out. | | fps | median | p99 | 1 % low | VRAM | working set | private | |---|---|---|---|---|---|---|---| | Windows 11, RTX 5080 — A | 173.5 (173.1–174.0) | 5.75 ms | 6.88 ms | 145.4 | 7857 MB | 10510 MB | 19477 MB | | Windows 11, RTX 5080 — B | 164.9 (164.9–164.9) | 6.05 ms | 7.35 ms | 136.1 | 7709 MB | 10451 MB | 19379 MB | | Linux (CachyOS, Wayland), RTX 3060 Laptop — A | 81.1 (81.0–81.3) | 12.27 ms | 16.22 ms | 62.1 | 4376 MB | 8214 MB | 2315 MB | | Linux (CachyOS, Wayland), RTX 3060 Laptop — B | 75.1 (74.7–75.7) | 13.22 ms | 17.87 ms | 56.2 | 4269 MB | 8451 MB | 2348 MB | (VRAM: the log's last `VRAM: ... used`; working set and private: its last `vk: memory:` line.) **What it costs:** - **Time:** about 0.3 ms a frame on Windows (−5 % fps) and about 0.95 ms a frame on Linux (−7 % fps). That is for a window whose picture changes at every frame, so it is drawn, copied back and handed to the host at every present. - **Memory:** no difference that stands out from the run-to-run spread, in VRAM or in RAM. - **At a 60 fps cap** the same work would be about 2 to 6 % of a 16.7 ms frame. I did not measure that case. **When it costs nothing:** the renderer redraws a popped-out window only when the UI's frame changed (`draw_popout`: a `same` frame keeps the last picture), so a still window, a Progress page left open for example, costs nothing between changes. **Why Linux costs more:** the larger share there is likely the host side. The picture is copied once more under the lock and put on an SDL surface. I have not profiled where the time goes. Xwayland and gamescope are still untested: no such session here.
Author
Contributor

Pop-out cost, after 6d8c02ea (the picture's hand-off to the system window)

dev.py ab, Hyrule Field, 3 interleaved runs of 60 s a side, the FPS counter's graph in a window (it changes every frame), uncapped (HOS_FPS_MAX=1000) unless said.

Machine No window Window in the picture Window popped out
PC (RTX 5080, Windows 11) 173.6 fps 173.6 fps 164.9 fps
Laptop (Linux, Wayland) 80.5 fps 81.2 fps 74.6 fps
Laptop, capped at 60 fps 60.0 fps, p99 23.6 ms 60.0 fps, p99 21.9 ms
  • A window in the picture costs nothing measurable on either machine (within the spread).
  • PC: popped out, every run holds exactly 164.9 fps, the refresh rate of a display there. While a layered window is updated every frame, the desktop compositor paces the game's presents. This is a cap, not work: below the refresh rate nothing is lost.
  • Laptop: +0.81 ms a frame uncapped (+0.95 ms before 6d8c02ea, the same within the spread). Capped at 60 fps, both sides hold 60.0 fps. One run of the capped A side (window in the picture) was lost to a GPU device lost at start-up on that laptop's driver; it is unrelated to the pop-out code.
  • What 6d8c02ea changes: the thread the game waits for does only a plain copy of the picture. On Windows the premultiply moves to the window's own thread, which keeps its DIB section while the size holds, and one paint message stands for every picture until the window paints. On Linux the picture is swapped instead of allocated and copied, and the blit has no division per pixel. The remaining cost is the system's compositor drawing a second window every frame, which the numbers cannot separate from this code's.
**Pop-out cost, after 6d8c02ea (the picture's hand-off to the system window)** `dev.py ab`, Hyrule Field, 3 interleaved runs of 60 s a side, the FPS counter's graph in a window (it changes every frame), uncapped (`HOS_FPS_MAX=1000`) unless said. | Machine | No window | Window in the picture | Window popped out | |---|---|---|---| | PC (RTX 5080, Windows 11) | 173.6 fps | 173.6 fps | 164.9 fps | | Laptop (Linux, Wayland) | 80.5 fps | 81.2 fps | 74.6 fps | | Laptop, capped at 60 fps | | 60.0 fps, p99 23.6 ms | 60.0 fps, p99 21.9 ms | - **A window in the picture costs nothing measurable** on either machine (within the spread). - **PC:** popped out, every run holds exactly 164.9 fps, the refresh rate of a display there. While a layered window is updated every frame, the desktop compositor paces the game's presents. This is a cap, not work: below the refresh rate nothing is lost. - **Laptop:** +0.81 ms a frame uncapped (+0.95 ms before 6d8c02ea, the same within the spread). Capped at 60 fps, both sides hold 60.0 fps. One run of the capped A side (window in the picture) was lost to a GPU device lost at start-up on that laptop's driver; it is unrelated to the pop-out code. - **What 6d8c02ea changes:** the thread the game waits for does only a plain copy of the picture. On Windows the premultiply moves to the window's own thread, which keeps its DIB section while the size holds, and one paint message stands for every picture until the window paints. On Linux the picture is swapped instead of allocated and copied, and the blit has no division per pixel. The remaining cost is the system's compositor drawing a second window every frame, which the numbers cannot separate from this code's.
Author
Contributor

6d8c02ea reached this branch after the merge, so it is not in main: it is now #3195, on current main, with the measurements above. That PR also brings tests/test_ui_renderer.py's pop-out read check in line with the fence-based reads this was merged with; the check fails on main until then.

6d8c02ea reached this branch after the merge, so it is not in `main`: it is now #3195, on current `main`, with the measurements above. That PR also brings `tests/test_ui_renderer.py`'s pop-out read check in line with the fence-based reads this was merged with; the check fails on `main` until then.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3175
No description provided.