Fix BVH sorted box hits: absent child can sort before a real hit (#173) #414
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/414"
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?
Imported from fxceless/victory-fork. Originally posted by AndradeTK on 2026-11-25T00:30:09Z.
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.
Imported from fxceless/victory-fork. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T00:31:31Z.
Review: COMMENTED
🟢 Approval recommended
No active review issues are reported for the BVH hit-sorting change.
No open issues 🎉
What changed in this PR
Fixes BVH hit sorting so absent children cannot sort ahead of valid hits, keeping the CPU reference and DXIL emitter consistent.
Changes:
crates/victory-shader/src/emit/intersect.rscrates/victory-shader/src/bvh.rsReview effort: Balanced
Imported from fxceless/victory-fork. Originally posted by kaayzouee on 2026-11-25T01:41:25Z.
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.
Imported from fxceless/victory-fork. Originally posted by AndradeTK on 2026-11-25T01:51:11Z.
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