Shaders: 64-bit built BVH pointers and unsplit node loads #2040
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2040
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2040/head"
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?
@mgunes1311-lab on GitHub · 2026-11-25 03:55 UTC · original
mgunes1311-lab:fix/bvh-built-pointer-64→main· +514 −52 · 2 files · 2 commits · closed without mergingFix 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 xtask@jeremygold02 on GitHub · 2026-11-25 04:01 UTC · original
Triage verdict — Keep, ready on the reviewed BVH cases (
7216eb7)Evidence
Checks and limits
Next step
This verification was AI-assisted.
@upipibi on GitHub · 2026-11-25 04:30 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 09:18 UTC · original
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
@sinan-cmyk on GitHub · 2026-11-25 09:38 UTC · original
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).
@bvtterbroot on GitHub · 2026-11-25 18:40 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 22:05 UTC · original
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