Direct DXIL: unused raw loads and f16 conversions are dropped #2202

Closed
tibzejoker wants to merge 1 commit from upstream-pr/2212 into main
tibzejoker commented 2026-11-25 09:58:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tibzejoker on 2026-11-25T09:58:17Z.


Module::optimize kept unused dx.op.rawBufferLoad and dx.op.legacyF16ToF32 calls: neither is in the list of calls dead-code removal may take. A raw load sets RawAndStructuredBuffers while the module is built, so when every raw load of a program is unused the first one stays and the flags still match the code. Part of #1269 (claimed here).

On 573 sampled programs (xcl shaders shaders.rpf --direct --sample 600 --seed 3 --max-bytes 40000 --validate, XCL_HEAP_WINDOWS=1), all validator-clean before and after:

main 568e7db this PR
direct DXIL 42 189 920 B 41 558 656 B (−1.5 %)
instructions (dxc -dumpbin) 5 704 098 5 660 172 (−0.8 %)

A small gain: about 21 000 unused raw loads and 3 100 unused f16 conversions in that sample.

What is in it

  • crates/xcl/src/gpu/dxil/module/opt.rs: removable takes dx.op.rawBufferLoad.* and dx.op.legacyF16ToF32; after liveness, one raw load is kept when none is live. Test unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays (fails without the change).

Tested

  • NVIDIA GeForce RTX 4090 (driver 621.01), Windows 11 Pro 26200, rustc 1.100.0, release build for the smoke runs and the sweep.
  • cargo test --workspace -- --test-threads=4 (through scripts/test.ps1): 1155 passed, 0 failed, 46 ignored.
  • SKIPPED GPU tests on this adapter (32-lane waves only, 24 lines): 7 no wave64, 13 wave64 variants of the instruction tests, 1 no heap windows, 3 per-lane f16 refusals (V_CVT_F16_F32, V_PK_MUL_F16, V_MUL_F16).
  • The sweep above with --validate: 573 / 573 translated, 0 validator errors, before and after.

Regression run

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4090
title: 82c27de1
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1488)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16522 MB

This PR:

xcl-smoke v1
commit: b09f06d50b793bb538dbddf883b3c736853a867e
gpu: NVIDIA GeForce RTX 4090
title: 82c27de1
seconds: 60
exit: 0x0
frames shown: 1631 (PresentX 1631)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16065 MB

