fix(vk): avoid unrelated PsychoV35 shader variants #3138
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3138
Loading…
Reference in a new issue
No description provided.
Delete branch "futondestroyer/Longshot:codex/psychov35-curve-filter"
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
TL;DR PsychoV35 was giving thousands of unrelated shaders their own curve variants and compiling them during play. This change checks aligned shader words with a filter sized to the shader. In the paired Native HDR runs, Field-to-Market shader pipeline wait fell from 2.50 seconds to zero.
The hitch shows up on first entry into Market or Zora’s Domain with Native HDR and PsychoV35 active. The four-byte scan and the larger filter keep unrelated programs on their ordinary keys. The minimum filter size preserves the order of hooks for small shaders. The renderer reports a curve with no candidates after 100,000 checks in one hook generation.
Start with
Words::ofandCurve::may_takeingpu/vk/program_hooks.h, and the regression intests/program_hooks_test.cpp. Reconstructed from the original PsychoV35 stutter handoff and its unpublished test and fix,0f68f7072and2d09245a9.Testing
Tested: Windows 11, GeForce RTX 4070, driver 621.01, 2560×1440 Native HDR10/PQ and PsychoV35. Two interleaved repetitions took the same child save from Hyrule Field into Market and then the Zora River entrance to Zora’s Domain. Both builds reached both scenes and applied the PsychoV35 curve. The candidate logged two applied hooks and zero refusals in each run. Stock logged one application and 63 refusals per run, filling the 64-entry diagnostic sample. Both current Windows runtimes passed Builder verification. All seven focused program-hook checks passed on
82929aa0. The game-free regression failed on stock and passed on the fix with Windows Clang and GCC. Removing the small-shader floor also failed the targeted regression.The earlier full Windows strict comparison on the same feature diff returned 831 passes, 51 platform skips and these nine shared failures on each side:
test_cursor_hidden_linux.py,test_dev_update.py,test_float_add_subgroup.py,test_helpers_extract.py,test_lifter.py,test_longshot_builder.py,test_native_zstd.py,test_run_all_junit.py, andtest_utf8_paths.py. The full suite at the final comparison revisions is pending.Still to test:
Measurements
Verdict: Median Field-to-Market p99 frame time fell from 94.05 ms to 32.00 ms. Recorded shader pipeline wait fell from 2.50 s to zero. At the Zora entrance it fell from 2.52 s to 2.2 ms.
Setup: RTX 4070, driver 621.01, Windows 11, 2560×1440 Native HDR10/PQ, PsychoV35, 60 FPS cap, game upscaler, frame generation off. Both sides prepared 70,273 graphics and 5,087 compute pipelines. Each prepared set contained 35,105 graphics notes with RGBA16F attachments and used its own NVIDIA cache. The reverse-order pair used independently copied, hash-checked caches. Rows are medians over two runs per side. The route measurements start at the transition and include 600 presentations in the destination.
5be6ba3082929aa0The game-free shader corpus check separately inspected 22,356 fragment stages. Stock admitted 8,528 stages. This filter admitted all 330 aligned constant matches and zero unrelated stages in that corpus.
Risks
A short shader can contain both constants in unrelated instructions. The pass still verifies that the curve it replaces is present. Larger shaders use a larger membership bitmap. The two Market private-memory snapshots per build varied by up to 0.46 GiB. Reverting the change restores the previous filter.
Checklist
Ready for review
main; the title is a Conventional Commit. The published head is the exact head used for gameplay. Main has since advanced.mise run testpasses (any failure that also fails onmainis named). The exact-head focused tests pass.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11, RTX 4070, driver 621.01. Two interleaved Field-to-Market and Zora Domain runs in 2560x1440 Native HDR10/PQ with PsychoV35. Both builds completed both routes and applied the curve. Field-to-Market median p99 was 94.05 ms on
5be6ba30and 32.00 ms on82929aa0. The candidate recorded zero pipeline wait on that stretch.@review
Recommendation: Approve. The code is ready: only testing is left. The paired Windows runs show a substantial reduction in shader waits and transition frame times. The renderer change still needs the stated Linux and other Tier 1 hardware coverage, plus a check of its startup and memory costs. Recommend approval; not approved on the forge.
The change filters fragment shaders by aligned words using a size-scaled bitmap, reducing unnecessary PsychoV35 variants and translations. It adds per-shader bitmap allocation and retains larger summaries in memory.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
gpu/vk/program_hooks.h:71: The size-scaled summary is allocated for every fragment stage, including when no curve is active; its startup and retained-memory cost has not been isolated. (more on the line) Do: Compare cold and warm startup or preparation time, process memory and cache size on the base and this head, including a run with the curve disabled. (@fixdoes its part first: Avoid constructing or retaining the summary when curve matching is not needed, while ensuring it is available if hooks change later.)gpu/vk/program_hooks.h:69: The changed shader-selection path needs gameplay coverage on the other Tier 1 systems it can affect. (more on the line) Do: Run Native HDR and PsychoV35 through the affected transitions on Linux and representative AMD and Steam Deck Tier 1 hardware, checking output and first-entry behavior; also complete the stated RTX 5080/DLSS run.@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, on the tested Windows RTX 4070: two interleaved runs per build report median Field-to-Market p99 falling from 94.05 ms to 32.00 ms and pipeline wait from 2.50 s to zero. The same comparison reports Zora entrance p99 falling from 58.70 ms to 35.71 ms.
Other systems: The filter is built for fragment stages regardless of whether a curve is active, and is used in live and prepared shader paths on both Windows and Linux. The RTX 4070 runs show the curve applying; Linux, AMD, Steam Deck, and the stated RTX 5080/DLSS case remain untested.
Switches: None.
Reviewed:
82929aa0d7against5be6ba309e: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, all changed code files and the diff, commit messages, and the relevant shader parsing, hook selection, cache-key and test-runner code. Reviewed the changed documentation passages and skimmed related decoder and cache references. docs/review-checklist.md and the adjacent Tooling checkout were absent. No recorded run files or generated files were changed.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run as requested. The author reports focused game-free checks and paired Windows gameplay runs; CI and the final full-suite comparison are still pending.
Overlaps and merge order: Not established; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by futondestroyer. Nothing was run; a maintainer decides.
@ -80,2 +67,3 @@Words s;for (size_t i = 0; i + 4 <= n; i++) {const size_t count = n / sizeof(uint32_t);if (!count) return s;L2 (should fix): The changed shader-selection path needs gameplay coverage on the other Tier 1 systems it can affect.
When: The only reported gameplay runs are on Windows with an RTX 4070. Linux Vulkan, AMD and Steam Deck have not demonstrated correct curve output and first-entry rendering with this filter.
Do: Run Native HDR and PsychoV35 through the affected transitions on Linux and representative AMD and Steam Deck Tier 1 hardware, checking output and first-entry behavior; also complete the stated RTX 5080/DLSS run.
@ -82,0 +68,4 @@const size_t count = n / sizeof(uint32_t);if (!count) return s;// Eight bits per input word, rounded up to a power of two. Preserve the old 4096-bit floor so a small shader// cannot newly match an earlier curve and shadow a later one.L1 (should fix): The size-scaled summary is allocated for every fragment stage, including when no curve is active; its startup and retained-memory cost has not been isolated.
When: A player without PsychoV35 still builds and retains these bitmaps as stages are parsed. Large stages use more memory than the former fixed 512-byte summary, and the reported Market snapshots vary enough that they do not settle the cost.
Do: Compare cold and warm startup or preparation time, process memory and cache size on the base and this head, including a run with the curve disabled.
I ran one local 60-second pair on Linux with an RTX 3090 and NVIDIA driver 620.70.06. Both builds used a nested Gamescope HDR10 surface at 2560×1440, Native HDR with PsychoV35, the game's upscaler, a 60 FPS cap, and V-Sync and frame generation off. I used the same Castle Town gate save and scripted entry into the Market, with matching copies of the warmed caches.
5be6ba309e5e82929aa0d746Both builds logged an applied PsychoV35 curve. Stock logged 63 curve refusals in the diagnostic sample and the PR logged zero. Across the full 60 seconds, average FPS was 58.3 vs 59.4 and p99 was 19.27 vs 19.85 ms. The queue reported no noise flags during either measured window. All seven focused program-hook checks passed on the PR head.
WIP: fix(vk): avoid unrelated PsychoV35 shader variantsto fix(vk): avoid unrelated PsychoV35 shader variants