Recompiler: replace tn[4]/id[4] local arrays in bvh_intersect with scalars #2292

Open
fixgep wants to merge 1 commit from upstream-pr/2302 into main
fixgep commented 2026-11-25 13:15:07 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fixgep on 2026-11-25T13:15:07Z.


Part of #2088. Replaces local array and vector-subscript indexing (tn[4], id[4], pairs[5], child[k]) and scalar ?: ternaries in PRELUDE_MEM's bvh_intersect helper (crates/xcl/src/gpu/recomp/emit.rs) with scalar registers and branchless select operations.

At -O0 (> 8 MB HLSL), DXC emitted 5 stack allocas and dynamic getelementptr sequences per bvh_intersect call site; at -O1 and -O3, per-k type == 5u branches 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] in bvh_intersect with a single type == 5u box-load branch (bvh_box16_bounds), 4 scalar bvh_box_t evaluations (tn0..tn3, id0..id3), a branchless 5-step bvh_swap sorting network inside if (sort), and select for GPURT triangle offsets, tri_ret mode selection, and hit/bad-ray selection; integrates main's bvh_grow_lo/bvh_grow_hi ULP expansion (computing valid = all(mn <= mx) before growing bounds), tri_ret, and bad_ray early return into bvh_box_t and bvh_intersect; adds bvh_intersect_uses_scalars_without_local_arrays.
  • crates/xcl/src/gpu/recomp/tests.rs: adds DXIL IR validation/zero-alloca test bvh_intersect_dxil_has_zero_allocas_and_validates (-O0, -O1, -O3), wave32/split-wave64 edge-case parity test gpu_bvh_intersect_scalar_matches_reference, and manual cold PSO benchmark bench_cold_bvh_intersect_pso (updated for bvh_grow_hi/bvh_grow_lo, bad_ray, and tri_ret).

Controlled synthetic benchmark from 30985d3 (32 IMAGE_BVH(64)_INTERSECT_RAY calls in an S_CBRANCH_VCCNZ traversal loop, dynamic sort, mem_windows = 4, median of 3 timestamp-salted runs on NVIDIA GeForce RTX 3060 / driver 32.0.15.9144, DXC 1.9.2602.17, warm re-create verified 50–69 ms):

Mode DXIL bytes IR alloca / gep / br / phi DXC median (ms) Cold PSO median (ms)
-O3 baseline 268,916 0 / 5 / 2,399 / 3,147 11,047.8 5,606.79
-O3 scalar 254,500 (-5.4%) 0 / 5 / 1,311 (-45.4%) / 2,763 7,684.4 (-30.4%) 4,599.03 (-18.0%)
-O1 baseline 269,648 0 / 5 / 2,396 / 3,146 6,449.7 5,391.07
-O1 scalar 254,544 (-5.6%) 0 / 5 / 1,308 (-45.4%) / 2,762 5,236.0 (-18.8%) 4,665.43 (-13.5%)
-O0 baseline 372,396 162 / 3,013 / 5,746 / 3,470 1,042.9 6,801.85
-O0 scalar 318,152 (-14.6%) 2 / 5 / 3,186 (-44.6%) / 3,022 810.2 (-22.3%) 5,838.35 (-14.2%)

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 3060 (driver 32.0.16.2140), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK DXC 1.9.2602.17, debug & release (rebased head b1d353e4 on upstream/main 6bfb5c51).
  • Builds: cargo build -j 4 --workspace, cargo test -j 4 --workspace --no-run, and cargo build -j 4 --release -p xcl all exited 0 with 0 new warnings in crates/xcl/src/gpu/recomp/emit.rs or tests.rs.
  • cargo test -j 4 -p xcl --lib gpu::recomp -- --test-threads=1 (RTX 3060): 532 passed, 0 failed, 22 ignored (SKIPPED: 21 no wave64 forms).
  • cargo test -j 4 -p xcl --lib bvh -- --test-threads=1 (RTX 3060): 29 passed, 0 failed, 1 ignored (bench_cold_bvh_intersect_pso; 0 SKIPPED — all 7 GPU BVH tests including gpu_bvh_box_grow_nan_inactivation_and_tri_mode0, gpu_bvh_intersect_scalar_matches_reference, gpu_bvh_triangle_types_2_and_3, gpu_bvh64_intersect_ray_across_memory_windows_and_grazing, and gpu_bvh_node_in_an_unmapped_window_returns_a_miss passed).
  • XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib gpu::recomp -- --test-threads=1: 532 passed, 0 failed, 22 ignored (SKIPPED: 324 GPU wave tests without wave32/wave64 shader support on WARP).
  • XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib bvh -- --test-threads=1: 29 passed, 0 failed, 1 ignored (SKIPPED: 7 no wave64).
  • cargo test -j 4 -p xcl --lib -- --test-threads=4 (via --workspace run): 2759 passed, 0 failed, 32 ignored (SKIPPED: 22 no wave64, 1 no heap windows (opt-in: XCL_HEAP_WINDOWS=1), 1 ShaderCacheControl 0x887A002D).
  • cargo test -j 4 -p xcl --test '*' --no-fail-fast -- --test-threads=4 (38 targets): 142 passed, 1 failed (two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs in gpu_two_pass_cache_e2e, which passed when rerun standalone via cargo test -p xcl --test gpu_two_pass_cache_e2e -- --test-threads=1: 1 passed, 0 failed), 20 ignored (SKIPPED: 1 heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; XCL_SAMPLE_* unset).

