Skip to content

shader: lower v_div_fixup_f64 - #3673

Open
lambirou wants to merge 5 commits into
R0Y00:mainfrom
lambirou:shader/div-fixup-f64
Open

lambirou wants to merge 5 commits into
R0Y00:mainfrom
lambirou:shader/div-fixup-f64

Conversation

@lambirou

@lambirou lambirou commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The pixel AOT path still refused v_div_fixup_f64, while the coverage references list the VOP3 form in both gfx1013 and gfx1030. The direct-compute path has its own f16/f32 fixup handling, but the pixel path had no integer lowering or draw record for the binary64 form.

Change

  • Adds div_fixup64(l0, h0, l1, h1, l2, h2), a uint2 helper over the two raw binary64 words. No HLSL double, Int64ShaderOps or DoublePrecisionFloatShaderOps are required.
  • Implements the ISA section 12.12, opcode 352 rules in order: Quiet(S2), Quiet(S1), canonical negative qNaN for 0/0 and Inf/Inf, signed infinity for S1 zero or S2 infinity, signed zero for S1 infinity or S2 zero, signed zero below the exponent(S2) - exponent(S1) < -1075 boundary, else sign(S1) ^ sign(S2) | abs(S0).
  • Accepts the plain VOP3A spelling, even-aligned VGPR destination pairs, and aligned tracked VGPR or SGPR source pairs. It refuses literals, inline constants, abs/neg, clamp, omod, op_sel, DPP, SDWA, non-entry masks, unknown binary64 denormal entry state, sample overlaps and unaligned or untracked pairs.
  • Adds the source-built draw-div-fixup-f64 fixture
  • Keeps the fixture constants under a DIV64_ prefix: the later min/max fixture redefines F64_ONE/F64_TWO as 64-bit integers, which made the div-fixup rows pass an integer to div_fixup64_words., translation controls, a Python model, mutations, the coverage pin, CTest entries and documentation.

Tests

Commands run in the worktree:

python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/rdna2_tools_check.py
ctest --test-dir out/build/dev --no-tests=error -R ^pixel_aot_div_fixup_f64_ -V

Results:

  • form_coverage_check.py: form coverage checks passed.
  • docs_links_check.py: self-test passed; 192 Markdown files and 745 links checked.
  • rdna2_tools_check.py: 161 tests OK, with 19 LLVM-dependent capability skips reported separately.
  • pixel_aot_div_fixup_f64_hardware and _warp: 2/2 passed, no skips. Five one-line mutations each reported mismatch on both adapters.
  • Hardware: AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows 11 build 26300, debug layer unavailable. WARP: Microsoft Basic Render Driver 10.0.26100.10068.

Coverage delta

The record contains exactly v_div_fixup_f64, mapped to one VOP3 row in both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv: +1 gfx1013 and +1 gfx1030 in the isolated measurement.

Limits

This is desktop DXIL translation evidence, not a console measurement. It does not establish the console's NaN payload, subnormal, or rounding behavior. The lowering covers plain register-pair VOP3A only; modifiers, DPP, SDWA and literals remain out of scope.

AI-assisted.

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed e0833669 by reading the diff; not built or run.

Verdict: comment. The lowering is correct and I would approve it. As on #3657, the docs block carries a personal path, which is better fixed before merge. No MUST.

  • SHOULD The new docs/experiments.md block sets -DINTAKE_PYTHON= to an absolute path inside the author's own user folder (docs/experiments.md:18350). Use out/pe-env/Scripts/python.exe like the neighbouring commands, or drop the flag.
  • NIT #3657 and this PR add their helpers and the helpers emit lines at the same spots in tools/pixel_aot.py (after DIV_FMAS_HELPERS), so whichever lands second needs a small rebase.
  • Checked, no finding:
    • div_fixup64 (tools/pixel_aot.py:693) is the f32 rule on raw (low, high) words: NaN needs the low word (m == 0x7ff00000 && l != 0), quieting sets high bit 19, the canonical NaN is 0xfff80000_00000000, and zero and infinity test both words. The underflow bound −1075 is the binary64 analogue of −150 (bias + mantissa bits) on the 11-bit exponent m >> 20. The result copies S0's low word and |high| under the sign XOR. The unreachable exponent(S1) == 2047 branch is correctly omitted.
    • Operands: only aligned VGPR/SGPR pairs, every half tracked, and pending values refused through int_operand. A destination that partially overlaps a source pair is refused (:8319), and an exact overlap is safe because the sources are read into the helper call first. A non-entry mask, a pending sample and an unknown binary64 denormal entry state (:8315) are refused.

Tests: the draw-div-fixup-f64 rows (18 rows, 144 words, lossless readback) prove each rule bit for bit, including NaN payloads in both words and the exponent boundary. The five mutations show the rows can fail. 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 and rest on the author's WARP and RX 9060 XT runs.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both focused cases fail at a32c9c01 before the GPU draw. Independent Windows/MSVC Debug ctest --preset dev --no-tests=error -V -j 1 -R '^pixel_aot_div_fixup_f64_(warp|hardware)$' reports TypeError: cannot unpack non-iterable int object at div_fixup64_words(F64_THREE, F64_TWO, F64_SIX) in check_div_fixup64_draw. The merged file defines F64_TWO as an integer whereas the helper requires a (low, high) tuple. Please use a local/prefixed fixture constant and run both selectors after the fix. Please also use a checkout-relative interpreter path in the reproduction command.

The module-level F64_ONE and F64_TWO names are redefined later as 64-bit integers for the min/max fixture, so the div-fixup rows passed integers to div_fixup64_words. Use DIV64_ prefixed tuples inside this fixture.

Refs R0Y00#3518

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixture constant collision is fixed on e71963c7. The Windows MSVC Debug pixel_aot_div_fixup_f64_(warp|hardware) tests passed 2/2, and all five built-in mutations produced the expected mismatch on each adapter. pixel_aot_check.py and form_coverage_check.py passed. rdna2_tools_check.py completed 165 cases with 19 capability skips. I also resolved the sole merge conflict locally against main c42b7ce3 by keeping the heap-token paragraph, appending the new section, and using out/pe-env/Scripts/python.exe in the docs command. On that combined tree, both GPU tests and mutation sets passed again, as did form coverage and the 968-link docs check. Please carry the docs resolution into your branch so the required CI can run.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for merging main. The current head resolves the docs conflict. The remaining documentation line below still points to a machine-specific interpreter.

Comment thread docs/experiments.md

```powershell
.\tools\dev.ps1
cmake --preset dev -DINTAKE_PYTHON=C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the interpreter path relative to the checkout so a contributor can run this command as written.

Suggested change
cmake --preset dev -DINTAKE_PYTHON=C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe
cmake --preset dev -DINTAKE_PYTHON=out/pe-env/Scripts/python.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants