Repository navigation
shader: lower v_div_fixup_f32 in the pixel AOT path - #3657
Conversation
Add the plain VOP3A v_div_fixup_f32 finalization on raw 32-bit words, with the ISA NaN priority, canonical invalid NaN, signed zero/infinity cases, -150 underflow boundary and sign(S1)^sign(S2)|abs(S0) default. Add the draw-div-fixup fixture, five detecting mutations, form-coverage pin, scanner support and experiment note.
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed fb934b05 by reading the diff; not built or run.
Verdict: comment. The lowering is correct and I would approve it. The one SHOULD is a one-line docs fix that is better made before merge than after. No MUST.
- SHOULD The new
docs/experiments.mdblock sets-DINTAKE_PYTHON=to an absolute path inside the author's own user folder (docs/experiments.md:14484). It is a personal path in public docs, and it won't work for anyone else. The other commands in the same block use.\out\pe-env\Scripts\python.exe, so-DINTAKE_PYTHON=out/pe-env/Scripts/python.exe(or no flag at all) fits. - Checked, no finding:
div_fixup32(tools/pixel_aot.py:692) uses the same priority order and constants as the existing referencetests/native_div_fixup_f32_check.py:61, which the direct compute path already uses: Quiet(S2), Quiet(S1), canonical0xffc00000for 0/0 and Inf/Inf, signed Inf, signed zero, the< -150exponent rule on raw exponents, then sign XOR over |S0|. The pixel and compute paths therefore agree, including an S0 NaN copied by magnitude.- The handler reads raw words with
asuint(fp_operand(...)). It refuses modifiers, clamp/omod, literals and inline constants by matching only plain[vs]Noperands, refuses a non-entry mask and an overlap with a pending sample, and range-checks the VGPR/SGPR indices. The helper is emitted only when used. The scanner pattern accepts the same spelling.
Tests: the draw-div-fixup rows (22 × 4 words, lossless R32G32B32A32_UINT) prove each rule bit for bit, including the −150/−151 boundary and NaN payloads. The five mutations show the rows catch a sign, priority, canonical-NaN, signed-zero or S1/S2 swap error. CI ran pixel_aot_check.py, form_coverage_check.py and rdna2_tools_check.py at this head. The WARP/hardware draws are outside the pr filter, so they rest on the author's WARP and RX 9060 XT runs.
R0Y00
left a comment
There was a problem hiding this comment.
Independent Windows checks passed on dcacef36: exact-head pixel translator and form coverage checks, plus draw-div-fixup on WARP and RTX 4060 Laptop. All five mutations mismatched on both adapters. This merges cleanly with current main. The one remaining documentation line is the checkout-specific interpreter path previously raised by lukaslw-lab.
R0Y00
left a comment
There was a problem hiding this comment.
The reproduction now uses the checkout default Python path. In the current form_coverage_check.py, however, the main block no longer invokes check_mullit_coverage. I compared the module-level calls on this head with current main: the function is still defined, but its only invocation is gone. Please keep the new div-fixup test and restore the existing MULLIT call in the active main block, then rerun python -B tests/form_coverage_check.py.
R0Y00
left a comment
There was a problem hiding this comment.
Re-reviewed 673e197. The active coverage entry point retains MULLIT and the new divide-fixup check, and the documented command uses the repository interpreter. form_coverage_check.py passed in the project Python environment. A deliberately failing MULLIT assertion also caused the entry point to fail. Windows build 26300, SDK DXC, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656: draw-div-fixup passed on both adapters, including all five failure mutations, with no skips. This resolves my previous change request.
Problem
v_div_fixup_f32(VOP3, gfx1013/gfx1030) is listed asunobservedin thecoverage tables. The direct-DXIL compute path has its own lowering and hardware
test, but the pixel
pixel_aotpath had no lowering and no passing fixture thatwrites a coverage record. No open pull request covers the f32 form; #3594 only
covers the binary16 form and is not a dependency.
Change
tools/pixel_aot.py: add the integerdiv_fixup32(s0, s1, s2)helper and aplain VOP3A lowering. It follows the RDNA 2 ISA section 12.12, opcode
351
and the existing
tests/native_div_fixup_f32_check.py::div_fixup_f32:Quiet(S2)beforeQuiet(S1),0xffc00000for 0/0 and Inf/Inf, signedinfinity for
S1 == 0orabs(S2) == Inf, signed zero forabs(S1) == Infor
S2 == 0, signed zero forexponent(S2) - exponent(S1) < -150, andsign(S1) ^ sign(S2) | abs(S0)otherwise, including an S0 NaN._e64),VGPR/SGPR sources and a VGPR destination.
abs/neg,clamp,omod,op_sel, DPP, SDWA, literals, inline constants, a non-entry mask and a writeoverlapping a pending sample are refused.
tests/pixel_aot_check.py: adddraw-div-fixup, 22 constant rows evaluatedfour ways each through the lossless
R32G32B32A32_UINTtarget, and compareevery word with
native_div_fixup_f32_check.div_fixup_f32. The rows cover thefinite default, both signed-zero defaults, both signs of S1 zero, S2
infinity, S1 infinity and S2 zero, 0/0, Inf/Inf, quiet/signaling NaNs with
payloads in S1 and S2, S2 priority, an S0 NaN, the -150/-151 boundary and
mixed signs. Five one-line mutations must mismatch: inverted sign XOR,
reversed NaN priority, non-canonical 0/0, lost signed zero and swapped S1/S2
special cases.
pixel_aot_div_fixup_warpandpixel_aot_div_fixup_hardwarewithFORM_COVERAGE_RECORD; pin exactly("VOP3", "v_div_fixup_f32")intests/form_coverage_check.py; add scanner support and its refusal controlin
tests/rdna2_tools_check.py; document the behavior indocs/experiments.md.Verification
Exact commands run from the worktree root:
Results:
offscreen_checkbuilt; the fullcmake --build --preset devcompleted with exit 0 (incremental re-run: no work beyond the build stamp).
python -B tests/pixel_aot_check.py: exit 0.ctest --preset dev --no-tests=error -R '^pixel_aot_div_fixup_' -V: 2/2passed, 0 failed, no skips.
pixel_aot_div_fixup_hardware6.88 s;pixel_aot_div_fixup_warp5.80 s. Both printed the five mutations asmismatch.10.0.26100.10068.1002:7590, driver32.0.32029.2010), Windows 11 build26300.0, DXC1.8.2502.11;the D3D12 debug layer was unavailable in this environment.
v_div_fixup_f32and no_e64, f16 or f64 form.gfx_formsmaps the record to one("VOP3", "v_div_fixup_f32")row in bothgfx1013.tsvandrdna2.tsv.Expected delta: +1 gfx1013 and +1 gfx1030.
python -B tests/form_coverage_check.py:form coverage checks passed.python -B tests/rdna2_tools_check.py: 161 tests,OK (skipped=19);the 19 skips are the LLVM-library-dependent cases, reported separately.
python -B tests/docs_links_check.py: self-test passed; 192 Markdown filesand 745 links checked.
Limits
No console measurement is claimed. The draws show the translated HLSL on WARP
and on one physical RDNA 4 adapter, not native RDNA 2 behavior. The ISA
Quiet()rule is applied to every signaling NaN; a guest MODE that leavessignaling NaNs unquieted is not modelled. The lowering covers plain VOP3A
register sources only; DPP, SDWA, literals, inline constants and modifiers stay
out of scope. No native RDNA 2 readback is claimed for the underflow or NaN
payload rows.
AI-assisted: yes (deepseek-v4.1-flash).