feat(input): a Screenshot control saves a PNG of the game's picture, F12 and the Capture button by default #1709
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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!1709
Loading…
Reference in a new issue
No description provided.
Delete branch "cuecuemoar/Longshot:feat/screenshot-button"
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
Longshot had no way for a player to take a screenshot, and the Capture button of a Switch controller did nothing. This adds a Screenshot control to the Controls page, F12 and the Capture button by default and changeable like any other control. One press writes a PNG of the game's picture at its own size, with the HUD and without the menu, to
screenshots/Longshot_<date>_<time>.pngin the game folder, and a notice at the top says where it went. Nothing else in the game changes: idle, the frame time ismain's; while a picture a second is taken the median is 0.6 ms higher and no frame went over 25 ms at 2560x1440 and 3840x2160.Read first:
screenshot_tickanddraw_shot_toastingpu/vk/vk_menu.cpp(the trigger and the notice),shot_ask_native,nat_prepareandnat_warmingpu/vk/vk_replay.cpp(the picture),host/nn_hid.c(the control and its rules),gpu/vk/screenshot_file.h.HOS_KEY_SCREENSHOTafter Sprint andHOS_PAD_MISC1(SDL'sMISC1: a Switch controller's Capture, an Xbox Series pad's Share) after the paddles, so savedpad_/key_lines keep their places;MKWVK_API_VERSION46. Screenshot is a gamepad-input peer of the Switch buttons and Sprint (pad_swaps): an input that is Screenshot's is no other control's, and choosing one another control has asks first, as everywhere on the page (hos_rebind_control). A mouse button is refused for it, inhos_bindand inhos_rebind_control; an options file from before it that gave F12 to another control leaves it without a key.SteamGameIdorSteamAppIdset, Screenshot starts with no key and no button (binding_defaultsmakes Reset give it none too, not run), because Steam takes F12 and the Capture button for its own pictures.RX_VK_SHOT_WxRX_VK_SHOT_H). The player's readback has its own image and buffer, made by a thread in the first presents of a session, used once there and kept; the PNG is written from the mapped buffer on a thread of its own, so the present thread copies nothing.docs/user/graphics-and-controls.md,tests/test_screenshot_button.py, and the fixtures and pinned lines of 14 other checks that cut the control table, the menu andvk_api.htake the new names.Fixes #712
Testing
Tested: on my PC (Windows 10 Pro 22H2, RTX 4090, driver 617.42, 2560x1440, a keyboard), in the game. The runs below were made on
274901a6(this branch overmaina2dc5385) and the hand checks again on6b39c8f3(overmain0e32bc10); the head,67b874dc, differs from6b39c8f3by one sentence ofdocs/user/graphics-and-controls.md, and from274901a6bymain's 18 commits since (Threaded rendering's Auto from 4 cores, Streamline presentation, ...), the API version (45 to 46) and one help text.274901a6(the Controls page, the question about C and the picture with the menu open again on6b39c8f3): the Controls page lists Screenshot last, after Toggle HUD and before Reset to defaults, with Capture, None and F12 and its help (onmainthe last row is Toggle HUD). Bound to F9 it is saved askey_screenshot=120,0, and the press that chose F9 made no picture (226 files before and after); F12 then made nothing and F9 made one, with the Insert menu open and with it closed. Giving it C, which the Right stick press has, asks "C is already bound to Right stick press. Remove that assignment and bind it to Screenshot?"; Cancel left both as they were (key_rs=67,0,key_screenshot=120,0). Its Reset button restoredpad_screenshot=21andkey_screenshot=123,0. A burst of 5 presses in 0.5 s made 1 file.SteamAppId=480and no options file the Controls page shows Screenshot as None, None, None, the file haspad_screenshot=-1andkey_screenshot=0,0, and F12 made no picture (229 files before and after); without itpad_screenshot=21(Capture) andkey_screenshot=123,0(F12).tests/test_screenshot_button.py(the file name, the press, the binding table's rules and defaults, the Steam defaults, the options file,screenshot_tickand its notice against stubs, the wiring, and that the readback is not made on the render thread) fails onmainand passes here.host/nn_hid.candhost/pad_sdl.ccompile with the same warnings asmain(63 and 0), nothing linked, the game not run.tests/run_all.py --stricton6b39c8f3againstmain0e32bc10: 922 passed and 18 failed on this branch, 921 and 18 onmain, the same 18 files:nx2/test_coop_spirv.py,test_cpp_preflight,test_crash_record,test_dev_packs,test_dev_update,test_dlss_actor,test_fsr3_math,test_fsr3_shaders,test_fsr3fi_hud_layer,test_fsr3fi_hudless_colour,test_late_fix_shaders,test_mesh_unreachable_outputs,test_obj_cache_size,test_pipeline_state_computes,test_prof_clock,test_reactive_mask,test_saveload_warm_cache,test_wmma16_spirv_val. The checks that read the docs pass on the head.A crash that is not this PR's: in 31 launches of the game on this PC, 1 of 18 on this branch and 1 of 13 on
main(a2dc5385) crashed 25 to 30 s after the save loaded (0xc0000005in the game's code, the same fault addresslongshot.exe+0x1e33b032and the same guest backtrace starting at0x83331040on both, no press involved). The PR run it hit was run again; no issue about it was found on the forge.Still to test:
screenshots/and the notice (by hand, or@Beanstalk windows, a Switch controller: press the Capture button in the game and check a PNG is written to screenshots/)@Beanstalk linux, press F12 in the game, a PNG in screenshots/)@Beanstalk windows amd, take screenshots with F12 and compare frame time)Not run at all: a controller of any kind (so a gamepad input that another control has, in the rebind dialog), Reset to defaults under Steam's environment, the DualSense's microphone button (SDL's
MISC1, a picture by default), HDR, frame generation on.Measurements
Verdict: idle, this PR's frame time is
main's (median 9.12 ms against 9.12 at 2560x1440 and 9.23 against 9.21 at 3840x2160; p99 +0.14 and +0.23 ms; no frame over 25 ms). While a picture is taken once a second the median is 0.63 ms (7%) higher at 2560x1440 (9.77 against 9.14,mainignoring F12) and 0.62 ms at 3840x2160, and no frame in 18 press phases went over 25 ms (the worst of them 17.8 ms). The extra shows only while pictures are being taken; it was not separated into the notice's overlay pass and the picture's own copy.mainhad one frame over 25 ms in an idle phase at each size (40.6 ms and 35.8 ms), the PR none.Setup: Windows 10 Pro 22H2 (19045), RTX 4090 24 GB, driver 617.42, Core i9-13900K, 32 GB; a copied save, adult Link standing in the Lost Woods;
RX_VK_FRAME_TRACE=1,HOS_FPS_MAX=1000(about 110 fps), Output resolution 2560x1440 and, in a second set, 3840x2160, Render resolution 100%, Upscaler Game's own, Frame generation Off, a job-queuetimingslot.maina2dc5385and the PR (274901a6) asdev.py packspacks over one base, a warm-up run of each, then interleaved runs: main, PR, main, PR, main, PR at 2560x1440 (the third PR run crashed, see Testing, and was run again after the thirdmainrun), main, PR, main, PR at 3840x2160. Each: 800 frames of warm-up, then 4 rounds (3 at 4K) of 1,500 frames with no press and 1,500 frames with F12 once a second (14 or 15 presses;mainignores F12), F12 sent only while the game's window was the foreground one. The table is the median over the phases of each phase's statistic fromlongshot_frames.csv.2560x1440, frame time in ms (12 phases a column, 18,000 frames):
a2dc5385a2dc53853840x2160 (6 phases a column, 9,000 frames; the game is not GPU-bound here: the same frame time as at 1440p):
a2dc5385a2dc5385The first press of a session, which cost one frame of 120 to 210 ms on this branch's earlier commits (the first use of the new image and buffer), now falls in the first presents instead (
nat_warm): in the three 2560x1440 PR runs above the first press phase's worst frame is 14.6 to 16.9 ms, and 14.7 and 17.3 ms in the two at 4K. The player's readback is kept for the session (image and buffer, 4 bytes a pixel each: 29.5 MB at 2560x1440 and 66 MB at 3840x2160).The head's build, once: this PR @
6b39c8f3overmain0e32bc10, 2560x1440, 4 rounds as above, nomainbeside it (the numbers are not an A/B): no press median 9.12, p99 11.24, p99.9 13.73, worst 18.62; F12 once a second median 9.73, p99 12.56, p99.9 15.88, worst 24.76 ms in one phase, no frame over 25 ms; 60 presses made 60 PNGs.Log lines:
longshot v3.0.0-208-ga2dc5385 (source 63363428)andlongshot v3.0.0-212-g274901a6 (source b6e279e1); each pressvk: present <n> written to ...Longshot_<date>_<time>.png (a screenshot).Screenshots
All 1280x720, the game window only, the same spot (adult Link, Lost Woods), taken by me.
Before:
main@a2dc5385, the Controls page (no Screenshot row; the last control is Toggle HUD):After: this PR @
6b39c8f3, the Controls page with the Screenshot row selected (Capture, None, F12) and its help:After: this PR @
6b39c8f3, the notice just after F12 (it is not in the saved picture):After: this PR @
6b39c8f3, giving Screenshot a key another control has (C, the right stick press) asks first:After: this PR @
6b39c8f3, the file F12 wrote with the Insert menu open (the whole 2560x1440 PNG as saved, 11 MB: the HUD, no menu, no notice):Risks
screenshots/.MISC1too, takes a picture by default (the issue says Share; on a DualSense that is the Create button, which SDL gives as Back).Turning it off: unbind Screenshot's key and button on the Controls page (Delete), or revert the commit; the readback is still made at the start of a session. Compatibility:
MKWVK_API_VERSIONis 46 (a host and a renderer built from other commits are refused as before; a renderer given an older host ignores the control).longshot_options.inigainspad_screenshotandkey_screenshotlines; older files load as before, and older builds ignore them. No shader or pipeline cache changes.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (tests/run_all.py --stricton Linux: the same 18 files fail onmainand here, named in Testing.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).host/nn_hid.candhost/pad_sdl.ccompile, nothing linked, the game not run there.)mainand here, for a change that shows on screen.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
https://claude.ai/code/session_01VxeaZhiNvC7bfnojvd99Rh
Tested in game: RTX 4090, driver 617.42, Windows 10 (19045), keyboard: F12 in the game's window (adult Link, Lost Woods) wrote a 2560x1440 PNG with the HUD and no menu, with the notice shown; frame time traced at 2560x1440 and 3840x2160 with a press a second: no frame over 25 ms (details in the description)
Update at
aa38014a: seven interleaved runs against main (the same PC, scene and settings): idle, this PR's frame time is main's (median 10.15 ms against 10.18, none over 25 ms), and with F12 pressed once a second the median is 0.4 ms higher and no frame went over 25 ms. The description now has the table, clean screenshots (the Controls page on main and here, the notice, the saved file) and a docs/tested row for the run. Still to run: the Capture button on a Switch controller, Linux and an AMD GPU (the Test Farm request follows).@Beanstalk test the Screenshot control of this pull request (F12 writes a PNG of the game's picture into a screenshots folder in the game folder, and a "Screenshot saved" notice shows at the top of the window). On Linux, any GPU: start a game from a save, press F12 once in the game's window and check that one valid PNG is written to screenshots/ and the notice shows. On AMD, Windows and Linux: stand still in a scene, then compare frame time with F12 pressed once a second against none, against main on the same PC, expecting no frame over 25 ms and a median within about 0.5 ms; a press while the last picture is still being written makes no second picture, so at 4K only every other press writes a file.
@cuecuemoar only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was foraa38014, and the PR has changed since (a07318c), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.aa38014a83a07318cf90Rebased onto main
a433db32(one conflict, in tests/test_menu_text_field.py: kept main's host stub and this PR's screenshot_tick stub). The commits are now57c34612,847a9421anda07318cf(were4f26f5c1,34a146d4andaa38014a). The Measurements section is unchanged: its numbers were taken on4f26f5c1over main47430e81and have not been measured again; the description says so.Claims check, no blame: where does this stand? Which test is still missing - the Capture button on a Switch controller, Linux, or an AMD GPU? The Test Farm request above was for
aa38014and no longer matches the head, so it needs a fresh @Beanstalk comment; meanwhile I can run Linux + an AMD GPU on the current head and report what the PR asks for (one PNG written on F12, and frame time with a press a second against main) - no code hand-over implied. One line keeps it, or one line releases it; after 2026-11-29 it is open to a fresh claim.@dazemc only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was fora07318c, and the PR has changed since (6b39c8f), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.Correction: the Beanstalk mention in my comment above was unintended - no farm run is requested on my account, and nobody should approve one for it. I meant only that the earlier request no longer matches the head. The offer is a hand run on Linux + an AMD GPU, reported here.
a07318cf906b39c8f3b86b39c8f3b867b874dcb9Rebased onto
main0e32bc10(4 commits, head67b874dc) and measured again in the game; the description is rewritten for it.mainhad added Sprint, Toggle HUD,hos_rebind_control(rebinding asks before taking an input) andbinding_defaults; Screenshot now sits after Sprint, is apad_swapspeer, and its Steam and mouse rules are in the new code paths too.MKWVK_API_VERSION46. Five checks that pin lines of the control table, the menu orvk_api.hwere updated, not weakened. The Controls help text and the user docs no longer say a taken input "trades places".host/nn_hid.candhost/pad_sdl.ccompile withmain's warnings,run_all.py --strictfails the same 18 files here and onmain.mainas before, interleaved (idle equal; +0.6 ms median while pictures are taken; no frame over 25 ms in 18 press phases), the hand checks again (F12, F9 rebind, the question about a taken key, Reset, a burst, the menu open, Steam's environment), and the head's build once.maintoo: the game crashed 25 to 30 s after loading once in 18 launches of this branch and once in 13 ofmain, with the same fault address and guest backtrace; not this PR's.Pictures for the description. All 1280x720, the game window only, the same spot (adult Link, Lost Woods), taken by me.
Before:
main@a2dc5385, the Controls page (no Screenshot row; the last control is Toggle HUD):After: this PR @
6b39c8f3, the Controls page with the Screenshot row selected (Capture, None, F12) and its help:After: this PR @
6b39c8f3, the notice just after F12 (it is not in the saved picture):After: this PR @
6b39c8f3, giving Screenshot a key another control has (C, the right stick press) asks first:After: this PR @
6b39c8f3, the file F12 wrote with the Insert menu open (the whole 2560x1440 PNG as saved, 11 MB: the HUD, no menu, no notice):The pictures of the description are attached now (the comment above): the Controls page on
mainand here, the notice, the binding-in-use question and a saved file with the menu open. The Screenshots box is ticked; Still to test and Ready to merge are as before.WIP: feat(input): a Screenshot control saves a PNG of the game's picture, F12 and the Capture button by defaultto feat(input): a Screenshot control saves a PNG of the game's picture, F12 and the Capture button by defaultView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.