Shaders: ordered paired FP32 reductions for Wave64 on Wave32 hosts #1419

Open
github-bot wants to merge 3 commits from github-bot/gh-1419 into main AGit
Owner

@⁠ByFxbian on GitHub · 2026-11-27 01:17 UTC · original
ByFxbian:fix/paired-wave64-fp32 → main · +1084 −584 · 6 files · 3 commits · open

Summary

Follow-up to #1397, integrated in b1d777a8.

Implements ordered paired FP32 reductions for recognized full
Wave64 reduction trees on Wave32 hosts.

This addresses the floating-point reduction rejection reported
by Filip722 when testing the two water TransmissionVolumetrics
compute shaders:

  • 5dc3b25986622949
  • 6f225b641c5b0708

Changes

  • Ordered FP32 AddF, MinF and MaxF reduction lowering.
  • Preserve guest instruction and operand order.
  • Handle masked identities, intermediate rounding, signed zero,
    NaN payload priority, infinities and denormals.
  • Correct paired ds_bpermute_b32 to operate within its own
    32-lane half, consistent with the updated RDNA2 lowering.
  • Independent paired and exact Wave32 regression fixtures.
  • Preserve shader-cache identity and opt-in behavior.
  • Extract existing helpers to comply with the source-size policy.

Targeted testing

Once the guest floating-point mode has been confirmed:

VICTORY_WAVE_PAIRS=0
VICTORY_WAVE_PAIRS_ONLY=5dc3b25986622949,6f225b641c5b0708
VICTORY_WAVE_PAIRS_FP32=non-ieee-rne-ftz
VICTORY_WAVE_WHY=1
VICTORY_GROUP_SYNC=2
VICTORY_SHADER_OPT=127

The two hashes should not be forced into the wave-wide workaround.

Fast math must remain disabled for the ordered FP32 path.

Hardware validation

NVIDIA GeForce RTX 3070, Windows.

  • 34 bit-exact FP32 CPU-reference comparisons passed.
  • Paired NVIDIA hardware regression fixtures passed.
  • Exact Wave32 permute regression passed.
  • Unconfirmed guest-mode rejection passed.
  • Staged asset policy and workspace checks passed.

Limitations

The FP32 path requires a confirmed non-IEEE, round-to-nearest,
flush-to-zero guest mode.

FP64, floating-point prefixes, unsupported instruction sequences,
unknown MODE changes and fast math remain conservatively rejected.

The two original water shaders still require replay and visual
validation.

The goal is to execute both programs correctly and determine
whether the original water appearance can be restored without
reintroducing the black tile artifacts.

No gameplay or visual fix is claimed until verified.

**@⁠ByFxbian** on GitHub · 2026-11-27 01:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/1419) `ByFxbian:fix/paired-wave64-fp32` → `main` · +1084 −584 · 6 files · 3 commits · open ## Summary Follow-up to #1397, integrated in b1d777a8. Implements ordered paired FP32 reductions for recognized full Wave64 reduction trees on Wave32 hosts. This addresses the floating-point reduction rejection reported by Filip722 when testing the two water TransmissionVolumetrics compute shaders: - 5dc3b25986622949 - 6f225b641c5b0708 ## Changes - Ordered FP32 AddF, MinF and MaxF reduction lowering. - Preserve guest instruction and operand order. - Handle masked identities, intermediate rounding, signed zero, NaN payload priority, infinities and denormals. - Correct paired ds_bpermute_b32 to operate within its own 32-lane half, consistent with the updated RDNA2 lowering. - Independent paired and exact Wave32 regression fixtures. - Preserve shader-cache identity and opt-in behavior. - Extract existing helpers to comply with the source-size policy. ## Targeted testing Once the guest floating-point mode has been confirmed: ```ini VICTORY_WAVE_PAIRS=0 VICTORY_WAVE_PAIRS_ONLY=5dc3b25986622949,6f225b641c5b0708 VICTORY_WAVE_PAIRS_FP32=non-ieee-rne-ftz VICTORY_WAVE_WHY=1 VICTORY_GROUP_SYNC=2 VICTORY_SHADER_OPT=127 ``` The two hashes should not be forced into the wave-wide workaround. Fast math must remain disabled for the ordered FP32 path. ## Hardware validation NVIDIA GeForce RTX 3070, Windows. - 34 bit-exact FP32 CPU-reference comparisons passed. - Paired NVIDIA hardware regression fixtures passed. - Exact Wave32 permute regression passed. - Unconfirmed guest-mode rejection passed. - Staged asset policy and workspace checks passed. ## Limitations The FP32 path requires a confirmed non-IEEE, round-to-nearest, flush-to-zero guest mode. FP64, floating-point prefixes, unsupported instruction sequences, unknown MODE changes and fast math remain conservatively rejected. The two original water shaders still require replay and visual validation. The goal is to execute both programs correctly and determine whether the original water appearance can be restored without reintroducing the black tile artifacts. No gameplay or visual fix is claimed until verified.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:34:17 +00:00
Author
Owner

