shader: lower v_cvt_f64_i32 and v_cvt_f64_u32 in pixel_aot #1356
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1363"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-24T09:22:01Z.
Refs #1325
Change
This is the first binary64 slice agreed in #1325.
tools/pixel_aot.pylowers the exact 32-bit integer to binary64 conversionsv_cvt_f64_i32andv_cvt_f64_u32into a VGPR pairv[d:d+1].uintoperations: the sign, the exponent1023 + firstbithigh, and the bits below the leading one shifted to the top of the 52-bit fraction. No HLSLdoubleis emitted, so the shader needs no double-precision capability and no capability skip applies. Zero gives+0.0(both words 0), andINT_MINgives0xc1e00000_00000000._e32(LLVM 15 prints_e32and accepts both)._e64(also without modifiers, which is narrower than necessary),clamp,omod, source modifiers, DPP, SDWA, a destination that is not a two-register VGPR range or goes above v255, and use inside a masked region.v_add_f64,v_mul_f64,v_cvt_*_f64,v_cmp_*_f64and the rest stay unsupported. Arithmetic, conversions out of binary64 andv_cvt_f64_f32are left out, as agreed.VOP1Instructions.tdatllvmorg-15.0.7. Not checked against the ISA document and not measured on a console. LLVM 15 assembles unaligned pairs, so they are accepted; hardware legality is assumed, not measured.Test
Mode and registration: new mode
draw-cvt-f64-int, registered aspixel_aot_cvt_f64_int_hardwareandpixel_aot_cvt_f64_int_warp, with a 60 s timeout, skip code 77 and its ownFORM_COVERAGE_RECORD. The LLVM 15 round trip covers the programs.Programs: four of them,
i32_sgpr,u32_sgpr,i32_vgprandu32_vgpr. Each writesv[13:14]and keeps distinct sentinels inv12andv15.Reference: independent of the lowering, Python
struct.pack('<d', float(x)).Rows: 0,
INT_MIN,INT_MAX, -1,UINT_MAX,UINT_MAX - 1and0x7fffffff. Also 2^24 - 1, 2^24 and 2^24 + 1 with their negative counterparts, and the integer patterns0x3f800000and0xbf800000.Export: both words go through the
R32G32B32A32_UINTtarget, each xor-ed with a per-row mask taken from the constants. The xor is a bijection, so the comparison stays bit for bit, and it keeps every exported word a normal binary32 or zero, which the test asserts. For example, the low word ofUINT_MAXis0xffe00000, a NaN pattern.Wrong references, each of which must report
pixel_mismatch:The test asserts that each kind is drawn.
Mutating the lowering (swapped words, swapped signedness, a mantissa bit, the exponent) turns
draw-cvt-f64-intred each time. Againstmain'stools/pixel_aot.py, the mode fails withValueError: Unsupported instruction 22: v_cvt_f64_i32_e32 v[13:14], s44.On commit
597f1710(rebased on623e2112), with an NVIDIA GeForce RTX 3080 (driver 32.0.16.2124), WARP 10.0.26100.9818 and Windows 11 build 26200, debug layer unavailable:The pure checks pass (
pixel_aot_check.py controls,form_coverage_check.py,rdna2_tools_check.py,pso_readiness_check.py,docs_links_check.py), and so does the LLVM 15.0.7 binary round trip.AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:28:44Z.
Review: COMMENTED
Technical peer review at commit
597f17106ff3a60d6b325f16354a71740876a5fc(LGTM, no blocking findings):Code audit:
tools/pixel_aot.py:v_cvt_f64_(i32|u32)(?:_e32)?lowers exact 32-bit signed/unsigned integer to binary64 into an adjacent VGPR pairv[d:d+1](last == first + 1,last <= 255,mask == "entry", neither register insample_dest). Constructs both binary64 words fromuintoperations (firstbithigh,0u - c{i}xfor signed negation,0->+0.0) without emitting HLSLdouble, readssrcbefore writing the destination pair, and leaves_e64, modifiers, DPP/SDWA, masked regions, and binary64 consumers rejected.tests/pixel_aot_check.py,tests/form_coverage_check.py,CMakeLists.txt,docs/experiments.md: addscheck_cvt_f64_int_lowering(),draw-cvt-f64-int(pixel_aot_cvt_f64_int_hardwareandpixel_aot_cvt_f64_int_warp) withFORM_COVERAGE_RECORD, and non-vacuous negative controls (swapped words, swapped signedness, sentinel overwrite, exponent +1, flipped mantissa bit).Checks:
docs_links_check.py(16 Markdown files, 301 links),bidi_controls_check.py(1145 files),pixel_aot_check.py,rdna2_tools_check.py(138 tests, 18 skipped), andform_coverage_check.pyall passed;git diff --checkclean.--preset dev,offscreen_check):pixel_aot_cvt_f64_int_hardware(2.97s) +pixel_aot_cvt_f64_int_warp(2.98s) — 2/2 passed (3.05s)./O2(--preset release,offscreen_check):pixel_aot_cvt_f64_int_hardware(2.74s) +pixel_aot_cvt_f64_int_warp(2.77s) — 2/2 passed (2.85s).tests/form_coverage_check.pypassed (40.53s).Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T10:13:47Z.
I integrated this with #1349 in
844cc9ec. The conversion can now feed an existing binary64 comparison, so the old rejection control has become a positive lowering check. Arithmetic and reverse conversions are still rejected. Conversion and comparison readbacks both passed on RTX 4060 Laptop and WARP, along with form coverage and the lowering controls. GitHub is checking the combined head.