Shaders: honor explicit half input flush in normalized conversions #3166
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!3166
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3166"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-26 10:48 UTC · original
andrewpozdnakov7-jpg:fix/normalized-f16-input-denorms→main· +206 −76 · 3 files · 2 commits · open
V_CVT_NORM_I16_F16andV_CVT_NORM_U16_F16must read half subnormals as zero when MODE[6] disables input denormals. Lyrnc's RDNA2 sweep in #376 measured the distinction for both instructions.Reuse the existing MODE dataflow for statically known
S_DENORM_MODEand literal MODE writes. The analysis runs lazily for shaders that use either conversion. Known flush sites zero the source magnitude below the smallest normal half before scaling. Entry and runtime-unknown modes retain the current behavior.On main, signed conversion of
0x0101in flush mode returns0x0001. On WARP the patch gives0x0000, and all 274 synthetic readbacks passed across both conversions, the four denormal modes, explicit MODE bit writes and agreeing branch paths. All 36 VALU tests, strict shader Clippy and the asset policy passed.AI-assisted with Codex. Please retain the Git author when cherry-picking or rebasing. If folded into another commit, please add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.@andrewpozdnakov7-jpg on GitHub · 2026-11-26 11:03 UTC · original
Updated to
b5a1678to keep the normalized-half code and its MODE analysis in one module. The initial tree exceeded the repository's source-size limit when combined with #2623 and the independent shader fixes. The composed tree now passes the asset policy withlower.rsat 521,358 bytes. All 36 WARP VALU tests passed on the new PR head and all 44 passed with #2623 and the other shader changes. Strict shader Clippy passed.@Dukestar69 on GitHub · 2026-11-26 11:10 UTC · original · approved these changes
Verified on RTX 5090 & WARP against
origin/main(63bcca4):cargo test -p victory-shader --lib v_cvt_norm_f16_honors_input_denormal_mode -- --test-threads=1: passed on RTX 5090 and WARP.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.Cleanly honors explicit half-float input denormal flush mode in normalized f16 conversions.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@Lyrnc on GitHub · 2026-11-26 17:21 UTC · original
Checked
b5a1678on RDNA2 hardware, using your MODE writes, with the same instruction words on both sides.Hardware: Radeon iGPU (Ryzen 7 9800X3D), gfx1036 / RDNA2, driver 32.0.21042.62. A HIP kernel (assembled by the driver's amd_comgr) runs one of your two ways of setting the mode:
s_denorm_mode (d << 2) | 3, ors_denorm_modewith the opposite input bit, thens_setreg_imm32_b32 hwreg(MODE, 6, 1)and ans_nop 3.Then it runs three
v_cvt_norm_i16_f16or threev_cvt_norm_u16_f16. The 390 halves are:Each source has junk in its high half, and each destination is preset.
Translator: the same words through a local copy of the
build_valu_csharness (a local test, not part of this PR). I ran it onmain63bcca4and on the PR merged onto it, on the RTX 5080 (610.88) and on the same Radeon (picked with a local adapter-name filter inhardware_adapter).The runs cover 2 opcodes × 4 FP16 denormal modes × 2 ways of writing MODE, which gives 6,240 results.
v_cvt_norm_i16_f16(0x0101)gives0x0001, and(0x83ff)gives0xfffe;v_cvt_norm_u16_f16(0x0081)gives0x0001.s_setreg_imm32_b32on MODE[6] gives the same results ass_denorm_modein all 8 combinations. So the bit your analysis reads is the one the hardware uses.I did not run the case where two branches join, because the hardware side would need one SGPR value per wave.
No game data was used.
AI use: Claude Code (Claude Opus 5.5) wrote the probe and the comparison and ran them on the GPUs above; the numbers come from those runs.
View 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.