Shaders: DXIL structure statistics for compile-cost reports #1944

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

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


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

Structure statistics of a DXIL module from one pass over its bitcode: functions, blocks, instructions, SSA values, phis and their incoming edges, branches, switches, backward branches, selects, loads, stores, calls by callee. --explain (#1955) prints them for both translation paths.

What is in it

  • Shaders: DXIL structure statistics for compile-cost reports – crates/xcl/src/gpu/dxil/stats.rs (container_stats, bitcode_stats, DxilStats::to_json) and stats_tests.rs. Value ids are tracked exactly (relative operands, explicit call types), so calls resolve to their callee.

About 415 lines of code and 273 of tests: the statistics are one walk over the module, and the tests are mostly the DXC cross-check below, so I did not split it further.

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 e7097e2: 981 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)
  • the tests compare every count with DXC's own disassembly (validate::disassemble) of three compiled compute shaders (a loop, nested branches with a three-way phi, a switch with buffer loads and stores), and check two modules built with XCL's writer exactly; truncated and bit-flipped bitcode returns Ok or Err without panicking
  • release: 20.6 MB of bitcode (3 M instructions) read in 86 ms

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 (e7097e2):

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

Not tested

  • AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton
  • the title run does not use the statistics; it checks only that nothing else changed

AI use

  • Claude Code with Claude Opus 5.5: a subagent wrote the statistics and their tests; the main session reviewed them and wrote this description. The tests and the smoke runs were run on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5482351754 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1954). Originally posted by [sombraSoft](https://github.com/sombraSoft) on 2026-11-24T23:51:14Z. --- Stacked on #1953; only the top commit belongs here. Part of #1269. Structure statistics of a DXIL module from one pass over its bitcode: functions, blocks, instructions, SSA values, phis and their incoming edges, branches, switches, backward branches, selects, loads, stores, calls by callee. `--explain` (#1955) prints them for both translation paths. **What is in it** - `Shaders: DXIL structure statistics for compile-cost reports` – `crates/xcl/src/gpu/dxil/stats.rs` (`container_stats`, `bitcode_stats`, `DxilStats::to_json`) and `stats_tests.rs`. Value ids are tracked exactly (relative operands, explicit call types), so calls resolve to their callee. About 415 lines of code and 273 of tests: the statistics are one walk over the module, and the tests are mostly the DXC cross-check below, so I did not split it further. **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 e7097e2: 981 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) - the tests compare every count with DXC's own disassembly (`validate::disassemble`) of three compiled compute shaders (a loop, nested branches with a three-way phi, a switch with buffer loads and stores), and check two modules built with XCL's writer exactly; truncated and bit-flipped bitcode returns Ok or Err without panicking - release: 20.6 MB of bitcode (3 M instructions) read in 86 ms **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 (e7097e2): ``` xcl-smoke v1 commit: e7097e2b25b0cdaff15987e1562e3261f98d960c gpu: NVIDIA GeForce RTX 3060 Ti title: 55118d47 seconds: 60 exit: 0x0 frames shown: 1197 (PresentX 1197) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15327 MB ``` **Not tested** - AMD and Intel GPUs, GPUs with native wave64, DXC 1.9, Linux / vkd3d-proton - the title run does not use the statistics; it checks only that nothing else changed **AI use** - Claude Code with Claude Opus 5.5: a subagent wrote the statistics and their tests; the main session reviewed them and wrote this description. The tests and the smoke runs were run on the hardware above.
DavidM1911 commented 2026-11-25 03:05:55 +00:00 (Migrated from github.com)

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


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!

<!-- greyfinch-sync:ivall/xcl:comment:7151472379 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1954#issuecomment-7151472379). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:59:24Z. --- 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!

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