Shaders: xcl shaders --explain reports a program's guest code and direct DXIL #1945

Closed
sombraSoft wants to merge 3 commits from upstream-pr/1955 into main
sombraSoft commented 2026-11-24 23:51:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sombraSoft on 2026-11-24T23:51:17Z.


Stacked on #1954; only the top commit belongs here. Part of #1269.

Numbers in #1269 come from different commits, program sets and cache states, so they rarely compare, and finding what makes one shader expensive is done by hand. xcl shaders <pack> --explain reports, per console program picked by --hash or a seeded --sample: the guest program (instruction classes, blocks, loops, back edges, indirect jumps) and the direct translator's time, memory and DXIL structure (#1954), or why it refused. Counts are portable (equal for the same commit and options; a fingerprint and a digest line say so), times and memory local. Programs are named by hash only, so a report can be posted. XCL caps its own commit during the run (--mem-gb, default 8) with a job object, since the direct translator runs in-process. The HLSL path (#1957) and JSON / comparing reports (#1958) follow.

What is in it

  • Shaders: xcl shaders --explain reports a program's guest code and direct DXIL – crates/xcl/src/shaders/explain.rs, explain/direct.rs, explain/limits.rs; the hook in shaders.rs; help in main.rs; README.md

About 480 lines of code and 100 of tests; the core without a translation path would report the guest program only, so the direct path is in the same PR.

Tested

  • NVIDIA GeForce RTX 3060 Ti (driver 32.0.16.2124), AMD Ryzen 9 5900X, Windows 11 Pro 10.0.26300, rustc 1.97.1; tests in debug, smoke run in release; DXC 1.8.2502.11 (Windows SDK 10.0.26100)
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on 21aee9d: 983 passed, 0 failed, 45 ignored
  • SKIPPED (all from existing tests): 18 × no wave64, 1 × no heap windows, 1 × cannot disable the driver cache (Developer Mode off), 3 × per-lane form refused (f16 / VOP3 modifiers)
  • unit tests: instruction classes; selection by hash (and an unknown hash is an error); the same program explained twice gives the same portable numbers
  • retail pack (shaders.rpf), on fb2eeec (the top of this stack): the largest compute program goes through the direct translator in 0.97 s and 172 MB, 3.8 MB of DXIL bitcode with 36 818 blocks

Regression run

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 3060 Ti
title: 55118d47
seconds: 60
exit: 0x0
frames shown: 1075 (PresentX 1075)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15431 MB

this PR (21aee9d):

xcl-smoke v1
commit: 21aee9da9e6ab07becb5763216e722e37fe13b21
gpu: NVIDIA GeForce RTX 3060 Ti
title: 55118d47
seconds: 60
exit: 0x0
frames shown: 1185 (PresentX 1185)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15331 MB

Not tested

  • AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton
  • the title run does not use --explain (a CLI report); it checks only that nothing else changed
  • the driver cost of the direct DXIL (36 818 blocks above): --measure-pso needs Windows Developer Mode, off on this machine

AI use

  • Claude Code with Claude Opus 5.5: wrote the code, the tests and this description. The tests, the pack runs and the smoke runs were run on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5482352287 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1955). Originally posted by [sombraSoft](https://github.com/sombraSoft) on 2026-11-24T23:51:17Z. --- Stacked on #1954; only the top commit belongs here. Part of #1269. Numbers in #1269 come from different commits, program sets and cache states, so they rarely compare, and finding what makes one shader expensive is done by hand. `xcl shaders <pack> --explain` reports, per console program picked by `--hash` or a seeded `--sample`: the guest program (instruction classes, blocks, loops, back edges, indirect jumps) and the direct translator's time, memory and DXIL structure (#1954), or why it refused. Counts are *portable* (equal for the same commit and options; a fingerprint and a digest line say so), times and memory *local*. Programs are named by hash only, so a report can be posted. XCL caps its own commit during the run (`--mem-gb`, default 8) with a job object, since the direct translator runs in-process. The HLSL path (#1957) and JSON / comparing reports (#1958) follow. **What is in it** - `Shaders: xcl shaders --explain reports a program's guest code and direct DXIL` – `crates/xcl/src/shaders/explain.rs`, `explain/direct.rs`, `explain/limits.rs`; the hook in `shaders.rs`; help in `main.rs`; `README.md` About 480 lines of code and 100 of tests; the core without a translation path would report the guest program only, so the direct path is in the same PR. **Tested** - NVIDIA GeForce RTX 3060 Ti (driver 32.0.16.2124), AMD Ryzen 9 5900X, Windows 11 Pro 10.0.26300, rustc 1.97.1; tests in debug, smoke run in release; DXC 1.8.2502.11 (Windows SDK 10.0.26100) - `cargo test --workspace --no-fail-fast -- --test-threads=4` on 21aee9d: 983 passed, 0 failed, 45 ignored - `SKIPPED` (all from existing tests): 18 × no wave64, 1 × no heap windows, 1 × cannot disable the driver cache (Developer Mode off), 3 × per-lane form refused (f16 / VOP3 modifiers) - unit tests: instruction classes; selection by hash (and an unknown hash is an error); the same program explained twice gives the same portable numbers - retail pack (`shaders.rpf`), on fb2eeec (the top of this stack): the largest compute program goes through the direct translator in 0.97 s and 172 MB, 3.8 MB of DXIL bitcode with 36 818 blocks **Regression run** main: ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: NVIDIA GeForce RTX 3060 Ti title: 55118d47 seconds: 60 exit: 0x0 frames shown: 1075 (PresentX 1075) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15431 MB ``` this PR (21aee9d): ``` xcl-smoke v1 commit: 21aee9da9e6ab07becb5763216e722e37fe13b21 gpu: NVIDIA GeForce RTX 3060 Ti title: 55118d47 seconds: 60 exit: 0x0 frames shown: 1185 (PresentX 1185) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15331 MB ``` **Not tested** - AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton - the title run does not use --explain (a CLI report); it checks only that nothing else changed - the driver cost of the direct DXIL (36 818 blocks above): `--measure-pso` needs Windows Developer Mode, off on this machine **AI use** - Claude Code with Claude Opus 5.5: wrote the code, the tests and this description. The tests, the pack runs and the smoke runs were run on the hardware above.
DavidM1911 commented 2026-11-25 03:05:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:59:31Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (README.md + crates/xcl/src/shaders.rs) — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7151475430 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1955#issuecomment-7151475430). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:59:31Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`README.md` + `crates/xcl/src/shaders.rs`) — needs a rebase before it can be tested.

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