Recompiler: pick root-UAV memory windows with bit tests, not a switch #2191

Open
github-bot wants to merge 1 commit from github-bot/gh-2191 into main AGit
Owner

@⁠ezamelczyk on GitHub · 2026-11-25 08:25 UTC · original
ezamelczyk:recomp-window-bit-tests → main · +32 −20 · 2 files · 1 commits · draft

The memory-window accessors (xcl_mLoad, xcl_mStore, the atomics, xcl_loadx4) now choose a root UAV with one [branch] if per window, testing a bit of a one-hot mask, instead of [branch] switch (xcl_w). Part of #1269.

Why: Mesa's SPIR-V front end lowers an OpSwitch into a chain of ifs with a path on which no case runs. Inside a loop, every accessor result then becomes a loop-carried value that is undefined on entry, and RADV keeps all of them live. This is the cause of the CS_RaytracingResolve builds that @⁠Fran-co-F and @⁠lucsoft saw ACO's spiller run out of memory on in #1269. In those builds the windows are root UAVs, which is the default because heap windows are opt-in. With per-window ifs the values are defined before the first test, so nothing is carried round the loop. The bits are tested as (wm & (1u << k)) != 0u, with wm = select(xcl_w < windows, 1u << xcl_w, 0u), not xcl_w == k: with equality tests, DXC's jump threading took 31 of 47 s of the compile. An xcl_w outside the windows sets no bit and keeps the default, as the switch's default did. The heap form (XCL_HEAP_WINDOWS=1) is unchanged.

What is in it

  • crates/xcl/src/gpu/recomp/emit.rs (mem_accessors): the switch form is replaced by per-window bit tests.
  • crates/xcl/src/gpu/recomp/tests.rs: the two checks that looked for switch (xcl_w) look for the new form.

Tested

  • RX 9070 XT (RDNA4), Mesa 26.3.1 RADV (ACO), Ryzen 5 8400F, 30 GB RAM, CachyOS kernel 7.3.6. Wine 11.0 Staging (GE-Proton), vkd3d-proton 3.1 with #257's patch and dxil-spirv 53aac418. DXC 1.9.2609. rustc 1.99.1, release, cross-built for x86_64-pc-windows-msvc. Not Windows.

  • One retail program, CS_RaytracingResolve (console 84eee477d68b6fdf, 1.28 MB of DXIL in the switch form), one cold pipeline build (VKD3D_SHADER_CACHE_PATH=0, empty caches):

    form DXC + pipeline peak RSS RADV registers loop-header phis (NIR)
    main (switch) 103–140 s 20.5 GB ~3 840 SGPRs needed 4 624
    ifs on xcl_w == k 61 s – 273 SGPRs, 192 VGPRs 644
    this PR (bit tests) 39 s (DXC ~20 s) 1.26 GB 301 SGPRs, 192 VGPRs 644

    (The register and phi counts come from a locally instrumented Mesa build. The times and memory are with the system Mesa.)

  • The retail pack's 2 689 compute programs, xcl shaders shaders.rpf --precompile --only cs --pipelines: 2 689 compiled, 0 errors, 2 689 pipelines made, 0 refused. This was on a local tree with this change on top of #1316, #1448 and #1288, not on this branch alone. In the switch form, the same pass ran out of memory on RADV in the CS_RaytracingResolve stretch for @⁠lucsoft (#1269).

  • cargo test --workspace -- --test-threads=4 (release, Wine): 1 083 passed, 15 failed, 26 ignored. SKIPPED: f16_programs_on_the_gpu / f32_programs_on_the_gpu (per-lane form refuses V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32) and pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode under Wine).

    • Each of the 15 was run again alone on main 568e7db and on this branch, with identical results on both. 6 fail on both: fuzz_validate_and_gpu_2, f64_programs_on_the_gpu, f32_programs_on_the_gpu, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed, xma2_source_voice_decodes_and_manages_lifetime. The other 9 pass alone on both; in the full run they failed because a device removal from another test took them out.
    • All memory-window GPU tests pass, among them gpu_memory_windows_reject_out_of_uma_aliasing, gpu_mesh_mode_reads_memory_windows, gpu_memory_windows_above_4_gib and gpu_bvh64_intersect_ray_across_memory_windows_and_grazing.

Regression run

