feat(ui): a mod window can be popped out of the game's picture into a window of its own #3175
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3175
Loading…
Reference in a new issue
No description provided.
Delete branch "neotoxic/Longshot:feat/ui-popout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A mod window (a
Windowmounted 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.game/crates/ui):Core::pop_synclays 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.MKW_UI_VERSION12 (gpu/vk/ui_draw.h,docs/dev/reference/ui-draw-list.md) andMKWVK_API_VERSION94 (popouts_able,popouts,popout_showlast onMkwVkHost).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.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.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=1turns the box off everywhere.closeOn) still closes it.Read first:
Core::pop_sync,Core::toggle_pop,Core::close_box(game/crates/ui/src/core.rs),ui_tickanddraw_popout(gpu/vk/vk_ui.cpp), then the two hosts'hos_display_popouts.Testing
Tested:
mainand 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.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_backfails on the previous head for each path (close box, Back), anda_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-memaccessin its owntest.cpp) andtest_native_zstd.dev.py rt(llvm-mingw):longshot-game.exeandlongshot_vk.dllbuilt and linked.dev.py baseanddev.py rtbuild (the SDL host's pop-out code included);cargo test -p game-ui -p longshot-game: 188 and 222 passed, 0 failed.mise run testin full, beforeeab4e75e: 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 metpopout_event's first) andtest_ui_record(its fixture had nopopouts_);eab4e75eupdates 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 onmain(d6e819e0) there (test_check_third_party,test_ci_source_times,test_dev_vcs,test_run_all_output,test_run_all_reap),test_run_all_junitpasses alone here and onmain, andtest_lifterandtest_lifter_semanticsstopped at 600 s under the load of the full run.Still to test:
@Beanstalkon a Deck, or by hand).Measurements
Nothing to measure: with no window popped out, the only added work is one
popoutscall a present that returns at once; a popped-out window's picture is drawn and read back when its frame or size changes.Risks
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 onmain.HOS_HEADLESSis not new: the hosts only read it, since a headless run has no screen to open a window on.HOS_NO_POPOUTS=1) gives no box; the windows stay in the picture as onmain. Reverting the branch is enough to undo it; nothing is saved (a popped-out window's place is kept for the run only).Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).mainand here, for a change that shows on screen. (#issuecomment-102831)Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
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.
Possibly related, for context:
Screenshots, Windows 11, this head merged with #2957 and #3174, the Progress window in Hyrule Field:
HOS_NO_POPOUTS=1, as onmain: the title bar has the close box alone.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.
WIP: feat(ui): a mod window can be popped out of the game's picture into a window of its ownto feat(ui): a mod window can be popped out of the game's picture into a window of its own@review
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.
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.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.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.
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)
@fixdoes its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)@fixcan 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:
eab4e75eadagainstd6e819e084: 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:
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.
@ -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];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);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;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;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.
Thanks. Pushed
ff345342(merge ofmaine345b3ca),daa991b1(the fixes below) ande185922e(merge ofmaine57f7793, with #3099), nothing rewritten.Version.
maintook 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'shost->version >= 94gate and the checks intests/test_ui_renderer.pyandtests/test_program_hooks.pyfollow.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'sGetForegroundWindowanswers 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_imagewaits 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,kFramesLaterstill 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_imageresets 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 throughclipboard_line, shared with the game window's paste; on Linux throughpop_text_utf8, shared with typed text.MKW_VK_POPOUT_TEXTis 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
mainwith an updating pop-out is still open, and so are Xwayland and gamescope.Checks at
e185922e:run_all.py --changed origin/main: 280 passed, 3 failed. The three failures aretest_dlssg,test_sync_watch_eventandtest_turf_budget, which fail onmainitself too.daa991b1: 255 passed, the same 3 failed.dev.py rtanddev.py smokepass on both Windows and Linux.e345b3ca) into feat/ui-popout: the pop-out windows move to MkwVkHost version 94 ff345342fbe57f7793) into feat/ui-popout@review
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.
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)
@fixdoes its part first: Avoid redundant picture copies and use GPU completion to limit unnecessary readback work.)@fixcan 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)
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:
e185922e98against9f76a4379c: 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:
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.
@fix
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
@fixchangedI changed this pull request: the new head is
9420da52d4. I mergedmain(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)
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)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (2; not asked for, not blocking)
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:
9420da52d4against921e6cbea8: 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:
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.
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.HOS_NO_POPOUTS=1: the same window drawn in the game's picture, as onmain.(VRAM: the log's last
VRAM: ... used; working set and private: its lastvk: memory:line.)What it costs:
When it costs nothing: the renderer redraws a popped-out window only when the UI's frame changed (
draw_popout: asameframe 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.
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.6d8c02ea reached this branch after the merge, so it is not in
main: it is now #3195, on currentmain, with the measurements above. That PR also bringstests/test_ui_renderer.py's pop-out read check in line with the fence-based reads this was merged with; the check fails onmainuntil then.