Shaders: preserve round mode changes in whole-wave sections #2886

Open
github-bot wants to merge 1 commit from github-bot/gh-2886 into main AGit
Owner

@⁠yumaste on GitHub · 2026-11-25 23:04 UTC · original
yumaste:fix/whole-wave-rounding-mode → main · +26 −0 · 2 files · 1 commits · open

## Summary

Whole-wave sections use a separate lowering path for their body. A rounding-mode write inside that body was skipped by the block's instruction-by-instruction tracking, so later FP16 conversions in the same block could use a stale mode.

Apply the existing round16_after transfer function to instructions in the section as well. Add a synthetic compute regression that selects round-toward-zero with s_round_mode and restores round-to-nearest-even with s_setreg_imm32_b32 in a second section. Both conversions run after EXEC is restored.

Validation

  • Before the fix, a positive input rounded to 0x3c00 instead of truncating to 0x3bff. The negative case also failed.
  • The regression passed on the hardware adapter and WARP. The semantics and whole-wave suites reported 42 passes, with one pre-existing ignored test.
  • Clippy passed for victory-shader with all targets and features and warnings denied.

AI-assisted (Codex). Validation used synthetic shaders only.

**@⁠yumaste** on GitHub · 2026-11-25 23:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886) `yumaste:fix/whole-wave-rounding-mode` → `main` · +26 −0 · 2 files · 1 commits · open ## Summary Whole-wave sections use a separate lowering path for their body. A rounding-mode write inside that body was skipped by the block's instruction-by-instruction tracking, so later FP16 conversions in the same block could use a stale mode. Apply the existing `round16_after` transfer function to instructions in the section as well. Add a synthetic compute regression that selects round-toward-zero with `s_round_mode` and restores round-to-nearest-even with `s_setreg_imm32_b32` in a second section. Both conversions run after EXEC is restored. ## Validation - Before the fix, a positive input rounded to `0x3c00` instead of truncating to `0x3bff`. The negative case also failed. - The regression passed on the hardware adapter and WARP. The semantics and whole-wave suites reported 42 passes, with one pre-existing ignored test. - Clippy passed for `victory-shader` with all targets and features and warnings denied. AI-assisted (Codex). Validation used synthetic shaders only.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:16:43 +00:00
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 23:10 UTC · original

Reviewed and verified 2aa17674 on Windows 11 (RTX 5090 + WARP + dxil.dll) against main (842b0cb):

  • Updating self.mode16 = round16_after(&p.blocks[b].insts[j], self.mode16) right after section_inst inside the whole-wave section loop preserves exact post-instruction rounding-mode semantics (s_round_mode / s_setreg_imm32_b32(HW_REG_MODE)).
  • Local checks: semantics_tests 35/35 passed (including whole_wave_sections_keep_rounding_mode_changes on RTX 5090 + WARP + dxil.dll), emit::lower::tests 33/33 passed, cargo clippy --locked -p victory-shader --all-targets -- -D warnings 0 warnings, cargo xtask policy (191 files ok; emit/lower.rs = 520,652 bytes).

Clean 1-line fix, ready to merge.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 23:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886#issuecomment-7177230739) Reviewed and verified `2aa17674` on Windows 11 (RTX 5090 + WARP + `dxil.dll`) against `main` (`842b0cb`): - Updating `self.mode16 = round16_after(&p.blocks[b].insts[j], self.mode16)` right after `section_inst` inside the whole-wave section loop preserves exact post-instruction rounding-mode semantics (`s_round_mode` / `s_setreg_imm32_b32(HW_REG_MODE)`). - Local checks: `semantics_tests` 35/35 passed (including `whole_wave_sections_keep_rounding_mode_changes` on RTX 5090 + WARP + `dxil.dll`), `emit::lower::tests` 33/33 passed, `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` 0 warnings, `cargo xtask policy` (`191 files ok`; `emit/lower.rs` = `520,652` bytes). Clean 1-line fix, ready to merge.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-26 04:28 UTC · original

Automated triage for the maintainers.

