gpu: bind the view-stride table shaders read at root SRV 255 #264
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/264"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Ketan-Kapse on 2026-11-27T06:41:55Z.
Refs #258 (cause 2)
What and why
A translated shader that takes a buffer view from the resource heap itself looks up the entry's stride in the translator's own table before it reads the entry (root SRV
t255,emit::VIEW_STRIDES). Where the table holds 0 it reads the host's null buffer view instead. The native host bound no such table. So every draw and dispatch of such a shader was dropped at submission as "root parameter 255 was never set". It was counted only inNativeHost::unset_rootsand warned about only withVICTORY_TRACE_TARGETS=1. The title's culling shaders are among them.This PR adds, on the native host only:
NativeHost::view_strides: one table per resource heap, with one dword for every index a shader can compute (HEAP_VIEWS). It holds the buffer view's element size at the title's entries and 0 elsewhere. The dword comes fromdescriptors::stride_word, which gives whatview_strideandview_kindgive the D3D12 host. The table is made the first time such a shader is bound with the heap, from the title's records, andmirror()keeps it current.HEAP_VIEWSentries), with the null raw buffer views atNULL_BUFFER_VIEWand the entry below it. This part is needed: the shader clamps its index to that range and reads the null view at that index, so both must be entries the heap has. The D3D12 host's heaps are sized the same way.dropped_unset_root, withdropped_unmappedanddropped_failed. The first drop for each root parameter warns without a switch. This is what would have shown the problem at once.This branch does not depend on the span buffers PR. It is cut from main and passes on its own. The two touch the same lines of
NativeHost::mirror, so whichever lands second needs a small rebase there (one conflict, both sides kept). I built and tested the two merged together, with the store order PR as well: same results as each alone.Cost
Not measured: how much of either becomes resident. Only the title's own entries, the view pairs and the two null views are ever written, but a heap's buffer is made resident for the passes that use the heap, so the whole 48 MiB may count. Please weigh this for 16 GB machines. If it is too much, the alternative is a change in the translator's clamp and null index, which this PR does not touch.
Limits (marked in the code)
dropped_failed.Tests
heap_tests::a_compute_shader_stores_through_a_buffer_view_it_takes_from_the_heap(new, on Metal): a hand-assembled compute program loads a buffer view from the heap by index and stores through it. While the entry is empty the table holds 0 and nothing is stored. After the title writes a view there and it is mirrored, the stores land. The view is inside one pool run, so the test does not need span buffers. Without the table binding the dispatch is dropped and the test fails.descriptors::tests::stride_words_of_buffer_views(new): the dword for structured, raw, constant and typed views, the integer kinds, and 0 for what is not a buffer view.How it was verified
Apple M4 Pro, macOS 27.0.1, Xcode 27.0, Metal Shader Converter 4.0 beta 3. Tests run as x86_64 under Rosetta (
--target x86_64-apple-darwin, release):list::tests::unordered_access_clears_have_the_same_slots_in_both_layouts, which fails the same way on main.--target, as AGENTS.md asks for victory-gpu): victory-gpu 318 passed, none failed (316 on main).cargo build --release --target x86_64-apple-darwin -p victorybuilds.cargo xtask policypasses.tools/macos/run-summary.sh --self-testpasses. clippy on the macOS target for the four crates reports the same findings as main.cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features) passes forx86_64-pc-windows-msvc, checked from this Mac with blake3's C build skipped (CARGO_FEATURE_PURE=1): a check, not a link. The gnullvm cross tools are not installed here, so the documented gnullvm command itself was not run.Not verified
🤖 Generated with Claude Code
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:08:09Z.
Thank you. This is the second input the cullers lacked, and the new warning without a switch is what would have shown it at once.
Before it can merge:
Sheffy007 has opened #278 in the same files for a second cause of the lost formatted stores in #255. Whichever of you lands second will need a rebase; please look at each other's changes.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Ketan-Kapse on 2026-11-27T08:34:06Z.
Thanks for the review. Taking the points in order; the ones that need a measurement or new code will follow as commits here.
I will look at #278 before pushing so the two do not collide in
mirror.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:32:19Z.
Thank you for the answers. Nothing is pushed yet, so I am waiting for: the count of resource heaps and the footprint before and after, the test for the record the title zeroes with plain stores, marcus-4's test from #255, and the corrected text about the held version (#267 replaces it).
Your workflow has not run; it needs my approval. The branch is behind main, and #267 and #278 also change
mirror, so please look at both before you push. I cannot say what #264 did alone in my run in #258: it was one of five.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:35:39Z.
#267 is merged now, and this branch conflicts with main in
mirror. Please rebase on main when you push the four items. Your workflow has been approved and has run.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T12:22:42Z.
Merged, together with #278. I resolved the one conflict with main myself (the draw-count log line in
native/glue.rs; your counters are kept and main's heap report follows them). My game run of main with this, #253 and #278 gives a G-buffer that is 60 to 87% covered. Two follow-ups I am testing before they go in: a record the title zeroes with plain stores kept its old stride until it was mirrored again (I have a fix and a test), and each resource heap now costs about 56 MiB at its first dispatch, which cannot be made smaller without changing the shader's index clamp. Thank you @Ketan-Kapse.