Not tested

  • AMD and wave64 hardware.
  • The 60 s smoke runs stay in the menus, where few programs take the direct path (huge compute programs since #1809); the change only touches the direct backend's output.
  • Driver compile times: at −0.8 % of instructions I did not time them.

AI use

  • Claude Code (Claude Opus 5.5): found the unused calls by attributing DXIL instructions to console opcodes, wrote the change and the test, ran the suite, the sweep and the smoke pair on this machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5489081650 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-11-25T09:58:17Z. --- `Module::optimize` kept unused `dx.op.rawBufferLoad` and `dx.op.legacyF16ToF32` calls: neither is in the list of calls dead-code removal may take. A raw load sets `RawAndStructuredBuffers` while the module is built, so when every raw load of a program is unused the first one stays and the flags still match the code. Part of #1269 (claimed [here](https://github.com/xcl-dev/xcl/issues/1269#issuecomment-7158839148)). On 573 sampled programs (`xcl shaders shaders.rpf --direct --sample 600 --seed 3 --max-bytes 40000 --validate`, `XCL_HEAP_WINDOWS=1`), all validator-clean before and after: | | `main` 568e7db | this PR | |---|---:|---:| | direct DXIL | 42 189 920 B | 41 558 656 B (−1.5 %) | | instructions (`dxc -dumpbin`) | 5 704 098 | 5 660 172 (−0.8 %) | A small gain: about 21 000 unused raw loads and 3 100 unused f16 conversions in that sample. **What is in it** - `crates/xcl/src/gpu/dxil/module/opt.rs`: `removable` takes `dx.op.rawBufferLoad.*` and `dx.op.legacyF16ToF32`; after liveness, one raw load is kept when none is live. Test `unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays` (fails without the change). **Tested** - NVIDIA GeForce RTX 4090 (driver 621.01), Windows 11 Pro 26200, rustc 1.100.0, release build for the smoke runs and the sweep. - `cargo test --workspace -- --test-threads=4` (through `scripts/test.ps1`): 1155 passed, 0 failed, 46 ignored. - SKIPPED GPU tests on this adapter (32-lane waves only, 24 lines): 7 `no wave64`, 13 wave64 variants of the instruction tests, 1 `no heap windows`, 3 per-lane f16 refusals (`V_CVT_F16_F32`, `V_PK_MUL_F16`, `V_MUL_F16`). - The sweep above with `--validate`: 573 / 573 translated, 0 validator errors, before and after. **Regression run** `main`: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 4090 title: 82c27de1 seconds: 60 exit: 0x0 frames shown: 1488 (PresentX 1488) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16522 MB ``` This PR: ``` xcl-smoke v1 commit: b09f06d50b793bb538dbddf883b3c736853a867e gpu: NVIDIA GeForce RTX 4090 title: 82c27de1 seconds: 60 exit: 0x0 frames shown: 1631 (PresentX 1631) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16065 MB ``` **Not tested** - AMD and wave64 hardware. - The 60 s smoke runs stay in the menus, where few programs take the direct path (huge compute programs since #1809); the change only touches the direct backend's output. - Driver compile times: at −0.8 % of instructions I did not time them. **AI use** - Claude Code (Claude Opus 5.5): found the unused calls by attributing DXIL instructions to console opcodes, wrote the change and the test, ran the suite, the sweep and the smoke pair on this machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DarkPanda69 commented 2026-11-25 10:10:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T10:06:55Z.


AMD with native wave64 (listed as untested), plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite, since this changes the direct backend's output for every program.

Head b09f06d applied on main 568e7db, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) 583 passed, 3 failed, 22 ignored, 6 SKIPPED 584 passed, 3 failed, 22 ignored, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32, split wave64) 585 passed, 1 failed, 22 ignored, 23 SKIPPED 586 passed, 1 failed, 22 ignored, 23 SKIPPED

Per-test comparison: on both cards the only difference is the new unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays (ok). No existing test changes result or skip state. The failures are the same on main: gpu_image_get_resinfo_1d_array on both cards (the direct-path bug #2046 fixes) and, on the RX 9070 XT only, the fuzz seeds 722 and 1599 tracked in #2115.

Not tested: a title with XCL_DIRECT_DXIL=1, driver compile time.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7159244955 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7159244955). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T10:06:55Z. --- AMD with native wave64 (listed as untested), plus an RTX 3060, paired against `main` with the direct translator on for the whole GPU suite, since this changes the direct backend's output for every program. Head `b09f06d` applied on `main` `568e7db`, debug, Windows 11 Pro 26200, `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4`, on `main` and on this PR for each card: | | `main` | this PR | |---|---|---| | RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) | 583 passed, 3 failed, 22 ignored, 6 SKIPPED | 584 passed, 3 failed, 22 ignored, 6 SKIPPED | | RTX 3060 (32.0.16.1088, wave32, split wave64) | 585 passed, 1 failed, 22 ignored, 23 SKIPPED | 586 passed, 1 failed, 22 ignored, 23 SKIPPED | Per-test comparison: on both cards the only difference is the new `unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays` (ok). No existing test changes result or skip state. The failures are the same on `main`: `gpu_image_get_resinfo_1d_array` on both cards (the direct-path bug #2046 fixes) and, on the RX 9070 XT only, the fuzz seeds 722 and 1599 tracked in #2115. Not tested: a title with `XCL_DIRECT_DXIL=1`, driver compile time. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
tibzejoker commented 2026-11-25 11:08:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tibzejoker on 2026-11-25T10:10:48Z.