Regression run

xcl-smoke v1
commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1672 (PresentX 1672)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14949 MB
xcl-smoke v1
commit: b1d353e4464987c0bc7f4f0eda36f8d1da0ee393
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1663 (PresentX 1663)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15278 MB

Not tested

  • Native wave64 GPU hardware paths (AMD RDNA2/RDNA4; skipped with no wave64 on RTX 3060 and WARP).
  • Non-Windows builds (unsupported target OS) and XCL_SAMPLE_* retail shader packs (unset).
  • ID3D12Device9::ShaderCacheControl cache disable (Windows Developer Mode not active) and post-rebase rerun of bench_cold_bvh_intersect_pso (benchmark table above is from pre-rebase 30985d3).

AI use
Antigravity (Gemini 4 Hydrogen): replaced bvh_intersect array indexing and scalar ternaries with scalar registers and select helpers in crates/xcl/src/gpu/recomp/emit.rs, wrote the synthetic IR/GPU parity tests and cold NVIDIA PSO benchmark, rebased onto upstream/main (6bfb5c51) carrying bvh_grow_lo/bvh_grow_hi, tri_ret, and bad-ray early return into bvh_box_t/bvh_intersect, and ran the build, targeted/workspace test, and smoke checks.

<!-- greyfinch-sync:ivall/xcl:issue:5492044970 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302). Originally posted by [fixgep](https://github.com/fixgep) on 2026-11-25T13:15:07Z. --- Part of #2088. Replaces local array and vector-subscript indexing (`tn[4]`, `id[4]`, `pairs[5]`, `child[k]`) and scalar `?:` ternaries in `PRELUDE_MEM`'s `bvh_intersect` helper (`crates/xcl/src/gpu/recomp/emit.rs`) with scalar registers and branchless `select` operations. At `-O0` (`> 8 MB` HLSL), DXC emitted 5 stack `alloca`s and dynamic `getelementptr` sequences per `bvh_intersect` call site; at `-O1` and `-O3`, per-`k` `type == 5u` branches 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]` in `bvh_intersect` with a single `type == 5u` box-load branch (`bvh_box16_bounds`), 4 scalar `bvh_box_t` evaluations (`tn0..tn3`, `id0..id3`), a branchless 5-step `bvh_swap` sorting network inside `if (sort)`, and `select` for GPURT triangle offsets, `tri_ret` mode selection, and hit/bad-ray selection; integrates `main`'s `bvh_grow_lo`/`bvh_grow_hi` ULP expansion (computing `valid = all(mn <= mx)` before growing bounds), `tri_ret`, and `bad_ray` early return into `bvh_box_t` and `bvh_intersect`; adds `bvh_intersect_uses_scalars_without_local_arrays`. - `crates/xcl/src/gpu/recomp/tests.rs`: adds DXIL IR validation/zero-alloca test `bvh_intersect_dxil_has_zero_allocas_and_validates` (`-O0`, `-O1`, `-O3`), wave32/split-wave64 edge-case parity test `gpu_bvh_intersect_scalar_matches_reference`, and manual cold PSO benchmark `bench_cold_bvh_intersect_pso` (updated for `bvh_grow_hi`/`bvh_grow_lo`, `bad_ray`, and `tri_ret`). Controlled synthetic benchmark from `30985d3` (`32` `IMAGE_BVH(64)_INTERSECT_RAY` calls in an `S_CBRANCH_VCCNZ` traversal loop, dynamic `sort`, `mem_windows = 4`, median of 3 timestamp-salted runs on NVIDIA GeForce RTX 3060 / driver `32.0.15.9144`, DXC `1.9.2602.17`, warm re-create verified `50–69 ms`): | Mode | DXIL bytes | IR `alloca` / `gep` / `br` / `phi` | DXC median (ms) | Cold PSO median (ms) | | --- | --- | --- | --- | --- | | `-O3` baseline | 268,916 | 0 / 5 / 2,399 / 3,147 | 11,047.8 | 5,606.79 | | `-O3` scalar | 254,500 (-5.4%) | 0 / 5 / 1,311 (-45.4%) / 2,763 | 7,684.4 (-30.4%) | 4,599.03 (-18.0%) | | `-O1` baseline | 269,648 | 0 / 5 / 2,396 / 3,146 | 6,449.7 | 5,391.07 | | `-O1` scalar | 254,544 (-5.6%) | 0 / 5 / 1,308 (-45.4%) / 2,762 | 5,236.0 (-18.8%) | 4,665.43 (-13.5%) | | `-O0` baseline | 372,396 | 162 / 3,013 / 5,746 / 3,470 | 1,042.9 | 6,801.85 | | `-O0` scalar | 318,152 (-14.6%) | 2 / 5 / 3,186 (-44.6%) / 3,022 | 810.2 (-22.3%) | 5,838.35 (-14.2%) | **Tested** - Hardware & toolchain: NVIDIA GeForce RTX 3060 (driver `32.0.16.2140`), AMD Ryzen 5 7500F 6-Core Processor, Windows 11 x64, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, Windows SDK DXC `1.9.2602.17`, debug & release (rebased head `b1d353e4` on `upstream/main` `6bfb5c51`). - Builds: `cargo build -j 4 --workspace`, `cargo test -j 4 --workspace --no-run`, and `cargo build -j 4 --release -p xcl` all exited `0` with 0 new warnings in `crates/xcl/src/gpu/recomp/emit.rs` or `tests.rs`. - `cargo test -j 4 -p xcl --lib gpu::recomp -- --test-threads=1` (RTX 3060): 532 passed, 0 failed, 22 ignored (`SKIPPED`: 21 `no wave64` forms). - `cargo test -j 4 -p xcl --lib bvh -- --test-threads=1` (RTX 3060): 29 passed, 0 failed, 1 ignored (`bench_cold_bvh_intersect_pso`; 0 `SKIPPED` — all 7 GPU BVH tests including `gpu_bvh_box_grow_nan_inactivation_and_tri_mode0`, `gpu_bvh_intersect_scalar_matches_reference`, `gpu_bvh_triangle_types_2_and_3`, `gpu_bvh64_intersect_ray_across_memory_windows_and_grazing`, and `gpu_bvh_node_in_an_unmapped_window_returns_a_miss` passed). - `XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib gpu::recomp -- --test-threads=1`: 532 passed, 0 failed, 22 ignored (`SKIPPED`: 324 GPU wave tests without wave32/wave64 shader support on WARP). - `XCL_ADAPTER=warp cargo test -j 4 -p xcl --lib bvh -- --test-threads=1`: 29 passed, 0 failed, 1 ignored (`SKIPPED`: 7 `no wave64`). - `cargo test -j 4 -p xcl --lib -- --test-threads=4` (via `--workspace` run): 2759 passed, 0 failed, 32 ignored (`SKIPPED`: 22 `no wave64`, 1 `no heap windows (opt-in: XCL_HEAP_WINDOWS=1)`, 1 `ShaderCacheControl` `0x887A002D`). - `cargo test -j 4 -p xcl --test '*' --no-fail-fast -- --test-threads=4` (38 targets): 142 passed, 1 failed (`two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` in `gpu_two_pass_cache_e2e`, which passed when rerun standalone via `cargo test -p xcl --test gpu_two_pass_cache_e2e -- --test-threads=1`: 1 passed, 0 failed), 20 ignored (`SKIPPED`: 1 `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`; `XCL_SAMPLE_*` unset). **Regression run** ``` xcl-smoke v1 commit: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c gpu: NVIDIA GeForce RTX 3060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1672 (PresentX 1672) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14949 MB ``` ``` xcl-smoke v1 commit: b1d353e4464987c0bc7f4f0eda36f8d1da0ee393 gpu: NVIDIA GeForce RTX 3060 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1663 (PresentX 1663) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15278 MB ``` **Not tested** - Native wave64 GPU hardware paths (AMD RDNA2/RDNA4; skipped with `no wave64` on RTX 3060 and WARP). - Non-Windows builds (unsupported target OS) and `XCL_SAMPLE_*` retail shader packs (unset). - `ID3D12Device9::ShaderCacheControl` cache disable (Windows Developer Mode not active) and post-rebase rerun of `bench_cold_bvh_intersect_pso` (benchmark table above is from pre-rebase `30985d3`). **AI use** Antigravity (Gemini 4 Hydrogen): replaced `bvh_intersect` array indexing and scalar ternaries with scalar registers and `select` helpers in `crates/xcl/src/gpu/recomp/emit.rs`, wrote the synthetic IR/GPU parity tests and cold NVIDIA PSO benchmark, rebased onto `upstream/main` (`6bfb5c51`) carrying `bvh_grow_lo`/`bvh_grow_hi`, `tri_ret`, and bad-ray early return into `bvh_box_t`/`bvh_intersect`, and ran the build, targeted/workspace test, and smoke checks.
DarkPanda69 commented 2026-11-25 14:10:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T13:25:40Z.


The native wave64 run listed as untested (on RDNA4 rather than RDNA2), plus an RTX 3060: the new test passes on both.

Head 30985d3 applied on main 1a0bbe3, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010, waves 32..64): gpu_bvh_intersect_scalar_matches_reference ok, with no no wave64 skip. 632 passed, 2 failed, 23 ignored, 6 SKIPPED; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on main.
  • RTX 3060 (driver 32.0.16.1088): the new test ok; 634 passed, 0 failed, 23 ignored.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7163761096 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7163761096). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T13:25:40Z. --- The native wave64 run listed as untested (on RDNA4 rather than RDNA2), plus an RTX 3060: the new test passes on both. Head `30985d3` applied on `main` `1a0bbe3`, debug, Windows 11 Pro 26200, `cargo test -p xcl --lib -- gpu:: --test-threads=4`: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010, waves 32..64): `gpu_bvh_intersect_scalar_matches_reference` ok, with no `no wave64` skip. 632 passed, 2 failed, 23 ignored, 6 SKIPPED; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on `main`. - **RTX 3060** (driver 32.0.16.1088): the new test ok; 634 passed, 0 failed, 23 ignored. 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 commented 2026-11-25 14:10:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-11-25T13:32:55Z.


