feat(runtime): one list of the game's switches, host/switches.def, kept in step with the reads #62
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
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
testing wanted
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!62
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:feat/switch-list"
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: feat · Risk: low · Tested on: Windows 11, RTX 3080 (NVIDIA 621.14), in the game · Needs: Linux, any GPU, in the game
Why
The game reads 774 switches and nothing lists them: a new one goes unnoticed, a removed one stays in the docs, and
longshot_env.txt's safety rules keep their own hand-written table of the switches a shared file must not set. This adds one list that a check keeps in step with the code.What changed
host/switches.deflists every switch the game reads, one line each with its type, its scope and the file that reads it, and a check fails when the code and the list disagree.longshot_env.txt's allow-list takes the switches a shared file must not set from that list, in place of its own table; what it refuses is unchanged.host/switches.def(new): one X-macro line per switch thathost/,gpu/vk,gpu/renderandgpu/compatread,SWITCH(NAME, TYPE, SCOPE, "area", "what").FLAG,INT,FLOAT,TEXT,PATH, orANYwhere the reads don't make it certain yet.GAME(may be set inlongshot_env.txt),LOCAL(from the environment only: it names a file or presses inputs on a timer), orSYSTEM(the OS's or a library's variable).""until someone who knows the switch writes one.env_line_allowedinhost/hos_main.cbuilds its table from the list (listed, throughSWITCH_LOCAL_GAME/LOCAL/SYSTEM) and refuses itsLOCALswitches, in place of its ownby_nametable and the two names it checked apart (RX_VK_FRAME_LOG,HOS_PRESENT_TRACE). Otherwise unchanged: the names it refused before areLOCAL(main'sHOS_CRASH_TEST, #593, among them); a_FILEor_DIRname not listed yet is still refused;RX_VK_DLSS_DIR, paths in values and the system's names behave as before.scripts/switch_list.py(new, standard library):reads,listedandcomparelist what's read and not listed, and what's listed and read nowhere;--update(update,certain_type,line_for) writes the missing lines (the type where the reads make it certain), drops the dead ones, and moves an area when that file no longer reads the switch.nx2/build.pycountshost/*.defamong the host's dependencies (host_deps), so an edit to the list compileshos_main.cagain;nx2/version.py's fingerprint counts.deffiles among the sources.tests/test_switch_list.py(new);tests/test_env_file.py's fixture compilesenv_line_allowedwithhost/on the include path.The cost for everyone: a new switch needs its line (
python -I scripts/switch_list.py --update, then the description), ortest_switch_listfails and names it.Measurements
Verdict: passes:
longshot_env.txtleaves out exactly the four lines it must (threeLOCALswitches and an unlisted_FILEname) and takesRX_VK_PACE=1, as main's own table does: in the game on this branch (no file written), and game-free on the rebased head against main @7bacf846. Nothing to time.Hardware: RTX 3080 (NVIDIA 621.14), Ryzen 9 3900X, 64 GB, Windows 11
Scene: one launch, from a save into Kokiri Forest
Method: one launch of this branch's build (on main
82de567a) with thelongshot_env.txtbelow; what the log names as left out, and whether the files were written. On the rebased head, game-free:env_line_allowedcut out of main'shost/hos_main.cand out of this branch's, each compiled (clang,-I host) and asked about the same five linesHow to reproduce: put these five lines in
longshot_env.txtbeside the game, start it, and readlongshot_log.txtlongshot_env.txt7bacf846(allow-list, game-free)c6c08d40(allow-list, game-free)5255a001HOS_AUDIO_DUMP=test.wavtest.wavnot writtenHOS_INPUT_SCRIPT=0:ARX_VK_FRAME_LOG=frames.csvframes.csvnot writtenRX_E1_NOT_LISTED_FILE=x.txt_FILEname not listedRX_VK_PACE=1Rebased since onto main
d652bbb4(this PR @c6c08d40), not run in the game again. Main'senv_line_allowedhad gainedHOS_CRASH_TESTin its table (#593); the rebase keeps it refused as aLOCALline. Since82de567amain also added 59 switches and stopped reading 221 (#577 took the WebGPU renderer out, and everyRX_switch only it read), so a third commit brings the list in step (switch_list.py --update): the new ones areGAMEas main's allow-list took them (the two_FILEnamesLOCAL),GAMESCOPE_WAYLAND_DISPLAYthe system's. The names main's table refused that the game no longer reads leave the list and the test's names refused before:LONGSHOT_BUILDER_HOME(#13; only the builder's scripts read it, and the game starts no builder) and the WebGPU renderer'sRX_DUMP_WGSL,RX_DUMP_SLOW_WGSL,RX_DUMP_TICS,RX_WGSL_OVERRIDE.Flags and settings
No switch is added or changed.
scripts/check_pr_description.pyfinds the names below becausehost/switches.defnames them in backquotes in other switches' descriptions, or the test's fixtures make them up; each existing one keeps its own line in the list.HOS_PROFILE,RX_VK_DUMP_DIR,RX_VK_HANG_SEC,RX_VK_PRESENTS_AHEAD,RX_VK_PRESENT_AHEAD,RX_VK_SHOT_EVERY,RX_VK_SHOT_W,RX_VK_SHOT_H,RX_VK_TRANSLATE_WAIT_MSHOS_GONE,HOS_KEPT,HOS_MOVED,HOS_NEW_LEVEL,RX_NEW_DUMP_DIR,RX_VK_FROM_A_TABLE,RX_NOT_LISTED_YET_DIR,RX_NOT_LISTED_YET_FILE,RX_VK_SOMETHINGtests/test_switch_list.py's fixtures; the game reads none of themscripts/switch_list.py [--update]--updatefixes the listtest_switch_listnames a switchTesting
Tested: the run under Measurements (Windows, in the game, this branch before the rebase); every check that read the changed files then (56; 51 passed, the 5 others failing the same way on main). On this rebased head (
c6c08d40, on main @d652bbb4), Windows with the Builder's llvm-mingw clang (6 at once): the 68 checks that read this diff (listed below: the tests that name a changed file, and the tests it adds or changes), not the whole suite: 58 passed, 1 skipped (tools this PC lacks, the Vulkan headers among them), 9 failed, each also failing on main:test_appimage_player_build,test_crash_dialog,test_linux_preflight,test_oot_state_tap,test_vk_pgoin the full run on main @1310ecc6; andtest_dll,test_driver_cache_folder,test_pipeline_tour,test_udmabuf_warningon main @7bacf846(run there alone, on a clean checkout of main from a few commits before this branch's base: they fail the same way; they passed in the1310ecc6run).The 68 checks run
nx2/test_dll.py,nx2/test_version.py,tests/test_appimage_headers.py,tests/test_appimage_licenses.py,tests/test_appimage_player_build.py,tests/test_aspect_default.py,tests/test_auto_settings.py,tests/test_bake_ds.py,tests/test_bake_skeleton.py,tests/test_bug_report.py,tests/test_build_cleanup_scope.py,tests/test_build_hash_cache.py,tests/test_build_times.py,tests/test_cheat_items.py,tests/test_compile_retry_jobs.py,tests/test_compiler_failure.py,tests/test_cpm_discovery.py,tests/test_cpu_target.py,tests/test_crash_dialog.py,tests/test_crash_record.py,tests/test_debug_tools_linux.py,tests/test_dev_packs.py,tests/test_display_modes.py,tests/test_display_startup_failure.py,tests/test_dlss_sdk_cache.py,tests/test_driver_cache_folder.py,tests/test_driver_cache_room.py,tests/test_env_file.py,tests/test_exclusive_marks.py,tests/test_failed_compile_keeps_objects.py,tests/test_flight_yields_to_events.py,tests/test_fpx_sticky.py,tests/test_hle_stats.py,tests/test_kept_translation.py,tests/test_late_fix_build.py,tests/test_lift_cache.py,tests/test_link_path_comma.py,tests/test_linux_preflight.py,tests/test_linux_saves_move.py,tests/test_low_memory_notice.py,tests/test_make_game_ngx.py,tests/test_mem_gate.py,tests/test_mem_gate_children.py,tests/test_mem_gate_leases.py,tests/test_mem_limit.py,tests/test_menu_restart.py,tests/test_movement_speed.py,tests/test_no_release_lookup.py,tests/test_no_webgpu.py,tests/test_oot_state_tap.py,tests/test_opening_skip.py,tests/test_output_resolution.py,tests/test_pipeline_tour.py,tests/test_prepare_at_build.py,tests/test_program_cache_format.py,tests/test_recorder_sync.py,tests/test_shader_stamp_cache.py,tests/test_shader_stamp_inputs.py,tests/test_split_giants.py,tests/test_stale_hot_pieces.py,tests/test_switch_list.py,tests/test_switches_removed.py,tests/test_teleport_minimap_flag.py,tests/test_third_party_objects.py,tests/test_udmabuf_warning.py,tests/test_utf8_paths.py,tests/test_vk_pgo.py,tests/test_widescreen_shapes.pyHost build:
host/hos_main.c(with thehost/switches.defit includes) compiled to an object on this head (c6c08d40) and on main @d652bbb4, both clean: on Windows with the Builder's llvm-mingw clang (x86_64-w64-mingw32), on Linux with gcc 14.2 (Dockerpython:3.12,host/posixon the include path); build.py's flags for one object, the runtime headers a lift makes (a64.h,a64_suyu.h,a64_fpx.h) copied from a local work folder, and for the renderer files the Builder's CPM Vulkan, SPIR-V and VMA headers. It covers the files this PR changes, not a whole game build.Not tested: Linux (the same C; the check runs there); the game on this rebased head.
Must be tested:
longshot_env.txtsetting aLOCALswitch (HOS_AUDIO_DUMP=test.wav), expecting it logged as left out and no file written (by hand: the log line, and notest.wav)Risks
What could break: a switch marked
LOCALby mistake is refused fromlongshot_env.txt, so a shared file loses that setting; one markedGAMEby mistake that writes a file would be let through. The names refused before that the game still reads are heldLOCALbytest_switch_list, and an unlisted_FILEor_DIRname is still refused. Every new switch now needs its line inhost/switches.def, ortest_switch_listfails. Host objects compile once after this change (host/*.definhost_deps). With #911 (longshot_env.txtcan't setHOS_CONTROL_PEER_SID): the two merge cleanly, but this list hasHOS_CONTROL_PEER_SIDasGAME; whichever of the two merges second marks itLOCALinhost/switches.def(one line), so the list says what the allow-list does.Turning it off: no switch: revert the commits.
Compatibility: Nothing changes:
longshot_env.txttakes and refuses what it did on main (apart from the five names its table refused that the game no longer reads:LONGSHOT_BUILDER_HOMEand the WebGPU renderer's four).Checklist
Everyone
type(scope): description) of the status line's type.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.mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
feat(runtime): one list of the game's switches, host/switches.def, kept in step with the readsto WIP: feat(runtime): one list of the game's switches, host/switches.def, kept in step with the readsBack to WIP under #48's process: this was carried over before the new template. Its description will be brought to the template and measured on Longshot (main against this PR, at named commits) when it's wanted for review; ask here if you'd like it sooner.
Description brought to Longshot's PR template (#48). Still WIP: it has a game run on this branch but no main-against-this-PR measurement yet, and it isn't rebased on current main.
Description moved to the template's Testing section and whole checklist (#72): what was tested, what wasn't, and what needs other testers (their test requests to open while this is WIP).
The description follows the template after #76 and #106: If applicable keeps only the boxes that apply (one that applies and isn't done yet stays unticked while this is WIP), the Flags table has the template's seven columns (Goal is now Recommendation), and GitHub references are full URLs. Nothing else changed.
This conflicts with
mainnow:host/hos_main.c'senv_line_allowed(the names that take a file or folder) was changed by #593 (the crash window), and this PR replaces that list withhost/switches.def. Please rebase onto currentmain(bbe6fdf2), keeping the entries main added in the list. Not rebased here since it needs the new switch added to the def file.5255a0012ac6c08d4032Rebased onto main
d652bbb4(head nowc6c08d40); the conflict was env_line_allowed's table, where main had added HOS_CRASH_TEST (kept refused, as a LOCAL line). A new commit brings host/switches.def in step with main (59 added, 221 gone with #577's WebGPU removal and others) and has nx2/version.py's fingerprint count .def files. Checks that read this diff, not the whole suite: 68 run, 58 passed, 1 skipped, 9 failed, each failing on main too (5 at1310ecc6, 4 at7bacf846); the allow-list refuses and takes the same five lines as main's (game-free A/B). Description moved to the current template. Still WIP: the host's Linux build is not checked yet (Must be tested).Host build box ticked: host/hos_main.c (with host/switches.def) compiles to an object on
c6c08d40and on maind652bbb4for Windows (llvm-mingw clang) and Linux (gcc in Docker); changed files only, not a whole game build. Risks now say whichever of this and #911 merges second marks HOS_CONTROL_PEER_SID LOCAL in the list.WIP: feat(runtime): one list of the game's switches, host/switches.def, kept in step with the readsto feat(runtime): one list of the game's switches, host/switches.def, kept in step with the readsView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.