refactor(menu): every Insert menu row in a feature module, built through a menu model (#1633) #1774
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1774
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:refactor/menu-model"
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?
Type: refactor · Risk: medium · Tested on: Windows 11, RTX 3080 · Needs: Linux, any GPU
TL;DR
Every row of the Insert (F1) menu lived in one long table in one file, so any change to the menu touched the same lines as
every other menu change, and a renamed row could lose a player's saved setting. This PR moves each feature's rows, and the
code behind them, into a small module of its own, built through a menu model that a future in-game menu can also draw.
The menu looks and behaves as before: every tab was gone through in the game, the saved settings file kept every key, and
the game-free checks pass, with new ones for the model and the modules.
Breakdown
gpu/vk/vk_menu.cpp(59 open PRs touched that file), special cases were matched by label, and a row's saved key was made from its label.gpu/vk/menu/, placed relative to other rows, with their own saved key; nothing a player sees changes.tests/run_all.pywith no new failure; new checks for the model, the modules' order, the frozen keys and the table's room.Why
The Insert menu is the most-changed part of the renderer, and all of it was one table and the functions around it, so
menu PRs conflicted with each other constantly and every special row needed edits in several places, found by its label.
A row's line in
longshot_options.iniwas made from its label, so renaming a row silently dropped that setting fromplayers' files. Issue #1633 asks for the menu to be built through a model, by feature, so rows can be added in one place
and the menu can later be drawn by the game's own menu too.
Fixes #1633
What changed
The menu is described by a model (
gpu/vk/menu_model.h, no ImGui or Vulkan in it) and 31 feature modules(
gpu/vk/menu/*.cpp); the ImGui menu invk_menu.cppdraws what the model builds.vk_menu.cppgoes from 6,942 to4,868 lines; host/ changes only in comments naming where a row is now.
gpu/vk/menu_model.h,menu_model.cpp:Setting(key, label, help, kind, value, range, choices, and hooks:shown,locked,text,hint,step_fn,on_change,on_activate,verb,confirm),tab/page/heading/section/row/custom, and placement byafter/before/first/last/order, worked out once whatever order themodules register in.
gpu/vk/menu/*.cpp, one feature each (display, output, upscaler, framegen, HDR, detail, GPU, audio,controller, camera, motion, walk, bindings, NFC, preset, session, bug report, pipeline list, debug tools, ...). A module
takes its feature's code with it: its texts and hints, its state, its engine (
output.cpp,preset.cpp,pipeline_list.cpp). Code that needs the renderer is under#ifndef MENU_LAYOUT_ONLYand its hooksMENU_HOOK(...),so the checks build every module without Vulkan; what modules ask the renderer is declared in one section of
gpu/vk/menu_module.h.gpu/vk/vk_menu.cpp:row_tablebuilds the rows from the model (room for 256 module rows,kModuleRowsMax); amodule's buttons, pages, sliders and locked rows are drawn and pressed generically, so the label-matched special cases
(
is_share_row,is_laptop_row,is_vibration_test_row, ...) are gone. Its own table keeps only the core's threesection headings and the menu's custom section (
bespoke_row: the Debug tools' panel, Custom output size's textfield, the Controls row's bindings grid), which the model has as
Custom; the Mods tab's list is custom code too..key);tests/test_menu_ini_keys.pyfreezes the100 keys players' files hold.
pressed by
draw_modsandmods_tick, the menu's own code, as the Debug tools' panel is.its fix:
main(
Setting.wraps,test_menu_slider_ends);gpu/vk/menu/audio.cppincludeshost/audio_output_devices.h, which only re-keyedvk_menu.cpp's object: a changeto it would have reused a stale object (
nx2/build.py,test_shader_stamp_cache);menu_tick, the tuning bar,debug_step;test_menu_empty_tab); none is empty today;kMaxRowsthrough headings, which take a row but no text slot (restart_slotwritten pastits end), and a module row's value texts were written by the drawing and the control bridge's thread at once: the
table stops at either limit and the buffers are
thread_local(test_menu_module_slots);test_menu_locked_button);test_menu_ini_keyscompared only the set of keys: it ties each key to the value its row saves, and asksini_keytogive a module row's own key first (a swap of two rows' keys, or that line taken out, now fails it).
tests/menu_model_fixture.py(builds the menu from the modules, no game),test_menu_model,test_menu_modules,test_menu_ini_keys,test_menu_module_slots,test_menu_slider_ends,test_menu_empty_tab,test_menu_locked_button; the checks that read a row's fields read it from its module.docs/development.md, "A row of the Insert menu", says how a row is built now; AGENTS.md's two menu rules.How a menu row is defined now
Before, a row was a positional entry in
vk_menu.cpp's one table, and anything more was matched by its label elsewhere:Now a feature's rows are described once, in its own module, by named fields, with their hooks and their place. A section
and its rows (
gpu/vk/menu/framegen.cpp):A button whose hooks ask the renderer, fenced so the checks can build the module without Vulkan
(
gpu/vk/menu/laptop.cpp, the whole module):A new feature's rows are a new file like these: the build compiles every
gpu/vk/menu/*.cpp, and nothing invk_menu.cppchanges. Placement is relative (after(key),before(key),first(),last(),order(n), or.section(id)to start a section's rows), so modules don't fight over positions. The full guide isdocs/development.md, "A row of the Insert menu".Measurements
Verdict: nothing to measure for speed: every change in
menu_tickis on its open-menu paths and the row table is built once at start, so the game's frames run as onmain; the in-game check is in Testing.Flags and settings
None: no switch, menu row or ini key is added or changed (every saved row keeps its key, frozen by
tests/test_menu_ini_keys.py);longshot_options.ini's lines come in another order, read by key as before.Testing
Tested: Windows 11, NVIDIA GeForce RTX 3080, driver 621.14, a runtime packed from this branch over the base
47430e81(dev_build.py):quit;
longshot_options.inibefore and after held the same 166 lines with the same keys and values but the rowschanged (the line order differs: the Motion, FPS counter details and Controls pages' rows now follow the tabs' rows;
the file is read by key);
describe 110, so 46 were left out and the NFC tab had none (a divide by zero in
menu_tick). Fixed here with room for256, and
tests/test_menu_module_slots.py, which fails without it;main@a5fbd680(with #405), packed and run again: the Controls tab shows Vibration, Vibrationstrength and Test vibration between Stick dead zone and Motion, Test vibration's cell says No controller with none
connected, no menu row is left out (the log), and the options file's first save adds
vibration=0beside the keys it had.main@3653c9c5(with #134's Mods tab, which moved Debug to the seventh place), packed and run: onthe Debug tab, in its new place, the Debug tools switched on and Autosave off, and the options file saved both under their
keys (
debug_tools=1,autosave:=0), nothing else changed; no menu row left out (the log).main@a433db32, whose two commits since (#1778, #1747: RenHDrum packaging, NFC) touch none ofthis PR's files.
main@621dae50and run again: Sharpness goes round at 100% and0% as on
main, the other sliders stop at their ends, and the options file saved the steps (quality_preset=0, as achange of Sharpness gives on
main); no menu row left out (the log).python -I -B tests/run_all.pyon Windows (llvm-mingw first on PATH), after the fixes, onmain@a433db32: 696 passed, 52 failed, 126 skipped, beside a shader preparation;main@3653c9c5on the same PC: 688 passed, 51 failed. The 52: the same 51, andtest_mesh_args_cleanup, which passes alone here (a timeout under the run's load). The 51:test_auto_handheld,test_bug_report_defaults,test_build_long_paths,test_capture_read_once,test_crash_dialog,test_crt_options,test_damage_debug_menu,test_dev_packs,test_discover,test_display_startup_failure,test_dlss_feature_size,test_failed_compile_keeps_objects,test_fastfp_fma,test_fma_soft,test_fpx_sticky,test_game_menu_mouse_buttons,test_guest_imported,test_high_fps_fixes,test_host_guest_writes,test_hud_layout_row,test_job_queue,test_libc_hooks,test_lift_lookups,test_linux_preflight,test_linux_pressure,test_longshot_ctl,test_make_game_cache,test_missing_nup,test_mods_list,test_pads_after_menu,test_pending_guest_import,test_pipeline_play_cache,test_prepare_cache_save,test_prepare_stall,test_present_thread,test_profiling_mode,test_psychov35_fsr3_fg,test_readback_timeout_source,test_release,test_sdiv_overflow,test_seed_reader,test_slow_frames,test_song_note_cue,test_spawn_emit,test_tested_configurations,test_upscaler_rows,test_vbytes,test_vcore_escape,test_vfpx_elem,test_walk,test_walk_key.Not tested: Linux (no Linux PC here); Test vibration's buzz and its cell with a controller connected (no controller
here; its texts for every report the host gives are run by
tests/test_vibration_menu.py); the menu on other GPUs.Must be tested:
cell to name what plays the controller (Motors, HD rumble, ...), its help line to say the same, the prompt to say Test,
and the controller to buzz once (by hand: anyone with a controller)
in the same order as on
mainand the changed rows kept (Test Farm: @Beanstalk linux, go through every tab of theInsert menu and compare with main)
Risks
What could break: a row out of place, a text lost (the translations match texts exactly) or a key lost; the checks
look for each (
test_menu_modules,test_readme_menu_rows,test_menu_ini_keys,menu_texts_kept.pyduring the port).A module row past the table's 256 would be left out and logged, and
test_menu_module_slotsfails. The table is builttab by tab, so three listings come in another order (the Motion, FPS counter details and Controls pages' rows after the
tabs' rows): the options file's lines, the restart line's and question's names, and the control bridge's
menu_setting(index)enumeration (by key, as before, it is the same).Turning it off: revert the PR.
Compatibility: nothing changes for a player: the same rows, texts, defaults and keys;
longshot_options.ini's linescome in another order.
MKWVK_API_VERSIONis unchanged (vk_api.huntouched).Issues
Fixes #1633
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
Three more features' rows out of vk_menu.cpp's table into gpu/vk/menu/, their texts as written (the C literals copied, not retyped: every literal vk_menu.cpp had is still in the menu's sources), their keys as players' files hold them: - detail.cpp: the Detail section after HDR, Anisotropic filtering and Shadow resolution, with their text and hint functions (and their comments). - volume.cpp: Volume (a slider, no longer in is_slider and stops_at_ends) and Mute in background, before Output device. - fps_counter.cpp: the FPS counter's level, corner and size and the row that opens its details page (a module's page row now, not by name), before Menu size; the details page's version row and its twelve Dev lines. menu_module.h: menu_text::percent ("%d%%", the translations' format) and MODULE_HINTS for the modules' hints. set_row's cases by value (the samplers made again for Anisotropic filtering) hold for a module's row as they did. Checks: test_fps_stats, test_audio_volume, test_oot_shadow and test_hdr_encode read the rows' modules; the menu as built (tests/menu_model_fixture.py) compiles the modules with gpu/vk on the include path. Co-Authored-By: Claude Opus 5.5 <[email protected]>menu_model.h's Setting has confirm: an Action that asks for a second Activate before it acts ("Press again to confirm"; Esc or B cancels). gpu/vk/menu/session.cpp describes Restart and Quit with it, after Bug report, their Activate the menu's own (menu_restart_game, menu_quit_game: vk_menu.cpp's, after its save and the pipeline cache's, as before). vk_menu.cpp no longer finds them by their place in its table (kRestartRow, kQuitRow): a row confirms when its setting says so, and Bug report is the table's last row (kBugReportRow). Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11, NVIDIA RTX 3080, driver 621.14, a runtime packed from this branch: went through every tab and page of the Insert menu, changed rows and quit; longshot_options.ini kept the same 166 keys and values except the rows changed. Rebased on
a5fbd680(with #405): the Controls tab's Vibration, Vibration strength and Test vibration rows in main's order, Test vibration's cell No controller with none connected, no menu row left out.Description: added How a menu row is defined now under What changed: a row as the old table had it, then the same kind of rows as a module describes them (a section with its rows, and a button whose hooks ask the renderer, fenced for the game-free build). No code change.
98ab32f3277198ef3eccRebased onto main
a433db32, over #134's Mods tab (7198ef3e).3653c9c5: 694 passed, 50 failed; main on the same PC fails the same 50 (and test_prepare_stall, under load).7198ef3ecc144ba4dcc7New commits pushed, approval review dismissed automatically according to repository settings
A cold review of the branch (a second agent, reading only) found six problems; each is fixed now with a check that failed before its fix (
144ba4dc, on main621dae50):Checks: 696 passed, 52 failed: main's 51, and test_mesh_args_cleanup, which passes alone (a timeout under load). Three listings come in another order (the options file's lines, the restart line's names, menu_setting(index)): in Risks.
WIP: refactor(menu): every Insert menu row in a feature module, built through a menu model (#1633)to refactor(menu): every Insert menu row in a feature module, built through a menu model (#1633)Ready for review. The checklist's box for host code on both platforms is taken out at the maintainer's word: the menu's modules are no platform's code (no host or renderer API of Windows or Linux in them). A Linux run is still in Must be tested, for the menu as players see it.
zeldaootr referenced this pull request2026-11-19 22:49:24 +00:00
mooki referenced this pull request2026-11-19 23:02:28 +00:00
mooki referenced this pull request2026-11-19 23:02:33 +00:00
mooki referenced this pull request2026-11-19 23:02:42 +00:00
mooki referenced this pull request2026-11-19 23:22:56 +00:00
mooki referenced this pull request2026-11-19 23:23:05 +00:00
mooki referenced this pull request2026-11-19 23:23:41 +00:00
gab9281 referenced this pull request2026-11-20 05:12:20 +00:00