BVH sorted box hits: absent child can sort before a valid hit (reproducer and patch) #173
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#173
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Bennet0k on GitHub · 2026-11-24 22:09 UTC · original
In the CPU BVH reference (
bvh::boxes) and the matching DXIL emitter (emit/intersect.rs), an absent child (0xffffffff) can get a finite sort key when its stored bounds pass the slab test. The ID is still NONE, but it can sort ahead of a valid hit. This is a candidate correctness fix for review; I don't know whether the console guarantees disabled bounds for every absent child.Small reproducer. Use a ray from (0,0,0) along +Z with extent 10. Slot 0 has ID NONE and bounds (-1,-1,1)..(1,1,2). Slot 1 has ID 8 and bounds (-1,-1,3)..(1,1,4). Leave the other slots absent. With sorting enabled the current logic can put NONE before 8. The patch gives absent children the same infinite distance as misses, so the result is [8,NONE,NONE,NONE]. The unsorted path keeps the original slot order. In the emitter the unsigned comparison
child < 0xffffffffis equivalent tochild != NONE.Verification and limits. In a standalone model of the sorting network, all 24 permutations of four distinct finite distances were crossed with all 16 presence masks. The old logic disagreed with the valid-hits-first expectation in 264/384 cases; the patched model agreed in all 384. These are synthetic cases, not measured game frequencies.
git apply --checkpassed on the source files used to prepare this patch. The included Rust test has not been executed and the emitted DXIL has not been run on hardware. This was found by AI-assisted source review.What would establish relevance. A GPU parity test with the same fixture, or a capture counting absent slots with intersecting bounds preceding real hits, would distinguish a live case from defensive handling. It matters to traversal if the consumer stops at the first NONE. I have no evidence this explains the builder fault in #16, black lighting, or any frame-rate loss.
Complete patch (CPU reference, DXIL emitter, and regression test):
github-bot referenced this issue2026-11-26 03:38:30 +00:00
@avt0m4t48 on GitHub · 2026-11-24 22:58 UTC · original
Independent CPU differential on exact refs. I used source-built packed 16-bit and 32-bit nodes, an intersecting
NONEslot, valid IDs0and0xffff_fffe, strict extent, and equal-distance hits with a nearer hit ahead of them.2119b0efailed the two sorted-hit checks. The intersectingNONEcould precede valid hits.1625a12), closed #217 (f446030), and #230 (6354761) passed both checks and the all-sentinel, all-zero and unsorted controls. All three emitter diffs add the same unsigned sentinel predicate in the common box path.This confirms the overlap. #213 also includes emitted-DXIL parity tests for both node widths and both addressing forms. I ran the CPU differential locally. Its Windows D3D12 results are in the independent reports on #213.
@FordMustang0288 on GitHub · 2026-11-25 19:36 UTC · original
Independent GPU parity result for the fixture this issue asks for, on different silicon and driver from #213 — offered as a second datapoint, not a duplicate fix.
Result: the four parity tests pass with the emitted DXIL running on hardware, over both node widths, both addressing forms (resource table and title memory), and both sort modes:
dxil.dllNVIDIA GeForce RTX 3080 10GB, vendor0x10de, device0x2206,software=falseDXGI: Hiding actual GPUmasking appears in the log, so the reported adapter cannot be a substitutionCoverage in the regression itself goes slightly past the original patch: both packed box widths, absent children with finite intersecting bounds (not just switched-off bounds), the boundary child ids
0and0xffff_fffe, and all-absent nodes, in sorted and unsorted modes.Two notes that may be useful for review:
DXVK's WARP adapter is not real software coverage here.
EnumWarpAdapteris unsupported on this setup and returns the first hardware adapter, soadapter=warpcompletion lines carrysoftware=falseand mean the same 3080 ran again. I assert on the LUID and the software flag rather than on the label — worth knowing if other reports cite WARP results under Wine.The production path never validates emitted DXIL.
crates/victory-gpu/src/pipeline/host.rsbuildsD3D12_COMPUTE_PIPELINE_STATE_DESCand callsCreateComputePipelineStatedirectly; the only reference to the validator in that file is inside#[cfg(test)]. So a bad module surfaces asE_INVALIDARGat pipeline creation with no shader-level diagnosis — the log says "shader translated" because the translator finished, not because the bytes were accepted. I hit exactly that with four compute programs in the game world and only worked out later that validation had never run. A switch to validate in production, or just counting validation failures, would turn that class into a named hash.Implementation here overlaps #213, so I am deferring to it and have not opened a competing PR.