Skip to content

Shaders: f16 wave sums behind early-outs translate on 32-lane hosts (compute_graph_ops:CS_TransposeVecMatMul*) - #13

Closed
Skyfrye wants to merge 1 commit into
LooperSalty:anyxboxx/fork-7b0-lot9-mursfrom
Skyfrye:fix/f16-wave-sum
Closed

Skyfrye wants to merge 1 commit into
LooperSalty:anyxboxx/fork-7b0-lot9-mursfrom
Skyfrye:fix/f16-wave-sum

Conversation

@Skyfrye

@Skyfrye Skyfrye commented Nov 25, 2026

Copy link
Copy Markdown

Problem

compute_graph_ops:CS_TransposeVecMatMulAlignedOperation (b22a16a178976e1b) and CS_TransposeVecMatMulOperation (a26a38d61f256901) do not translate on a host with 32-lane waves: "a wave sum of 16-bit floats where not every lane runs is not supported". In our runs (RTX 5080) the first is requested in game and dropped 14 to 42 times a frame; it runs next to the blendshape and ped skinning dispatches.

Why: half_sum lowers a 16-bit-float WaveActiveSum as the console's tree; on two 32-lane host waves the last addition needs a block every lane of the group reaches. In these shaders the sums sit behind early-outs (v_cmpx + s_cbranch_execz to the end). ir::without_early_outs could not drop them, because its guard walks_with_empty_exec wants EXEC to stay empty in the walked region and the sum's own whole-wave section opens with s_or_saveexec_b64 ..., -1.

Change

victory-shader/src/ir.rs only (plus tests): whole_wave_arithmetic recognises a whole-wave section that only computes — opens with s_or_saveexec -1 or s_nand_saveexec 0, only VALU instructions, no other EXEC write, ends with the s_mov that restores exactly the saved mask — and walks_with_empty_exec accepts it. Lanes that left walk the section as the console's inactive lanes do: their terms are +0 by the saved mask, the saved (empty) EXEC is put back, nothing is stored. The early-outs can then go and the existing bit-exact half_sum applies unchanged.

// shortcut: only sections that contain v_add_f16 qualify.

Tests (emit/wave64_tests.rs)

  • a_sum_of_halves_behind_early_outs_adds_zero_for_the_lanes_that_left: two console waves in a group of 128, two early-outs, then the sum; asserts the refusal as is, that without_early_outs removes both branches, validates the DXIL and runs 14 cases (all lanes, partial halves, a whole wave gone, lane 0 gone, nobody) against a reference tree built on an f64 round-to-nearest-even add_f16. Bit-exact on the RTX 5080.
  • an_early_out_before_a_whole_wave_section_that_stores_stays.
  • the_reference_addition_of_halves_rounds_to_nearest_even.
  • cargo test --profile diag -p victory-shader: 208 passed, 0 failed, 2 ignored.

In the title

Not tested

  • WARP: it refuses the fixed-wave-size test program ("The parameter is incorrect"), as with the existing exact-sum tests; the new GPU test ran on hardware only.
  • Whether the picture changes (faces, bodies): not compared.
  • The real shaders' numeric output: exactness is shown on the synthetic program with the same section shape.

AI use: Claude Code (Claude Fable 5.2) found the cause, wrote the change and the tests, ran them and the game on my machine with my own copy, and wrote this description.

🤖 Generated with Claude Code

…can go (f16 wave sums on 32-lane hosts)

`half_sum` lowers a 16-bit-float WaveActiveSum as the console's tree, and on
two 32-lane host waves needs a block every lane of the group reaches. In
compute_graph_ops:CS_TransposeVecMatMul{,Aligned}Operation the sums sit behind
early-outs (v_cmpx + s_cbranch_execz), and `without_early_outs` could not drop
them: its guard `walks_with_empty_exec` wants EXEC to stay empty in the walked
region, and the sum's own section opens with `s_or_saveexec ..., -1`.

`whole_wave_arithmetic` recognises a whole-wave section that only computes
(opens with s_or_saveexec -1 or s_nand_saveexec 0, VALU instructions only, no
other EXEC write, ends restoring exactly the saved mask) and the guard accepts
it: lanes that left walk it as the console's inactive lanes do, their terms
+0 by the saved mask, nothing stored.
shortcut: only sections with v_add_f16 qualify.

Both shaders now translate ("a wave sum of 16-bit floats where not every lane
runs" before); every other program's DXIL is byte for byte what it was.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@Skyfrye

Skyfrye commented Nov 25, 2026

Copy link
Copy Markdown
Author

Closing: AnyXboxX Marvisak#199 moved the engine into the main repository (third_party/victory, no fork any more), so this fork is no longer where changes land. I am re-basing this onto current AnyXboxX main and will re-submit it there, re-measured on that base.

AI use: Claude Code (Claude Fable 5.2).

@Skyfrye Skyfrye closed this Nov 25, 2026
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.

1 participant