Foliage culling (#35): three bugs that zero the tree counts, plus a trace of where the canopies are still lost #252
Closed
AyyBeeDee20738 wants to merge 1 commit from
leaves-culling into main
pull from: leaves-culling
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!252
Loading…
Reference in a new issue
No description provided.
Delete branch "leaves-culling"
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?
Follow-up to #138, on the missing leaves (#35; also #124, and the earlier #61, #78, #84). Based on
main(ccdf22e), renderer build-checked there (RX_VK_ONLY=1: 0 failures, links), played onless-stutterwith each change. Nothing from the game is included: programs are named by their Hookshot keys only.This does not bring the canopies back yet. It removes three bugs that each forced the culling's counts to 0 (each confirmed in frame dumps), so the remaining cause can be found. The trace of what is left is below.
In this PR
dispatch()filled c0+0..0xc from guest memory at recording time, but the foliage chain writes the next pass's group counts on the GPU in the same frame. The program now gets a c0 upload of its own, and the 12 bytes of arguments are copied into it on the GPU just before the dispatch.RX_VK_NO_GRID_PATCH=1: as before0 1 1, GPU had0x658 1 1for44511d69,0x22dforcb2e06dd,0xb1for521f8ef5, …)vk_draw.cpp(uniform_range,dispatch)nvn_bias, so the unbiased search took the first constant it met. The counters are atc0[0x90] + c1[0] + k,c1[0] = 12. Now c0 0x40–0xA00 (align 16) is tried before the unbiased search, compute only.RX_VK_C1_FIRST=1: as beforessbo=c1+0w->0xcinf0fed2bb,cb2e06dd,44511d69,6344c53d,102f5b0a,abccf81b,7650519f); nowc0+0x90/c0+0xc0. No white flashes seen or logged errors (the blanket "skip c1" from #138's notes caused flashes)global_memory_to_storage_buffer_pass.cpp383a5669(fills the instance lists the culling reads) writes through a table of bare pointers in c4: 16 bytes an entry, no size. Every entry read size 0 and was left unbound, so all its writes went nowhere. Such an entry now takes the size another compute descriptor gave the same address (e.g. the culling's ownssbo1, 0xa040); one never seen with a size stays unbound.RX_VK_TABLE_NO_SIZE=1: as beforedump ssboshowed all of383a5669's c4 entriessize 0 bound NO; now boundvk_draw.cpp(binding loop)RX_VK_PTR_SCAN=<prog>: in a dump, pointer-like values in the game's storage buffers for that program, inside / outside the page table's windows.vk_dump.cpp: buffer dumps also count all-ones words (the culling's "no entry")Why #3 takes a known size instead of a guess: binding such an entry to its pool's end (I tried 4 MB) made the write-back copy that whole range over guest memory at the submission's end. It overwrote the game's pool headers past the buffers, and the game crashed in
ModuleSystemWorker2right after loading a save. With known sizes: no crash, 60 fps.Where the canopies are still lost
After 1–3, 12 of 41 indirect mesh draws in Kokiri Forest get work (the release: 10). The other 29 stay at 0, the canopies among them. Measured, so nobody repeats it:
44511d69(1624 groups) sorts instances into three lists. One gets about 100 groups and the other two none. A lane's list index is -1 when the keep flag (%12450in its SPIR-V) is false. The flag starts asssbo1[i] > -1(signed).ssbo1(41 KB) is mostly 0 with no all-ones words, so that test passes. The rejection happens later in that chain.14058c1a), and the 1360x1000x8 one holds 0–1 data.RX_VK_PIPE_SKIP=0.RX_VK_MIRROR=0: the page table points at the imported pools, not the mirrors, but this made no difference.RX_VK_MESH_ARGS=1together with 1–3. It must be tested with them: alone, every count was 0 anyway. With them it made no visible difference, at about 40 fps.6612817cb,d151e53e6: GPU-written command lists read before the GPU filled them) doesn't apply: Hookshot hands indirect draws to Vulkan directly.Related open PRs:
RX_VK_MESH_FIRSTandRX_VK_FOLLOW_MESH.Once the counts get through, those two switches are worth retesting with this PR.
Happy to test anything on this card.
🤖 Generated with Claude Code
Closing to keep the queue clear — please rebase on current main and reopen; thanks! (Part 1, the indirect dispatch grids, is on main as
08b413e; main handles part 2 with its own compute bias, so only the sizeless pointer tables are still new.)