Shaders: 64-bit built BVH pointers and unsplit node loads #2038
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2040"
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 mgunes1311-lab on 2026-11-25T03:55:32Z.
Fix two bugs in
Lower::bvh(crates/victory-shader/src/emit/lower/bvh.rs):Root-built BVH descriptors truncated pointer and base arithmetic to 32 bits and dropped
node_hi:When
resource::trackresolved a BVH descriptor built by shifting a root SRV/UAV address (Source::Built),Lower::bvhshifted(node & !7) << 3and addedbuilt_offsetin 32-biti32before widening to 64 bits, ignorednode_hionimage_bvh64_intersect_ray, did not mask the shifted base to bits8..47(0x0000_FFFF_FFFF_FF00), and did not reject 64-bit node pointers on non-address built buffer views.(root + zext(k) + zext(dynamic)) & 0x0000_FFFF_FFFF_FF00in 64-bit integers and share the 64-bit(lo | hi << 32) << 3node address calculation with the unbuilt descriptor path.image_bvh64_intersect_raywhenSource::Builtresolves to a buffer view without a root GPU address.Divergent
begin_guardedblocks aroundLower::memoryzeroed BVH node loads on WARP:Unlike
global_loadandraw_view,Lower::bvhwrappedbvh_lanesinbegin_guarded(guard)and thebox32tail load inbegin_guarded(Some(is32)). BecauseLower::memoryemitscreateHandleFromHeap(..., nonUniform = true)followed bybegin_guarded(marks)beforerawBufferLoad, enteringLower::memoryinside a lane-divergent branch caused WARP to read zeros for active lanes whenever lane 0 of the wave was inactive (breakingbox32children 2-3 inbvh_testson WARP and all node types under maskedEXEC).guardandguard & is32asactivetoLower::memoryso inactive or non-box32lanes never mark stray page misses.box32tail load's byte offset withselect(is32, 64, 0)so 64-byte nodes re-read byte 0 of their own page or buffer rather than probing past byte 64.Verification
cargo test -p victory-shader --lib bvh_tests(all 17 tests pass on both hardware D3D12 and WARP)cargo clippy --workspace --all-targets --all-features -- -D warningscargo doc --workspace --no-deps(with-D warnings)cargo run -p xtask -- policy --stagedandcargo test -p xtaskImported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:01:10Z.
Triage verdict — Keep, ready on the reviewed BVH cases (
7216eb7)Evidence
Checks and limits
Next step
This verification was AI-assisted.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T04:06:54Z.
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::bvh_tests::— 17 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1(includingroot_srv_bvh_handles_high_pointer_bits_and_unaligned_bases,masked_lanes_and_page_end_nodes_leave_no_stray_marks, andsixty_four_bit_bvh_pointer_in_non_address_built_view_is_refused)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean 64-bit built BVH pointer handling and unsplit node loads with comprehensive GPU+WARP verification. Looks great.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:17:01Z.
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. 64-bit built BVH pointers and unsplit node loads — BVH traversal with 64-bit pointers; relates to #1794's BVH a16/unsorted-boxes work.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T04:30:32Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
7216eb7.victory-shader: 247 passed, 3 failed, 3 ignored. The 3 newbvh_testspass (root_srv_bvh_handles_high_pointer_bits_and_unaligned_bases,masked_lanes_and_page_end_nodes_leave_no_stray_marks,sixty_four_bit_bvh_pointer_in_non_address_built_view_is_refused). The 3 failures are #1744's NVIDIA failures onmain. Same asmainon this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:18:39Z.
Automated triage for the maintainers.
Merge candidate.
This fixes two things in
crates/victory-shader/src/emit/lower/bvh.rsLower::bvh. First, a BVH descriptor built from a root address now gets its node address in 64-bit arithmetic and honoursnode_hi, through the same(lo | hi << 32) << 3path the unbuilt descriptor already uses. The base is masked to bits 8..47, the same representationmaindecodes for real descriptors (40-bit base<< 8). A 64-bit pointer into a buffer view is now refused instead of silently truncated. Second, the node loads inbvh_lanes/node_dwords/raw_loadare no longer split into divergent guarded blocks; inactive lanes are instead masked throughLower::memory's existingactiveargument, and non-box32 lanes re-read their own first 64 bytes. I checked that this matches howLower::memoryusesactive(page-miss marks only). Three newbvh_testscover both fixes, and two independent runs in the thread report them passing on hardware and WARP. #1794 touches the same lowering for other cases and will need a rebase after this.Recommending a look, not approving.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:38:01Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
7216eb7fontomain940d32f(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 bvtterbroot on 2026-11-25T18:40:11Z.
AMD check at
7216eb7(base940d32f), on an RDNA3 and an RDNA2 GPU:cargo test -p victory-shader -p victory-gpu --locked: 393 passed, 0 failed, 5 ignored, on both GPUs. That includes its 3 new tests (masked_lanes_and_page_end_nodes_leave_no_stray_marks,root_srv_bvh_handles_high_pointer_bits_and_unaligned_bases,sixty_four_bit_bvh_pointer_in_non_address_built_view_is_refused).bindless::tests::heap_views_follow_writes_through_another_mapping(dword 0 read 0, expected 1064). That is the flake of #2252 (fixed by #2262), which this PR does not touch. The other three runs on that card passed.Synthetic tests only, no game files. Tested with AI assistance (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:05:00Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing in favour of #2501 for the one fix both make (the
Source::Builtroot-address branch), because the second part rewrites code every title site runs for a defect that does not reproduce:masked_lanes_and_page_end_nodes_leave_no_stray_markspasses withmain'sbvh.rson an RX 6700 XT and on WARP, as domain's existing BVH tests. With the change, inactive and non-box lanes would do page-table lookups and loads they do not do today.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed