Compute programs prepared before the game find their storage buffer table #761
Closed
ZurielAtr wants to merge 1 commit from
fix/compute-table-precompile into main
pull from: fix/compute-table-precompile
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!761
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/compute-table-precompile"
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?
What
The shader precompile (
seed_program) translates every compute program with a blankNvnState. NVN2 compute keeps itsstorage buffer table in c0 after the push area and the uniform buffer table, and
vk_bank.cppcs_layoutfinds it fromthe bound program's control section. With nothing bound it says nothing, so
translate_intofell back to Maxwell's0x310, where NVN2's c0 holds nothing. 3756 of the game's 3808 compute programs have storage buffers.Compute programs have no variants, so the program cache handed the game that translation from then on. OoT's foliage
culling then left some of its draw lists empty: plants near Link lost their leaves (the bushes in Hyrule Field, the plants
by the rocks), while the far impostors were fine.
Fix
parse_codereads the table from the compute stage's own control section, the same bytescs_layoutreads(
+0xa9push words,+0xb1uniform buffers,+0xb2storage buffers,+0xb3textures,+0xb6images). For all 3808compute programs in the game the sum matches the bank size the control section stores at
+0xba. The compute translationuses it only when the state has no program bound, i.e. for the precompile.
RX_VK_CS_TABLE_SEED=0turns it off.Changing
vk_shader.cppchanges the shader stamp, so the caches are prepared again on the first start.Testing
RX_VK_NO_PROGRAM_CACHE=1was right, which is what pointed at the prepared translations. Retranslating the sevenfoliage mesh programs in play changed nothing (their prepared and in-play IR are identical).
this change draws them both near and far.
tests/test_compute_table_precompile.py(game-free, wired intosource-regressions.yml):parse_codeandcs_layoutread the same control bytes with the same arithmetic over 2000 random control sections, and the translationtakes the program's own table only when no program is bound, before the translator is told. It fails if the
!s.prog.nstagecondition is dropped.Addresses #590.
🤖 Generated with Claude Code
Tested this on an RTX 3070 8 GB (Windows 11, driver
0x98960000as the log prints it, mesh shaders yes). I built from the command line, cherry-picked ontomainat58af2c0(v2.0.4), and played by hand from a save at the Kakariko entrance into Hyrule Field. Each build prepared its shaders again (the stamp changes), and I moved the caches aside before switchingEDEN_NX2_GM_LEGACY, so every translation matches its row.EDEN_NX2_GM_LEGACYb179914(port on by default)b179914with onlyafbb2d5revertedsubmit … failed (-4),device lost: 0 checkpoints)So on this card, with the port off:
With the port on,
b179914ran fine but had no distant foliage. v2.0.4 + this PR lost the device at the load every time, black screen with the audio still going. I couldn't check whether the port plus this PR draws the distant foliage and the mountain together. The logs from the two lost starts are available if useful.Tested on Windows, RTX 4080 16 GB, i9-14900KF, 32 GB: this fixes the near-plant textures there.
.github/workflows/source-regressions.yml(kept v2.0.5's);vk_shader.cppmerged cleanly, and the fix also covers v2.0.5'sseed_compute(blank state,!s.prog.nstage).97 failedprograms, constant for the whole run (from the prepare, presumablyseed_compute's trial variants); 0 compute pipelines were built in play.v2.0.5's prepare-plus makes many more compute programs before the game, so without this fix more of them carry Maxwell's
0x310table, which fits the plant issue looking worse after v2.0.5 in #811.Closing to keep the queue clear — please rebase on current main and reopen; thanks!