WIP: refactor(settings): environment switches set settings, one system (stacked on #2882) #2894
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2894
Loading…
Reference in a new issue
No description provided.
Delete branch "cleanup/area2b-switches-as-settings"
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
Stacked on #2882 (settings flow one way): merge that first. If #2882 has merged by then, this goes onto mod-api.
The renderer and the host had about 170 environment switches that were really choices (kinds
tune,hwandplayer). Each was read withgetenvwherever it was used. Now one system covers them:longshot --list-settings, set for a run withLONGSHOT_SETor--set.system/renderer-settings,system/memory-settings,system/thread-settings,system/upscaling-settingsandsystem/host-settings.switch = "RX_VK_..."names the switch for each setting. As the game opens its settings, it reads each declared switch and sets the setting for the run, the same wayLONGSHOT_SETdoes (longshot-gamerun_set.rsswitches).LONGSHOT_SETand--setwin over a switch.hos_switchisgetenv). The builder resolveslongshot_env.txtand hands the game a finished environment. The builder-is-the-game stack (step 2) removes the game's own file reader and its sandbox grant, and drops prepare-run switch handling the same way. This PR adds no second file reader.api::settings::decl::switch_value):0/off/false/noas off and any other value as on;switchValues, the switch's text per option, or else the option's index;switchScale(ms to µs, a fraction to a percent), plusswitchAdd(1 where the setting's 0 is Auto and the switch's 0 was a value).settings_start(),HOS_SETTING_START), never the environment.gpu/vk/setting_text.hturns a setting back into its old switch text for the rules that still parse text, so their game-free checks stay as they were.SETTING(name, "mod:key").tests/test_switch_table.pychecks each such row against the mod's"switch", and fails if the name is still read anywhere. The renderer'svk: switches setline names the setting each switch set.HOS_AUDIO_DEVICE,HOS_LANGUAGE,HOS_RESERVE_CORE_MASK,HOS_WINDOW_*,RX_VK_TAAU_KEYS,RX_VK_DLSS_DIRand others;LONGSHOT_*switch, which the builder or the launcher sets;RX_VK_PRECOMPILE_*,RX_VK_PREDICT_*,RX_VK_PREPARE_*,RX_VK_STREAM_MB,HOS_LOG_BATCH_MS,HOS_NO_MODS,RX_VK_COMPILE_SHADERS;RX_VK_DEVICE,RX_VK_QUEUE_PRIORITY,RX_VK_RECORDER,RX_VK_ASYNC,RX_VK_REFLEX,RX_VK_ANTILAG,RX_VK_DESC_REUSE,RX_VK_SAMPLER_CACHE,RX_VK_XESS,HOS_FPS_MAX,HOS_ASPECT,HOS_MOUSE_SENS,HOS_RES_SCALE,HOS_INPUT_BACKGROUND;HOS_DAV1D_THREADS,HOS_NATIVE_ZSTD,HOS_PRESENT_NOWAIT,HOS_RT_POOL_MB,RX_VK_TEX_MAX_*,RX_VK_READBACK_*,RX_VK_RECORDER_*and others. These can follow in another change.RX_VK_FIFOandRX_VK_IMMEDIATEstay removed: both would set V-Sync, and a setting takes one switch.Read first:
game/crates/longshot-game/src/run_set.rs(switches),game/crates/api/src/settings/decl.rs(switch_value),game/crates/api/src/manifest/setting.rs(switch*),gpu/vk/switches.h(SETTING,report),gpu/vk/setting_text.h, andgame/mods/*-settings/mod.toml.See #2434.
Testing
Tested: Linux (CachyOS), RTX 3090, through the job queue: a headless run with
RX_VK_MIRROR=0,HOS_CORES=4andRX_VK_UPLOAD_BUDGET_MS=8set. The log said each one as it set its setting for the run, before the renderer started:RX_VK_MIRROR=0: system/memory-settings's buffer_mirrors is 1 for this run(Off),upload_budget_us is 8001(8 ms, stored n + 1),host_cores is 4. The renderer'svk: switches setline namedHOS_CORES=4 (sets system/thread-settings:host_cores). The run got into play and drew 900 frames.Checks:
cargo test -p api(452) and-p longshot-game(183) pass, including the new tests:schema-gen --check,test_switch_tableandtest_menu_ini_keyspass.run_all: 829 passed and 8 failed. 7 of the failures were fixtures that needed the settings stand-in; they are fixed and passed in a second small build job. The 8th,test_lifter, also fails on mod-api (build-core'sProfileLock::held).longshot_vk.dlllinked).nn_video.c, which this PC can't compile (no FFmpeg headers); this change doesn't touch it.Still to test:
RX_VK_MIRROR=0inlongshot_env.txt. ExpectRX_VK_MIRROR=0: system/memory-settings's buffer_mirrors is ...in the log and mirrors off (by hand, or @Beanstalk "an old RX_VK_ switch in longshot_env.txt still applies").--prepare-shaders) with a converted shader switch set (RX_VK_MESH_SHADERS,RX_VK_MMA_*,RX_VK_NATIVE_FADD,RX_VK_TASK_*). Expect the default (no game, no settings); it applies in a game run (by hand).Measurements
Nothing to measure: every default is unchanged. A setting at 0 runs the code that ran with its switch unset, and the reads move from
getenvto a field of the snapshot.Risks
Old switch values that change meaning or are refused (the log says each refusal and leaves the setting as it is):
HOS_MEMORY_MBloses hex;RX_VK_EQ_BIAS,RX_VK_HOLD_GPU_MS,RX_VK_DLSS_ACTOR_REACHand the mouse decays take whole numbers only.RX_VK_TS_SCALEtakes thousandths,RX_VK_REACTIVE_*hundredths,RX_VK_UPLOAD_BUDGET_MSandRX_VK_TEX_AHEAD_MSwhole microseconds,RX_VK_DLSS_LOD_OFFSEThundredths of a step.RX_VK_AVAIL_RESERVE_MB,RX_VK_IMPORT_CAP_MB,RX_VK_FRAME_GATE_MS,RX_VK_COMPUTE_PHI_LIMIT,RX_VK_FALLBACK_CALL_LIMIT,HOS_SHADOW_BUCKET(4096) and others.RX_VK_VRAM_MB,RX_VK_PART_MIN/MAX,RX_VK_RETIRE_SECSandRX_VK_WB_PROBATION;RX_VK_BC_SMALL_LAYERS,RX_VK_COMPACT_MB,RX_VK_IMAGE_BLOCK_MBandRX_VK_IMPORT_LOW;RX_VK_FALLBACK_PHI_LIMIT(0 was no limit) andRX_VK_DLSSG_HOLD/TOGGLE(TOGGLE=0was never toggle);HOS_PAD_SPEAKER_BUFFER_MSandRX_VK_MIRROR_HOT_MB,RX_VK_MIRROR_HEAT_CAP_KB,RX_VK_MIRROR_SMALL_PCT,RX_VK_TEX_CAPTURE_MAX_MB.HOS_CORESis Auto too.HOS_MOUSE_NATIVE,HOS_HANDHELD: only0or1.HOS_AUDIO_CHANNELS: only2or6.RX_VK_MESH_LANES: only8,16or32.RX_VK_GPU_CLOCK: only0,peakorstandard.RX_VK_LOW_VRAM_MIPS: only0.RX_VK_TASK_MESH_FALLBACKandRX_VK_FRAG_SHUFFLE_FALLBACK.HOS_FULLSCREENnow sets the Fullscreen setting for the run, where before it kept the row out of it. A switch-set value is a run value and is never saved.--prepare-shadersrun has no game, so its settings read their defaults. The builder stack drops prepare-run switch handling the same way.MKWVK_API_VERSIONis unchanged;LsSettingsgrows (generated, its layout hash moves).A revert is enough to undo all of it.
Checklist
Ready for review
main; the title is a Conventional Commit. (stacked on #2882, onto mod-api)mise run testpasses (any failure that also fails onmainis named). (test_lifterfails on mod-api too)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def. (defaults unchanged;SETTINGrows)tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Windows host compile (llvm-mingw, with tools.lock's FFmpeg 9.0.2 headers): every host unit compiles at this head; box ticked.
b25a0c7dd551473e9f86Restacked on #2882's new head
5536cf21(rebased onto mod-api75bcd270); now51473e9f, no conflict. Its settings ABI files regenerated (schema-gen --check passes); run_all 837 passed, 0 failed. MKWVK_API_VERSION 83 now comes from #2882.Landed on mod-api as
1e1704d1(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