Shaders: preserve 64-bit node offsets and descriptor alignment in built BVH paths (fixes #2368) #2402
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!2402
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2402/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?
@Xvania7 on GitHub · 2026-11-25 12:57 UTC · original
Xvania7:fix/issue-2368-bvh-node-address-decoding→main· +137 −29 · 2 files · 2 commits · closed without mergingFixes #2368.
Summary
Addresses the address-calculation inconsistency reported by @FunWithFlagsDev in #2368 between the root-derived (
Source::Built) and explicit-address BVH lowering paths.Previously,
crates/victory-shader/src/emit/lower/bvh.rscalculated node offsets inSource::Builtusing a 32-bit shift (Bin::Shl, lo, three), losing the upper bits of node pointers when offsets crossed 4 GiB, droppingnode_hi, and ignoring the descriptor's 256-byte quantization.Changes
crates/victory-shader/src/emit/lower/bvh.rs:Source::Builthas root memory address available (root_address(src).is_some()), route to the explicit descriptor decoder path instead of truncating via 32-bit arithmetic.wide64(self, lo, node_hi.unwrap_or(zero)) << 3), preserves the descriptor's 256-byte base quantization (wide64(d[0], d[1] & 0xFF) << 8), and preserves the existing title-memory bounds-checking pipeline.root_address(src).is_none()) and resource tracking unchanged.Verification
cargo test -p victory-shader emit::bvh_tests::boxes_passed (1/1).cargo test -p victory-shader emit::lower::testspassed (21/21).cargo clippy -p victory-shaderpassed with 0 warnings.cargo run -p xtask policyverified clean (182 files ok).@Xvania7 on GitHub · 2026-11-25 13:21 UTC · original
Thanks @catminou4 for the macOS validation and approval!
To complement your ARM64 test pass, we verified this on native Windows 10 x64 + NVIDIA GeForce RTX 5060:
cargo test -p victory-shader --locked— all targeted unit tests pass cleanly (emit::bvh_tests,emit::lower::tests,emit::stride_tests).cargo clippy --workspace --all-targets --locked -- -D warnings— zero warnings.cargo run -p xtask --target-dir ... -- policy— all asset and encoding checks pass.Ready for upstream merge into
main.@andrewpozdnakov7-jpg on GitHub · 2026-11-25 13:33 UTC · original
I ran the same translated compute test on Windows/WARP with three sparse synthetic guest pages. Each node has one hittable child, so the readback identifies the address used by the shader.
940d32f5e873ab7216eb7Test-only commit 1f8ce62 is directly on
5e873ab7feif this narrower PR is selected. The base was940d32f69b. All 15 BVH tests passed here. The full shader suite moved from 244 passed / 4 failed / 3 ignored to 245 passed / 3 failed / 3 ignored. The three shared failures are gather, lane permute and edge-flagged triangles under this WARP runtime. Strict shader Clippy and staged asset policy passed.#2040 covers these address cases in its own fixture and also has tests for masked lanes and a non-address buffer fallback. Its 18 BVH tests passed here with the independent test included.
Please keep the Git author if you cherry-pick the test. If you fold the fixture into another commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
@Xvania7 on GitHub · 2026-11-25 13:43 UTC · original
@andrewpozdnakov7-jpg Thanks for running the Windows/WARP compute tests across the sparse guest page scenarios and verifying all 15 BVH tests pass cleanly on
5e873ab.The readback breakdown on low byte 0x80 alignment, 4 GiB offsets, and high word preservation proves the 64-bit root decoding works as expected without clipping. Happy to fold your synthetic test fixture commit
1f8ce62into the branch with attribution.@Xvania7 on GitHub · 2026-11-25 14:19 UTC · original
Thanks @DenRakEiw for testing across NVIDIA GeForce RTX 5090 and WARP, and verifying all 15/15 BVH unit and GPU intersection tests pass cleanly! Ready for upstream merge.
@Marvisak on GitHub · 2026-11-25 15:30 UTC · original
Automated triage for the maintainers.
Proposed close (duplicate). Thanks for picking up #2368; the change looks sound: in
Lower::bvh(crates/victory-shader/src/emit/lower/bvh.rs), aSource::Builtdescriptor with a root address now goes through the explicit descriptor decode, which keepsnode_hi, shifts in 64 bits and keeps the 256-byte base, and the tests check the high-offset cases. However, #2040 (opened earlier, a merge candidate) fixes the same root-built BVH address truncation and covers more: 64-bit base and offset arithmetic,node_hi, refusing 64-bit pointers on built buffer views with no address, and the WARP zeroed-load problem in the guarded node loads; a comment here reports #2040 passing the same address cases. Two fixes to the same lines would conflict. If something here is missing from #2040 (for example the test commit 1f8ce62), please offer it there.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
Generated by Claude Code
@Xvania7 on GitHub · 2026-11-25 15:46 UTC · original
Concur with triage: #2040 is the prior and more comprehensive fix for root-built BVH descriptors, covering 64-bit base and offset arithmetic,
node_hipreservation, and the WARP zeroed-load behavior across its test suite. Closing in favor of #2040.@Xvania7 on GitHub · 2026-11-25 15:46 UTC · original
Concur with triage: #2040 is the prior and more comprehensive fix for root-built BVH descriptors, covering 64-bit base and offset arithmetic,
node_hipreservation, and the WARP zeroed-load behavior across its test suite. Closing in favor of #2040.Pull request closed