Independent Turing validation of 30985d3f48b605d1cdc9d4c39256afcb14ffea1a (parent 1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6). 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:

  • 8ba2877: exercise split-wave64 and check all triangle outputs: the new reference fixture now explicitly exercises wave32 and split-wave64 on NVIDIA, uses the HLSL route, and checks all four output words for hit/miss cases of triangle types 0..3. Native wave64 remains conditional on support.
  • 905fef6: balance the manual compilation benchmark: identical synthetic input within each pair, four AB/BA/AB/BA pairs per explicit optimization mode, fresh salts, DXIL validation/fingerprints, even-sample median, and first/repeat PSO labels. No runtime implementation changes.

Tested

Windows 11 Pro 26200, i7-9750H, 32 GB RAM, Quadro RTX 3000 6 GB (driver 32.0.15.9706 / 597.06), DXC 1.9.2609.5, Rust/Cargo 1.100.0, AC power. XCL_ADAPTER=nvidia; XCL_SAMPLE_*, XCL_DIRECT_DXIL, and XCL_HEAP_WINDOWS unset. Incremental compilation and profile debug symbols disabled.

  1. Unmodified PR head: cargo build --workspace --locked passed. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 completed: 1252 passed, 1 failed, 47 ignored (exit 101). The new scalar-source, DXIL-validation and GPU-reference tests, plus the existing gpu_bvh_intersect_ray, passed. There were 27 explicit SKIPPED records: 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.
  2. The failure was 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 unchanged crates/xcl relative to the parent, but that historical run enabled XCL_HEAP_WINDOWS=1. A fresh isolated parent-runtime attempt failed earlier in CreateComputePipelineState with 0x80070057, 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.
  3. Supplemental test overlay: the strengthened reference test passed separately with the PR emitter and with the exact parent emitter substituted: 1 passed, 0 failed each, explicitly logging wave32 and split-wave64. The PR emitter was restored before benchmarking. These overlay runs are separate from the unmodified-head suite above.

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.

