Recompiler: replace tn[4]/id[4] local arrays in bvh_intersect with scalars #2302
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!2302
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2302"
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?
@fixgep on GitHub · 2026-11-25 13:15 UTC · original
fixgep:perf/hlsl-bvh-intersect-scalar→main· +369 −28 · 2 files · 1 commits · openPart of #2088. Replaces local array and vector-subscript indexing (
tn[4],id[4],pairs[5],child[k]) and scalar?:ternaries inPRELUDE_MEM'sbvh_intersecthelper (crates/xcl/src/gpu/recomp/emit.rs) with scalar registers and branchlessselectoperations.At
-O0(> 8 MBHLSL), DXC emitted 5 stackallocas and dynamicgetelementptrsequences perbvh_intersectcall site; at-O1and-O3, per-ktype == 5ubranches inside the unrolled loop,if (tn[j] < tn[i])swap diamonds, and scalar?:ternaries on triangle offsets bloated control-flow graphs and slowed both DXC and cold NVIDIA PSO compilation.What is in it
crates/xcl/src/gpu/recomp/emit.rs: replaces[unroll] for k+tn[4]/id[4]/pairs[5]/child[k]inbvh_intersectwith a singletype == 5ubox-load branch (bvh_box16_bounds), 4 scalarbvh_box_tevaluations (tn0..tn3,id0..id3), a branchless 5-stepbvh_swapsorting network insideif (sort), andselectfor GPURT triangle offsets and hit selection; addsbvh_intersect_uses_scalars_without_local_arrays.crates/xcl/src/gpu/recomp/tests.rs: adds DXIL IR validation/zero-alloca testbvh_intersect_dxil_has_zero_allocas_and_validates(-O0,-O1,-O3), wave32/split-wave64 edge-case parity testgpu_bvh_intersect_scalar_matches_reference, and manual cold PSO benchmarkbench_cold_bvh_intersect_pso.Controlled synthetic benchmark (
32IMAGE_BVH(64)_INTERSECT_RAYcalls in anS_CBRANCH_VCCNZtraversal loop, dynamicsort,mem_windows = 4, median of 3 timestamp-salted runs on NVIDIA GeForce RTX 3060 / driver32.0.15.9144, DXC1.9.2602.17, warm re-create verified50–69 ms):alloca/gep/br/phi-O3baseline-O3scalar-O1baseline-O1scalar-O0baseline-O0scalarTested
32.0.15.9144), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 x64,rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK DXC1.9.2602.17, debug & release.cargo test -p xcl --lib gpu::recomp -- --test-threads=4: 369 passed, 1 failed (gpu_clamp_and_omod_per_instructiononv_pk_add_i16 clamp, verified failing identically onmain1a0bbe3), 20 ignored (SKIPPED: 21no wave64, 3 refused#1426f16 forms).cargo test -p xcl --lib -- --test-threads=4: 1183 passed, 1 failed (gpu_clamp_and_omod_per_instruction, pre-existing onmain), 27 ignored (SKIPPEDlines: 21no wave64, 3 refused#1426f16 forms, 1ShaderCacheControl/ Developer Mode unavailable).cargo test -p xcl --test '*' -- --test-threads=4(aftercargo build --workspace): 70 passed, 0 failed, 20 ignored (SKIPPED: 1heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows;XCL_SAMPLE_*unset).cargo test --release -p xcl --lib gpu::recomp::tests::bench_cold_bvh_intersect_pso -- --ignored --nocapture: 1 passed, 0 failed (reported above;ShaderCacheControl(DISABLE)unavailable0x887A002D, cold misses verified via salted DXIL cache misses vs warm repeats).Regression run
Not tested
no wave64on RTX 3060).XCL_SAMPLE_*retail shader packs (unset).ID3D12Device9::ShaderCacheControlcache disable (Windows Developer Mode not active; cold PSO runs verified via salted DXIL cache misses vs50–69 mswarm hits).AI use
Antigravity (Gemini 4 Hydrogen): replaced
bvh_intersectarray indexing and scalar ternaries with scalar registers andselecthelpers incrates/xcl/src/gpu/recomp/emit.rs, wrote the synthetic IR/GPU parity tests and cold NVIDIA PSO benchmark, and ran the test, benchmark, and smoke checks.@DarkPanda69 on GitHub · 2026-11-25 13:25 UTC · original
The native wave64 run listed as untested (on RDNA4 rather than RDNA2), plus an RTX 3060: the new test passes on both.
Head
30985d3applied onmain1a0bbe3, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_bvh_intersect_scalar_matches_referenceok, with nono wave64skip. 632 passed, 2 failed, 23 ignored, 6 SKIPPED; the 2 failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: RDNA2,
XCL_SAMPLE_*shader packs, cold-cache PSO timing.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@jeroenhaentjens on GitHub · 2026-11-25 13:32 UTC · original · edited 2026-11-25 13:52 UTC
Independent Turing validation of
30985d3f48b605d1cdc9d4c39256afcb14ffea1a(parent1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6). On this machine, DXC compilation improved in all three modes; median first PSO creation improved at O0 but was slower at O1/O3 in this run.Two test-only commits based on this PR head are available for cherry-pick:
Tested
Windows 11 Pro 26200, i7-9750H, 32 GB RAM, Quadro RTX 3000 6 GB (driver
32.0.15.9706/597.06), DXC1.9.2609.5, Rust/Cargo1.100.0, AC power.XCL_ADAPTER=nvidia;XCL_SAMPLE_*,XCL_DIRECT_DXIL, andXCL_HEAP_WINDOWSunset. Incremental compilation and profile debug symbols disabled.cargo build --workspace --lockedpassed.cargo test --workspace --locked --no-fail-fast -- --test-threads=4completed: 1252 passed, 1 failed, 47 ignored (exit 101). The new scalar-source, DXIL-validation and GPU-reference tests, plus the existinggpu_bvh_intersect_ray, passed. There were 27 explicitSKIPPEDrecords: 20 native-wave64, 3 unsupported f16 forms (#1426), 2 missing D3D12 debug layer, 1 unavailable cache control, 1 disabled heap-window path. These records are separate from the harness totals.hle::d3d12x::bind::tests::execute_indirect_reads_the_arguments_written_before_it: 20/40 mismatches, zero results on even trials. This matches a historical full-suite log with unchangedcrates/xclrelative to the parent, but that historical run enabledXCL_HEAP_WINDOWS=1. A fresh isolated parent-runtime attempt failed earlier inCreateComputePipelineStatewith0x80070057, so it is inconclusive as a matched parent comparison; its adapter was not confirmed. I am not claiming a fresh baseline reproduction of the 20/40 failure.Synthetic compilation measurements
The modified manual benchmark passed (release, 450.26 s). It retains the supplied 32-call BVH traversal workload, dynamic sort, four memory windows, and split-wave64. The embedded baseline helper matches the parent helper after accessor/comment normalization. No other compiler/GPU workload was launched by this validation.
DXC was faster in all 12 pairs. First PSO creation was slower in 3/4 pairs at both O3 and O1, faster in 4/4 at O0. First-PSO ranges, base/scalar in ms: O3
11467.27–13423.64 / 12152.26–12653.75; O110123.84–12353.89 / 10960.94–12429.38; O019661.46–24402.34 / 14159.85–18141.12. Repeat creation across all samples was27.50–50.09 ms.ShaderCacheControl(DISABLE)failed with0x887A002D. Salts/fingerprints distinguish the inputs and direct compilation bypasses XCL's disk cache, but implicit driver-cache state is not proven cold. Four pairs are descriptive measurements, not statistical significance or a general NVIDIA speedup. Process-commit deltas are not peak-memory measurements.Supplemental commands (with the linked test-only changes):
Not tested: native wave64/AMD, retail shader packs or titles, GPU execution throughput, frame rate, time to first playable frame, or guaranteed cold-cache performance.
AI use: Codex and three agents prepared these test-only extensions, checked BVH semantics and benchmark arithmetic, ran the local validation, and wrote this report. The exact model identifier is unavailable in this session. This is a measured test report, not a formal code-review approval.
@luckyteagirl on GitHub · 2026-11-25 14:23 UTC · original
Independent RX 6800M (RDNA2 native-wave64) check of exact PR head
30985d3f48b605d1cdc9d4c39256afcb14ffea1a.Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver
30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. I selected the discrete GPU withXCL_ADAPTER=6800Mand required wave64 withXCL_REQUIRE_GPU=wave64.I ran the clean-head
bvh_intersect_focused tests twice, once withXCL_DIRECT_DXIL=1and once withXCL_DIRECT_DXIL=0. Each run finished 4 passed, 0 failed, 1 ignored, with noSKIPPEDline. Passing tests were the scalar-source check,bvh_intersect_dxil_has_zero_allocas_and_validates, the existing GPU BVH ray fixture, andgpu_bvh_intersect_scalar_matches_reference. The manual cold-PSO benchmark was the ignored test.The new reference fixture's
gpu_waves()runs both native wave64 and wave32 on this selected adapter. It compares per-lane sorted and unsorted box32/box16 child IDs and GPURT triangle results, including ties, misses, invalid bounds, NaNs, axis-parallel rays, and negativetmax. The DXIL inspection fixture validated O0, O1, and default output and checked for zero local array allocations.Limits: This is focused synthetic correctness evidence on RDNA2. I did not run the full workspace suite, title smoke, sampled shader packs, GPU throughput, or cold PSO timing on this head. I am not claiming a performance change.
AI use: OpenAI Codex (GPT-6; exact variant unavailable in this session) ran the tests, checked the exact head and clean worktree, and drafted this report. No game data was used.
@nnonno91 on GitHub · 2026-11-25 14:50 UTC · original
Focused HLSL-path verification on exact head
30985d3f48b605d1cdc9d4c39256afcb14ffea1awith the Windows SDK's DXC 1.8.Tested
cargo test --locked -p xcl --lib bvh_intersect -- --nocapture --test-threads=1withXCL_DIRECT_DXIL=0and each adapter selected viaXCL_ADAPTER. Each run gave 4 passed, 0 failed, 1 ignored (the manual cold-PSO benchmark) and no skips.Not tested
The benchmark, retail inputs, the parent, the full workspace suite and game regression runs.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the tests and wrote this report.
@MarcosMDev on GitHub · 2026-11-25 16:08 UTC · original
Test report:
30985d3on an RTX 4060: suite green, and this PR's own synthetic benchmark shows a driver gain only at-O0on this card. No game data was used.Suite,
cargo build --workspace, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4, debug, a separate target folder per commit:1a0bbe3: 1250 passed, 0 failed, 46 ignoredbench_cold_bvh_intersect_pso, release, nothing else of ours running, a new exe basename (ShaderCacheControlreturned0x887A002D, so the driver cache stayed on; the second call took 4 ms at most). Medians of the benchmark's 3 runs:-O1-O0The scalar form was slower in all 3 pairs at O3 and at
-O1, and faster in all 3 at-O0. Allocas at O3 are 0 on both sides already. The benchmark builds the base form first in every pair, so an order effect is possible; I did not swap it. An earlier run overlapped other work, so I leave its numbers out.So on this card the DXC time improves at every level, but I do not reproduce the −18 % cold PSO at
-O3reported from an RTX 3060.RTX 4060 8 GB (32.0.16.2101), Ryzen 7 5700X, 24 GB, Windows 11 26200, rustc 1.100.0, DXC 1.9.2609.5. Not tested: any title, retail shaders, AMD / Intel, GPU time, the branch merged with today's
main(it conflicts).AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests and the benchmark, and wrote this.
@DavidM1911 on GitHub · 2026-11-25 17:41 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!
@Aniseto on GitHub · 2026-11-25 17:44 UTC · original
Ran the bvh_intersect tests at
30985d3:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
The new
bvh_intersect_dxil_has_zero_allocas_and_validatesandgpu_bvh_intersect_scalar_matches_referencepass, as doesbvh_intersect_uses_scalars_without_local_arrays; the ignored one is the manual release benchmark.What this adds: the author tested an Ampere RTX 3060 with Windows SDK DXC 1.9.2602.17; this is a Blackwell wave32 part with DXC 1.9.2609.5. The new GPU parity test ran on the real adapter here. I did not repeat the cold PSO timing benchmark.
Not tested: the cold PSO A/B timings, a paired 60 s smoke run, native wave64 hardware, AMD and Intel GPUs, Wine, release profile, retail title data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.