@⁠fxceless on GitHub · 2026-11-27 01:31 UTC · original

Tested on an RTX 4070 (Windows) with the recipe above (WAVE_PAIRS_ONLY for both hashes, WAVE_PAIRS_FP32=non-ieee-rne-ftz, GROUP_SYNC=2, SHADER_OPT=127). Both programs are still refused, in two steps:

  1. paired FP32 reduction with fast math or an unknown MODE change: each program has three s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 0 (5dc3: 0x2bfc, 0x3010, 0x3494; 6f22: 0x4b78, 0x4f88, 0x5408). That field is the 64/16-bit rounding only, so it does not change FP32 rounding or denormals. We narrowed the gate locally to refuse only MODE writes touching bits 0-1 / 4-5.
  2. After that: a paired FP32 section without a proven full reduction is not supported at 0x570 (5dc3) and 0x580 (6f22). We are looking at that section's shape now.
**@⁠fxceless** on GitHub · 2026-11-27 01:31 UTC · [original](https://github.com/fxceless/victory-fork/pull/1419#issuecomment-7207358653) Tested on an RTX 4070 (Windows) with the recipe above (WAVE_PAIRS_ONLY for both hashes, WAVE_PAIRS_FP32=non-ieee-rne-ftz, GROUP_SYNC=2, SHADER_OPT=127). Both programs are still refused, in two steps: 1. `paired FP32 reduction with fast math or an unknown MODE change`: each program has three `s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 0` (5dc3: 0x2bfc, 0x3010, 0x3494; 6f22: 0x4b78, 0x4f88, 0x5408). That field is the 64/16-bit rounding only, so it does not change FP32 rounding or denormals. We narrowed the gate locally to refuse only MODE writes touching bits 0-1 / 4-5. 2. After that: `a paired FP32 section without a proven full reduction is not supported` at 0x570 (5dc3) and 0x580 (6f22). We are looking at that section's shape now.
Author
Owner

@⁠akimfomin on GitHub · 2026-11-27 01:35 UTC · original

The two-bit write beginning at MODE bit 2 is confined to FP16/FP64 rounding. One guard edge worth keeping while narrowing it: AMD RDNA2 ISA §3.5, Table 4 also defines DX10_CLAMP at bit 8 and IEEE at bit 9. Those matter when this lowering promises a non-IEEE NaN/min/max result. A rule that rejects only writes overlapping FP32 round/denorm (bits 0–1, 4–5) would also admit writes to bits 8 and 9.

A small positive/negative fixture can keep the exact offset=2,width=2 write and the existing bit-exact reduction, then move the write to bit 8 or 9 and require conservative refusal. I checked the bit overlaps independently. This leaves the second failure in your report separate. In the current 1338677e path, the same diagnostic covers an unproven live-out shape, an unsupported opcode/modifier and an EXEC write, so reporting which predicate failed first would help people reproduce the remaining shape with a synthetic program. PortBridge can help run that isolated fixture on a second NVIDIA adapter once available. No replay or picture claim here.

**@⁠akimfomin** on GitHub · 2026-11-27 01:35 UTC · [original](https://github.com/fxceless/victory-fork/pull/1419#issuecomment-7207409583) The two-bit write beginning at MODE bit 2 is confined to FP16/FP64 rounding. One guard edge worth keeping while narrowing it: [AMD RDNA2 ISA §3.5, Table 4](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=24) also defines `DX10_CLAMP` at bit 8 and `IEEE` at bit 9. Those matter when this lowering promises a non-IEEE NaN/min/max result. A rule that rejects only writes overlapping FP32 round/denorm (bits 0–1, 4–5) would also admit writes to bits 8 and 9. A small positive/negative fixture can keep the exact `offset=2,width=2` write and the existing bit-exact reduction, then move the write to bit 8 or 9 and require conservative refusal. I checked the bit overlaps independently. This leaves the second failure in your report separate. In the current `1338677e` path, the same diagnostic covers an unproven live-out shape, an unsupported opcode/modifier and an EXEC write, so reporting which predicate failed first would help people reproduce the remaining shape with a synthetic program. [PortBridge](https://github.com/akimfomin/PortBridge) can help run that isolated fixture on a second NVIDIA adapter once available. No replay or picture claim here.
Author
Owner

@⁠ByFxbian on GitHub · 2026-11-27 01:42 UTC · original

Just updated the PR based on your feedback.

The MODE guard now permits the reported FP16/FP64 rounding write while retaining conservative rejection of changes affecting FP32 rounding, denormals, DX10_CLAMP and IEEE mode.

The reduction rejection is now split into more specific diagnostics. All new FP32 hardware tests and the existing NVIDIA regression fixtures passed on my RTX 3070.

Both water hashes are ready for another replay test if possible

**@⁠ByFxbian** on GitHub · 2026-11-27 01:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/1419#issuecomment-7207518729) Just updated the PR based on your feedback. The MODE guard now permits the reported FP16/FP64 rounding write while retaining conservative rejection of changes affecting FP32 rounding, denormals, DX10_CLAMP and IEEE mode. The reduction rejection is now split into more specific diagnostics. All new FP32 hardware tests and the existing NVIDIA regression fixtures passed on my RTX 3070. Both water hashes are ready for another replay test if possible
Author
Owner

@⁠akimfomin on GitHub · 2026-11-27 01:46 UTC · original

Thanks. I independently tested the updated 8d1162e31491ca8c462356e921b31f39ee99d58d on a physical RTX 4070 Ti SUPER, driver 617.14, Windows 11 28000.3501, release. All four paired_fp32 tests passed. The three GPU fixtures validated DXIL and passed 37 bit-exact comparisons in the paired path with 32 threads; the fourth test confirms refusal when the guest mode is absent. This includes the FP16/FP64 MODE write and the conservative refusal controls for the FP32 and NaN settings.

$env:VICTORY_WAVE_PAIRS='1'
$env:VICTORY_WAVE_PAIRS_FP32='non-ieee-rne-ftz'
$env:VICTORY_SHADER_OPT='127'
$env:VICTORY_GROUP_SYNC='2'
$env:VICTORY_WAVE_WHY='1'
cargo test --locked --release -p victory-shader --features host --lib paired_fp32 -- --include-ignored --nocapture --test-threads=1

For volunteers, set both the paired switch and the optimization mask explicitly in this test command. A first run with only the guest-mode variable exercised a non-paired or fast-math fallback and should not be compared. The two water-program replays and a visual check are still open. OpenAI Codex assisted with the isolated build and test run.

**@⁠akimfomin** on GitHub · 2026-11-27 01:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/1419#issuecomment-7207563987) Thanks. I independently tested the updated `8d1162e31491ca8c462356e921b31f39ee99d58d` on a physical **RTX 4070 Ti SUPER**, driver **617.14**, Windows 11 **28000.3501**, release. All four `paired_fp32` tests passed. The three GPU fixtures validated DXIL and passed **37 bit-exact comparisons** in the paired path with 32 threads; the fourth test confirms refusal when the guest mode is absent. This includes the FP16/FP64 MODE write and the conservative refusal controls for the FP32 and NaN settings. ```powershell $env:VICTORY_WAVE_PAIRS='1' $env:VICTORY_WAVE_PAIRS_FP32='non-ieee-rne-ftz' $env:VICTORY_SHADER_OPT='127' $env:VICTORY_GROUP_SYNC='2' $env:VICTORY_WAVE_WHY='1' cargo test --locked --release -p victory-shader --features host --lib paired_fp32 -- --include-ignored --nocapture --test-threads=1 ``` For volunteers, set both the paired switch and the optimization mask explicitly in this test command. A first run with only the guest-mode variable exercised a non-paired or fast-math fallback and should not be compared. The two water-program replays and a visual check are still open. OpenAI Codex assisted with the isolated build and test run.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1419/head:github-bot/gh-1419'
git switch 'github-bot/gh-1419'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1419'
git switch 'github-bot/gh-1419'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1419'
git switch 'github-bot/gh-1419'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1419'
git switch 'main'
git merge --squash 'github-bot/gh-1419'
git switch 'main'
git merge --ff-only 'github-bot/gh-1419'
git switch 'main'
git merge 'github-bot/gh-1419'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.