Recompiler: select vertices for BVH triangle node types 2 and 3 #1959
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!1959
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1959/head"
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?
@n-romanovich on GitHub · 2026-11-24 23:52 UTC · original
n-romanovich:recomp/bvh-triangle-types-2-3→main· +108 −8 · 4 files · 1 commits · merged 2026-11-25 01:21 UTCFixes #1917.
GFX10 triangle nodes pack up to four triangles across five vertices:
0:(v0, v1, v2)at byte offsets(0, 12, 24)1:(v1, v3, v2)at byte offsets(12, 36, 24)2:(v2, v3, v4)at byte offsets(24, 36, 48)3:(v2, v4, v0)at byte offsets(24, 48, 0)Previously
bvh::intersect_node,emit.rsbvh_intersect, anddxil/lower_image.rsbvh_intersectonly checkedtype == 1and fell back to type0(v0, v1, v2) for types2and3.What is in it
crates/xcl/src/gpu/bvh.rs: select(o0, o1, o2)across node types0..=3inintersect_node, and add unit testtriangle_node_types_0_to_3_select_expected_vertices.crates/xcl/src/gpu/recomp/emit.rs: updatebvh_intersectto select vertex offsets for types0..=3.crates/xcl/src/gpu/dxil/lower_image.rs: updatebvh_intersectto select vertex offsets for types0..=3.crates/xcl/src/gpu/recomp/tests.rs: add GPU testgpu_bvh_triangle_types_2_and_3.Tested
Hardware: Windows 11 x64, NVIDIA GeForce RTX 5060 Ti.
cargo test -p xcl --lib bvh -- --test-threads=4: 13 passed, 0 failed, 0 ignored (949 filtered out)cargo test --workspace -- --test-threads=4: 986 passed, 0 failed, 45 ignoredSKIPPED: 21gpu::recompwave64 / refused per-lane f16 tests (no wave64/ refused per-lane f16),shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is required,0x887A002D),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)Regression run
Main (
f5136a640a69be3ce072e1ea8939e97d005b4cb1):PR (
f7bd213ca7d5ade6785a4a9aa3be2eb6491f754d):Not tested
AI use
smoke.ps1runs.@Anon64 on GitHub · 2026-11-24 23:57 UTC · original
Independent check of this PR's head
f7bd213on NVIDIA, with tests written separately from yours (I had the same fix locally before I saw this PR, so I ran my tests against your code instead of opening a second one).The tests (local only, not pushed):
each_triangle_type_tests_its_own_verticesinbvh::testschecks the CPU mirror.gpu_each_triangle_type_tests_its_own_verticesruns oneIMAGE_BVH_INTERSECT_RAYover those 8 rays on the GPU. It checks hit / miss and t against the expected values and againstbvh::intersect_node.Results:
main20cf130(without the fix)f7bd213type 2: the ray through its centroid hits … [inf, 1.0, 0.0, 0.0]XCL_DIRECT_DXIL=1(yourlower_image.rschange)On this PR's head, your
triangle_node_types_0_to_3_select_expected_verticesandgpu_bvh_triangle_types_2_and_3and the existing BVH tests (gpu_bvh_intersect_ray,gpu_triangle_pair_and_box16_nodes,gpu_built_bvh_nodes_match_the_cpu_node_test,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing) pass on both paths: 8 passed, 0 failed each.Tested: RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, DXC 1.8.2502.11,
cargo test -p xcl --release --lib -- each_triangle_type triangle_node_types gpu_triangle_pair gpu_built_bvh gpu_bvh.Not tested: the whole suite; AMD hardware, so not against a real RDNA2
image_bvh_intersect_ray; a title that packs more than two triangles in a node.Written with Claude Code (Claude Opus 5.5) from runs on this machine.
@DarkPanda69 on GitHub · 2026-11-25 00:11 UTC · original
AMD run with native 64-lane waves, which this PR lists as not tested (the other report here is NVIDIA).
Tested: pass, head
f7bd213applied onmain80f4819, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_bvh_triangle_types_2_and_3andtriangle_node_types_0_to_3_select_expected_verticesok. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3, which fail the same way onmain80f4819without this PR on this card (seeds 722 and 1599), so they are not from this change.Not tested: Linux; the whole workspace suite; a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@upipibi on GitHub · 2026-11-25 00:29 UTC · original
The vertex selection matches hardware. boykopovar/AnyPS5#24128 measured
image_bvh_intersect_rayon gfx1036 through their hardware oracle. Type 2 is (v2, v3, v4) and type 3 is (v2, v4, v0), with v4 at dwords 12–14 and the id at dword 15, which is what this PR uses at (24, 36, 48) and (24, 48, 0).RTX 3070 (Ampere, driver 616.56, Windows 11, debug) at
f7bd213: thedxil::/bvh::units (122 passed) and thegpu_tests withXCL_DIRECT_DXIL=0and1(111 passed each, including the new one) all pass.The same measurement found two more triangle-node rules that XCL doesn't follow yet. Both are outside this PR's scope; listing them in case someone wants a follow-up:
bvh_intersect(HLSL andbvh::intersect_node) returns(+inf, 1.0, 0, 0).(t, denominator, id + type, …), and on a miss(+inf, 1.0, id + type, 0), wrapping at 2^32. XCL always returns barycentrics.Not measured there: a zero or NaN denominator. Their hits are f32 Möller–Trumbore, a few ULP from the hardware's, as XCL's are.
AI-assisted (Claude Code). Synthetic tests only.
@JJAutoCompare on GitHub · 2026-11-25 00:39 UTC · original · edited 2026-11-25 00:51 UTC
Intel Arc A770 test report at
f7bd213ca7d5ade6785a4a9aa3be2eb6491f754dTested on Intel Arc A770 driver
32.0.101.9175, Ryzen 7 3800X, Windows 11 Enterprise Evaluation26200.9974, Rust1.100.0MSVC debug, DXC/DXIL1.9.2609.5. The clean test head still matched GitHub after the runs. WithXCL_ADAPTER=A770,XCL_REQUIRE_GPU=wave64andXCL_PER_LANE=0, rancargo test -p xcl --lib gpu_bvh_triangle_types_2_and_3 -- --nocapture --test-threads=1twice.XCL_DIRECT_DXIL=0(HLSL + DXC)XCL_DIRECT_DXIL=1(direct DXIL)The test executed on both backends. The elapsed times are single test runs rather than a performance comparison. Stale build-script artifacts prevented the initial launch. Refreshing Cargo's input timestamps fixed the build without source edits.
Not tested the PR base, CPU mirror test, full suite, retail smoke or native AMD behavior.
AI use Codex in T3 Code (
gpt-6.2-sol) ran the tests and prepared the report. The coordinator verified both logs and the PR head.@raylitebull on GitHub · 2026-11-25 01:08 UTC · original
Vertex selection across
bvh.rs,emit.rs, andlower_image.rs((0, 12, 24),(12, 36, 24),(24, 36, 48),(24, 48, 0)),Build and test+PR description, and AMD + NVIDIA + Intel verification all pass onf7bd213.Remaining before merge: please let us know if you plan to address @maritzaloas96-ship-it's two minor test nits (dropping the redundant
assert!(hit2[1] != 1.0 || ...)check inbvh.rsand adding a type-3 outside miss ray ingpu_bvh_triangle_types_2_and_3), or if this head is final.@n-romanovich on GitHub · 2026-11-25 01:12 UTC · original
@raylitebull, this head (
f7bd213) is final — both points are minor test-only nits, and all code and hardware checks are already green on it. Happy to leave it as-is for merge.@DavidM1911 on GitHub · 2026-11-25 02:59 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!