Mode DXIL bytes, base → scalar Median DXC, ms Median first PSO, ms First PSO change
O3 268792 → 254380 8312.5 → 6321.0 11493.14 → 12596.01 +9.6%
O1 269524 → 254420 4989.4 → 4721.0 11018.91 → 11741.16 +6.6%
O0 372060 → 317804 826.6 → 659.4 22334.43 → 15705.37 −29.7%

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; O1 10123.84–12353.89 / 10960.94–12429.38; O0 19661.46–24402.34 / 14159.85–18141.12. Repeat creation across all samples was 27.50–50.09 ms.

ShaderCacheControl(DISABLE) failed with 0x887A002D. 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):

cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_bvh_intersect_scalar_matches_reference -- --exact --nocapture --test-threads=1
cargo test --release --locked -p xcl --lib gpu::recomp::tests::bench_cold_bvh_intersect_pso -- --exact --ignored --nocapture --test-threads=1

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.

<!-- greyfinch-sync:ivall/xcl:comment:7163936020 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7163936020). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-11-25T13:32:55Z. --- Independent Turing validation of `30985d3f48b605d1cdc9d4c39256afcb14ffea1a` (parent `1a0bbe3a2ba91ea8f5b6fc29130a053868d3c9e6`). 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: - [8ba2877: exercise split-wave64 and check all triangle outputs](https://github.com/jeroenhaentjens/xcl/commit/8ba287771adb054a0966f323d47ef2767282a556): the new reference fixture now explicitly exercises wave32 and split-wave64 on NVIDIA, uses the HLSL route, and checks all four output words for hit/miss cases of triangle types 0..3. Native wave64 remains conditional on support. - [905fef6: balance the manual compilation benchmark](https://github.com/jeroenhaentjens/xcl/commit/905fef607191a642e36a4283a98c827757e54cdc): identical synthetic input within each pair, four AB/BA/AB/BA pairs per explicit optimization mode, fresh salts, DXIL validation/fingerprints, even-sample median, and first/repeat PSO labels. No runtime implementation changes. **Tested** Windows 11 Pro 26200, i7-9750H, 32 GB RAM, Quadro RTX 3000 6 GB (driver `32.0.15.9706` / `597.06`), DXC `1.9.2609.5`, Rust/Cargo `1.100.0`, AC power. `XCL_ADAPTER=nvidia`; `XCL_SAMPLE_*`, `XCL_DIRECT_DXIL`, and `XCL_HEAP_WINDOWS` unset. Incremental compilation and profile debug symbols disabled. 1. **Unmodified PR head:** `cargo build --workspace --locked` passed. `cargo test --workspace --locked --no-fail-fast -- --test-threads=4` completed: **1252 passed, 1 failed, 47 ignored** (exit 101). The new scalar-source, DXIL-validation and GPU-reference tests, plus the existing `gpu_bvh_intersect_ray`, passed. There were 27 explicit `SKIPPED` records: 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. 2. The failure was `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 unchanged `crates/xcl` relative to the parent, but that historical run enabled `XCL_HEAP_WINDOWS=1`. A fresh isolated parent-runtime attempt failed earlier in `CreateComputePipelineState` with `0x80070057`, 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. 3. **Supplemental test overlay:** the strengthened reference test passed separately with the PR emitter and with the exact parent emitter substituted: **1 passed, 0 failed** each, explicitly logging wave32 and split-wave64. The PR emitter was restored before benchmarking. These overlay runs are separate from the unmodified-head suite above. **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. | Mode | DXIL bytes, base → scalar | Median DXC, ms | Median first PSO, ms | First PSO change | | --- | ---: | ---: | ---: | ---: | | O3 | 268792 → 254380 | 8312.5 → 6321.0 | 11493.14 → 12596.01 | +9.6% | | O1 | 269524 → 254420 | 4989.4 → 4721.0 | 11018.91 → 11741.16 | +6.6% | | O0 | 372060 → 317804 | 826.6 → 659.4 | 22334.43 → 15705.37 | −29.7% | 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`; O1 `10123.84–12353.89 / 10960.94–12429.38`; O0 `19661.46–24402.34 / 14159.85–18141.12`. Repeat creation across all samples was `27.50–50.09 ms`. `ShaderCacheControl(DISABLE)` failed with `0x887A002D`. 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): ```text cargo test --locked -p xcl --lib gpu::recomp::tests::gpu_bvh_intersect_scalar_matches_reference -- --exact --nocapture --test-threads=1 cargo test --release --locked -p xcl --lib gpu::recomp::tests::bench_cold_bvh_intersect_pso -- --exact --ignored --nocapture --test-threads=1 ``` **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 commented 2026-11-25 15:07:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T14:23:16Z.


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 with XCL_ADAPTER=6800M and required wave64 with XCL_REQUIRE_GPU=wave64.

I ran the clean-head bvh_intersect_ focused tests twice, once with XCL_DIRECT_DXIL=1 and once with XCL_DIRECT_DXIL=0. Each run finished 4 passed, 0 failed, 1 ignored, with no SKIPPED line. Passing tests were the scalar-source check, bvh_intersect_dxil_has_zero_allocas_and_validates, the existing GPU BVH ray fixture, and gpu_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 negative tmax. 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.

<!-- greyfinch-sync:ivall/xcl:comment:7165199384 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7165199384). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T14:23:16Z. --- 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 with `XCL_ADAPTER=6800M` and required wave64 with `XCL_REQUIRE_GPU=wave64`. I ran the clean-head `bvh_intersect_` focused tests twice, once with `XCL_DIRECT_DXIL=1` and once with `XCL_DIRECT_DXIL=0`. Each run finished **4 passed, 0 failed, 1 ignored**, with no `SKIPPED` line. Passing tests were the scalar-source check, `bvh_intersect_dxil_has_zero_allocas_and_validates`, the existing GPU BVH ray fixture, and `gpu_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 negative `tmax`. 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 commented 2026-11-25 15:08:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T14:50:56Z.


Focused HLSL-path verification on exact head 30985d3f48b605d1cdc9d4c39256afcb14ffea1a with the Windows SDK's DXC 1.8.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742.
  • cargo test --locked -p xcl --lib bvh_intersect -- --nocapture --test-threads=1 with XCL_DIRECT_DXIL=0 and each adapter selected via XCL_ADAPTER. Each run gave 4 passed, 0 failed, 1 ignored (the manual cold-PSO benchmark) and no skips.
  • DXIL validation and the no-local-array assertions passed in all three compiler modes. The GPU fixtures passed their ray intersection and scalar-versus-reference comparisons on both adapters.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7165910130 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7165910130). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-25T14:50:56Z. --- Focused HLSL-path verification on exact head `30985d3f48b605d1cdc9d4c39256afcb14ffea1a` with the Windows SDK's DXC 1.8. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, SDK DXC/DXIL 1.8.2502.11, unoptimized profile. AMD Radeon(TM) Graphics driver 32.0.21042.62 and RTX 5090 driver 32.0.16.1742. - `cargo test --locked -p xcl --lib bvh_intersect -- --nocapture --test-threads=1` with `XCL_DIRECT_DXIL=0` and each adapter selected via `XCL_ADAPTER`. Each run gave 4 passed, 0 failed, 1 ignored (the manual cold-PSO benchmark) and no skips. - DXIL validation and the no-local-array assertions passed in all three compiler modes. The GPU fixtures passed their ray intersection and scalar-versus-reference comparisons on both adapters. **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 commented 2026-11-25 16:12:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MarcosMDev on 2026-11-25T16:08:31Z.


Test report: 30985d3 on an RTX 4060: suite green, and this PR's own synthetic benchmark shows a driver gain only at -O0 on this card. No game data was used.

Suite, cargo build --workspace, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4, debug, a separate target folder per commit:

  • base 1a0bbe3: 1250 passed, 0 failed, 46 ignored
  • head: 1253 passed, 0 failed, 47 ignored; the three new tests pass. 27 SKIPPED lines on both.

bench_cold_bvh_intersect_pso, release, nothing else of ours running, a new exe basename (ShaderCacheControl returned 0x887A002D, so the driver cache stayed on; the second call took 4 ms at most). Medians of the benchmark's 3 runs:

DXC DXIL DXC time cold PSO, base → scalar
default (O3) −5.4 % 7.39 → 5.86 s (−21 %) 8.73 → 9.08 s (+4.1 %)
-O1 −5.6 % 4.82 → 4.18 s (−13 %) 9.95 → 10.28 s (+3.3 %)
-O0 −14.6 % 0.94 → 0.68 s (−28 %) 19.32 → 14.80 s (−23.4 %)

The 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 -O3 reported 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.

<!-- greyfinch-sync:ivall/xcl:comment:7167629037 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7167629037). Originally posted by [MarcosMDev](https://github.com/MarcosMDev) on 2026-11-25T16:08:31Z. --- **Test report: `30985d3` on an RTX 4060: suite green, and this PR's own synthetic benchmark shows a driver gain only at `-O0` on this card.** No game data was used. **Suite**, `cargo build --workspace`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`, debug, a separate target folder per commit: - base `1a0bbe3`: 1250 passed, 0 failed, 46 ignored - head: 1253 passed, 0 failed, 47 ignored; the three new tests pass. 27 SKIPPED lines on both. **`bench_cold_bvh_intersect_pso`**, release, nothing else of ours running, a new exe basename (`ShaderCacheControl` returned `0x887A002D`, so the driver cache stayed on; the second call took 4 ms at most). Medians of the benchmark's 3 runs: | DXC | DXIL | DXC time | cold PSO, base → scalar | |---|---|---|---| | default (O3) | −5.4 % | 7.39 → 5.86 s (−21 %) | 8.73 → 9.08 s (**+4.1 %**) | | `-O1` | −5.6 % | 4.82 → 4.18 s (−13 %) | 9.95 → 10.28 s (**+3.3 %**) | | `-O0` | −14.6 % | 0.94 → 0.68 s (−28 %) | 19.32 → 14.80 s (**−23.4 %**) | The 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 `-O3` reported 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 commented 2026-11-25 18:04:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T17:41:07Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7169853937 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7169853937). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T17:41:07Z. --- 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 commented 2026-11-25 18:04:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-25T17:44:46Z.


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.

