Ray tracing: a child that is not there is a miss, whatever its box #213

Open
Pablo-Barros wants to merge 1 commit from upstream-pr/213 into main
Pablo-Barros commented 2026-11-24 22:35:46 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Pablo-Barros on 2026-11-24T22:35:46Z.


What and why

The node test took a child whose pointer is 0xffff_ffff for 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 was 0xffff_ffff either 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.

  • The reference's new test is the reproducer of #173: a child that is not there whose box is entered first, one child behind it, and two that are not there with their boxes at the ray's origin, in both node widths. Without the change it fails: sorted, the reference returns [ffffffff, ffffffff, ffffffff, 8].
  • The card tests run the same node and ray. With the reference corrected and the emitter not, the four parity tests fail on the card (got [ffffffff, ffffffff, ffffffff, 8], want [8, ffffffff, ffffffff, ffffffff]). With both corrected, they pass on the hardware adapter and on WARP (no skipped line).
  • 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

  • What the console returns for such a child, and whether the title's builder ever leaves a box under one. The cases of #173 are synthetic, and nothing here was run with the title: ray tracing is off by default. docs/fork-ray-tracing.md lists 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

<!-- greyfinch-sync:fxceless/victory-fork:issue:5481478675 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/213). Originally posted by [Pablo-Barros](https://github.com/Pablo-Barros) on 2026-11-24T22:35:46Z. --- ## What and why The node test took a child whose pointer is `0xffff_ffff` for 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 was `0xffff_ffff` either 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`. - The reference's new test is the reproducer of #173: a child that is not there whose box is entered first, one child behind it, and two that are not there with their boxes at the ray's origin, in both node widths. Without the change it fails: sorted, the reference returns `[ffffffff, ffffffff, ffffffff, 8]`. - The card tests run the same node and ray. With the reference corrected and the emitter not, the four parity tests fail on the card (`got [ffffffff, ffffffff, ffffffff, 8]`, `want [8, ffffffff, ffffffff, ffffffff]`). With both corrected, they pass on the hardware adapter and on WARP (no `skipped` line). - `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 - What the console returns for such a child, and whether the title's builder ever leaves a box under one. The cases of #173 are synthetic, and nothing here was run with the title: ray tracing is off by default. `docs/fork-ray-tracing.md` lists 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
Flyander commented 2026-11-24 22:49:53 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Flyander on 2026-11-24T22:49:53Z.

Review: COMMENTED


Cross-validation on Windows D3D12 with an RTX 5070 Ti: cargo test --locked -p victory-shader --lib passes (211 passed, 2 ignored). The four emitted-DXIL intersection parity tests for both node widths and both title-buffer addressing forms pass in this run, along with the new missing-child reference test. This adds NVIDIA coverage to the RTX 3070 and WARP results in the PR.

<!-- greyfinch-sync:fxceless/victory-fork:review:6048628426 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/213#pullrequestreview-6048628426). Originally posted by [Flyander](https://github.com/Flyander) on 2026-11-24T22:49:53Z. **Review:** COMMENTED --- Cross-validation on Windows D3D12 with an RTX 5070 Ti: `cargo test --locked -p victory-shader --lib` passes (211 passed, 2 ignored). The four emitted-DXIL intersection parity tests for both node widths and both title-buffer addressing forms pass in this run, along with the new missing-child reference test. This adds NVIDIA coverage to the RTX 3070 and WARP results in the PR.
pr0vId3nce commented 2026-11-25 14:10:52 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pr0vId3nce on 2026-11-25T13:56:17Z.


Hardware result for this fixture: an RDNA2 GPU returns [8, ffffffff, ffffffff, ffffffff]

I ran this PR's MISSING_FIRST node 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_ray and image_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.

sorted not sorted
RDNA2 GPU (32-bit and 16-bit node, both instruction forms) 00000008 ffffffff ffffffff ffffffff ffffffff 00000008 ffffffff ffffffff
4e17478b9: bvh.rs, and its DXIL on an RTX 4080, the AMD iGPU and WARP ffffffff ffffffff ffffffff 00000008 ffffffff 00000008 ffffffff ffffffff
4e17478b9 with this PR's condition in bvh.rs 00000008 ffffffff ffffffff ffffffff ffffffff 00000008 ffffffff ffffffff

A second node, children [8, ffffffff, 18, 1ffffffc] with boxes entered at 10, 5, 20 and 15 along +x: the GPU returns 00000008 1ffffffc 00000018 ffffffff, 4e17478b9 returns ffffffff 00000008 1ffffffc 00000018. Only ffffffff is special: with children 8, fffffffe, 7fffffff, fffffff8 the 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.rs condition applied to 4e17478b9 on the CPU.

AI-assisted (Claude Code); the runs are from my machine.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7164508496 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/213#issuecomment-7164508496). Originally posted by [pr0vId3nce](https://github.com/pr0vId3nce) on 2026-11-25T13:56:17Z. --- **Hardware result for this fixture: an RDNA2 GPU returns `[8, ffffffff, ffffffff, ffffffff]`** I ran this PR's `MISSING_FIRST` node 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_ray` and `image_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. | | sorted | not sorted | |---|---|---| | RDNA2 GPU (32-bit and 16-bit node, both instruction forms) | `00000008 ffffffff ffffffff ffffffff` | `ffffffff 00000008 ffffffff ffffffff` | | `4e17478b9`: `bvh.rs`, and its DXIL on an RTX 4080, the AMD iGPU and WARP | `ffffffff ffffffff ffffffff 00000008` | `ffffffff 00000008 ffffffff ffffffff` | | `4e17478b9` with this PR's condition in `bvh.rs` | `00000008 ffffffff ffffffff ffffffff` | `ffffffff 00000008 ffffffff ffffffff` | A second node, children `[8, ffffffff, 18, 1ffffffc]` with boxes entered at 10, 5, 20 and 15 along +x: the GPU returns `00000008 1ffffffc 00000018 ffffffff`, `4e17478b9` returns `ffffffff 00000008 1ffffffc 00000018`. Only `ffffffff` is special: with children `8, fffffffe, 7fffffff, fffffff8` the 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.rs` condition applied to `4e17478b9` on the CPU. _AI-assisted (Claude Code); the runs are from my machine._
UncommonDLL commented 2026-11-27 03:55:06 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by UncommonDLL on 2026-11-27T03:55:06Z.


I tested this PR (1625a129) on top of main 67429060 with an RTX 5070 Ti, driver 32.0.16.2140. I used the same synthetic inputs and expected results for both runs.

With the original shader code, all four tests put the empty slots ahead of child 8: [NONE, NONE, NONE, 8]. With the fix, all four passed and put child 8 first: [8, NONE, NONE, NONE]. No tests were skipped, and the order stayed the same with sorting turned off.

cargo xtask policy reported the same two file size violations on clean main and with the PR applied.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7209373718 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/213#issuecomment-7209373718). Originally posted by [UncommonDLL](https://github.com/UncommonDLL) on 2026-11-27T03:55:06Z. --- I tested this PR (`1625a129`) on top of main `67429060` with an RTX 5070 Ti, driver `32.0.16.2140`. I used the same synthetic inputs and expected results for both runs. With the original shader code, all four tests put the empty slots ahead of child `8`: `[NONE, NONE, NONE, 8]`. With the fix, all four passed and put child `8` first: `[8, NONE, NONE, NONE]`. No tests were skipped, and the order stayed the same with sorting turned off. `cargo xtask policy` reported the same two file size violations on clean main and with the PR applied.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/213:upstream-pr/213'
git switch 'upstream-pr/213'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/213'
git switch 'upstream-pr/213'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/213'
git switch 'upstream-pr/213'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/213'
git switch 'main'
git merge --squash 'upstream-pr/213'
git switch 'main'
git merge --ff-only 'upstream-pr/213'
git switch 'main'
git merge 'upstream-pr/213'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
fxceless/victory-fork!213
No description provided.