Shaders: emit fewer instructions for FP16 denormal rounding #3620
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!3620
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3620"
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-27 22:34 UTC · original
andrewpozdnakov7-jpg:codex2/fp16-denormal-rounding-cost→main· +19 −15 · 2 files · 1 commits · openFor #2384. Narrowing f32 to f16 still uses the software path in several shader instructions. This shortens the calculation for magnitudes below the smallest normal half by adding the nearest-even bias to the mantissa before shifting it. The clamped shift already yields zero for f32 subnormals, so the explicit zeroing step can go.
For a generated compute shader with one runtime
v_cvt_f16_f32and a readback, DXIL instructions fell from 62 to 55 under nearest-even and from 46 to 44 under round-to-zero. The same shader passed readback and validation on Windows WARP 1.0.22 with D3D12 Agility 1.620.2.A CPU sweep compared both integer calculations for every magnitude below the smallest normal half, including zero, across both rounding modes. All 947,912,704 magnitudes match. The expanded WARP regression passes 62 inputs under both modes, including both signs and values around four subnormal midpoints. Both strict shader Clippy configurations and the asset policy passed.
Coordination claim
AI-assisted with OpenAI Codex.
@andrewpozdnakov7-jpg on GitHub · 2026-11-27 22:37 UTC · original
Verified
0fcf49don Windows with app-local WARP 1.0.22 and the DXIL validator. For one runtime conversion, the disassembler counts 62 → 55 instructions under nearest-even and 46 → 44 under round-to-zero. The DXIL containers also shrink from 2,392 to 2,356 bytes and from 2,316 to 2,304 bytes, respectively.The CPU comparison covered all 947,912,704 magnitudes below the smallest normal FP16 value in each mode. The expanded WARP test passed 62 inputs under both settings, including ties at zero, odd and even retained bits, the normal boundary, and their signed counterparts. Both strict shader Clippy configurations and the asset policy passed. Windows CI for this head
Git's merge checks with #3617, #2943 and #3365 are clean. These are useful as independent changes to the rounding rule, the NaN path and the output denormal setting.
Please keep the Git author on a cherry-pick or rebase, or add
Co-authored-by: andrewpozdnakov7-jpg <[email protected]>if this work is folded into another commit.AI-assisted with OpenAI Codex.
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.