Skip to content

Shaders: xcl shaders statistics and the dump take the wave size from the header - #880

Open
throny wants to merge 2 commits into
xcl-dev:mainfrom
throny:shaders-stats-wave-size-from-header
Open

throny wants to merge 2 commits into
xcl-dev:mainfrom
throny:shaders-stats-wave-size-from-header

Conversation

@throny

@throny throny commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #573; only the top commit (6576d75) belongs here.

xcl shaders --recomp and the per-shader dump (XCL_DUMP_SHADERS) told a program's wave size from its code alone (detect_wave64). After #573 the pipelines take wave32 from the FSSM header's flag, so a wave32 program without an EXEC write was still counted and translated as wave64 by these two tools. Both now use fssm_wave64, so the statistics describe what the pipelines build. MesshM suggested it in the review of #573. No issue covers it; no other open PR touches these call sites.

What is in it

  • crates/xcl/src/shaders.rs: RecompAgg::add gets the wave size from its caller, which has the FSSM (recomp::fssm_wave64(f, code)); the test recompiler_statistics_count_wave32_by_the_header_flag.
  • crates/xcl/src/gpu/shader.rs: the dump's recompile uses fssm_wave64.

Tested

  • Windows 11 Pro 10.0.26300, NVIDIA GeForce RTX 4080 (driver 610.88, 32-lane waves), Intel i9-12900K, 64 GB; Rust 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); tests in debug, title runs in release.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 on 6576d75 (on Recompiler: the FSSM header's wave32 flag decides a program's wave size #573 b8b4135, main bdda528): 1 130 passed, 0 failed, 46 ignored, first run (one more than Recompiler: the FSSM header's wave32 flag decides a program's wave size #573 on the same main: this PR's test). XCL_SAMPLE_* unset.
  • SKIPPED on this adapter: the wave64 GPU tests (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (the driver cache cannot be disabled without Developer Mode).
  • xcl shaders <pack> --recomp on a retail shader pack (26 698 programs; counts only): main 1ec4c98 reports wave32 2 608, this PR 2 662 – the 54 compute programs Recompiler: the FSSM header's wave32 flag decides a program's wave size #573 describes. Both translate 26 698 of 26 698 with 0 errors; the VS / PS wave size line is the same in both (wave32 1 127, wave64 13 210).
  • Negative control: with the caller passing detect_wave64(code) again, the new test fails (left: (1, 0), right: (1, 1)).

Regression run

scripts/smoke.ps1, a retail title, release builds, warm shader cache, main first. The change is not reached by a title run (it is in xcl shaders and the dump).

main:

xcl-smoke v1
commit: bdda528ee26cc2f5626eeb460213480c4176f813
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15979 MB

PR:

xcl-smoke v1
commit: 6576d75b66735120b4d459c046318a52b6ba807f
gpu: NVIDIA GeForce RTX 4080
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15876 MB

Not tested

  • The dump (XCL_DUMP_SHADERS): no test covers it; the change there is the same one-line call.
  • AMD and wave64 hardware.

AI use

🤖 Generated with Claude Code

@ettehn

ettehn commented Nov 24, 2026

Copy link
Copy Markdown

Independently verified the shader dump on Windows x64 at 051b86e. With XCL_DUMP_SHADERS=1, I passed two synthetic CS containers through shader::capture. Both used the same three RDNA2 instructions with no EXEC write. I checked the captured binaries against the inputs and read the generated fssm0.p0.hlsl files. Header flags 0x20 produced [WaveSize(32)] and 0x00 produced [WaveSize(64)].

As a negative control, restoring only the previous detect_wave64(code) call made the same test fail: the 0x20 case emitted [WaveSize(64)]. This exercises HLSL export; I did not compile or dispatch the dumped shaders.

OpenAI Codex (GPT-6.2 Astra) assisted with verification.

@4usphs

4usphs commented Nov 24, 2026

Copy link
Copy Markdown

Test run on AMD RDNA4 (native wave64), since the PR's own run is on a wave32-only adapter where the wave64 tests are skipped.

Tested: the PR head 051b86e (stack: #573's 09b1fb0 + this commit, base main beaa245, so this is the same code as the merge). RX 9070 XT (RDNA4), driver 32.0.32029.2010, Ryzen 7 9800X3D, Windows 11 Pro 26200, Rust 1.100.0, debug.

  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 716 passed, 0 failed, 41 ignored, 0 SKIPPED (lib: 674 / 0 / 21). The two tests skipped on the RTX 4080 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware) run and pass here.
  • Recompiler: the FSSM header's wave32 flag decides a program's wave size #573's console_compute_without_an_exec_write_has_the_wave_size_of_its_header runs here (backend 'real' – AMD Radeon RX 9070 XT, not skipped) and passes, also with XCL_TRANSLATED_CACHE=0.
  • Negative control for this commit: with the shaders.rs caller passing detect_wave64(code) again, recompiler_statistics_count_wave32_by_the_header_flag fails (left: (1, 0), right: (1, 1)), as in the description.
  • Negative control for Recompiler: the FSSM header's wave32 flag decides a program's wave size #573's pipeline change: with console_translation in pso.rs passing detect_wave64(code) again and XCL_TRANSLATED_CACHE=0, the e2e test fails 2 of 2 runs: flags 0x20, thread 32, left: (0, 32), right: (32, 32). So thread 32 reads thread 0, as in one 64-lane wave.

A note for anyone repeating that last control: without XCL_TRANSLATED_CACHE=0 the test still passes, because pso.rs is not in the translator source hash (build.rs) and the translation from the earlier run is reused. That is not a problem for the PR itself: it also changes mod.rs, xbox.rs and shader.rs, which are in the hash.

Not tested: smoke or a retail title, xcl shaders --recomp or XCL_DUMP_SHADERS on a real shader pack (no XCL_SAMPLE_* set), a release build.

AI use: Claude Code (Claude Opus 5.5) read the diff, ran the tests and the controls on my PC and wrote this comment. I have not reviewed the code.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 051b86e onto main 077ce40, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 712 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. wave-size-from-header statistics green.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

throny and others added 2 commits November 25, 2026 02:57
detect_wave64 tells the wave size from the code: 32-bit EXEC writes and no
64-bit ones mean wave32, anything else wave64. A wave32 program that never
writes EXEC has nothing in its code to tell, so it was translated as wave64:
its cross-lane reads (v_readfirstlane, v_readlane, permutes) then span 64
threads instead of 32.

The FSSM header has the answer: bit 5 of the flags word at +0xD4. Measured
on a retail shader pack (26 698 programs): the bit is set for all 2 608
programs the code shows to be wave32 and clear for all 24 036 the code takes
for wave64, except 54 compute programs with the bit set and no EXEC write in
their code. 27 of those 54 have cross-lane instructions (v_readfirstlane,
v_readlane, permutes, LDS). As wave32 all 54
translate completely and compile with DXC.

fssm_wave64 takes wave32 from the header and leaves everything else to
detect_wave64, so only those programs change. An unused field (0xDEADBEEF)
and other FSSM versions say nothing.

A compute program through the PSO hook (gpu_compute_e2e) shows the effect:
64 threads store v_readfirstlane of their thread id; with the flag threads
32..63 read thread 32, without it they read thread 0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…the header

`xcl shaders --recomp` counted and translated a program as wave32 or wave64
from its code alone (detect_wave64), and so did the per-shader HLSL dump
(`XCL_DUMP_SHADERS`). A wave32 program without an EXEC
write was counted and translated as wave64 there, while the pipelines
translate it as wave32 by the FSSM header's flag (fssm_wave64).

Both now use fssm_wave64, so the statistics describe what the pipelines
build. Suggested in the review of the header-flag change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@throny
throny force-pushed the shaders-stats-wave-size-from-header branch from 11f9327 to 6576d75 Compare November 25, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants