shader: lower gfx1013 v_cvt_u32_f32_e64 and v_cvt_i32_f32_e64 in pixel_aot #534
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/540"
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 alexander-src on 2026-11-22T10:10:30Z.
Change
Refs #360.
Lower gfx1013 VOP3 truncating float-to-integer conversions (
v_cvt_u32_f32_e64andv_cvt_i32_f32_e64) intools/pixel_aot.pywith optional sourceabsandnegmodifiers (|src|,abs(src),-src,neg(src),-|src|,-abs(src),neg(abs(src)),neg(|src|)) on VGPR, SGPR, or 32-bit hex literal sources under the entry mask (+2 VOP3 forms in bothgfx1013.tsvandrdna2.tsv).Plain
_e32handling from #545 and #438 is left untouched, andv_cvt_flr_i32_f32/v_cvt_rpi_i32_f32remain rejected for a separate follow-up.tools/pixel_aot.py: addparse_cvt_f32_e64_sourceand thev_cvt_(u32|i32)_f32_e64lowering branch. Source modifiers apply bitwise (& 0x7fffffffuforabs, then^ 0x80000000uforneg) to the raw IEEE-754 word before calling the sharedcvt_u32_f32andcvt_i32_f32helpers insrc/ffx_float_to_int.hlsli. Rejectsclamp,omod, decimal/float literals, bare-0x..., reversed modifiers (|-src|), DPP/SDWA variants, pending scalar/sample reads, WQM mask execution, and FLR/RPI forms.tools/scan_unsupported_shaders.pyandtests/rdna2_tools_check.py: recognize supportedv_cvt_{u32,i32}_f32_e64source modifier forms while keepingclamp,omod, decimal/float literals,-0x...,|-src|, double spaces, and FLR/RPI rejected.tests/pixel_aot_check.py: add_e64codegen/diagnostic controls, LLVM binary round-trip fixtures, andcheck_cvt_float_int_e64_drawusing losslessR32G32B32A32_UINTreadback across all 18CVT_FLOAT_WORDS(SGPR and VGPR), five modifier sets (fractions, saturation limits,±Inf,-0.0, quiet/signaling NaNs, and-min_subnormal), bitwise single-bit flip negative controls, a plainu32/i32swap control, and shader-mutation negative controls dropping eachabsandnegmodifier individually.tests/pixel_uint_conversion_check.py: update the whole-quad_e64diagnostic check to expectInvalid conversionand add aclamprejection check.tests/form_coverage_check.py: assertVOP1e32 andVOP3e64 coverage in bothgfx1013.tsvandrdna2.tsvwhile FLR/RPI stay excluded.docs/experiments.md: record the_e64lowering, bitwise modifier rules, and negative controls.Verification
Tested on Linux x64 at commit
3c68a90(rebased onmaind3586dd) with Python 3 and LLVM 23.1.4 (llvm-mc,llvm-objcopy,/usr/lib/libLLVM.so):out/pe-env/bin/python -B tests/pixel_aot_check.py binary llvm-mc llvm-objcopy /usr/lib/libLLVM.so: passed.out/pe-env/bin/python -B tests/form_coverage_check.py: passed.out/pe-env/bin/python -B tests/pso_readiness_check.py: passed.out/pe-env/bin/python -B tests/rdna2_tools_check.py: passed (41 tests, 1 skipped without LLVM 15).out/pe-env/bin/python -B -c "import sys; sys.path.insert(0, 'tests'); import pixel_uint_conversion_check; pixel_uint_conversion_check.check_forms()": passed.out/pe-env/bin/python -B tests/docs_links_check.py: passed.out/pe-env/bin/python -B tests/bidi_controls_check.py: passed.Could not run DXC / D3D12 WARP or hardware draws locally on Linux (no Windows SDK, DXC, or D3D12 runtime); Windows CI runs
pixel_aot_e64_warpandpixel_aot_u32_from_f32_warp.Evidence and follow-up
All fixtures are synthetic gfx1013 assembly programs written directly in
tests/pixel_aot_check.py. Plain_e64emits identical HLSL to_e32, and source modifiers manipulate the sign bit before callingsrc/ffx_float_to_int.hlsli. Follow-up work forv_cvt_flr_i32_f32andv_cvt_rpi_i32_f32is left for a separate PR once an independent native reference covers raw-word edge cases.Checklist
AI-assisted: yes (rebased, narrowed to
_e64per review, and verified locally with the Linux + LLVM test suite listed above).Imported from R0Y00/Xbox2Windows. Originally posted by MarlomMedeiros on 2026-11-22T18:08:41Z.
Review: COMMENTED
Community review + independent run, since the PR notes DXC/D3D12/WARP could not run on the authoring Linux host.
Environment
3c68a90on based3586ddctest --preset dev --no-tests=error -R '^pixel_aot_(u32_from_f32|e64)_(warp|hardware)$' -V: 4/4 passeddebug_errors=0 debug_warnings=0,pixels=4096 max_absolute_error=0tests/pixel_aot_check.pycontrols,tests/form_coverage_check.py,tests/rdna2_tools_check.py(41 tests, 1 skipped) and the LLVM 15.0.7 binary round-trip all passReview notes
absmasks the IEEE sign bit (& 0x7fffffff) andnegflips it (^ 0x80000000) on the raw word before the shared truncatingcvt_{u32,i32}_f32helper. Reusing the FFx conversion helper keeps rounding identical to the e32 forms.parse_cvt_f32_e64_sourceshows real disassembler awareness: bare-0x...rejects because llvm-mc folds two's-complement negation on hex literals instead of setting the sign-flip modifier (neg(0x...)is the accepted spelling), whileabs(),|x|and-|x|all map correctly.|-s|,--s, register bounds on both sides, unbound vector inputs, plus pending-load and attribute-mask placements.v_cvt_u32_f32_e64 v12, s44line correctly moved from the reject list to an accept, and both conversions exercise the lossless integer readback.No blockers found.
AI-assisted: yes. All reported checks ran locally on the adapter and driver listed.
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T10:24:03Z.
Heads-up on overlap, so we don't duplicate work: #438 (open since 03:10 UTC today) already lowers
v_cvt_u32_f32_e32andv_cvt_i32_f32_e32inpixel_aot. It is the stage 3 of #360 that I claimed there, and @abilliontokens confirmed the split. Like this PR, it truncates, maps NaN to 0, saturates, and uses clamped helper casts. The draws cover 18 binary32 words plus SGPR rows and a u32/i32 swap control. CI is green, and the maintainer has already pushed onto it. It also treatsv_cvt_flr_i32_f32andv_cvt_rpi_i32_f32as rejections.The parts of #540 that #438 does not cover are the
_e64forms withabs/negandv_cvt_flr_i32_f32/v_cvt_rpi_i32_f32. A suggestion, if that works for you and the maintainer: keep #540 to those additions on top of #438, or the other way round if @R0Y00 prefers #540's approach. I'm happy to rebase #438 or drop the overlapping part, whichever is decided.This comment is AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T11:00:42Z.
Let’s land the e64 truncating conversions with source abs/neg after #438. Please reuse the shared float-to-int helper, preserve the modifier and bitwise negative controls, and leave the plain e32 implementation to #545 and #438.
Please keep the FLR/RPI work for a separate follow-up. The finite reference is floor for FLR and nearest with half-integer ties toward +∞ for RPI. Before extending to NaN, infinities, or out-of-range values, we need an independent native reference that can observe those results as raw words, including values around ±0.5 and both integer endpoints.
Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-22T13:05:34Z.
Thanks @R0Y00 and @JB2WIN. Rebased onto
mainafter #438 and #545, narrowed this PR tov_cvt_u32_f32_e64andv_cvt_i32_f32_e64with optional sourceabs/neg, and left plain_e32untouched and FLR/RPI out for a separate follow-up.Source modifiers now operate bitwise (
& 0x7fffffffuthen^ 0x80000000u) before calling the sharedcvt_u32_f32/cvt_i32_f32helpers fromsrc/ffx_float_to_int.hlsli, with losslessR32G32B32A32_UINTdraws covering all 18CVT_FLOAT_WORDSplus five modifier sets, single-bit flip negative controls, a plainu32/i32swap control, and shader-mutation controls dropping eachabsandnegmodifier individually. Updated the scanner, form coverage checks, whole-quad diagnostic test, anddocs/experiments.md, and ran the Linux + LLVM binary/control/tool checks locally (Windows DXC/WARP draws are running in CI now).AI-assisted: yes
Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-22T18:31:20Z.
Thanks @MarlomMedeiros for running the RTX 5070 and WARP checks on the _e64 draw suite. Rebased onto
719552e(3c68a90 ->c90d3f5) to clear the conflicts in tests/pixel_aot_check.py and tests/rdna2_tools_check.py, and re-ran pixel_aot_check.py binary, form_coverage_check.py, pso_readiness_check.py, rdna2_tools_check.py (49 passed, 1 skipped), pixel_uint_conversion_check.check_forms(), docs_links_check.py, and bidi_controls_check.py locally.AI-assisted: yes
Imported from R0Y00/Xbox2Windows. Originally posted by rwZephyr on 2026-11-22T18:47:25Z.
Independent Windows 10 retest after the rebase, on
c90d3f507aef44e9bc720bafb808258be72895c9. Windows 10 22H2 build19045.6466, MSVC19.44.35230, Windows SDK10.0.26100.0, DXC1.8.2502.11. The Debug build used/MTd. D3D12 debug layer unavailable on both backends.10de:2414), driver621.24(32.0.16.2124via DXGI). Both tests passed.1414:008c), driver10.0.19041.5794. Both tests passed.I also called
check_cvt_float_int_e64_drawdirectly on each backend. All 19 positive draws matched the integer reference bit-for-bit across all 4,096 pixels per draw, including NaNs, infinities, and saturation boundaries. All 14 negative controls produced the expected mismatches.AI-assisted. All reported runs were executed locally.