Shaders: preserve round mode changes in whole-wave sections #2886
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2886
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2886"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@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_aftertransfer function to instructions in the section as well. Add a synthetic compute regression that selects round-toward-zero withs_round_modeand restores round-to-nearest-even withs_setreg_imm32_b32in a second section. Both conversions run after EXEC is restored.Validation
0x3c00instead of truncating to0x3bff. The negative case also failed.victory-shaderwith all targets and features and warnings denied.AI-assisted (Codex). Validation used synthetic shaders only.
@fuzeofficlal on GitHub · 2026-11-25 23:10 UTC · original
Reviewed and verified
2aa17674on Windows 11 (RTX 5090 + WARP +dxil.dll) againstmain(842b0cb):self.mode16 = round16_after(&p.blocks[b].insts[j], self.mode16)right aftersection_instinside the whole-wave section loop preserves exact post-instruction rounding-mode semantics (s_round_mode/s_setreg_imm32_b32(HW_REG_MODE)).semantics_tests35/35 passed (includingwhole_wave_sections_keep_rounding_mode_changeson RTX 5090 + WARP +dxil.dll),emit::lower::tests33/33 passed,cargo clippy --locked -p victory-shader --all-targets -- -D warnings0 warnings,cargo xtask policy(191 files ok;emit/lower.rs=520,652bytes).Clean 1-line fix, ready to merge.
@Marvisak on GitHub · 2026-11-26 04:28 UTC · original
Automated triage for the maintainers.
Merge candidate. The lowering loop in
emit/lower.rsnow updatesmode16withround16_afterfor instructions inside whole-wave sections, so ans_round_modeor MODEs_setreginside a section is no longer lost for the rest of the block; this matches the block-entry analysisround16(), which already counts them. The test decodes correctly per the RDNA2 ISA and expectsv_cvt_f16_f32results to follow the mode per section.CI: passing.
Generated by Claude Code
@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.
@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).
@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 existinground16()block-entry analysis, and the regression verifies boths_round_modeands_setreg_imm32_b32mode changes before restoringEXEC.git merge-treeagainst currentmain(63bcca43) is clean, andemit/lower.rsis520,652bytes (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): cleanwhole_wave_sections_keep_rounding_mode_changes -- --test-threads=1(RTX 5090 andVICTORY_WARP=1): 1 passed, 0 failed on bothView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.