Recompiler: keep BVH box intersection loops rolled #1542
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!1542
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1542"
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?
@coolpersonnn on GitHub · 2026-11-24 17:27 UTC · original
coolpersonnn:recomp/retail-compile-cost→main· +47 −1 · 2 files · 1 commits · openDXC inlines the BVH intersection helper, so unrolling its four-child loop repeats the slab test and memory loads at every call site. Emit a single counted loop body for box intersections. Part of #1269.
What is in it
emit.rs. Add-O0compile and GPU checks for packed children, distance clipping, and sorted output intests.rs.Tested
.\scripts\test.ps1onf6147f3withXCL_ADAPTER=nvidiareported 778 passed, 0 failed, and 41 ignored (debug).SKIPPED gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64SKIPPED gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows9e3831eandf6147f3viacargo build --release -p xcl. One coldxcl shaders <dir> --precompile --only cs --windows 4 --split 1per build/sample with isolated DXIL caches.--pipelinesreruns used unique executable paths and the populated DXIL cache. Each made one pipeline, refused zero, loaded zero XCL driver-cache blobs, and kept the DXIL timestamp.Before rebasing, two larger
-O0inputs againstb7aa9f3produced 7.5-8.0% less DXIL. The larger input cut precompile time from 63.53 s to 50.31 s, and both of its PSO passes reached the 420 s cap. The earlier run of the 18,396-instruction sample took 35.97 s to precompile on main and 39.42 s with the patch.Regression run
Both runs used
.\scripts\smoke.ps1 -Game <folder> -Seconds 60withXCL_ADAPTER=nvidia. Main had a warm DXIL cache (0 compilations). The head used the existing cache and compiled 11 shaders.Not tested
AMD, native wave64, heap-window performance, and in-game dispatch time for the benchmark shaders.
AI use
Codex in T3 Code (gpt-6.2-sol) wrote the change and tests, ran the measurements, and drafted this report.
@nnonno91 on GitHub · 2026-11-24 17:39 UTC · original
Independent AMD check of
f6147f38d3a488f32d286f513dd48b8588469e4f.Tested
cargo build --workspace --lockedpassed.cargo test --locked -p xcl --lib bvh -- --test-threads=1 --nocapturepassed all 12, including the new packed-child test and the existing 64-bit intersection test across memory windows. No GPU skips in this run.cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-outputreported 778 passed, 0 failed, and 41 ignored. One reported GPU skip (heap_window_out_of_memory_falls_back_to_the_switch_form, no heap windows). The bundled title passed.IMAGE_BVH_INTERSECT_RAYon base9e3831e1f570d3646e53ab753b19ec07eb8f1485and this PR withcargo test --locked -p xcl --test bvh_size_probe -- --exact synthetic_bvh_sizes --nocapture --test-threads=1(temporary test). Four memory windows, three wave modes, and three optimization levels per DXC version. The test checked the change from[unroll]to[loop]in the emitted HLSL.-O0-O1-O3DXIL was smaller in all 18 matched comparisons with DXC 1.8.2502.11 and 1.9.2609.5 across wave32, native wave64, and split wave64. The reductions ranged from 22.8% to 32.6% for this one fixture.
Not tested
Retail shaders, retail titles, and driver compile times. The size comparison used one synthetic kernel.
AI use
OpenAI Codex (GPT-6 family, exact variant unavailable) prepared the temporary comparison, ran the checks, and drafted this report.
@lows78 on GitHub · 2026-11-24 17:45 UTC · original · edited 2026-11-24 18:43 UTC
Test report for #1542 at
f6147f38d3a488f32d286f513dd48b8588469e4f(clean tree), on an RTX 4090. I am not a graphics developer: Claude Code ran this on my PC, and I can rerun things if that helps.Tested
NVIDIA GeForce RTX 4090 (driver 621.01, 32-lane waves), Intel Core i9-14900KF, 32 GB RAM, Windows 11 Pro 10.0.26200, rustc 1.99.1 MSVC, DXC 1.8.2502.11, debug.
XCL_SAMPLE_*unset.cargo build --workspace && cargo test --workspace -- --test-threads=4, one run each:main9e3831e: 776 passed, 0 failed, 41 ignoredf6147f3: 778 passed, 0 failed, 41 ignoredSKIPPED, the same three on both:
gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)XCL_ADAPTER=nvidia cargo test -p xcl --lib bvh -- --test-threads=4, 10 runs: 12 passed, 0 failed in each[loop]against[unroll]on the GPU with random box16 / box32 nodes (temporary test,-O0,-O1,-O3): 7,680 results compared, 0 differencesSynthetic programs of BVH instructions at
-O3, four windows, unroll → loop:Added later: driver time (
CreateComputePipelineState), loop against unroll on this commit. Synthetic kernels of N BVH instructions, split wave64, four windows, default DXC arguments, debug build. 6 pairs per N, driver calls in alternating order (DXC always compiled the unrolled form first), new random literals in every pair so no program repeats, and a wait for the process to be idle between pipelines. 48 pipelines, none refused. Medians, unroll → loop:From N = 8 on the loop's driver call was faster in all 18 pairs (0.22 to 0.45 of the unrolled time). At N = 1 the ratio ranged from 0.63 to 1.05. These kernels are almost only BVH instructions, so a real shader gains less.
Not tested
smoke.ps1run) and retail shaders, driver time on real shaders, GPU run time of the loop, release builds, AMD, Intel, native wave64, heap windows, DXC 1.9. The PC was in use during the driver timing (GPU at 39 % just before it).mainhas moved toc160d86since; not rerun on top of itAI use
@DavidM1911 on GitHub · 2026-11-24 19:13 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodifiedmain.)Thanks!
@LocranKing on GitHub · 2026-11-24 20:03 UTC · original
Independent Windows release verification on NVIDIA RTX 3060 Ti (
f6147f38d3a488f32d286f513dd48b8588469e4fvs basemain9e3831e1f570d3646e53ab753b19ec07eb8f1485).Setup
8024 MiB VRAM, wave32), driver32.0.16.210131.8 GBRAM26200rustc 1.100.0, DXC1.9.2602.17,--releaseWorkspace tests (
cargo test --workspace --release --no-fail-fast -- --test-threads=4)0: 778 passed, 0 failed, 41 ignored across 20 result blocks (SKIPPED: 2no wave64, 2no D3D12 debug layer,heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).Regression run (
scripts/smoke.ps1, 60 s,XCL_NETWORK=0, title folder name redacted)main:1493 / 1566frames (95.3%),15704 / 14715 MBpeak commit (106.7%),0device removals,0crashes.Base (
main9e3831e):PR head (
f6147f3):Not tested: cold-cache BVH compute shader compile-time benchmark on the retail shader pack, AMD / wave64 hardware.
AI use: Antigravity (
Gemini 4 Neon) built and ran the test suite and smoke pair on this hardware and drafted this report from the captured outputs; reviewed before posting. No game files attached.@Melow-code on GitHub · 2026-11-24 23:02 UTC · original
The rolled-loop change is a clear win: 8% smaller DXIL, 15% faster cold PSO, no GPU output differences over 7,680 comparisons from lows78. The 58% growth on one synthetic case with overlapping outputs is expected — rolled loops trade code size for iteration overhead, and a fully overlapping box set hits every iteration.
One thing to watch: the
[loop]attribute relies on DXC respecting it. If a future DXC version decides to unroll despite the hint, the compile-time regression comes back. A comment noting this would help.The
-O0test coverage is good — it catches the rolled/unrolled difference at the DXIL level where it matters.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.