Recompiler: compress batched DXIL replacement chains #2069

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

@⁠ifBars on GitHub · 2026-11-25 02:46 UTC · original
ifBars:shaders/compress-replacements → main · +71 −5 · 2 files · 1 commits · open

Cascaded trivial phis can make Module::replace_uses walk the same replacement tail for every operand. Resolve encountered chains once in a local map, preserving the caller's map and output. Part of #1269 and #1833. Scope and measurements plan.

What is in it

  • gpu/dxil/module.rs: iterative path compression in a local map copy; unmapped operands still take one lookup.
  • gpu/dxil/tests.rs: chained/shared replacements, repeated uses, metadata and caller-map preservation, checked against flattened maps and DXIL validation.

Tested

  • RTX 3060 Ti, driver 32.0.16.1088; i5-11600K; Windows 10 19045; Rust 1.97.1 MSVC; Agility 1.620.2; DXC/DXIL 1.8.2502.11. Debug tests, release measurements.
  • scripts/test.ps1 --nocapture (workspace build and cargo test --workspace -- --test-threads=4 --nocapture): 1,155 passed, 0 failed, 46 ignored. 24 SKIPPED messages: 20 native-wave64 cases, 3 existing per-lane instruction refusals, 1 heap-window case. Main: 1,154/0/46 with the same skips.
  • Standalone release harness calling the actual Module::replace_uses, setup/serialization excluded, alternating order: 1,024-link synthetic chain 23.85 → 0.144 ms (5 trials); 16,384 links 8,153.92 → 3.149 ms (3 trials). Flat-map control at 16,384 entries: 1.740 → 2.031 ms (9 trials), a regression from copying the map. All 36 generated bitcode pairs identical, including the 1,024-entry flat control.
  • 64 retail compute programs sampled by size quantiles, three alternating process pairs: matching digests of every analysis field/refusal and all 75 native/split lowering results. Each pair produced 27 containers with matching FNV64 digests over DXIL and static samplers; all 27 validated. Median cumulative lowering 611.7 → 607.2 ms, within the observed variation.

Regression run
Retail regression blocked. Clean main and head both fault during startup at title offset +0xb5a5f8, reading 0x68. No world-load or driver-compile improvement measured. Command on each revision: scripts/smoke.ps1 -Game <title> -Seconds 60 -Xcl <release exe>, with XCL_DIRECT_DXIL=1 XCL_PER_LANE=1, Agility SDK configured, separate fresh data/cache roots; the script disables networking. The unchanged generated blocks follow.

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 22 59 15
device removals: 0
crashes: 3
peak commit: 8913 MB
xcl-smoke v1
commit: 9d2758fa31d482ad8a89473ca8df02d760d1ee92
gpu: NVIDIA GeForce RTX 3060 Ti
title: 9cc6a39e
seconds: 60
exit: 0xc0000005
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 0 19 29
device removals: 0
crashes: 3
peak commit: 8610 MB

Not tested

  • Successful 60-second retail regression or world loading; the startup fault prevents both. PR description check is expected to reject these smoke runs.
  • AMD/Intel/native wave64 hardware; per-lane lowering of sampled programs over 64 KiB; data-dependent XCL_SAMPLE_* suite cases (variables unset).

AI use

  • OpenAI Codex (GPT-6) investigated, wrote and reviewed the change/tests, ran the commands and drafted this description.
