Skip to content

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

Closed
ufoptg wants to merge 2 commits into
mainfrom
upstream-pr/880
Closed

ufoptg wants to merge 2 commits into
mainfrom
upstream-pr/880

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Stacked on xcl-dev#573; only the top commit (051b86e) 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 xcl-dev#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 xcl-dev#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 051b86e: 716 passed, 0 failed, 41 ignored (lib: 674 / 0 / 21), first run. XCL_SAMPLE_* unset.
  • SKIPPED on this adapter: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64).
  • 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 xcl-dev/xcl#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. The PR ran twice (the block is the second run; the first: 1632 frames, exit 0x0, 0 removals, 0 crashes), then main. The change is not reached by a title run (it is in xcl shaders and the dump).

main:

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

PR:

xcl-smoke v1
commit: 051b86e7982008778c1b78885f83ca2262f4e09f
gpu: NVIDIA GeForce RTX 4080
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1625)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15001 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

  • Claude Code (Claude Fable 5.2): the change, the test, the runs above and this description. The user approved opening the PR.

🤖 Generated with Claude Code


Mirror of xcl-dev#880 (auto-synced, do not edit).

throny and others added 2 commits November 24, 2026 07:29
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>
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#880 was closed or merged.

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.

2 participants