@DarkPanda69 Thanks for running it on RDNA4 and the 3060 with XCL_DIRECT_DXIL=1. That covers the AMD and native wave64 side I listed as untested.

<!-- greyfinch-sync:ivall/xcl:comment:7159335055 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7159335055). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-11-25T10:10:48Z. --- @DarkPanda69 Thanks for running it on RDNA4 and the 3060 with `XCL_DIRECT_DXIL=1`. That covers the AMD and native wave64 side I listed as untested.
raylitebull commented 2026-11-25 11:09:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:46:59Z.


Diff review on b09f06d (crates/xcl/src/gpu/dxil/module/opt.rs) looks clean, CI passed, and both NVIDIA (RTX 4090 / RTX 3060) and AMD (RX 9070 XT) runs passed.

b09f06d now conflicts in opt.rs after #2194 (simplify_cfg) landed on main — please rebase onto main so we can get CI green and merge.

<!-- greyfinch-sync:ivall/xcl:comment:7160166461 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7160166461). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-25T10:46:59Z. --- Diff review on `b09f06d` (`crates/xcl/src/gpu/dxil/module/opt.rs`) looks clean, CI passed, and both NVIDIA (RTX 4090 / RTX 3060) and AMD (RX 9070 XT) runs passed. `b09f06d` now conflicts in `opt.rs` after #2194 (`simplify_cfg`) landed on `main` — please rebase onto `main` so we can get CI green and merge.
bielfreedom commented 2026-11-25 11:09:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bielfreedom on 2026-11-25T11:04:56Z.


AMD Windows driver timing for #2212: on the RX 9070 XT the DXIL shrinks by 1.9 %, but AMD's CreateComputePipelineState time doesn't move (−0.4 %, within noise). The AMD compiler seems to drop these unused loads itself, so the gain here is in DXIL size and translation, not driver time.

Setup

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

Method

  • XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=0, XCL_PIPELINE_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.
  • 26 retail compute programs, 6 KB to 1.0 MB of direct DXIL: the set I used for #2207 and #2194. They include 84eee477d68b6fdf (CS_RaytracingResolve) and 620491641aa9bad6.
  • 2 rounds, interleaved.

Results (means of 2 rounds; all 104 builds succeeded, 0 refused)

base #2212 change
direct DXIL, total 8,598,156 B 8,438,560 B −1.86 %
programs changed 19 of 26
driver, sum (r1 / r2) 268.0 / 267.8 s 266.5 / 267.2 s −0.4 %
driver run, process peak private 4.45–4.60 GB 4.52–4.55 GB same
  • Every program's driver time is within ±3 % of base, apart from sub-100 ms ones.
  • The largest cut is 84eee477d68b6fdf: 1,025,520 → 1,003,012 B (−2.2 %), driver 52.7 → 52.6 s.
  • ActivateRays (95cc13288a27a96e, plain here): 3,916,120 → 3,912,160 B. It still reached 24 GB after 153 s and was killed (base: 153 s).

Tests on this card (XCL_REQUIRE_GPU=1, XCL_ADAPTER=9070)

  • unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays: passed.

Read / inference

  • No regression on AMD, and smaller modules, but no driver compile-time gain on this vendor.

Not tested

  • GPU suite with XCL_DIRECT_DXIL=1.
  • XCL_HEAP_WINDOWS=1.
  • A title run.
  • RDNA2 and RDNA3.

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