XCL_ADAPTER=nvidia cargo test -p xcl --lib bvh_intersect -- --test-threads=4 --nocapture
4 passed; 0 failed; 1 ignored; 1206 filtered out      (exit 0)

The new bvh_intersect_dxil_has_zero_allocas_and_validates and gpu_bvh_intersect_scalar_matches_reference pass, as does bvh_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.

<!-- greyfinch-sync:ivall/xcl:comment:7169939855 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7169939855). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-25T17:44:46Z. --- 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. ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib bvh_intersect -- --test-threads=4 --nocapture 4 passed; 0 failed; 1 ignored; 1206 filtered out (exit 0) ``` The new `bvh_intersect_dxil_has_zero_allocas_and_validates` and `gpu_bvh_intersect_scalar_matches_reference` pass, as does `bvh_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.
Foniass commented 2026-12-01 07:47:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:47:31Z.


Triage (#1607) – head b1d353e

#1542 targets the same cost in PRELUDE_MEM's bvh_intersect (the box-node loop repeated at every inlined BVH instruction), but in the opposite direction:

  • #1542 changes [unroll] to [loop], so one copy of the slab test remains and the arrays stay.
  • This PR removes tn[4] / id[4] / pairs[5] and writes four scalar bvh_box_t calls with a branchless sorting network.
    Both edit the same lines, so at most one can land; the measurements in the two descriptions are the basis for choosing.
    The box offsets (16/28 + 24k, 16 + 12k) and the sorting network match the old loop. The rebase onto main (b1d353e4) carries the bvh_grow_lo/hi bounds into bvh_box_t and keeps tri_ret and the bad-ray early return; it also turns the triangle path's ternaries into select.
    Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304484020 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7304484020). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:47:31Z. --- **Triage (#1607)** – head b1d353e #1542 targets the same cost in `PRELUDE_MEM`'s `bvh_intersect` (the box-node loop repeated at every inlined BVH instruction), but in the opposite direction: - #1542 changes `[unroll]` to `[loop]`, so one copy of the slab test remains and the arrays stay. - This PR removes `tn[4]` / `id[4]` / `pairs[5]` and writes four scalar `bvh_box_t` calls with a branchless sorting network. Both edit the same lines, so at most one can land; the measurements in the two descriptions are the basis for choosing. The box offsets (16/28 + 24k, 16 + 12k) and the sorting network match the old loop. The rebase onto main (b1d353e4) carries the `bvh_grow_lo/hi` bounds into `bvh_box_t` and keeps `tri_ret` and the bad-ray early return; it also turns the triangle path's ternaries into `select`. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
fixgep commented 2026-12-01 17:29:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fixgep on 2026-12-01T17:29:27Z.


@Foniass Rebased onto upstream/main (6bfb5c51 -> b1d353e4): bvh_grow_lo/bvh_grow_hi (preserving the pre-growth mn <= mx validity check), tri_ret, and the bad_ray early return are now integrated into bvh_box_t and bvh_intersect alongside the scalar register / sorting-network path. Both gpu_bvh_box_grow_nan_inactivation_and_tri_mode0 and gpu_bvh_intersect_scalar_matches_reference pass on RTX 3060, and the paired 60 s smoke run is updated in the description.

<!-- greyfinch-sync:ivall/xcl:comment:7319381516 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7319381516). Originally posted by [fixgep](https://github.com/fixgep) on 2026-12-01T17:29:27Z. --- @Foniass Rebased onto `upstream/main` (`6bfb5c51` -> `b1d353e4`): `bvh_grow_lo`/`bvh_grow_hi` (preserving the pre-growth `mn <= mx` validity check), `tri_ret`, and the `bad_ray` early return are now integrated into `bvh_box_t` and `bvh_intersect` alongside the scalar register / sorting-network path. Both `gpu_bvh_box_grow_nan_inactivation_and_tri_mode0` and `gpu_bvh_intersect_scalar_matches_reference` pass on RTX 3060, and the paired 60 s smoke run is updated in the description.
fromthemoonx commented 2026-12-03 11:13:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T11:13:09Z.


merge-check
base: 0c725d5da2
head: b1d353e446
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 57 ignored; SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. Base alone: 3015 passed, 1 failed, 56 ignored; the one was cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly with E_OUTOFMEMORY in the parallel run, and it passed in 50 of 50 further runs of its module
review: read the whole diff (2 files, +394 -33). The results are right; the speed-up is not there any more on this head.

  1. Results: I put main's bvh_intersect and this PR's into one compute shader and ran both on random nodes and rays (box32, box16, triangle types 0 to 3; ties, inverted boxes, NaN, infinities, signed zeros, all grow values, sort on and off). They gave the same four words in 65,536,000 of 65,536,000 cases, at the default level, at -O1 and at -Od. About 4.8 million of the cases had a hit. A control with one sorting step removed differed in 112,386 cases.
  2. cargo test -p xcl --lib bvh: 29 passed, 0 failed with XCL_DIRECT_DXIL=0 and with =1.
  3. The direct DXIL translator, the default now, has its own BVH code (dxil/lower_image.rs). So this change only reaches shaders that go through HLSL: the ones the direct translator refuses, or with XCL_DIRECT_DXIL=0.
  4. #1542 changes the same lines in the other direction (loops kept rolled), so only one of the two can land.
  5. Not tested: a retail title (none on this machine), AMD.
  6. Points 1 and 2 and the timings below are from the merge onto 16c2fd08, a few commits earlier. Nothing under crates/xcl/src/gpu changed between the two.
    performance: slower on this card at the levels XCL normally uses. This is the PR's own bench_cold_bvh_intersect_pso on that merge (debug build). Its baseline text is the same as main's code; I checked that by script.
DXC level DXC time, main → PR driver compile, main → PR runs
default (-O3) 13.7 → 18.1 s (+32 %) 14.9 → 15.3 s (+3 %) median of 3
-O1 (HLSL over 1 MB) 9.3 → 15.7 s (+68 %) 14.9 → 15.2 s (+2 %) median of 3
-O0 (HLSL over 8 MB) 1.6 and 1.7 → 1.5 and 1.4 s 24.3 and 24.7 → 18.4 and 18.2 s (about −25 %) 2 runs, PR built first

The order does not explain it: with the PR's form built first, one run each gave +38 % DXC time at the default level and +73 % at -O1. The table in the description is from 30985d3, before the rebase brought in bvh_grow_lo / bvh_grow_hi, and it is the only place that shows a gain at -O1 and -O3. MarcosMDev and jeroenhaentjens had already measured a slower driver compile at those two levels on the old head. I did not look into which part of the new form costs DXC the time.
verdict: not yet: the change is meant to make compiles faster, and on this head it makes them slower at the default level and at -O1
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300, DXC 1.9.2602.17 / Claude Code (Claude Opus 5.5)

@fixgep could you rerun the benchmark on the rebased head? The description lists that rerun under Not tested.

<!-- greyfinch-sync:ivall/xcl:comment:7376381127 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2302#issuecomment-7376381127). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T11:13:09Z. --- merge-check base: 0c725d5da298b90797993b568e30e6ff6b16e8b6 head: b1d353e4464987c0bc7f4f0eda36f8d1da0ee393 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3019 passed, 0 failed, 57 ignored; SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none. Base alone: 3015 passed, 1 failed, 56 ignored; the one was `cpu_watchdog_signal_with_inflight_gpu_signal_completes_cleanly` with E_OUTOFMEMORY in the parallel run, and it passed in 50 of 50 further runs of its module review: read the whole diff (2 files, +394 -33). The results are right; the speed-up is not there any more on this head. 1) Results: I put main's `bvh_intersect` and this PR's into one compute shader and ran both on random nodes and rays (box32, box16, triangle types 0 to 3; ties, inverted boxes, NaN, infinities, signed zeros, all grow values, sort on and off). They gave the same four words in 65,536,000 of 65,536,000 cases, at the default level, at `-O1` and at `-Od`. About 4.8 million of the cases had a hit. A control with one sorting step removed differed in 112,386 cases. 2) `cargo test -p xcl --lib bvh`: 29 passed, 0 failed with `XCL_DIRECT_DXIL=0` and with `=1`. 3) The direct DXIL translator, the default now, has its own BVH code (`dxil/lower_image.rs`). So this change only reaches shaders that go through HLSL: the ones the direct translator refuses, or with `XCL_DIRECT_DXIL=0`. 4) #1542 changes the same lines in the other direction (loops kept rolled), so only one of the two can land. 5) Not tested: a retail title (none on this machine), AMD. 6) Points 1 and 2 and the timings below are from the merge onto 16c2fd08, a few commits earlier. Nothing under `crates/xcl/src/gpu` changed between the two. performance: **slower on this card at the levels XCL normally uses.** This is the PR's own `bench_cold_bvh_intersect_pso` on that merge (debug build). Its baseline text is the same as main's code; I checked that by script. | DXC level | DXC time, main → PR | driver compile, main → PR | runs | |---|---|---|---| | default (`-O3`) | 13.7 → 18.1 s (**+32 %**) | 14.9 → 15.3 s (+3 %) | median of 3 | | `-O1` (HLSL over 1 MB) | 9.3 → 15.7 s (**+68 %**) | 14.9 → 15.2 s (+2 %) | median of 3 | | `-O0` (HLSL over 8 MB) | 1.6 and 1.7 → 1.5 and 1.4 s | 24.3 and 24.7 → 18.4 and 18.2 s (about −25 %) | 2 runs, PR built first | The order does not explain it: with the PR's form built first, one run each gave +38 % DXC time at the default level and +73 % at `-O1`. The table in the description is from 30985d3, before the rebase brought in `bvh_grow_lo` / `bvh_grow_hi`, and it is the only place that shows a gain at `-O1` and `-O3`. MarcosMDev and jeroenhaentjens had already measured a slower driver compile at those two levels on the old head. I did not look into which part of the new form costs DXC the time. verdict: not yet: the change is meant to make compiles faster, and on this head it makes them slower at the default level and at `-O1` hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300, DXC 1.9.2602.17 / Claude Code (Claude Opus 5.5) @fixgep could you rerun the benchmark on the rebased head? The description lists that rerun under Not tested.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2302:upstream-pr/2302'
git switch 'upstream-pr/2302'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2302'
git switch 'upstream-pr/2302'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2302'
git switch 'upstream-pr/2302'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2302'
git switch 'main'
git merge --squash 'upstream-pr/2302'
git switch 'main'
git merge --ff-only 'upstream-pr/2302'
git switch 'main'
git merge 'upstream-pr/2302'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2292
No description provided.