shader: lower compute v_cvt_u32_f32 with RDNA2 saturation #1905
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!1905
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1905/head"
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?
@henriazz10 on GitHub · 2026-11-24 20:44 UTC · original
henriazz10:shader/compute-cvt-u32-f32→main· +197 −1 · 4 files · 1 commits · merged 2026-11-24 21:23 UTCChange
Refs #721. This is the
v_cvt_u32_f32slice (item 5) claimed in #721. It touches onlytools/compute_store_aot.py,tests/compute_store_check.py,CMakeLists.txtanddocs/experiments.md.v_cvt_u32_f32_e32 vD, S0converts a binary32 source to an unsigned 32-bit integer with RDNA2 saturation: NaN and values<= 0.0give0, values>= 2^32(including+inf) give0xffffffff, and values in(0, 2^32)truncate toward zero.cvt_u32_f32helper only when called, clamping finite values to4294967040.0f(2^32 - 256) beforeuint()so even speculatively evaluated casts stay in range.S0accepts a VGPR holding a known word, a ready SGPR, a 32-bit literal, an integer inline constant or an inline float constant (FLOAT_INLINE), including NaN, infinity and denormal constants.s30), pending SGPR (s12), unknown VGPR (v40), unaccepted float literal (1.5), out-of-range integer literal (0x100000000);v255(v256);v_cvt_u32_f32_e64, barev_cvt_u32_f32), input modifiers (-v1,|v1|), output modifiers (clamp,mul:2) and register range (v[1:2]).Verification
Commit
0c560c21, rebased onto27cf223d(after #1904 merged). The draws,controls()and the LLVM 15 round trip were re-run on0c560c21. Windows 11, DXC 10.0.26100.0, Python 3.12 (out/pe-env), debug layer enabled.offscreen_checkwas built from an earliermain; this PR does not change it.groups=1 compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0groups=1 compared_words=320 mismatches=0,debug_errors=0 debug_warnings=0x2w-llvm15Dockerbinary_exit=0docs_links_check.pyChecked 18 Markdown files and 376 links.)bidi_controls_check.pyChecked 1330 tracked source, script and build/CI files: no bidirectional controls.)git diff --check HEAD~1cvt_u32_f32_binary()decodes the assembled fixture back to the samev_cvt_u32_f32_e32lines and requires the same translation.Negative control. With
tools/compute_store_aot.pyfromorigin/main(b80058f0),cvt_u32_f32_controls()fails withValueError: Unsupported compute instruction: v_cvt_u32_f32_e32 v4, v1.Evidence
The fixture is source-built in LLVM 15 spelling (
CVT_U32_F32, 32 threads, stride 16, 128 active words and 128..319 sentinel). It covers0.75,1.5,3.0..3*2^29,2^32 - 256,2^32,> 2^32,FLT_MAX,+inf,sNaN,qNaN,-0.0,-denorm,-inf,-1.0,4.0and an SGPR5.0, comparing all 320 words against an independent Python model (cvt_u32_f32_word).cvt_u32_f32_controls()checks the emittedcvt_u32_f32helper, helper omission when unused, integer inline0, NaN/denormal constants and all rejection conditions.0;2^32: word65;0xffffffff: word3;128.2^32saturation dropped;4.0replaced by2.0;0.75replaced by1.0.Checklist
docs/experiments.md).AI-assisted. Gemini 4 Hydrogen (Antigravity CLI) wrote the change and ran the checks; Claude Code reviewed it.
🤖 Generated with Claude Code
@tedin7 on GitHub · 2026-11-24 20:57 UTC · original · reviewed
Review of head 74446809f58b6a0b95afce2c10e3c2febd0c50a2 (TIER_D_ISOLATED_SHADER_OPS; files: CMakeLists.txt, docs/experiments.md, tests/compute_store_check.py, tools/compute_store_aot.py).
Commands executed locally:
Mutations of tool logic (each reverted with git checkout -- .):
P1: 0. P2: 0. The lowering matches the documented saturation (NaN and <= 0 give 0, >= 2^32 gives 0xffffffff, otherwise truncate), and the clamp below 2^32 keeps speculative casts in range.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-24 21:10 UTC · original · reviewed
Review of head
bc349a3e9fc04365085e8ac432fae12aac4ba54a(technical comment only, no merge from this pass).Blocked: the branch conflicts with current main, and the head has moved. GitHub reports
CONFLICTING/DIRTY.git merge-tree --write-tree --name-only origin/main <head>reports a content conflict intests/compute_store_check.py; the other files merge cleanly. The last review on record is for74446809, so this head has no receipt. Please rebase on main and resolve it, then ask for a new review.Commands run (Linux):
git fetch origin pull/1905/head,git merge-tree --write-tree --name-only origin/main <head>(rc=1),python3 x2w_pipe.py safe-merge-check(verdict BLOCK: conflict, receipt missing).No receipt and no merge.
AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-24 21:23 UTC · original · reviewed
Review of head
0c560c218eScope: TIER_D_ISOLATED_SHADER_OPS. Files: CMakeLists.txt (one new ctest entry plus its SKIP_RETURN_CODE for the hardware variant, nothing else), docs/experiments.md, tests/compute_store_check.py, tools/compute_store_aot.py. Author henriazz10. New head after the rebase; the earlier reviews on 74446809 and bc349a3e are superseded. Merge state: MERGEABLE, no conflict (git merge-tree --write-tree --name-only origin/main HEAD: rc=0).
Semantics read against the RDNA2 definition of v_cvt_u32_f32: NaN -> 0, values <= 0 -> 0, values >= 2^32 (including +inf) -> 0xffffffff, otherwise truncation toward zero. The helper forces NaN to 0, clamps finite values to [0, 4294967040.0f] (the largest binary32 below 2^32, so no value is lost) and saturates at 2^32 before uint(). Operands are limited to known words, modifiers/_e64/range are refused, and the helper is emitted only when used. The independent Python model in the test agrees.
Commands executed locally:
Mutation checks (logic in tools/compute_store_aot.py, each reverted with git checkout -- .):
Note: the helper body itself is checked on the device side, where the test recompiles HLSL with the 2^32 saturation dropped and with 4.0 replaced by 2.0 and requires each to fail (this ran in the Win2025 passes above).
Findings: P1=0, P2=0.
AI-assisted; commands listed were executed locally.