Recompiler: add BVH box-grow ULP, ray NaN/Inf inactivation, and triangle mode 0 #3288
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3288"
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 ivall/xcl. Originally posted by Foniass on 2026-11-29T05:37:25Z.
The emulated ray intersection (
image_bvh_intersect_ray/image_bvh64_intersect_ray, direct DXIL and HLSL) now follows RDNA2 in three places where it did not:desc::bvh_words) now set mode 1 explicitly, so what they produce does not change.What is in it
crates/xcl/src/gpu/dxil/lower_image.rs,crates/xcl/src/gpu/recomp/emit.rs: the three behaviours in both translatorscrates/xcl/src/gpu/desc.rs:bvh_wordsword 3 =1 << 24(mode 1, as before by default); its view test and the test title'sraytracing_surfaceexpectation updated to matchcrates/xcl/src/gpu/recomp/tests.rs:gpu_bvh_box_grow_nan_inactivation_and_tri_mode0Tested
cargo test --workspace --no-fail-fast -- --test-threads=4ona173b472: 2605 passed, 4 failed, 49 ignored. The 4 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3:E_OUTOFMEMORYfromCreateComputePipelineStateat seeds 70 / 545 / 1019 / 1507, the same as on main on this machine (they pass on another RTX 5070 Ti). SKIPPED GPU tests: 44 notices, almost allno wave64.Regression run
main:
this PR:
Not tested
AI use
f9fd4bfb(raylitebull), test updates froma46703b6.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T05:54:28Z.
Two finite ray/box cases distinguish this PR's world-coordinate growth from AMD GPURT's published software intersection reference. On
a173b472both XCL translators agreed with each other, but they differed from that reference in both directions at grow=4.AMD's RDNA2 ISA guide defines the unsigned box-growth field at bits 62:55 and the triangle return layout at bit 120 (tables 49–50). It does not specify the growth calculation in that table. AMD's software implementation projects the unexpanded slabs, then compares the near distance to the far distance multiplied by
1 + grow * 2^-24. The PR instead steps each world-space box minimum/maximum outward before projection. RDNA2 ISA guide · GPURT projected intervals · GPURT growth comparisonI dispatched an encoded
IMAGE_BVH_INTERSECT_RAYon RTX 5070 (616.92) through HLSL→DXIL and direct DXIL, with one valid Box32 child. All direction and inverse-direction components were +1, tmax=65536. Four cases repeated across 64 lanes and two fresh processes. Each table entry gives the grow=0 / grow=4 result.The translated pair has the same exactly representable projected interval (near 2, far 1.875). The third case crosses the reference's post-projection tolerance. A child hit here means traversal would visit the child; it does not establish a final triangle hit. These cases could distinguish the conventions on an actual RDNA2 GPU before settling the expected regression values. This was software BVH execution on NVIDIA, without hardware DXR RayQuery, a console trace, or retail image measurements.
AI-assisted fixture and verification.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T07:54:00Z.
merge-check
base:
fa204595head:
a173b472verdict: safe to merge
Merged cleanly onto
origin/main(fa204595) in a 5-PR batch (#3288,#3290,#3292,#3294,#3300) and verified on NVIDIA GeForce RTX 5070 Ti with DXC 1.9.2609.5:gpu_bvh_box_grow_nan_inactivation_and_tri_mode0,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing,gpu_bvh_intersect_ray,gpu_bvh_triangle_types_2_and_3,gpu_bvh_node_in_an_unmapped_window_returns_a_miss,gpu_built_bvh_nodes_match_the_cpu_node_test): all passed on RTX 5070 Ti.gpu::: 853 passed, 0 failed, 24 ignored (10.45 s, includingfuzz_validate_and_gpu_0..3).hle::d3d12x::(--test-threads=1, skipping 2 knownmain#3187uma_drivermixed-window tests): 1144 passed, 0 failed, 3 ignored (30.21 s).xcl --lib(--test-threads=1): 0 failed.-p xcl --test e2e(after rebuildingxcl-testtitle): 5 passed, 0 failed (including D3D12 debug layer + DRED).Build and test (Windows, no GPU)andPR description): green.Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:01:36Z.
merge-check claim
head:
a173b47293Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:20:40Z.
merge-check
base:
d8bd9a38head:
a173b47293merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2619 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at
d8bd9a38: 2618 passed, 0 failed, 49 ignored. The new GPU test ran on this card.review: no correctness finding in the code. Box growth by descriptor ULPs, rays with NaN or infinity made inactive, and the triangle return mode without barycentrics are implemented the same way in both translators; XCL's own descriptors set the bit that keeps barycentrics, and the test title follows the new descriptor word. What I cannot confirm from the code is the console behaviour it models: that 16-bit boxes grow in f32 ULPs after conversion, and what the id word holds in the mode without barycentrics. The description should say where those two come from.
performance: not measured.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).