Ray tracing: a child that is not there is a miss, whatever its box #213
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!213
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-213"
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?
@Pablo-Barros on GitHub · 2026-11-24 22:35 UTC · original
Pablo-Barros:bvh/missing-child-is-a-miss→main· +67 −12 · 4 files · 1 commits · openWhat and why
The node test took a child whose pointer is
0xffff_fffffor a hit whenever the ray entered its box, in the CPU reference (bvh.rs) and in the emitted DXIL (emit/intersect.rs). Its result dword was0xffff_ffffeither way, but sorted it came with a finite distance, so it could stand before a child that is there. A traversal that stops at the first "none" would then miss that child.Both now test the pointer too: a child that is not there is a miss, as the reference's description of the result already said. Unsorted output does not change.
What it moves in the emitted code: two integer instructions per child (a compare and an and). The parity tests' program (the 64-bit form) goes from 519 to 527 instructions by
dxc -dumpbin; apart from block numbering, the rest of it is the same.Validation
Machine: RTX 3070 8 GB (32-lane waves), driver 610.88, Windows 11 Pro 26300 with the in-box D3D12 runtime, Rust 1.98.1. Based on
2119b0e.[ffffffff, ffffffff, ffffffff, 8].got [ffffffff, ffffffff, ffffffff, 8],want [8, ffffffff, ffffffff, ffffffff]). With both corrected, they pass on the hardware adapter and on WARP (noskippedline).cargo test -p victory-shader --lib -- bvh:: intersect_tests: 22 passed, 0 failed.cargo clippy --workspace --all-targets --locked -- -D warnings, and again with--all-features: no warnings.cargo test --workspace --locked: 497 passed, 0 failed, 7 ignored (main's 496 and the new test).cargo xtask policy: 169 files ok.Not known
docs/fork-ray-tracing.mdlists it with the other assumptions.Reproducer and first patch: @Bennet0k in #173. AI-assisted patch (the emitter change, the tests and the validation).
Fixes #173
@pr0vId3nce on GitHub · 2026-11-25 13:56 UTC · original
Hardware result for this fixture: an RDNA2 GPU returns
[8, ffffffff, ffffffff, ffffffff]I ran this PR's
MISSING_FIRSTnode and ray (children[ffffffff, 8, ffffffff, ffffffff], the boxes of the test, ray from the origin along +z, extent 10) through the real instruction:image_bvh64_intersect_rayandimage_bvh_intersect_ray, run natively from raw words on a Ryzen 9 7900X's iGPU (gfx1036, RDNA2 with the ray accelerators, driver 32.0.21042.62) through the AMD driver's own amd_comgr/HIP DLLs.00000008 ffffffff ffffffff ffffffffffffffff 00000008 ffffffff ffffffff4e17478b9:bvh.rs, and its DXIL on an RTX 4080, the AMD iGPU and WARPffffffff ffffffff ffffffff 00000008ffffffff 00000008 ffffffff ffffffff4e17478b9with this PR's condition inbvh.rs00000008 ffffffff ffffffff ffffffffffffffff 00000008 ffffffff ffffffffA second node, children
[8, ffffffff, 18, 1ffffffc]with boxes entered at 10, 5, 20 and 15 along +x: the GPU returns00000008 1ffffffc 00000018 ffffffff,4e17478b9returnsffffffff 00000008 1ffffffc 00000018. Onlyffffffffis special: with children8, fffffffe, 7fffffff, fffffff8the GPU returns all four, in entry order.So the expected value here (and in #173) is what the hardware does.
Scope: desktop RDNA2, not the console. Synthetic nodes, no game data. I did not build this branch; the third row is its
bvh.rscondition applied to4e17478b9on the CPU.AI-assisted (Claude Code); the runs are from my machine.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.