<!-- greyfinch-sync:ivall/xcl:comment:7160561639 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7160561639). Originally posted by [bielfreedom](https://github.com/bielfreedom) on 2026-11-25T11:04:56Z. --- **AMD Windows driver timing for #2212: on the RX 9070 XT the DXIL shrinks by 1.9 %, but AMD's `CreateComputePipelineState` time doesn't move (−0.4 %, within noise).** The AMD compiler seems to drop these unused loads itself, so the gain here is in DXIL size and translation, not driver time. **Setup** - GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010. - CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release. - Builds: - base `568e7db`; - this PR at `b09f06d`. - Both builds carry a local patch that logs per-program DXIL size, record hash (`fnv64`) and per-`CreateComputePipelineState` time. **Method** - `XCL_DIRECT_DXIL=1`, `XCL_HEAP_WINDOWS=0`, `XCL_PIPELINE_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. - 26 retail compute programs, 6 KB to 1.0 MB of direct DXIL: the set I used for #2207 and #2194. They include `84eee477d68b6fdf` (`CS_RaytracingResolve`) and `620491641aa9bad6`. - 2 rounds, interleaved. **Results** (means of 2 rounds; all 104 builds succeeded, 0 refused) | | base | #2212 | change | |---|---:|---:|---:| | direct DXIL, total | 8,598,156 B | 8,438,560 B | **−1.86 %** | | programs changed | | 19 of 26 | | | driver, sum (r1 / r2) | 268.0 / 267.8 s | 266.5 / 267.2 s | −0.4 % | | driver run, process peak private | 4.45–4.60 GB | 4.52–4.55 GB | same | - Every program's driver time is within ±3 % of base, apart from sub-100 ms ones. - The largest cut is `84eee477d68b6fdf`: 1,025,520 → 1,003,012 B (−2.2 %), driver 52.7 → 52.6 s. - ActivateRays (`95cc13288a27a96e`, plain here): 3,916,120 → 3,912,160 B. It still reached 24 GB after 153 s and was killed (base: 153 s). **Tests on this card** (`XCL_REQUIRE_GPU=1`, `XCL_ADAPTER=9070`) - `unused_raw_loads_and_f16_conversions_go_but_one_raw_load_stays`: passed. **Read / inference** - No regression on AMD, and smaller modules, but no driver compile-time gain on this vendor. **Not tested** - GPU suite with `XCL_DIRECT_DXIL=1`. - `XCL_HEAP_WINDOWS=1`. - A title run. - RDNA2 and RDNA3. AI use: Claude Code (Claude Opus 5.5) ran the measurements and the test and drafted this. The account owner is away; counts and timings only, no game data.
github-actions[bot] commented 2026-11-29 20:41:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:11Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262277211 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7262277211). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:41:11Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:35:44 +00:00 (Migrated from github.com)

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


Triage (#1607) – head b09f06d

Main already has this change. Commit 6ff86e3 (merged in #3503) adds dx.op.legacyF16ToF32 and dx.op.rawBufferLoad. to the pure-call list in dxil/module/opt.rs. It also adds the same flagged/reachable block that keeps one raw load alive so RawAndStructuredBuffers still matches the code (main's opt.rs around line 1470).
Recommendation: close (superseded by main commit 6ff86e3 / #3503).

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:7304249084 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7304249084). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:35:44Z. --- **Triage (#1607)** – head b09f06d Main already has this change. Commit 6ff86e3 (merged in #3503) adds `dx.op.legacyF16ToF32` and `dx.op.rawBufferLoad.` to the pure-call list in `dxil/module/opt.rs`. It also adds the same `flagged`/`reachable` block that keeps one raw load alive so `RawAndStructuredBuffers` still matches the code (main's opt.rs around line 1470). Recommendation: close (superseded by main commit 6ff86e3 / #3503). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:50:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:50:48Z.


Closing as superseded: this change is already on main (6ff86e30). main opt.rs lists dx.op.legacyF16ToF32 and dx.op.rawBufferLoad. as pure and keeps one raw load for the RawAndStructuredBuffers flag (same code as the PR at lines 530 and 1472)

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311731606 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2212#issuecomment-7311731606). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:50:48Z. --- Closing as superseded: this change is already on `main` (6ff86e30). main opt.rs lists dx.op.legacyF16ToF32 and dx.op.rawBufferLoad. as pure and keeps one raw load for the RawAndStructuredBuffers flag (same code as the PR at lines 530 and 1472) Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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!2202
No description provided.