Shaders: lower buffer descriptors built around computed and root-constant addresses #2154
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2156"
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 Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T06:27:04Z.
Problem
resource::track(Tracer::classify) already classifies 4-dwordV#buffer descriptors assembled in shader code around root-constant 64-bit pointer pairs or computed addresses asSource::Built { address: Address { param: MEMORY, .. }, bits, words }, whereasLower::handle(crates/victory-shader/src/emit/lower.rs) still rejects them withErr("a buffer descriptor built around a computed address")(and indexed MUBUF operations fall through toErr("a structured buffer of unknown stride")).Changes
Source::BuiltoverMEMORY(including uniformPhi/Selectjoins with matching(bits, words)) inLower::new'sroot_memoryscan.0..=1of the descriptor SGPR operand (s[code]ands[code + 1] & 0xFFFF), fold structured element strides onidxen, and enforce GFX10OOB_SELECT(0..=3) andNUM_RECORDSlimits viaraw_view_bounded— routing out-of-range lanes to the null viewpair (0reads, dropped writes) without setting false unmapped-page misses or dirty bits inmemory_dirty.s_buffer_load_dword*, raw/structuredbuffer_load_*andbuffer_store_*, sub-dword byte/short loads and stores (preserving sub-dword base alignment),buffer_atomic_*, andtbuffer_load_format_*/buffer_load_format_*(refusing swizzled orADD_TID_ENABLEdescriptors).Verification
emit::memory_tests::buffer_descriptors_built_around_root_constant_addresses_read_and_write_title_memoryandbuilt_computed_address_descriptors_with_swizzling_or_tid_are_refusedvalidated withdxil.dlland executed across RTX 5090, AMD Radeon Graphics, and D3D12 WARP.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T06:46:00Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib emit::memory_tests::— 5 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean lowering of buffer descriptors built around computed and root-constant addresses, verified end-to-end on hardware and WARP. Looks great.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T06:49:57Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Buffer descriptors built around computed and root... — descriptor-building coverage for computed/root bases.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T07:19:29Z.
One question on the raw case (
OOB_SELECT3, or 0 with stride 0).built_boundschecks the whole access,off <= NUM_RECORDS - access_bytes, so abuffer_load_dwordx2/x4ors_buffer_load_dwordx*that straddles NUM_RECORDS reads 0 in every dword. XCL checks each dword separately and pins it in a GPU test:gpu_grouped_loads_bounds_and_inactive_lanes(crates/xcl/src/gpu/recomp/tests.rs). There, ans_buffer_load_dwordx2across NUM_RECORDS gives(in-range dword, 0), and abuffer_load_dwordx2(offen) keeps the dwords withoff + 4 <= NUM_RECORDS. If that is the RDNA2 behaviour, a straddling load here loses its in-range dwords, and a straddling store drops them.I haven't found a hardware measurement of this case in XCL or AnyPS5, only XCL's test. If you have an RDNA2 reading for a straddling raw load, it would settle which one is right. The
OOB_SELECT0/1/2 branches match the rules I know.AI-assisted (Claude Code); source read only.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T08:11:31Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
1bb33665ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T11:26:14Z.
Automated triage for the maintainers.
Needs work. In
crates/victory-shader/src/emit/lower.rs,Lower::handle's refusal "a buffer descriptor built around a computed address" is replaced by lowering through the title-memory page table. The newbuilt_memory_descandbuilt_memory_baseread the base from the descriptor SGPRs, andraw_view_boundedappliesNUM_RECORDS/OOB_SELECTbounds for SMEM, raw/structured MUBUF, sub-dword, atomic and format accesses. The tests run on hardware and WARP, and the plumbing reads coherently. CI: passing (check).What it needs:
mainand 23,918 with this PR, and no program changed its failure reason. So nothing in the title currently reaches this refusal, or it stops earlier for another reason. Please show a program that this PR makes translate, or the refusal from a run. Without one, this is about 300 lines of new emulation logic for a case the title does not show.OOB_SELECThandling is emulation behaviour and cites no source. One concrete open point, raised by @upipibi and still unanswered: for raw descriptors (OOB_SELECT3, or 0 with stride 0), the MUBUF paths gate the whole access withoff <= NUM_RECORDS - access_bytes. Abuffer_load_dwordx2/x4that straddlesNUM_RECORDStherefore reads 0 in every dword, and a straddling store drops all of them. Your owns_buffer_loadpath checks each dword separately, which also matches the reference he cites. Please make the two consistent and cite the RDNA2 ISA or a hardware reading for the rule you choose. The same applies toOOB_SELECT0 with a stride, where onlyoff < strideis checked, notoff + bytes <= stride.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T12:05:09Z.
Thanks for the triage review and @sinan-cmyk / @upipibi for the offline check and per-dword
OOB_SELECTnote.Re-checking #614 and the world-run failure breakdowns (#815, #1481) confirms that the root-constant pointer shaders in #614 use
global_load/global_store/s_load_dword*directly on the 64-bit address (already served viaMEMORYonmain), rather than constructing 4-dwordV#buffer descriptors around computed addresses — so no title program currently reaches"a buffer descriptor built around a computed address".Closing this PR to avoid adding ~300 lines of unexercised emulation logic; if a future shader reaches this refusal, we can revisit with per-dword
OOB_SELECTbounds.Pull request closed