**@⁠ifBars** on GitHub · 2026-11-25 02:46 UTC · [original](https://github.com/xcl-dev/xcl/pull/2069) `ifBars:shaders/compress-replacements` → `main` · +71 −5 · 2 files · 1 commits · open Cascaded trivial phis can make `Module::replace_uses` walk the same replacement tail for every operand. Resolve encountered chains once in a local map, preserving the caller's map and output. Part of #1269 and #1833. [Scope and measurements plan](https://git.gtahub.st/github/xcl-dev--xcl/issues/1269). **What is in it** - `gpu/dxil/module.rs`: iterative path compression in a local map copy; unmapped operands still take one lookup. - `gpu/dxil/tests.rs`: chained/shared replacements, repeated uses, metadata and caller-map preservation, checked against flattened maps and DXIL validation. **Tested** - RTX 3060 Ti, driver 32.0.16.1088; i5-11600K; Windows 10 19045; Rust 1.97.1 MSVC; Agility 1.620.2; DXC/DXIL 1.8.2502.11. Debug tests, release measurements. - `scripts/test.ps1 --nocapture` (workspace build and `cargo test --workspace -- --test-threads=4 --nocapture`): **1,155 passed, 0 failed, 46 ignored**. 24 SKIPPED messages: 20 native-wave64 cases, 3 existing per-lane instruction refusals, 1 heap-window case. Main: 1,154/0/46 with the same skips. - Standalone release harness calling the actual `Module::replace_uses`, setup/serialization excluded, alternating order: 1,024-link synthetic chain **23.85 → 0.144 ms** (5 trials); 16,384 links **8,153.92 → 3.149 ms** (3 trials). Flat-map control at 16,384 entries: **1.740 → 2.031 ms** (9 trials), a regression from copying the map. All 36 generated bitcode pairs identical, including the 1,024-entry flat control. - 64 retail compute programs sampled by size quantiles, three alternating process pairs: matching digests of every analysis field/refusal and all 75 native/split lowering results. Each pair produced 27 containers with matching FNV64 digests over DXIL and static samplers; all 27 validated. Median cumulative lowering **611.7 → 607.2 ms**, within the observed variation. **Regression run** **Retail regression blocked.** Clean main and head both fault during startup at title offset `+0xb5a5f8`, reading `0x68`. No world-load or driver-compile improvement measured. Command on each revision: `scripts/smoke.ps1 -Game <title> -Seconds 60 -Xcl <release exe>`, with `XCL_DIRECT_DXIL=1 XCL_PER_LANE=1`, Agility SDK configured, separate fresh data/cache roots; the script disables networking. The unchanged generated blocks follow. ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 60 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 22 59 15 device removals: 0 crashes: 3 peak commit: 8913 MB ``` ``` xcl-smoke v1 commit: 9d2758fa31d482ad8a89473ca8df02d760d1ee92 gpu: NVIDIA GeForce RTX 3060 Ti title: 9cc6a39e seconds: 60 exit: 0xc0000005 frames shown: none logged (the run did not reach its end) presents per 2 s (last 3): 0 19 29 device removals: 0 crashes: 3 peak commit: 8610 MB ``` **Not tested** - Successful 60-second retail regression or world loading; the startup fault prevents both. PR description check is expected to reject these smoke runs. - AMD/Intel/native wave64 hardware; per-lane lowering of sampled programs over 64 KiB; data-dependent `XCL_SAMPLE_*` suite cases (variables unset). **AI use** - OpenAI Codex (GPT-6) investigated, wrote and reviewed the change/tests, ran the commands and drafted this description.
Cascaded trivial phis can share long replacement tails. Resolve each encountered chain once in a local map instead of following it again for every instruction operand and metadata value. Preserve the supplied map and emitted bitcode.

Part of #1269; part of #1833.

Assisted-by: OpenAI Codex (GPT-6)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:17:26 +00:00
Author
Owner

@⁠Parakeet-Wheat on GitHub · 2026-11-25 04:18 UTC · original

NVIDIA RTX 3070 on native Windows, head 9d2758f on its base cbc296a (current main): the new test passes on the head and, as expected for a change that keeps the output the same, on the base too; the whole suite passes and the smoke pair is within the limits. The first independent run on this PR.

Tested

  • NVIDIA GeForce RTX 3070 8 GB (driver 610.88, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head 9d2758f (one commit on main cbc296a), checked out clean. Tests in the debug profile, smoke in release.
  • cargo test -p xcl --lib replacement_chains_match_flattened_maps -- --nocapture --test-threads=1:
    • on cbc296a with only the PR's tests.rs copied in: 1 passed, 0 failed (0.14 s). It does not fail without the change, because the output is meant to be identical; it checks that the new code keeps it so (chains of 1, 32 and 1024 against the flattened maps, the caller's map unchanged, DXIL validation);
    • on 9d2758f: 1 passed, 0 failed (0.02 s). One run each, so the two times are an observation, not a measurement.
  • .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4) on 9d2758f: 1155 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 × no wave64, 3 × per-lane form refused (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16: "its #1426 semantics differ from the console's"), 1 × no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).