Merge candidate. The lowering loop in emit/lower.rs now updates mode16 with round16_after for instructions inside whole-wave sections, so an s_round_mode or MODE s_setreg inside a section is no longer lost for the rest of the block; this matches the block-entry analysis round16(), which already counts them. The test decodes correctly per the RDNA2 ISA and expects v_cvt_f16_f32 results to follow the mode per section.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-26 04:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886#issuecomment-7182630329) <!-- victory-triage v1 head=2aa17674855c6089f017b656f01430b84bee9a44 verdict=merge-candidate at=2026-11-26T04:28:36Z --> Automated triage for the maintainers. **Merge candidate.** The lowering loop in `emit/lower.rs` now updates `mode16` with `round16_after` for instructions inside whole-wave sections, so an `s_round_mode` or MODE `s_setreg` inside a section is no longer lost for the rest of the block; this matches the block-entry analysis `round16()`, which already counts them. The test decodes correctly per the RDNA2 ISA and expects `v_cvt_f16_f32` results to follow the mode per section. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 23:34 UTC · original · reviewed

Correct: a MODE write inside a whole-wave section must take effect for the remaining section instructions — tracking round16_after per j while walking the section does that, and the test covers both s_round_mode and s_setreg restoring default. The before-behavior (entry mode for the whole section) was observably wrong for sectioned mode changes. LGTM.

**@⁠kotekompotek** on GitHub · 2026-11-25 23:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886#pullrequestreview-6066474173) · **reviewed** Correct: a MODE write inside a whole-wave section must take effect for the remaining section instructions — tracking round16_after per j while walking the section does that, and the test covers both s_round_mode and s_setreg restoring default. The before-behavior (entry mode for the whole section) was observably wrong for sectioned mode changes. LGTM.
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 09:28 UTC · original · approved these changes

Verified on RTX 5090 & WARP against origin/main (63bcca4):

  • cargo test -p victory-shader --lib whole_wave_sections_keep_rounding_mode_changes -- --test-threads=1: passed on RTX 5090 and WARP.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Clean one-line fix preserving rounding mode updates across whole-wave sections.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 09:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886#pullrequestreview-6071556078) · **approved these changes** Verified on RTX 5090 & WARP against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib whole_wave_sections_keep_rounding_mode_changes -- --test-threads=1`: passed on RTX 5090 and WARP. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Clean one-line fix preserving rounding mode updates across whole-wave sections. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 10:32 UTC · original · approved these changes

Updating self.mode16 = round16_after(&p.blocks[b].insts[j], self.mode16) inside the whole-wave section loop (emit/lower.rs:1372) aligns in-block lowering with the existing round16() block-entry analysis, and the regression verifies both s_round_mode and s_setreg_imm32_b32 mode changes before restoring EXEC. git merge-tree against current main (63bcca43) is clean, and emit/lower.rs is 520,652 bytes (under the 512 KiB limit).

Verified locally on Windows 11 x64 (RTX 5090 + WARP + dxil.dll, 2aa17674):

  • cargo run --locked -p xtask -- policy: passed (191 files ok)
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings (default and --all-features): clean
  • whole_wave_sections_keep_rounding_mode_changes -- --test-threads=1 (RTX 5090 and VICTORY_WARP=1): 1 passed, 0 failed on both
**@⁠fuzeofficlal** on GitHub · 2026-11-26 10:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/2886#pullrequestreview-6072499001) · **approved these changes** Updating `self.mode16 = round16_after(&p.blocks[b].insts[j], self.mode16)` inside the whole-wave section loop (`emit/lower.rs:1372`) aligns in-block lowering with the existing `round16()` block-entry analysis, and the regression verifies both `s_round_mode` and `s_setreg_imm32_b32` mode changes before restoring `EXEC`. `git merge-tree` against current `main` (`63bcca43`) is clean, and `emit/lower.rs` is `520,652` bytes (under the 512 KiB limit). Verified locally on Windows 11 x64 (RTX 5090 + WARP + `dxil.dll`, `2aa17674`): - `cargo run --locked -p xtask -- policy`: passed (`191 files ok`) - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` (default and `--all-features`): clean - `whole_wave_sections_keep_rounding_mode_changes -- --test-threads=1` (RTX 5090 and `VICTORY_WARP=1`): 1 passed, 0 failed on both
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/2886/head:github-bot/gh-2886'
git switch 'github-bot/gh-2886'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2886'
git switch 'github-bot/gh-2886'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2886'
git switch 'github-bot/gh-2886'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2886'
git switch 'main'
git merge --squash 'github-bot/gh-2886'
git switch 'main'
git merge --ff-only 'github-bot/gh-2886'
git switch 'main'
git merge 'github-bot/gh-2886'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2886
No description provided.