scripts/linux/smoke.sh from #257 (it prints the block smoke.ps1 prints), retail title, 300 s, the same button script. Each run had an empty DXIL cache, Mesa's shader cache off and VKD3D_SHADER_CACHE_PATH=0.

In both runs presents had stopped before the end (presents per 2 s (last 3): 0 0 0). I have not checked where each run stopped.

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: game_dump
seconds: 300
exit: 0x0
frames shown: 2135 (PresentX 2135)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: fb84fde754d03463fcc56e424b2e6e79866e6b20
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: game_dump
seconds: 300
exit: 0x0
frames shown: 1885 (PresentX 1885)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows, and the AMD and NVIDIA Windows drivers. On NVIDIA the switch costs a lot of driver time (#1269), and I have not measured whether bit tests do better or worse there than the switch or @⁠pr1sm-dev's read-select form.
  • Other AMD generations on RADV, and the native-Windows test suite.
  • The direct DXIL path (XCL_DIRECT_DXIL), which picks its windows separately.

AI use

  • Claude Code with Claude Opus 5.5: found the cause (with a locally instrumented Mesa), wrote the change and the test updates, ran the builds, the tests and the smoke runs on the machine above, and wrote this description.

🤖 Generated with Claude Code

**@⁠ezamelczyk** on GitHub · 2026-11-25 08:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191) `ezamelczyk:recomp-window-bit-tests` → `main` · +32 −20 · 2 files · 1 commits · draft The memory-window accessors (`xcl_mLoad`, `xcl_mStore`, the atomics, `xcl_loadx4`) now choose a root UAV with one `[branch] if` per window, testing a bit of a one-hot mask, instead of `[branch] switch (xcl_w)`. Part of #1269. Why: Mesa's SPIR-V front end lowers an `OpSwitch` into a chain of ifs with a path on which no case runs. Inside a loop, every accessor result then becomes a loop-carried value that is undefined on entry, and RADV keeps all of them live. This is the cause of the `CS_RaytracingResolve` builds that @⁠Fran-co-F and @⁠lucsoft saw ACO's spiller run out of memory on in #1269. In those builds the windows are root UAVs, which is the default because heap windows are opt-in. With per-window ifs the values are defined before the first test, so nothing is carried round the loop. The bits are tested as `(wm & (1u << k)) != 0u`, with `wm = select(xcl_w < windows, 1u << xcl_w, 0u)`, not `xcl_w == k`: with equality tests, DXC's jump threading took 31 of 47 s of the compile. An `xcl_w` outside the windows sets no bit and keeps the default, as the switch's `default` did. The heap form (`XCL_HEAP_WINDOWS=1`) is unchanged. **What is in it** - `crates/xcl/src/gpu/recomp/emit.rs` (`mem_accessors`): the switch form is replaced by per-window bit tests. - `crates/xcl/src/gpu/recomp/tests.rs`: the two checks that looked for `switch (xcl_w)` look for the new form. **Tested** - RX 9070 XT (RDNA4), Mesa 26.3.1 RADV (ACO), Ryzen 5 8400F, 30 GB RAM, CachyOS kernel 7.3.6. Wine 11.0 Staging (GE-Proton), vkd3d-proton 3.1 with #257's patch and dxil-spirv `53aac418`. DXC 1.9.2609. rustc 1.99.1, release, cross-built for `x86_64-pc-windows-msvc`. Not Windows. - One retail program, `CS_RaytracingResolve` (console `84eee477d68b6fdf`, 1.28 MB of DXIL in the switch form), one cold pipeline build (`VKD3D_SHADER_CACHE_PATH=0`, empty caches): | form | DXC + pipeline | peak RSS | RADV registers | loop-header phis (NIR) | |---|---|---|---|---| | `main` (switch) | 103–140 s | 20.5 GB | ~3 840 SGPRs needed | 4 624 | | ifs on `xcl_w == k` | 61 s | – | 273 SGPRs, 192 VGPRs | 644 | | this PR (bit tests) | 39 s (DXC ~20 s) | 1.26 GB | 301 SGPRs, 192 VGPRs | 644 | (The register and phi counts come from a locally instrumented Mesa build. The times and memory are with the system Mesa.) - The retail pack's 2 689 compute programs, `xcl shaders shaders.rpf --precompile --only cs --pipelines`: 2 689 compiled, 0 errors, 2 689 pipelines made, 0 refused. This was on a local tree with this change on top of #1316, #1448 and #1288, not on this branch alone. In the switch form, the same pass ran out of memory on RADV in the `CS_RaytracingResolve` stretch for @⁠lucsoft (#1269). - `cargo test --workspace -- --test-threads=4` (release, Wine): **1 083 passed, 15 failed, 26 ignored**. SKIPPED: `f16_programs_on_the_gpu` / `f32_programs_on_the_gpu` (per-lane form refuses `V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`) and `pso_measurement_compiles_an_exact_synthetic_record` (no Developer Mode under Wine). - Each of the 15 was run again alone on `main` `568e7db` and on this branch, with identical results on both. 6 fail on both: `fuzz_validate_and_gpu_2`, `f64_programs_on_the_gpu`, `f32_programs_on_the_gpu`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`, `xma2_source_voice_decodes_and_manages_lifetime`. The other 9 pass alone on both; in the full run they failed because a device removal from another test took them out. - All memory-window GPU tests pass, among them `gpu_memory_windows_reject_out_of_uma_aliasing`, `gpu_mesh_mode_reads_memory_windows`, `gpu_memory_windows_above_4_gib` and `gpu_bvh64_intersect_ray_across_memory_windows_and_grazing`. **Regression run** `scripts/linux/smoke.sh` from #257 (it prints the block `smoke.ps1` prints), retail title, 300 s, the same button script. Each run had an empty DXIL cache, Mesa's shader cache off and `VKD3D_SHADER_CACHE_PATH=0`. In both runs presents had stopped before the end (`presents per 2 s (last 3): 0 0 0`). I have not checked where each run stopped. main: ```xcl-smoke xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: game_dump seconds: 300 exit: 0x0 frames shown: 2135 (PresentX 2135) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` this PR: ```xcl-smoke xcl-smoke v1 commit: fb84fde754d03463fcc56e424b2e6e79866e6b20 gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: game_dump seconds: 300 exit: 0x0 frames shown: 1885 (PresentX 1885) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** - Windows, and the AMD and NVIDIA Windows drivers. On NVIDIA the switch costs a lot of driver time (#1269), and I have not measured whether bit tests do better or worse there than the switch or @⁠pr1sm-dev's read-select form. - Other AMD generations on RADV, and the native-Windows test suite. - The direct DXIL path (`XCL_DIRECT_DXIL`), which picks its windows separately. **AI use** - Claude Code with Claude Opus 5.5: found the cause (with a locally instrumented Mesa), wrote the change and the test updates, ran the builds, the tests and the smoke runs on the machine above, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The accessors that pick a memory window (`xcl_mLoad`, `xcl_mStore`, the
atomics, `xcl_loadx4`) branched with `[branch] switch (xcl_w)` over the
root UAVs. Mesa's SPIR-V front end (vtn) lowers OpSwitch into a chain of
ifs with a path on which no case runs. In a loop, every accessor result
then becomes a loop-carried value that is undefined on entry, and RADV
has to keep all of them live around the loop. On a 1.28 MB-DXIL
CS_RaytracingResolve program (console 84eee477d68b6fdf), NIR had 4 624
loop-header phis where the SPIR-V had 204. ACO needed about 3 800 SGPRs,
and its spiller grew past 20 GB in 100-140 s (the out-of-memory builds
reported in #1269).

Each window is now one `[branch] if` on a value that is set before the
first one, so nothing is carried round the loop. The ifs test bits of a
one-hot mask, `wm = select(xcl_w < windows, 1u << xcl_w, 0u)`, not
`xcl_w == k`: with equality tests DXC's jump threading took 31 of 47 s
of the same program's compile. An `xcl_w` outside the windows sets no
bit and keeps the default, as the switch's `default` did. The heap form
(`XCL_HEAP_WINDOWS=1`) is unchanged.

That program on an RX 9070 XT, Mesa 26.3.1 RADV, vkd3d-proton
(VKD3D_SHADER_CACHE_PATH=0), one cold build:
- switch: 103-140 s, 20.5 GB peak, 3 840 SGPRs
- bit tests: 39 s (DXC about 20 s of it), 1.26 GB peak, 301 SGPRs,
  192 VGPRs; 644 loop-header phis in NIR

Part of #1269.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:22:33 +00:00
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 08:58 UTC · original

Independent native Windows compiler measurement on exact PR head fb84fde754d03463fcc56e424b2e6e79866e6b20 against the runtime-identical pre-PR source 6020a33b16ba2de25b3aef5947552f2dc1831f09. The diff from that source to PR base 568e7db7729c8fa6c8f0f4b32d798faaf11462bb changes only README/SVG, not compiler code. The PR release workspace build passed and its checkout is clean.

Environment: Windows 11 build 26200, Ryzen 9 5980HX, RX 6800M driver 30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. From a locally owned title pack, each XCL release executable exported the same compute record hash 84eee477d68b6fdf (CS_RaytracingResolve), with four root-UAV windows and --split 0. Both exports reported one program and zero errors. No title or shader bytes are attached here.

I compiled each exported HLSL file using dxc.exe -E main -T cs_6_6 -HV 2021 -O1 -Fo ...; these are the flags dxc::compile selects for a source of this size. I alternated three sequential runs per revision, with a memory guard that did not fire:

Source HLSL bytes DXIL bytes DXC wall seconds (three runs) Median Sampled peak DXC RSS
Pre-PR 4,278,297 1,288,592 32.438, 34.156, 35.969 34.156 s 643–693 MiB
PR head 4,281,101 1,509,652 40.265, 42.891, 37.781 40.265 s 779–787 MiB

All six DXC processes exited 0. On this Windows DXC path, the PR's median was 6.109 s / 17.9% longer and its DXIL was 221,060 bytes / 17.2% larger for this record. The sampled RSS is an approximate process measure, not total system commit. This differs from the Linux/RADV end-to-end improvement in the PR description; it does not measure or contradict the RADV driver result.

Scope: Exact-record HLSL generation and standalone native DXC compilation only. I did not run CreateComputePipelineState, measure a Windows driver pipeline, execute the shader, run the full test suite, or perform a retail-title smoke on this PR. The synthetic/root-UAV semantics and gameplay performance remain unverified here.

AI use: OpenAI Codex identified the record in the locally owned pack, built the PR, exported both HLSL variants, wrote and ran the bounded DXC measurement script, checked the exact revisions and numbers, and prepared this report.

**@⁠luckyteagirl** on GitHub · 2026-11-25 08:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191#issuecomment-7157715738) Independent native Windows compiler measurement on exact PR head `fb84fde754d03463fcc56e424b2e6e79866e6b20` against the runtime-identical pre-PR source `6020a33b16ba2de25b3aef5947552f2dc1831f09`. The diff from that source to PR base `568e7db7729c8fa6c8f0f4b32d798faaf11462bb` changes only README/SVG, not compiler code. The PR release workspace build passed and its checkout is clean. **Environment:** Windows 11 build 26200, Ryzen 9 5980HX, RX 6800M driver `30.0.13002.13003`, Rust 1.99.0 MSVC, DXC/DXIL 1.9.2609.5. From a locally owned title pack, each XCL release executable exported the *same* compute record hash `84eee477d68b6fdf` (`CS_RaytracingResolve`), with four root-UAV windows and `--split 0`. Both exports reported one program and zero errors. No title or shader bytes are attached here. I compiled each exported HLSL file using `dxc.exe -E main -T cs_6_6 -HV 2021 -O1 -Fo ...`; these are the flags `dxc::compile` selects for a source of this size. I alternated three sequential runs per revision, with a memory guard that did not fire: | Source | HLSL bytes | DXIL bytes | DXC wall seconds (three runs) | Median | Sampled peak DXC RSS | | --- | ---: | ---: | --- | ---: | ---: | | Pre-PR | 4,278,297 | 1,288,592 | 32.438, 34.156, 35.969 | 34.156 s | 643–693 MiB | | PR head | 4,281,101 | 1,509,652 | 40.265, 42.891, 37.781 | 40.265 s | 779–787 MiB | All six DXC processes exited 0. On this Windows DXC path, the PR's median was **6.109 s / 17.9% longer** and its DXIL was **221,060 bytes / 17.2% larger** for this record. The sampled RSS is an approximate process measure, not total system commit. This differs from the Linux/RADV end-to-end improvement in the PR description; it does not measure or contradict the RADV driver result. **Scope:** Exact-record HLSL generation and standalone native DXC compilation only. I did not run `CreateComputePipelineState`, measure a Windows driver pipeline, execute the shader, run the full test suite, or perform a retail-title smoke on this PR. The synthetic/root-UAV semantics and gameplay performance remain unverified here. AI use: OpenAI Codex identified the record in the locally owned pack, built the PR, exported both HLSL variants, wrote and ran the bounded DXC measurement script, checked the exact revisions and numbers, and prepared this report.
Author
Owner

@⁠bielfreedom on GitHub · 2026-11-25 09:51 UTC · original

AMD Windows driver data for #2191: on the RX 9070 XT, the bit-test form makes the DXIL 15 % larger and AMD's CreateComputePipelineState 1.56× slower on 24 large retail programs. CS_RaytracingResolve still doesn't finish on the HLSL path. This adds the driver side to @⁠luckyteagirl's DXC-only numbers above. The PR's gain is on RADV/ACO; on the native AMD Windows compiler it goes the other way.

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release, DXC 1.9.2609.
  • Builds:
    • base 568e7db;
    • this PR at fb84fde.
  • Both builds carry a local patch that logs per-program DXIL size, record hash (fnv64), DXC time and per-CreateComputePipelineState time.

Method

  • HLSL path (direct DXIL off), root-UAV windows (XCL_HEAP_WINDOWS=0), XCL_PIPELINE_THREADS=1, XCL_DXC_THREADS=1.
  • XCL_PSO_DISK_CACHE=0 and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name.
  • 24 retail compute programs from 8 KB to 1.0 MB of DXIL, the same set I used for earlier PRs. 2 rounds, interleaved; the rounds agree within 1 %.
  • A watchdog killed a run after 25 min or at 24 GB.

24 programs (means of 2 rounds; all 96 builds succeeded, 0 refused)

base #2191 change
DXIL, total 7,930,908 B 9,120,608 B +15.0 %
DXC, sum 192.9 s 224.2 s +16 %
driver, sum 128.5 s 201.0 s ×1.56
driver run, process peak private 4.48 GB 7.32 GB +63 %
  • 23 of the 24 programs grow by 4–19 % of DXIL. Driver time is within ±5 % on 9 of them and 8–26 % slower on most of the others.
  • Two programs dominate the change:
program DXIL base → PR driver base → PR
ed2f8fa2e996c6a6 1,024,664 → 1,206,152 B 20.9 → 53.8 s (×2.58)
c6f8ee0f53ed5709 917,236 → 1,077,452 B 18.7 → 46.1 s (×2.46)

84eee477d68b6fdf (CS_RaytracingResolve), 1 run each:

build DXIL DXC driver peak private
base 1,288,596 B 21.6 s not finished after 25 min (killed) 19.6 GB
#2191 1,509,660 B 25.6 s not finished after 25 min (killed) 22.9 GB

The DXIL sizes match luckyteagirl's (+17 %). Both builds were still working, at 9–11 GB private, when they were killed. So on AMD Windows the bit tests don't remove whatever stalls this program in the driver. The direct route (53 s whole, 7.8 s with #2107's split; data) remains the way through here.

Read / inference

  • The AMD Windows compiler takes the switch form better than the bit-test chain. It slows down more than the DXIL grows, so this is not size alone.
  • If this goes in for RADV, it might be worth keeping the switch on the native AMD (and maybe NVIDIA) Windows drivers. For example, the form could be chosen by a vendor or Vulkan-layer check, or by an env switch, so both paths can still be measured.

Not tested

  • The PR's unit tests on this card.
  • XCL_HEAP_WINDOWS=1 (unchanged by the PR).
  • The direct DXIL route (the PR changes HLSL emission only).
  • A title run.
  • RDNA2 and RDNA3.

AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this. The account owner is away; counts and timings only, no game data.

**@⁠bielfreedom** on GitHub · 2026-11-25 09:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191#issuecomment-7158898538) **AMD Windows driver data for #2191: on the RX 9070 XT, the bit-test form makes the DXIL 15 % larger and AMD's `CreateComputePipelineState` 1.56× slower on 24 large retail programs. `CS_RaytracingResolve` still doesn't finish on the HLSL path.** This adds the driver side to @⁠luckyteagirl's DXC-only numbers above. The PR's gain is on RADV/ACO; on the native AMD Windows compiler it goes the other way. **Setup** - GPU: RX 9070 XT 16 GB (RDNA4), AMD driver 32.0.32029.2010. - CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release, DXC 1.9.2609. - Builds: - base `568e7db`; - this PR at `fb84fde`. - Both builds carry a local patch that logs per-program DXIL size, record hash (`fnv64`), DXC time and per-`CreateComputePipelineState` time. **Method** - HLSL path (direct DXIL off), root-UAV windows (`XCL_HEAP_WINDOWS=0`), `XCL_PIPELINE_THREADS=1`, `XCL_DXC_THREADS=1`. - `XCL_PSO_DISK_CACHE=0` and a fresh exe name per run, because the AMD driver cache is keyed on the exe file name. - 24 retail compute programs from 8 KB to 1.0 MB of DXIL, the same set I used for earlier PRs. 2 rounds, interleaved; the rounds agree within 1 %. - A watchdog killed a run after 25 min or at 24 GB. **24 programs** (means of 2 rounds; all 96 builds succeeded, 0 refused) | | base | #2191 | change | |---|---:|---:|---:| | DXIL, total | 7,930,908 B | 9,120,608 B | **+15.0 %** | | DXC, sum | 192.9 s | 224.2 s | +16 % | | driver, sum | 128.5 s | **201.0 s** | **×1.56** | | driver run, process peak private | 4.48 GB | 7.32 GB | +63 % | - 23 of the 24 programs grow by 4–19 % of DXIL. Driver time is within ±5 % on 9 of them and 8–26 % slower on most of the others. - Two programs dominate the change: | program | DXIL base → PR | driver base → PR | |---|---:|---:| | `ed2f8fa2e996c6a6` | 1,024,664 → 1,206,152 B | 20.9 → **53.8 s** (×2.58) | | `c6f8ee0f53ed5709` | 917,236 → 1,077,452 B | 18.7 → **46.1 s** (×2.46) | **`84eee477d68b6fdf` (`CS_RaytracingResolve`)**, 1 run each: | build | DXIL | DXC | driver | peak private | |---|---:|---:|---|---:| | base | 1,288,596 B | 21.6 s | **not finished after 25 min** (killed) | 19.6 GB | | #2191 | 1,509,660 B | 25.6 s | **not finished after 25 min** (killed) | 22.9 GB | The DXIL sizes match luckyteagirl's (+17 %). Both builds were still working, at 9–11 GB private, when they were killed. So on AMD Windows the bit tests don't remove whatever stalls this program in the driver. The direct route (53 s whole, 7.8 s with #2107's split; [data](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1809)) remains the way through here. **Read / inference** - The AMD Windows compiler takes the switch form better than the bit-test chain. It slows down more than the DXIL grows, so this is not size alone. - If this goes in for RADV, it might be worth keeping the switch on the native AMD (and maybe NVIDIA) Windows drivers. For example, the form could be chosen by a vendor or Vulkan-layer check, or by an env switch, so both paths can still be measured. **Not tested** - The PR's unit tests on this card. - `XCL_HEAP_WINDOWS=1` (unchanged by the PR). - The direct DXIL route (the PR changes HLSL emission only). - A title run. - RDNA2 and RDNA3. AI use: Claude Code (Claude Opus 5.5) ran the measurements and drafted this. The account owner is away; counts and timings only, no game data.
Author
Owner

@⁠zohaiblazuli on GitHub · 2026-11-25 14:32 UTC · original

Data for the cost this PR targets, measured on main 1a0bbe3 (not on this PR's head): #2088 comment. RTX 3060 (NVIDIA 617.42), 8 compute programs, cold driver builds. Replacing switch (xcl_w) with switch (0u) (wrong results; an upper bound) makes the build 1.6–6.2× shorter.

The largest gap left after the heap form is on the 5 MB outlier 219287eb2f6021fe: 819 s with the switch, 434 s heap, 133 s for the bound. A timing of this PR on that program would show how much of it this form recovers.

AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.

**@⁠zohaiblazuli** on GitHub · 2026-11-25 14:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191#issuecomment-7165436319) Data for the cost this PR targets, measured on `main` `1a0bbe3` (not on this PR's head): [#2088 comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/2088). RTX 3060 (NVIDIA 617.42), 8 compute programs, cold driver builds. Replacing `switch (xcl_w)` with `switch (0u)` (wrong results; an upper bound) makes the build 1.6–6.2× shorter. The largest gap left after the heap form is on the 5 MB outlier `219287eb2f6021fe`: 819 s with the switch, 434 s heap, 133 s for the bound. A timing of this PR on that program would show how much of it this form recovers. AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.
Author
Owner

@⁠siam4201 on GitHub · 2026-11-25 15:56 UTC · original

Tested on NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2101, Ryzen 9 7900X, Rust 1.97.1), including a cold PSO benchmark on a large compute outlier from a retail pack (83a0f0eec0ddb740):

Cold PSO benchmark (--measure-pso 83a0f0eec0ddb740 --repeat 2)

  • main (568e7db): 263716 bytes DXIL, 3053 ms DXC, median 10.442 s (min 9.418 s, max 11.465 s)
  • pr-2191 (fb84fde): 312640 bytes DXIL, 2428 ms DXC, median 6.383 s (min 5.855 s, max 6.911 s) — ~38.9% faster cold driver compile (~20.5% faster DXC)

Tested (.\scripts\test.ps1)

  • pr-2191 (fb84fde): 1094 passed, 4 failed (pre-existing fuzz_validate_and_gpu_0..3 E_OUTOFMEMORY #1905, same as main 568e7db), 26 ignored
  • Skipped GPU tests on this adapter: 14 no wave64, 3 per-lane form: refused (V_CVT_F16_F32, V_MUL_F16, V_PK_MUL_F16)

Regression run (.\scripts\smoke.ps1, 30s)

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 30
exit: 0x0
frames shown: 740 (PresentX 740)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15434 MB

pr-2191:

xcl-smoke v1
commit: fb84fde754d03463fcc56e424b2e6e79866e6b20
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 30
exit: 0x0
frames shown: 660 (PresentX 660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15887 MB

Not tested

  • Not tested on AMD RDNA / wave64 GPUs

AI use

  • Antigravity (Gemini 4 Neon)
**@⁠siam4201** on GitHub · 2026-11-25 15:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191#issuecomment-7167448771) Tested on **NVIDIA GeForce RTX 5070 Ti** (driver `32.0.16.2101`, Ryzen 9 7900X, Rust `1.97.1`), including a cold PSO benchmark on a large compute outlier from a retail pack (`83a0f0eec0ddb740`): **Cold PSO benchmark (`--measure-pso 83a0f0eec0ddb740 --repeat 2`)** - `main` (`568e7db`): `263716 bytes DXIL`, `3053 ms DXC`, median **`10.442 s`** (`min 9.418 s, max 11.465 s`) - `pr-2191` (`fb84fde`): `312640 bytes DXIL`, `2428 ms DXC`, median **`6.383 s`** (`min 5.855 s, max 6.911 s`) — **~38.9% faster** cold driver compile (~20.5% faster DXC) **Tested (`.\scripts\test.ps1`)** - `pr-2191` (`fb84fde`): 1094 passed, 4 failed (pre-existing `fuzz_validate_and_gpu_0..3` `E_OUTOFMEMORY` #1905, same as `main` `568e7db`), 26 ignored - Skipped GPU tests on this adapter: 14 `no wave64`, 3 `per-lane form: refused` (`V_CVT_F16_F32`, `V_MUL_F16`, `V_PK_MUL_F16`) **Regression run (`.\scripts\smoke.ps1`, 30s)** `main`: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 30 exit: 0x0 frames shown: 740 (PresentX 740) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15434 MB ``` `pr-2191`: ``` xcl-smoke v1 commit: fb84fde754d03463fcc56e424b2e6e79866e6b20 gpu: NVIDIA GeForce RTX 5070 Ti title: 9cc6a39e seconds: 30 exit: 0x0 frames shown: 660 (PresentX 660) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15887 MB ``` **Not tested** - Not tested on AMD RDNA / wave64 GPUs **AI use** - Antigravity (Gemini 4 Neon)
Author
Owner

@⁠afpruivo on GitHub · 2026-11-25 21:32 UTC · original

Native Windows NVIDIA result: #2191 slowed seven of eight cold driver builds on an RTX 3090.

RTX 3090 24 GB, NVIDIA 621.40, Windows 11 build 26300, i5-13600K, DXC 1.8.2502.11. All four arms use main 68a284a, with PR #2191 head fb84fde and PR #1380 head 7d43a46 merged locally. The #1380 merge kept main’s coherent_mem and the PR’s flat gate. One cold CreateComputePipelineState measurement per record and arm, four windows, caches disabled. Runtime and workspace tests were outside this measurement.

Record Switch (s) Heap (s) #2191 bit tests (s) #1380 flat loads (s)
1b0362e416b36cba 6.032 4.669 7.291 5.946
26fad5fd65eaf255 11.449 4.611 13.348 7.722
062468c09af883b9 51.006 33.883 60.331 41.128
73fb752d7f62c3a5 59.174 44.025 66.595 49.118
1623a8c07824a06c 106.975 20.151 112.671 31.751
2d2bbb32f64e4801 139.678 21.682 157.105 31.440
f9d73adcc1ad69ef 203.328 34.740 234.329 130.125
219287eb2f6021fe 1079.463 347.000 955.349 505.207
Sum 1657.1 510.8 1607.0 802.4

The bit-test arm took 1.05–1.21× as long on seven records. The largest record improved by 11.5%, enough to lower the total by 3.0%. Aggregate DXIL grew from 14.95 to 16.86 MB (+12.7%), DXC time rose 9.6%, and peak private memory on the largest record rose from 9.37 to 11.32 GB. The comparison is consistent with per-window branches contributing to driver compile cost. The flat-load arm also changes the memory access pattern, so this run does not isolate that effect.

AI disclosure: OpenCode ran the benchmark and drafted the report. ChatGPT checked the figures against the saved matrix and posted at my request.

**@⁠afpruivo** on GitHub · 2026-11-25 21:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2191#issuecomment-7175204061) **Native Windows NVIDIA result: #2191 slowed seven of eight cold driver builds on an RTX 3090.** RTX 3090 24 GB, NVIDIA 621.40, Windows 11 build 26300, i5-13600K, DXC 1.8.2502.11. All four arms use main `68a284a`, with PR #2191 head `fb84fde` and PR #1380 head `7d43a46` merged locally. The #1380 merge kept main’s `coherent_mem` and the PR’s flat gate. One cold `CreateComputePipelineState` measurement per record and arm, four windows, caches disabled. Runtime and workspace tests were outside this measurement. | Record | Switch (s) | Heap (s) | #2191 bit tests (s) | #1380 flat loads (s) | |---|---:|---:|---:|---:| | `1b0362e416b36cba` | 6.032 | 4.669 | 7.291 | 5.946 | | `26fad5fd65eaf255` | 11.449 | 4.611 | 13.348 | 7.722 | | `062468c09af883b9` | 51.006 | 33.883 | 60.331 | 41.128 | | `73fb752d7f62c3a5` | 59.174 | 44.025 | 66.595 | 49.118 | | `1623a8c07824a06c` | 106.975 | 20.151 | 112.671 | 31.751 | | `2d2bbb32f64e4801` | 139.678 | 21.682 | 157.105 | 31.440 | | `f9d73adcc1ad69ef` | 203.328 | 34.740 | 234.329 | 130.125 | | `219287eb2f6021fe` | 1079.463 | 347.000 | 955.349 | 505.207 | | **Sum** | **1657.1** | **510.8** | **1607.0** | **802.4** | The bit-test arm took 1.05–1.21× as long on seven records. The largest record improved by 11.5%, enough to lower the total by 3.0%. Aggregate DXIL grew from 14.95 to 16.86 MB (+12.7%), DXC time rose 9.6%, and peak private memory on the largest record rose from 9.37 to 11.32 GB. The comparison is consistent with per-window branches contributing to driver compile cost. The flat-load arm also changes the memory access pattern, so this run does not isolate that effect. *AI disclosure: OpenCode ran the benchmark and drafted the report. ChatGPT checked the figures against the saved matrix and posted at my request.*
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/emit.rs
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.
git fetch -u origin '+refs/pull/2191/head:github-bot/gh-2191'
git switch 'github-bot/gh-2191'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2191'
git switch 'github-bot/gh-2191'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2191'
git switch 'github-bot/gh-2191'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2191'
git switch 'main'
git merge --squash 'github-bot/gh-2191'
git switch 'main'
git merge --ff-only 'github-bot/gh-2191'
git switch 'main'
git merge 'github-bot/gh-2191'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.