Regression run (scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited). main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1529 (PresentX 1530)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17869 MB

PR head 9d2758f:

xcl-smoke v1
commit: 9d2758fa31d482ad8a89473ca8df02d760d1ee92
gpu: NVIDIA GeForce RTX 3070
title: 3d7db37d
seconds: 60
exit: 0x0
frames shown: 1440 (PresentX 1441)
presents per 2 s (last 3): 60 60 33
device removals: 0
crashes: 0
peak commit: 18336 MB

That is 94 % of main's frames and 103 % of its peak commit. One run each; I did not repeat either, so the 6 % is within what I would expect between two runs of the same build, but I have not shown that.

Not tested

  • The timings in the PR text (the release harness for 1,024 and 16,384 links, and the flat-map control that gets slower), a world run, AMD, native wave64 (the 20 no wave64 skips above), the tests on game data (XCL_SAMPLE_* not set).
  • The PR's "PR description" check is red on all 5 runs; I did not look into it.

AI use

  • Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.
**@⁠Parakeet-Wheat** on GitHub · 2026-11-25 04:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2069#issuecomment-7152725508) NVIDIA RTX 3070 on native Windows, head `9d2758f` on its base `cbc296a` (current `main`): the new test passes on the head and, as expected for a change that keeps the output the same, on the base too; the whole suite passes and the smoke pair is within the limits. The first independent run on this PR. **Tested** - NVIDIA GeForce RTX 3070 8 GB (driver `610.88`, 32-lane waves), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0 `stable-x86_64-pc-windows-msvc`, DXC 1.8.2502.11, retail 1.0.2.1. Head `9d2758f` (one commit on `main` `cbc296a`), checked out clean. Tests in the debug profile, smoke in release. - `cargo test -p xcl --lib replacement_chains_match_flattened_maps -- --nocapture --test-threads=1`: - on `cbc296a` with only the PR's `tests.rs` copied in: **1 passed**, 0 failed (0.14 s). It does not fail without the change, because the output is meant to be identical; it checks that the new code keeps it so (chains of 1, 32 and 1024 against the flattened maps, the caller's map unchanged, DXIL validation); - on `9d2758f`: **1 passed**, 0 failed (0.02 s). One run each, so the two times are an observation, not a measurement. - `.\scripts\test.ps1` (`cargo build --workspace`, then `cargo test --workspace -- --test-threads=4`) on `9d2758f`: **1155 passed, 0 failed, 46 ignored**, exit 0. SKIPPED, 25: 20 × `no wave64`, 3 × per-lane form refused (`V_CVT_F16_F32`, `V_PK_MUL_F16`, `V_MUL_F16`: "its #1426 semantics differ from the console's"), 1 × `no heap windows`, 1 × cannot disable the driver cache (Windows Developer Mode required). **Regression run** (`scripts/smoke.ps1 -Game <folder> -Seconds 60`, the same title, back to back, menus, no input; unedited). `main` `cbc296a`: ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 3070 title: 3d7db37d seconds: 60 exit: 0x0 frames shown: 1529 (PresentX 1530) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17869 MB ``` PR head `9d2758f`: ``` xcl-smoke v1 commit: 9d2758fa31d482ad8a89473ca8df02d760d1ee92 gpu: NVIDIA GeForce RTX 3070 title: 3d7db37d seconds: 60 exit: 0x0 frames shown: 1440 (PresentX 1441) presents per 2 s (last 3): 60 60 33 device removals: 0 crashes: 0 peak commit: 18336 MB ``` That is 94 % of `main`'s frames and 103 % of its peak commit. One run each; I did not repeat either, so the 6 % is within what I would expect between two runs of the same build, but I have not shown that. **Not tested** - The timings in the PR text (the release harness for 1,024 and 16,384 links, and the flat-map control that gets slower), a world run, AMD, native wave64 (the 20 `no wave64` skips above), the tests on game data (`XCL_SAMPLE_*` not set). - The PR's "PR description" check is red on all 5 runs; I did not look into it. **AI use** - Claude Code (Claude Sonnet 5.5) ran the tests and wrote this report. The account owner has not reviewed it.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 05:09 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!

