Fix BVH sorted box hits: absent child can sort before a real hit (#173) #414

Closed
github-bot wants to merge 1 commit from gh-pr/414/head into gh-pr/414/base
Owner

@⁠AndradeTK on GitHub · 2026-11-25 00:30 UTC · original
AndradeTK:fix/bvh-sorted-absent-child → main · +22 −2 · 2 files · 1 commits · closed without merging

In bvh::boxes and the matching DXIL emitter (emit/intersect.rs), an absent child (NONE) could get a finite sort key when its stored bounds pass the slab test, letting it sort ahead of a valid hit. Give absent children the same infinite distance as misses: in the CPU reference guard the hit on children[n] != NONE, and in the emitter AND an unsigned child < NONE (i.e. present) into the hit mask.

Adds a regression test (sorted_boxes_put_absent_children_after_real_hits) covering the issue's reproducer: ray +Z extent 10, slot 0 absent with intersecting bounds, slot 1 present; sorted result is [8, NONE, NONE, NONE] and unsorted keeps slot order. Synthetic cases only; no game data.

Verified: victory-shader lib tests pass, clippy clean.

**@⁠AndradeTK** on GitHub · 2026-11-25 00:30 UTC · [original](https://github.com/fxceless/victory-fork/pull/414) `AndradeTK:fix/bvh-sorted-absent-child` → `main` · +22 −2 · 2 files · 1 commits · closed without merging In bvh::boxes and the matching DXIL emitter (emit/intersect.rs), an absent child (NONE) could get a finite sort key when its stored bounds pass the slab test, letting it sort ahead of a valid hit. Give absent children the same infinite distance as misses: in the CPU reference guard the hit on children[n] != NONE, and in the emitter AND an unsigned child < NONE (i.e. present) into the hit mask. Adds a regression test (sorted_boxes_put_absent_children_after_real_hits) covering the issue's reproducer: ray +Z extent 10, slot 0 absent with intersecting bounds, slot 1 present; sorted result is [8, NONE, NONE, NONE] and unsorted keeps slot order. Synthetic cases only; no game data. Verified: victory-shader lib tests pass, clippy clean.
In bvh::boxes and the matching DXIL emitter (emit/intersect.rs), an
absent child (NONE) could get a finite sort key when its stored bounds
pass the slab test, letting it sort ahead of a valid hit. Give absent
children the same infinite distance as misses: in the CPU reference guard
the hit on children[n] != NONE, and in the emitter AND an unsigned
child < NONE (i.e. present) into the hit mask.

Adds a regression test (sorted_boxes_put_absent_children_after_real_hits)
covering the issue's reproducer: ray +Z extent 10, slot 0 absent with
intersecting bounds, slot 1 present; sorted result is [8, NONE, NONE,
NONE] and unsorted keeps slot order. Synthetic cases only; no game data.

Verified: victory-shader lib tests pass, clippy clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:42:57 +00:00
github-bot closed this pull request 2026-11-26 03:42:57 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:41 UTC · original

Is this a duplicate of #213?

Both fix absent BVH children sorting ahead of valid hits in the CPU reference and DXIL emitter.

This is an automated message. If you believe it is incorrect, please reply with the relevant technical differences.

**@⁠kaayzouee** on GitHub · 2026-11-25 01:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/414#issuecomment-7149841953) Is this a duplicate of #213? Both fix absent BVH children sorting ahead of valid hits in the CPU reference and DXIL emitter. This is an automated message. If you believe it is incorrect, please reply with the relevant technical differences.
Author
Owner

@⁠AndradeTK on GitHub · 2026-11-25 01:51 UTC · original

Closing as duplicate of #213 ("Ray tracing: a child that is not there is a miss, whatever its box" by Pablo-Barros), which covers the same fix in bvh.rs and emit/intersect.rs with a broader change set (+docs). No need for two PRs addressing the same issue. Thanks for the catch, @⁠kaayzouee.

**@⁠AndradeTK** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/fxceless/victory-fork/pull/414#issuecomment-7150032750) Closing as duplicate of #213 ("Ray tracing: a child that is not there is a miss, whatever its box" by Pablo-Barros), which covers the same fix in bvh.rs and emit/intersect.rs with a broader change set (+docs). No need for two PRs addressing the same issue. Thanks for the catch, @⁠kaayzouee.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.