fix(vk): the simulated-turf switch rows sit in name order, so find() finds them #2197
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!2197
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/Longshot:fix/switch-table-sort"
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
gpu/vk/switches.defis sorted by name becausegpu/vk/switches.h'sfind()binary-searchesrows[]. #2093 (1885234b) insertedRX_VK_SIM_TURF_ADAPTIVEandRX_VK_SIM_TURF_POOLSaround the existingRX_VK_GRASS_DISTANCErow, which leaves two inversions:RX_VK_SIM_TURF_ADAPTIVEbefore line 467RX_VK_GRASS_DISTANCE(Gsorts beforeS);RX_VK_SIM_TURF_POOLSbefore line 469RX_VK_HALF_RATE_SHADING(Hsorts beforeS).tests/test_switch_table.pyreports only the first (it stops at the first inversion), so moving that one row alone would leave the second in place.This is a product bug, not a lint. With the table unsorted,
find()misses four real switches —RX_VK_SIM_TURF_ADAPTIVE,RX_VK_SIM_TURF_POOLS,RX_VK_HALF_RATE_SHADINGandRX_VK_HANDLE_TABLES— soreport()at start would tell a run that sets one of them that it "is not a switch of this build: a misspelt name, or one from another build", and leave it out of theswitches setline.What changed: the two rows move to their alphabetical place among the
Snames, afterSHOT_Wand beforeSKIP_CODE. Two lines moved; no name, kind, type, unset or summary text changes. AnSWrow has no ID or index — a switch's identity is its name — andfind()is the only consumer of the row order (the program-cache stamp hashes the environment's names and values,find_gone()is a linear scan, and the menu's rows are a table of their own).Read first:
gpu/vk/switches.h(find(), and its "sorted by name" comment), then the two moved rows ingpu/vk/switches.def, then the sortedness check attests/test_switch_table.py:150.Testing
Tested: the full suite,
--jobs 3in an 8 GiB memory scope with the pinned headers: here 912 passed, 22 failed, 18 skipped in 620 s againstmain @ a2dc5385's 911 / 23 / 18 in 635 s. Every failing name here is one of main's 23; the only difference istests/test_switch_table.py, which this change fixes (main's 23 less that one = this branch's 22), and no name fails here that does not fail on main.At the check itself: on
main @ a2dc5385it fails withFAIL: the switch table and the source disagree: switches.def is not sorted by name: RX_VK_GRASS_DISTANCE comes after RX_VK_SIM_TURF_ADAPTIVE; here it passes.In the game (Linux
7.3.4-zen2-2-zen, NVIDIA GeForce RTX 4070 Ti, Vulkan 1.4, driver620.70.06): Kokiri Forest, 20 s after warm-up, one run each side (recordruns/ab/20261121-191618-change-kokiri-forest) — main 1804 frames, 90.2 fps, median 11.11 ms, p99 13.86 ms, 1% low 72.2 fps, 0 cold frames; here 1805 frames, 90.3 fps, median 11.09 ms, p99 13.76 ms, 1% low 72.7 fps, 0 cold frames. The smoke is a boot/play check with the reordered table; the check above, not the smoke, is what proves the four lookups.Still to test: None (the check and the smoke cover this PC; CI builds both platforms).
Measurements
Verdict: the table is sorted again:
find()finds all 788 switches, 4 more than onmain, andtest_switch_table.pygoes from red to green through the check's ownfind(name) == &rows[i]test. No switch's name, default or behaviour changes.a2dc5385abbc5703test_switch_table.pyfind()finds, of 788find()missesRisks
Only which row
find()returns can change, and the order is now correct, so every name maps to its own row. No switch's value, default, read or log text changes; nothing changes for saves,longshot_options.ini, the game folder's caches, or the program-cache stamp. A revert is enough; no switch.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (912 / 22 / 18 here against main's 911 / 23 / 18; the 22 are main's 23 lesstest_switch_table.py, which this fixes, and no name here is absent from main's list)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 (test_switch_table.pyalready readsswitches.defand is unchanged; its sortedness check is the guard).Ready to merge
main, measured again or a comment says why the numbers still hold. (CI has not run on this head)Tested in game: Linux 7.3.4-zen2-2-zen, NVIDIA GeForce RTX 4070 Ti (Vulkan 1.4, driver 620.70.06): Kokiri Forest, 20 s after warm-up, one run each side — main 1804 frames / 90.2 fps / 11.11 ms median / 0 cold frames; this branch 1805 frames / 90.3 fps / 11.09 ms / 0 cold frames.
Possibly related, for context:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.