**@⁠DavidM1911** on GitHub · 2026-11-25 05:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/2069#issuecomment-7153508113) 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!
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 14:49 UTC · original

amd-win test report for head 9d2758fa31d482ad8a89473ca8df02d760d1ee92

Setup

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke
  • Tested as a local merge of the PR head onto main 06c9f5505f63f10c5ec49ef932d75b2c28177324 (merge commit b0a250ba3b411b1a6f0ae2cbcfe285c3db66c1f8; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit.

Tests

  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 1265 passed, 1 failed, 46 ignored, 7 SKIPPED lines (f16/f32 per-lane form, no heap windows)
  • The 1 failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] GPU 0x1 vs CPU 0x7fffffff). It fails the same way on main (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR.
  • The PR's new test gpu::dxil::tests::replacement_chains_match_flattened_maps passes.

Regression run (60 s, same title, networking off; main first, then the merge)

xcl-smoke v1  main 06c9f5505f63f10c5ec49ef932d75b2c28177324
frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB
xcl-smoke v1  merge b0a250ba3b411b1a6f0ae2cbcfe285c3db66c1f8
frames shown: 1576, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 15131 MB

Exit code 0x0 on both. The full xcl-smoke blocks are not pasted because of the merge-commit caveat above.

Not tested

  • Not measured: the compile-time effect of the chain compression on a large real shader; the smoke run only shows no regression.
  • NVIDIA, wave32-only GPUs.

AI use: this run and report were done by Claude Code (Claude Sonnet 5.5).

**@⁠oni-swr** on GitHub · 2026-11-25 14:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/2069#issuecomment-7165871098) **amd-win test report** for head `9d2758fa31d482ad8a89473ca8df02d760d1ee92` **Setup** - AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 (build 26200), rustc 1.100.0, debug build for tests, release for smoke - Tested as a local merge of the PR head onto `main` `06c9f5505f63f10c5ec49ef932d75b2c28177324` (merge commit `b0a250ba3b411b1a6f0ae2cbcfe285c3db66c1f8`; it merged without conflicts). That is not the PR head itself, so the smoke block below names the merge commit. **Tests** - `cargo build --workspace` then `cargo test --workspace --no-fail-fast -- --test-threads=4`: **1265 passed, 1 failed, 46 ignored**, 7 `SKIPPED` lines (f16/f32 per-lane form, no heap windows) - The 1 failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 722: `res[30]` GPU 0x1 vs CPU 0x7fffffff). It fails the same way on `main` (1264 passed, 1 failed, 46 ignored), so it is not caused by this PR. - The PR's new test `gpu::dxil::tests::replacement_chains_match_flattened_maps` passes. **Regression run** (60 s, same title, networking off; `main` first, then the merge) ``` xcl-smoke v1 main 06c9f5505f63f10c5ec49ef932d75b2c28177324 frames shown: 1540, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 16495 MB xcl-smoke v1 merge b0a250ba3b411b1a6f0ae2cbcfe285c3db66c1f8 frames shown: 1576, presents per 2 s (last 3): 60 60 60, device removals: 0, crashes: 0, peak commit: 15131 MB ``` Exit code 0x0 on both. The full `xcl-smoke` blocks are not pasted because of the merge-commit caveat above. **Not tested** - Not measured: the compile-time effect of the chain compression on a large real shader; the smoke run only shows no regression. - NVIDIA, wave32-only GPUs. **AI use:** this run and report were done by Claude Code (Claude Sonnet 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2069/head:github-bot/gh-2069'
git switch 'github-bot/gh-2069'

Merge

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