refactor(settings)!: settings flow one way: the game makes every rule, the renderer reads the snapshot and reports facts #2882
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2882
Loading…
Reference in a new issue
No description provided.
Delete branch "cleanup/area2-settings-one-way"
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
Settings now go one way, from the game to the renderer. Before, the renderer copied every setting into its own options, wrote its own lines into the options file, and made its own rules: the presets, Auto (this PC)'s choice and its tuning in play, the weak laptop's rows, and a new install's Output resolution. The game then had to read those lines back. Now:
settings_now()and, for what applies at the next start,settings_start()(gpu/vk/menu/settings_apply.h,vk_menu.cpp).game/crates/longshot-game/src/engine_rules.rs,settings_now.rstake_facts). The renderer only reports facts: inLsCapabilitiesthe device and monitor ids, the card's fingerprint, low spec and the boot output size; inLsRendererStatusAuto's measured load and a bindings serial (game/settings_caps.h,LS_CAPS_LAYOUT20). Device ids are 512 bytes in the snapshot and the capabilities (LS_SETTINGS_ID_BYTES,LS_CAPS_ID_BYTES); a longer one is left empty or not listed, never cut.hidden = true, for system mods only):memory_budget,auto_for,auto_tuned,auto_stepsanddlss5_custom. These are removed:hand_line,own_lines,lines_known, theoptions_version=9cue, the renderer half ofgame_options_load,game_options_has,HOS_OPT_OPTIONS_SAVE, and the save after every apply.HOS_SETTING_STARTinhost/game_settings.h). Old files are moved only inoptions_store::migrateandmigrate_controls; the host's dead version moves innn_hid.care deleted.GONErow gives itsLONGSHOT_SETline. Debugging, kill and attempt switches stay environment variables.MKWVK_API_VERSIONgoes to 83: thegame_options_*members are removed fromMkwVkHost, andgame_languageis added last (the language the game plays in, as the host chose it, so the renderer reads no line for a mod's game language from #2881).hos_screen_ratio) before the settings file is first opened, on Windows (hos_main.c) and Linux (the SDL init), so an older profile's Aspect ratio migration sees it.Read first:
settings_now.rs(take_facts,start_facts,output_fact,tune),engine_rules.rs,vk_menu.cpp(menu_settings_apply,menu_capabilities,menu_status,menu_auto_tune),settings_caps.h.See #2434.
Merge order: after area 1 (#2877, cleanup/area1-old-menu), which goes first. Files both touch: the renderer's
Optionsfields (gpu/vk/vk_menu.h,gpu/vk/vk_menu.cpp,gpu/vk/menu/*.cpp),host/nn_hid.c,game/crates/longshot-game/src/menu.rs,gpu/vk/vk_api.h(MkwVkHost, both atMKWVK_API_VERSION82: this PR takes the next number when rebased after area 1),host/rx_backend.c,host/game_host.c/h,game/crates/api/src/settings/ffi.rs, andtests/test_menu_ini_keys.py.Testing
Tested: Linux (CachyOS), RTX 3090, through the job queue, headless. Two starts of one profile (
LONGSHOT_PROFILE, fresh run folders): the first a new install with no settings file, the second the same profile again. Second start: Speaker layout 5.1 and Auto's lines kept (auto_for,auto_tuned,memory_budget), no "first start" or "none chosen" line, the tuning not repeated. First start, on a new install with no settings file: Auto (this PC) chose tier 5, DLSS and Render resolution 3. The Output resolution was set to 2560x1440 with the "none chosen" line. The in-play measurement "the CPU holds the frame rate" kept resolution 3.settings.tomlwas written withquality_preset = "auto-this-pc",auto_forandmemory_budget. Setting the restart-taking Speaker layout row to 5.1 through the bridge wroteaudio_output = "5-1". Rebased onto mod-api12f42db5(#2861's places: hidden settings stay out of the menu fake's lists,game.menu.systemSettings/unplacedSettings, anddlss5_customis offNOT_ROWS); after it,cargo test -p modtool the_typescript_system_mods_pass_their_tests,schema-gen --check,test_menu_ini_keysandtest_switch_tablepass. Before the rebase, checks:run_allgives 835 passed and 3 failed. Of the 3,test_lifteralso fails on mod-api:game-core/src/nav.rsfmt from #2745, and build-coreProfileLock::held.test_walk_keywas fixed after the run and passes.test_reshade_fxfailed only because of my job's SPIR-V path and passes with the right one. The renderer builds for Windows (llvm-mingw); clippy and fmt pass on api, longshot-game and host-sys. In the host's Windows compile onlynn_video.cfails, because FFmpeg headers are missing in this environment (a file this change does not touch).After the review (rebased onto mod-api
75bcd270, #2881; job-queue build job, Linux, for this head and #2894's):run_all837 passed, 0 failed, 11 skipped;dev.py rtbuilds; the host compiles for Windows (llvm-mingw, with the FFmpeg headers) and Linux; the renderer's Windows sources compile; clippy passes on host-sys, longshot-game and schema. New game-free checks:test_fullscreen_monitor_platform(the screen's shape before any settings read, Windows and Linux paths),options_storedevice_ids_whole_or_left_empty, andtest_game_language(a mod's game language through the host's answer).Still to test:
options_version5,ultrawide=0) on a 16:10 or 4:3 screen: expect the Aspect ratio moved to the monitor's shape (by hand).gpu_device_idsaved at the first start (by hand, multi-GPU PC).Measurements
Nothing to measure: settings plumbing. The renderer reads the same values through a pointer instead of a copy, and each frame the game reads a 352-byte status. Auto's tuning rules are unchanged.
Risks
longshot_options.inireadable.capture_spare_mbandstaging_keep_mbare stored as n + 1 (1 is the old switch's 0).vk:logs a line naming theLONGSHOT_SETreplacement.Checklist
Ready for review
main; the title is a Conventional Commit. (on mod-api75bcd270)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
gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.MKWVK_API_VERSIONbumped (MkwVkHostorMkwVkRendereringpu/vk/vk_api.hchanged).Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Possibly related, for context:
@review
Recommendation: Request changes. Older profiles can lose their aspect-ratio migration, and long device identifiers are truncated before the host uses them. The refactor also needs in-game coverage on the other affected platforms before merge.
The change moves settings rules and persistence into the game and has the renderer consume snapshots. It reduces duplicated ownership, but changes startup, device selection, live settings and rendering paths across both supported platforms.
Blocking (2): must change before merging.
host/hos_main.c:1301: The monitor is prepared before its aspect ratio is published, but preparing it now opens and migrates the settings file. (more on the line) Do: Determine and publish the screen aspect before opening and migrating settings, while avoiding the monitor-loading dependency cycle. Add a startup-path test using an older profile and a narrow monitor.PR description / Title and description (pull_request_target)fails on this head and passes on the base branch: Failing after 7s.Should fix (1): not blocking, but worth doing before merging.
game/crates/host-sys/src/settings_abi.rs:932: Device identifiers are silently truncated to 127 bytes when copied into the settings snapshot. When: A saved audio-output or fullscreen-monitor identifier longer than 127 UTF-8 bytes is passed to the host as a different identifier. The host then cannot match the selected device and falls back instead of restoring the player's choice; the previous monitor path accepted identifiers up to 511 bytes. Do: Carry complete supported device identifiers through the snapshot and capability lists, or reject overlong identifiers without saving a choice that cannot be restored. Test an identifier longer than 127 bytes through selection and restart.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2 and L4.More: does it help, other systems, switches, what was read
Does it help: Not a perf change. The reported Linux RTX 3090 run exercised two starts and Auto tuning, but it does not establish that existing profiles and device choices work across the affected systems.
Other systems: Startup settings, fullscreen monitors, audio devices, input bindings, Auto tuning and renderer settings are affected on Windows and Linux. The reported run covers Linux on one NVIDIA GPU; Windows, AMD and Steam Deck behavior remain unverified.
Switches: The PR removes 58 environment switches and replaces them with hidden settings; debugging and kill switches remain. The switch table documents replacements, but I did not independently verify every replacement and default.
Reviewed:
fbf1783788against12f42db5c1: Read the repository rules, PR template, standards, commit and change summary, and inspected the settings snapshot, startup, migration, host monitor and device-ID paths. Skimmed the remaining changes; I did not read every changed code file or test in full, so this review is incomplete.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code or tests were run. The PR reports a headless Linux RTX 3090 run and several checks, with Windows host compilation and other hardware runs still outstanding.
Overlaps and merge order: The PR identifies #2877 as a prerequisite, with overlapping renderer, host, API and test files; #2877 should merge first and this PR must then take the next API version.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -1299,4 +1299,3 @@int saved = ultrawide < 0 ? -1 : ultrawide != 0, version = hos_options_int("options_version", 0);void hos_monitor_prepare(void);int hos_monitor_screen_size(int *,int *);hos_monitor_prepare();L1 (blocking): The monitor is prepared before its aspect ratio is published, but preparing it now opens and migrates the settings file.
When: On a 16:10 display with an older profile containing options_version=5 and ultrawide=0, hos_monitor_prepare calls hos_monitor_load, which calls game_settings_at_start. The migration sees no screen aspect, keeps ultrawide=0 and writes the current version; the intended migration to the monitor's shape is then permanently skipped.
Do: Determine and publish the screen aspect before opening and migrating settings, while avoiding the monitor-loading dependency cycle. Add a startup-path test using an older profile and a narrow monitor.
fbf17837885536cf21b1Thanks. L1 fixed: the screen's shape is now set from the current or main monitor before the settings are first read, on Windows (
hos_main.c) and on Linux (the SDL init), with a game-free order test. L2 fixed: device ids are 512 bytes in the snapshot and the capabilities, and an id that still doesn't fit is left empty or not listed, never cut (tested). L4: the description is fixed. Rebased onto mod-api75bcd270(#2881): a mod's game language now reaches the renderer through the host's answer (MkwVkHost.game_language, API 83). L3 (Windows, AMD, Steam Deck runs) is listed under Still to test.Landed on mod-api as
3ad99c9e(one commit), after its review fixes and one batched build + game run of all six cleanup areas together. mod-api work now goes straight onto the branch once self-reviewed.Pull request closed