shader: lower the 16-bit three-operand float VOP3 ops in pixel_aot #1459

Closed
agilesh08 wants to merge 1 commit from upstream-pr/1466 into main
agilesh08 commented 2026-11-24 12:01:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-24T12:01:53Z.


Summary

Lowers the three remaining unlowered 16-bit float ternary VOP3 math instructions (v_min3_f16, v_max3_f16, and v_med3_f16) in tools/pixel_aot.py across their unsuffixed and _e64 spellings, completing RDNA2 VOP3 ternary floating-point coverage.

Implementation Details

  • Lowering (tools/pixel_aot.py):

    • Widens each 16-bit operand using widen16(hf...).
    • Evaluates under precise mode using HLSL intrinsics: min(min(a, b), c) for v_min3_f16, max(max(a, b), c) for v_max3_f16, and max(min(a, b), min(max(a, b), c)) for v_med3_f16.
    • Narrows the result with narrow16(hs...) and tags the destination as ("half16", alu).
    • Enforces the binary16 finite proof contract via half16_arith_source (accepting proven inline constants, numeric literals, scalar constant registers, and prior half16 arithmetic results).
    • Emits exact rational tracking via f16_min3_max3_med3_result with signed-zero tie breaking (-0.0 < +0.0).
  • Scanner & Tooling (tools/scan_unsupported_shaders.py, tests/rdna2_tools_check.py, tests/pso_readiness_check.py):

    • Registers PIXEL_VOP3_F16_TERNARY in opcode tables and adds syntax parsing regex for v_min3_f16, v_max3_f16, v_med3_f16.
    • Adds syntax and negative control tests in tests/rdna2_tools_check.py and tracking assertions in tests/pso_readiness_check.py.
  • Form Coverage (tests/form_coverage_check.py):

    • Verifies that ("VOP3", "v_min3_f16"), ("VOP3", "v_max3_f16"), and ("VOP3", "v_med3_f16") are counted as covered in both gfx1013.tsv and rdna2.tsv when translated with translate_f16, and remain uncovered without the accepted fixtures.
  • Draw Fixture & CMake (tests/pixel_aot_check.py, CMakeLists.txt):

    • Adds draw-f16-ternary test harness covering 18 programs (all 6 strict permutations of values, negative values, mixed signs, subnormals, all 4 tie shapes, and chained arithmetic results) through bit-exact R32G32B32A32_UINT readback.
    • Verifies five deliberate mutation deviations (med3_as_min3, med3_as_max3, max3_as_min3, min3_as_max3, and source_high).
    • Registers pixel_aot_f16_ternary_${adapter} with timeout and form coverage logging in CMakeLists.txt.
  • Documentation (docs/experiments.md):

    • Documents the instruction semantics, low-16 operand contract, half16 result tagging, draw harness, and mutation testing.

Evidence

All local verification checks pass on Windows:

python -B tests/form_coverage_check.py
python -B tests/rdna2_tools_check.py
python -B tests/pso_readiness_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
python -c "import tempfile, pathlib; import tests.pixel_aot_check as p; p.check_controls(pathlib.Path(tempfile.mkdtemp()))"
git diff --check

All checks exit with code 0.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6581297744 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466). Originally posted by [agilesh08](https://github.com/agilesh08) on 2026-11-24T12:01:53Z. --- ## Summary Lowers the three remaining unlowered 16-bit float ternary `VOP3` math instructions (`v_min3_f16`, `v_max3_f16`, and `v_med3_f16`) in `tools/pixel_aot.py` across their unsuffixed and `_e64` spellings, completing RDNA2 `VOP3` ternary floating-point coverage. ## Implementation Details - **Lowering (`tools/pixel_aot.py`):** - Widens each 16-bit operand using `widen16(hf...)`. - Evaluates under `precise` mode using HLSL intrinsics: `min(min(a, b), c)` for `v_min3_f16`, `max(max(a, b), c)` for `v_max3_f16`, and `max(min(a, b), min(max(a, b), c))` for `v_med3_f16`. - Narrows the result with `narrow16(hs...)` and tags the destination as `("half16", alu)`. - Enforces the binary16 finite proof contract via `half16_arith_source` (accepting proven inline constants, numeric literals, scalar constant registers, and prior `half16` arithmetic results). - Emits exact rational tracking via `f16_min3_max3_med3_result` with signed-zero tie breaking (`-0.0 < +0.0`). - **Scanner & Tooling (`tools/scan_unsupported_shaders.py`, `tests/rdna2_tools_check.py`, `tests/pso_readiness_check.py`):** - Registers `PIXEL_VOP3_F16_TERNARY` in opcode tables and adds syntax parsing regex for `v_min3_f16`, `v_max3_f16`, `v_med3_f16`. - Adds syntax and negative control tests in `tests/rdna2_tools_check.py` and tracking assertions in `tests/pso_readiness_check.py`. - **Form Coverage (`tests/form_coverage_check.py`):** - Verifies that `("VOP3", "v_min3_f16")`, `("VOP3", "v_max3_f16")`, and `("VOP3", "v_med3_f16")` are counted as covered in both `gfx1013.tsv` and `rdna2.tsv` when translated with `translate_f16`, and remain uncovered without the accepted fixtures. - **Draw Fixture & CMake (`tests/pixel_aot_check.py`, `CMakeLists.txt`):** - Adds `draw-f16-ternary` test harness covering 18 programs (all 6 strict permutations of values, negative values, mixed signs, subnormals, all 4 tie shapes, and chained arithmetic results) through bit-exact `R32G32B32A32_UINT` readback. - Verifies five deliberate mutation deviations (`med3_as_min3`, `med3_as_max3`, `max3_as_min3`, `min3_as_max3`, and `source_high`). - Registers `pixel_aot_f16_ternary_${adapter}` with timeout and form coverage logging in `CMakeLists.txt`. - **Documentation (`docs/experiments.md`):** - Documents the instruction semantics, low-16 operand contract, `half16` result tagging, draw harness, and mutation testing. ## Evidence All local verification checks pass on Windows: ```powershell python -B tests/form_coverage_check.py python -B tests/rdna2_tools_check.py python -B tests/pso_readiness_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py python -c "import tempfile, pathlib; import tests.pixel_aot_check as p; p.check_controls(pathlib.Path(tempfile.mkdtemp()))" git diff --check ``` All checks exit with code `0`. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets.
tedin7 commented 2026-11-24 13:00:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:20:59Z.

Review: COMMENTED


Reviewed PR #1466 (da9be0ef):

Findings

  1. Blocking bug in tests/pixel_aot_check.py (main()):
    "draw-f16-ternary" was added to the draw = {...} dispatch dictionary (line 21521), but it was omitted from the if mode in (...) guard tuple (lines 21483–21494). As a result, invoking tests/pixel_aot_check.py draw-f16-ternary ... falls through to else: and raises:
    ValueError: Expected binary, draw, draw-e64, three-way or buffer-color mode
    
    Both pixel_aot_f16_ternary_warp and pixel_aot_f16_ternary_hardware fail immediately because of this.

Verification

  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at da9be0ef:
    • tests/form_coverage_check.py: PASS (45.39s)
    • cmake --build --preset dev --target offscreen_check: PASS
    • ctest --preset dev -R '^pixel_aot_f16_ternary_': 0/2 passed, 2 failed (pixel_aot_f16_ternary_warp and pixel_aot_f16_ternary_hardware both failed with the ValueError above).
  • Linux checks at da9be0ef:
    • tests/docs_links_check.py, tests/bidi_controls_check.py, git diff --check origin/main..HEAD: PASS
    • tests/rdna2_tools_check.py: PASS (141 tests, 18 skipped)
    • tests/pso_readiness_check.py: PASS
    • tests/pixel_aot_check.py (check_controls): PASS
    • LLVM-19 (llvm-mc-19, llvm-objcopy-19, libLLVM-19.so) assembly/disassembly/translation roundtrip of all 23 f16_ternary_ops and F16_TERNARY_PROGRAMS: PASS

Code Audit Notes

  • tools/pixel_aot.py: VOP3_F16_TERNARY, f16_min3_max3_med3_result, and the lowering path look clean and consistent with the existing half16 finite-proof and -0.0 < +0.0 tie-breaking contracts.
  • tools/scan_unsupported_shaders.py, tests/rdna2_tools_check.py, tests/pso_readiness_check.py, tests/form_coverage_check.py: clean and well-scoped.

Once "draw-f16-ternary" is added to the mode in (...) tuple in tests/pixel_aot_check.py and the pixel_aot_f16_ternary_* CTest targets pass on Windows, this looks ready.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039090778 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#pullrequestreview-6039090778). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T12:20:59Z. **Review:** COMMENTED --- Reviewed PR #1466 (`da9be0ef`): ### Findings 1. **Blocking bug in `tests/pixel_aot_check.py` (`main()`):** `"draw-f16-ternary"` was added to the `draw = {...}` dispatch dictionary (line 21521), but it was **omitted** from the `if mode in (...)` guard tuple (lines 21483–21494). As a result, invoking `tests/pixel_aot_check.py draw-f16-ternary ...` falls through to `else:` and raises: ``` ValueError: Expected binary, draw, draw-e64, three-way or buffer-color mode ``` Both `pixel_aot_f16_ternary_warp` and `pixel_aot_f16_ternary_hardware` fail immediately because of this. ### Verification - **Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at `da9be0ef`:** - `tests/form_coverage_check.py`: **PASS** (`45.39s`) - `cmake --build --preset dev --target offscreen_check`: **PASS** - `ctest --preset dev -R '^pixel_aot_f16_ternary_'`: **0/2 passed, 2 failed** (`pixel_aot_f16_ternary_warp` and `pixel_aot_f16_ternary_hardware` both failed with the `ValueError` above). - **Linux checks at `da9be0ef`:** - `tests/docs_links_check.py`, `tests/bidi_controls_check.py`, `git diff --check origin/main..HEAD`: **PASS** - `tests/rdna2_tools_check.py`: **PASS** (`141` tests, `18` skipped) - `tests/pso_readiness_check.py`: **PASS** - `tests/pixel_aot_check.py` (`check_controls`): **PASS** - LLVM-19 (`llvm-mc-19`, `llvm-objcopy-19`, `libLLVM-19.so`) assembly/disassembly/translation roundtrip of all 23 `f16_ternary_ops` and `F16_TERNARY_PROGRAMS`: **PASS** ### Code Audit Notes - `tools/pixel_aot.py`: `VOP3_F16_TERNARY`, `f16_min3_max3_med3_result`, and the lowering path look clean and consistent with the existing `half16` finite-proof and `-0.0 < +0.0` tie-breaking contracts. - `tools/scan_unsupported_shaders.py`, `tests/rdna2_tools_check.py`, `tests/pso_readiness_check.py`, `tests/form_coverage_check.py`: clean and well-scoped. Once `"draw-f16-ternary"` is added to the `mode in (...)` tuple in `tests/pixel_aot_check.py` and the `pixel_aot_f16_ternary_*` CTest targets pass on Windows, this looks ready.
R0Y00 commented 2026-11-24 14:02:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T13:53:03Z.

Review: CHANGES_REQUESTED


I locally added draw-f16-ternary to the main draw-mode branch so both registered cases execute. They both fail main-13 on RTX and WARP: median channel 2 expects +0 (0x0000) and returns -0 (0x8000). Please include the CLI dispatcher fix and establish which signed-zero tie result the native instruction yields under this profile. Then preserve that bit result in the generated path and keep this case strict.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6040427718 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#pullrequestreview-6040427718). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T13:53:03Z. **Review:** CHANGES_REQUESTED --- I locally added draw-f16-ternary to the main draw-mode branch so both registered cases execute. They both fail main-13 on RTX and WARP: median channel 2 expects +0 (0x0000) and returns -0 (0x8000). Please include the CLI dispatcher fix and establish which signed-zero tie result the native instruction yields under this profile. Then preserve that bit result in the generated path and keep this case strict.
ChazY11 commented 2026-11-24 14:03:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T13:21:56Z.


The two tests this PR registers cannot run: draw-f16-ternary is not an accepted mode

Independent reviewer, not the author. I built da9be0ef clean and ran the tests the PR adds.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling
available (pixel_aot_region_scalar_load_warp passes on this machine, so the binary path works here).

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^pixel_aot_f16_ternary_' -V
1/2 Test #723: pixel_aot_f16_ternary_hardware ... ***Failed   17.07 sec
2/2 Test #856: pixel_aot_f16_ternary_warp ....... ***Failed   16.32 sec

Traceback (most recent call last):
  File ".../tests/pixel_aot_check.py", line 21623, in main
    raise ValueError("Expected binary, draw, draw-e64, three-way or buffer-color mode")
ValueError: Expected binary, draw, draw-e64, three-way or buffer-color mode

The registration passes draw-f16-ternary:

add_test(NAME pixel_aot_f16_ternary_${adapter} COMMAND "${INTAKE_PYTHON}" -B
  "${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-f16-ternary "${DXC_EXECUTABLE}"
  "$<TARGET_FILE:offscreen_check>" ${adapter})

and the mode dispatch in the same commit knows only binary, draw, draw-core, draw-e64, three-way and
buffer-color, so the run stops before any lowering is exercised. The fixture data itself is present in that file
(F16_TERNARY_WORDS, F16_TERNARY_GROUPS, F16_TERNARY_CHAIN, F16_TERNARY_MED_CHAIN, f16_ternary_ops), which is
why this reads like a missing elif mode == "draw-f16-ternary": hunk rather than a wrong test name.

Two consequences worth checking on your side:

  1. The lowering in tools/pixel_aot.py is unverified by these tests — they never reach it. So v_min3_f16,
    v_max3_f16 and v_med3_f16 have no executed coverage in this commit, whatever the diff says.
  2. CI may not have caught it: the _warp case should run in the Windows job, but a missing DXC/LLVM on a runner
    turns these into capability skips, which is exactly the failure mode AGENTS.md asks to report separately.

I have not pushed anything. Once the dispatch exists I am happy to re-run the pair plus a mutation of the v_med3_f16
formula to confirm the tests actually reject a wrong lowering — that is the check I was going to do before I hit this.

Verdict

Not mergeable as it stands: the two registered cases fail on a clean local build with a ValueError from the harness,
before reaching the code under test. Everything else I could check is in order (tools/pixel_aot.py, the docs line and
the other Python checks load fine).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7132725195 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7132725195). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T13:21:56Z. --- ## The two tests this PR registers cannot run: `draw-f16-ternary` is not an accepted mode Independent reviewer, not the author. I built `da9be0ef` clean and ran the tests the PR adds. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling available (`pixel_aot_region_scalar_load_warp` passes on this machine, so the binary path works here). ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^pixel_aot_f16_ternary_' -V ``` ```text 1/2 Test #723: pixel_aot_f16_ternary_hardware ... ***Failed 17.07 sec 2/2 Test #856: pixel_aot_f16_ternary_warp ....... ***Failed 16.32 sec Traceback (most recent call last): File ".../tests/pixel_aot_check.py", line 21623, in main raise ValueError("Expected binary, draw, draw-e64, three-way or buffer-color mode") ValueError: Expected binary, draw, draw-e64, three-way or buffer-color mode ``` The registration passes `draw-f16-ternary`: ```cmake add_test(NAME pixel_aot_f16_ternary_${adapter} COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_SOURCE_DIR}/tests/pixel_aot_check.py" draw-f16-ternary "${DXC_EXECUTABLE}" "$<TARGET_FILE:offscreen_check>" ${adapter}) ``` and the mode dispatch in the same commit knows only `binary`, `draw`, `draw-core`, `draw-e64`, `three-way` and `buffer-color`, so the run stops before any lowering is exercised. The fixture data itself is present in that file (`F16_TERNARY_WORDS`, `F16_TERNARY_GROUPS`, `F16_TERNARY_CHAIN`, `F16_TERNARY_MED_CHAIN`, `f16_ternary_ops`), which is why this reads like a missing `elif mode == "draw-f16-ternary":` hunk rather than a wrong test name. Two consequences worth checking on your side: 1. **The lowering in `tools/pixel_aot.py` is unverified by these tests** — they never reach it. So `v_min3_f16`, `v_max3_f16` and `v_med3_f16` have no executed coverage in this commit, whatever the diff says. 2. **CI may not have caught it**: the `_warp` case should run in the Windows job, but a missing DXC/LLVM on a runner turns these into capability skips, which is exactly the failure mode `AGENTS.md` asks to report separately. I have not pushed anything. Once the dispatch exists I am happy to re-run the pair plus a mutation of the `v_med3_f16` formula to confirm the tests actually reject a wrong lowering — that is the check I was going to do before I hit this. ### Verdict Not mergeable as it stands: the two registered cases fail on a clean local build with a `ValueError` from the harness, before reaching the code under test. Everything else I could check is in order (`tools/pixel_aot.py`, the docs line and the other Python checks load fine).
ChazY11 commented 2026-11-24 14:03:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T13:31:13Z.


Addendum — the mapping exists, but the dispatch chain never consults it

Correction to the cause in my review above, found while re-checking at the same head da9be0ef. The behaviour is the
same (both tests still fail), but my "missing elif" reading was one step short of the actual defect.

No build or ctest needed to see it:

python -B tests/pixel_aot_check.py draw-f16-ternary <dxc path>
File ".../tests/pixel_aot_check.py", line 21623, in main
    raise ValueError("Expected binary, draw, draw-e64, three-way or buffer-color mode")

The mode is declared in this commit, at line 21521:

    "draw-f16-ternary": check_f16_ternary_draw,

but main() does not read that mapping. Its hand-written chain runs draw-e64-spellings, draw-e64, draw-e64-approx,
draw-sdwa-unary, then binary, bits, draw/draw-core, three-way, buffer-color, and falls through to the
ValueError above. draw-f16-ternary matches none of the branches, so the declared handler is unreachable.

So the fix is one branch in that chain (or routing the chain through the mapping table), not a new handler. The rest of
the review stands: the two registered cases fail before reaching the lowering, and the fixture data plus the handler
already exist in the file.

I have not pushed anything.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7132947067 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7132947067). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T13:31:13Z. --- ## Addendum — the mapping exists, but the dispatch chain never consults it Correction to the cause in my review above, found while re-checking at the same head `da9be0ef`. The behaviour is the same (both tests still fail), but my "missing `elif`" reading was one step short of the actual defect. No build or `ctest` needed to see it: ```powershell python -B tests/pixel_aot_check.py draw-f16-ternary <dxc path> ``` ```text File ".../tests/pixel_aot_check.py", line 21623, in main raise ValueError("Expected binary, draw, draw-e64, three-way or buffer-color mode") ``` The mode **is** declared in this commit, at line 21521: ```python "draw-f16-ternary": check_f16_ternary_draw, ``` but `main()` does not read that mapping. Its hand-written chain runs `draw-e64-spellings`, `draw-e64`, `draw-e64-approx`, `draw-sdwa-unary`, then `binary`, `bits`, `draw`/`draw-core`, `three-way`, `buffer-color`, and falls through to the `ValueError` above. `draw-f16-ternary` matches none of the branches, so the declared handler is unreachable. So the fix is one branch in that chain (or routing the chain through the mapping table), not a new handler. The rest of the review stands: the two registered cases fail before reaching the lowering, and the fixture data plus the handler already exist in the file. I have not pushed anything.
agilesh08 commented 2026-11-24 15:02:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by agilesh08 on 2026-11-24T14:18:41Z.


@R0Y00 @tedin7 @ChazY11 Thank you for the detailed diagnostics and hardware/WARP runs! Updated PR #1466 with both fixes:

  1. CLI Mode Dispatch (@tedin7, @ChazY11, @R0Y00): Added "draw-f16-ternary" to the if mode in (...) dispatch guard in tests/pixel_aot_check.py (main()) so pixel_aot_f16_ternary_warp and pixel_aot_f16_ternary_hardware execute check_f16_ternary_draw instead of falling through to ValueError. Added unit verification asserting "draw-f16-ternary" is in the dispatch guard tuple.
  2. Native RDNA2 Signed-Zero Tie-Breaking (@R0Y00): Under IEEE total ordering, native RDNA2 v_min3_f16 / v_max3_f16 / v_med3_f16 order -0.0 (0x8000) strictly below +0.0 (0x0000). Updated min16_num and max16_num in tools/pixel_aot.py to enforce -0.0 < +0.0 bit-level ordering when a == 0.0f && b == 0.0f (asfloat(asuint(a) | asuint(b)) for min, asfloat(asuint(a) & asuint(b)) for max), and lowered v_min3_f16, v_max3_f16, and v_med3_f16 using min16_num / max16_num instead of bare HLSL min / max. Added unit test assertions across all permutations of the four signed-zero tie cases ((-0.0, -0.0, +0.0), (-0.0, +0.0, +0.0), (-1.0, -0.0, +0.0), (-0.0, +0.0, +1.0)) verifying exact bit agreement with the reference oracle.

Verified all platform-independent checks (form_coverage_check.py, rdna2_tools_check.py, pso_readiness_check.py, pixel_aot_check.py, docs_links_check.py, bidi_controls_check.py) with exit code 0. Assisted by AI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134169027 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7134169027). Originally posted by [agilesh08](https://github.com/agilesh08) on 2026-11-24T14:18:41Z. --- @R0Y00 @tedin7 @ChazY11 Thank you for the detailed diagnostics and hardware/WARP runs! Updated PR #1466 with both fixes: 1. **CLI Mode Dispatch (`@tedin7`, `@ChazY11`, `@R0Y00`):** Added `"draw-f16-ternary"` to the `if mode in (...)` dispatch guard in `tests/pixel_aot_check.py` (`main()`) so `pixel_aot_f16_ternary_warp` and `pixel_aot_f16_ternary_hardware` execute `check_f16_ternary_draw` instead of falling through to `ValueError`. Added unit verification asserting `"draw-f16-ternary"` is in the dispatch guard tuple. 2. **Native RDNA2 Signed-Zero Tie-Breaking (`@R0Y00`):** Under IEEE total ordering, native RDNA2 `v_min3_f16` / `v_max3_f16` / `v_med3_f16` order `-0.0` (`0x8000`) strictly below `+0.0` (`0x0000`). Updated `min16_num` and `max16_num` in `tools/pixel_aot.py` to enforce `-0.0 < +0.0` bit-level ordering when `a == 0.0f && b == 0.0f` (`asfloat(asuint(a) | asuint(b))` for min, `asfloat(asuint(a) & asuint(b))` for max), and lowered `v_min3_f16`, `v_max3_f16`, and `v_med3_f16` using `min16_num` / `max16_num` instead of bare HLSL `min` / `max`. Added unit test assertions across all permutations of the four signed-zero tie cases (`(-0.0, -0.0, +0.0)`, `(-0.0, +0.0, +0.0)`, `(-1.0, -0.0, +0.0)`, `(-0.0, +0.0, +1.0)`) verifying exact bit agreement with the reference oracle. Verified all platform-independent checks (`form_coverage_check.py`, `rdna2_tools_check.py`, `pso_readiness_check.py`, `pixel_aot_check.py`, `docs_links_check.py`, `bidi_controls_check.py`) with exit code 0. Assisted by AI.
R0Y00 commented 2026-11-24 15:02:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T14:27:23Z.


Retested 46704ada in Release. The CLI now reaches both draws. WARP passes, but RTX 4060 Laptop driver 32.0.16.1656 still fails main-13 at (0,0), median channel 2: expected 0x0000, got 0x8000. Debug layer enabled, zero messages. Please verify the exact native median result for the zero permutations with the instruction specification or an independent raw-word native run. Then preserve the selected half as integer bits through the final write and rerun both draw backends. The Python oracle and the WARP pass alone leave the RTX discrepancy open.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7134403468 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7134403468). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-24T14:27:23Z. --- Retested 46704ada in Release. The CLI now reaches both draws. WARP passes, but RTX 4060 Laptop driver 32.0.16.1656 still fails main-13 at (0,0), median channel 2: expected 0x0000, got 0x8000. Debug layer enabled, zero messages. Please verify the exact native median result for the zero permutations with the instruction specification or an independent raw-word native run. Then preserve the selected half as integer bits through the final write and rerun both draw backends. The Python oracle and the WARP pass alone leave the RTX discrepancy open.
ChazY11 commented 2026-11-24 15:02:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T14:55:32Z.


Dispatch is fixed — _warp now passes with all four mutations caught; _hardware fails on my adapter

Re-checked at the new head 46704ada. The blocking finding in my earlier review is resolved, and one narrower issue replaces
it.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, RTX 5080 Laptop
(32.0.15.8142) for the hardware case, in-box WARP for warp.

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^pixel_aot_f16_ternary_' -V
pixel_aot_f16_ternary_warp ........ Passed  5.95 s
pixel_aot_f16_ternary_hardware .... ***Failed 12.03 s

What now works

draw-f16-ternary is in the dispatch table, and the warp case runs the whole fixture: the reference draw passes and all
four in-tree mutations are detected.

f16_ternary mutation med3_as_min3: statuses ['mismatch']
f16_ternary mutation med3_as_max3: statuses ['mismatch']
f16_ternary mutation max3_as_min3: statuses ['mismatch']
f16_ternary mutation min3_as_max3: statuses ['mismatch']

That is the check I said I would do once the dispatch existed: the v_med3_f16 formula and the min/max distinctions are
each noticed. Good.

What fails

The hardware case dies on the reference draw, before any mutation:

AssertionError: Expected ['pass'], got ['mismatch']
backend=hardware debug_layer=enabled
adapter=NVIDIA GeForce RTX 5080 Laptop GPU vendor=10de device=2c59

run_pixel_batch compares the GPU readback against f16_ternary_expected(...) computed in Python, so this is the
lowered output disagreeing with the fixture's own model on this adapter, not a disagreement with WARP's pixels. WARP
agrees with the model; this GPU does not.

Two possibilities and I cannot separate them from here:

  1. the hardware path rounds or orders min3/max3/med3 differently from the HLSL the translator emits, which would be
    a real finding for half-precision ternary coverage;
  2. the expected model is right for WARP's implementation of those intrinsics but not for this driver's.

Either way it is worth knowing before merge, because CI excludes _hardware, so this case would land green.

If it helps: tell me which of the F16_TERNARY_PROGRAMS keys is the first to mismatch and I will narrow it to a single
component (I did not modify the harness to print it, since that is your file).

Verdict

Reviewed 46704ada. The dispatch fix is correct and the warp case is now a real check with four mutation detections. The
hardware case fails on my adapter at the reference comparison; I would not merge with that unexplained, even though the
CI job cannot see it.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135171915 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7135171915). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T14:55:32Z. --- ## Dispatch is fixed — `_warp` now passes with all four mutations caught; `_hardware` fails on my adapter Re-checked at the new head `46704ada`. The blocking finding in my earlier review is resolved, and one narrower issue replaces it. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, RTX 5080 Laptop (32.0.15.8142) for the `hardware` case, in-box WARP for `warp`. ```powershell cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R '^pixel_aot_f16_ternary_' -V ``` ```text pixel_aot_f16_ternary_warp ........ Passed 5.95 s pixel_aot_f16_ternary_hardware .... ***Failed 12.03 s ``` ### What now works `draw-f16-ternary` is in the dispatch table, and the warp case runs the whole fixture: the reference draw passes and all four in-tree mutations are detected. ```text f16_ternary mutation med3_as_min3: statuses ['mismatch'] f16_ternary mutation med3_as_max3: statuses ['mismatch'] f16_ternary mutation max3_as_min3: statuses ['mismatch'] f16_ternary mutation min3_as_max3: statuses ['mismatch'] ``` That is the check I said I would do once the dispatch existed: the `v_med3_f16` formula and the min/max distinctions are each noticed. Good. ### What fails The hardware case dies on the **reference** draw, before any mutation: ```text AssertionError: Expected ['pass'], got ['mismatch'] backend=hardware debug_layer=enabled adapter=NVIDIA GeForce RTX 5080 Laptop GPU vendor=10de device=2c59 ``` `run_pixel_batch` compares the GPU readback against `f16_ternary_expected(...)` computed in Python, so this is the lowered output disagreeing with the fixture's own model on this adapter, not a disagreement with WARP's pixels. WARP agrees with the model; this GPU does not. Two possibilities and I cannot separate them from here: 1. the hardware path rounds or orders `min3`/`max3`/`med3` differently from the HLSL the translator emits, which would be a real finding for half-precision ternary coverage; 2. the expected model is right for WARP's implementation of those intrinsics but not for this driver's. Either way it is worth knowing before merge, because **CI excludes `_hardware`**, so this case would land green. If it helps: tell me which of the `F16_TERNARY_PROGRAMS` keys is the first to mismatch and I will narrow it to a single component (I did not modify the harness to print it, since that is your file). ### Verdict Reviewed `46704ada`. The dispatch fix is correct and the warp case is now a real check with four mutation detections. The hardware case fails on my adapter at the reference comparison; I would not merge with that unexplained, even though the CI job cannot see it.
Makto94 commented 2026-11-24 16:03:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-24T16:03:11Z.


Independent run of 46704ada on another NVIDIA adapter (RTX 3070 Ti, desktop), Debug build. The hardware case fails with the same signature as R0Y00's Release retest: main-13, pixel (0,0), channel 2 expected 0x0000, got 0x8000.

ctest --preset dev --no-tests=error -j1 -R '^pixel_aot_f16_ternary_' -V

Environment: commit 46704adaaa031ca53c7dd6752d0935b5431fcb84, preset dev (Debug); NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2101 (621.01); Windows 11 Pro 10.0.26300.9974; DXC 1.9.2602.17 (Windows SDK 10.0.26100); debug_layer=enabled, debug_errors=0 debug_warnings=0.

  • pixel_aot_f16_ternary_warp: passed. The reference draw passes and all 5 mutations are detected.
  • pixel_aot_f16_ternary_hardware: failed on the reference draw main-13, before any mutation ran.
pixel_mismatch x=0 y=0
channel=0 expected=4.59177e-41 actual=4.59177e-41 expected_bits=00008000 actual_bits=00008000
channel=1 expected=4.44814e-41 actual=4.44814e-41 expected_bits=00007bff actual_bits=00007bff
channel=2 expected=0 actual=4.59177e-41 expected_bits=00000000 actual_bits=00008000
channel=3 expected=4.59177e-41 actual=4.59177e-41 expected_bits=00008000 actual_bits=00008000
AOT color export differs from CPU reference

Not measured here: the native result for the zero permutations, and any non-NVIDIA adapter.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7137042378 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7137042378). Originally posted by [Makto94](https://github.com/Makto94) on 2026-11-24T16:03:11Z. --- Independent run of `46704ada` on another NVIDIA adapter (RTX 3070 Ti, desktop), Debug build. The hardware case fails with the same signature as R0Y00's Release retest: `main-13`, pixel (0,0), channel 2 expected `0x0000`, got `0x8000`. ```powershell ctest --preset dev --no-tests=error -j1 -R '^pixel_aot_f16_ternary_' -V ``` Environment: commit `46704adaaa031ca53c7dd6752d0935b5431fcb84`, preset `dev` (Debug); NVIDIA GeForce RTX 3070 Ti (`10de:2482`), driver 32.0.16.2101 (621.01); Windows 11 Pro 10.0.26300.9974; DXC 1.9.2602.17 (Windows SDK 10.0.26100); `debug_layer=enabled`, `debug_errors=0 debug_warnings=0`. - `pixel_aot_f16_ternary_warp`: passed. The reference draw passes and all 5 mutations are detected. - `pixel_aot_f16_ternary_hardware`: failed on the reference draw `main-13`, before any mutation ran. ```text pixel_mismatch x=0 y=0 channel=0 expected=4.59177e-41 actual=4.59177e-41 expected_bits=00008000 actual_bits=00008000 channel=1 expected=4.44814e-41 actual=4.44814e-41 expected_bits=00007bff actual_bits=00007bff channel=2 expected=0 actual=4.59177e-41 expected_bits=00000000 actual_bits=00008000 channel=3 expected=4.59177e-41 actual=4.59177e-41 expected_bits=00008000 actual_bits=00008000 AOT color export differs from CPU reference ``` Not measured here: the native result for the zero permutations, and any non-NVIDIA adapter.
tedin7 commented 2026-11-24 17:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T16:55:32Z.

Review: COMMENTED


Re-review of head 46704ada.

Previous blocker

  • The earlier gate run failed because "draw-f16-ternary" was missing from the mode in (...) guard in main(). It is now in that tuple and in the draw dispatch (tests/pixel_aot_check.py), and CMakeLists.txt registers the draw-f16-ternary runs. I could not run those on Windows, so the fix is confirmed by reading and by the Linux run below, not by the WARP run.

Observations, none blocking

  • min16_num and max16_num are shared helpers. The diff changes them for every user, not only the new ops: a +0/-0 pair now returns -0 for min (sign bits ORed) and +0 for max (ANDed). That is the documented tie order and matches the new proof function, but it also changes the output of the existing v_min_f16/v_max_f16 lowerings in the tie case. Worth one sentence in the PR body.
  • check_f16_ternary_lowering reads the source of main() with inspect.getsource and searches for the mode string. The draw tests already fail if the mode is missing, so this text search duplicates them and breaks on a harmless reformat.
  • The encodings are right: llvm-mc-19 -mcpu=gfx1030 gives opcodes 0x351, 0x354 and 0x357 for v_min3_f16, v_max3_f16 and v_med3_f16, the same ones tools/disasm_rdna2.py lists. With clamp set the encoding differs (bit 15 of the second byte), which the lowering refuses.

Checks run (Linux only; the draw runs need Windows and were not run)

  • git diff --check origin/main...HEAD: clean.
  • python3 tests/docs_links_check.py: self-test passed, 16 files, 344 links.
  • python3 tests/bidi_controls_check.py: self-test passed, 1247 files, no bidirectional controls.
  • python3 tests/pso_readiness_check.py: passed.
  • python3 tests/pixel_aot_check.py: exit 0.
  • python3 tests/rdna2_tools_check.py: 141 tests, OK, 18 skipped.
  • Mutation 1, med3 lowered as min3 in tools/pixel_aot.py: KILLED (a lowering assertion fails). It is caught by a text assertion on the emitted HLSL, not by evaluating the shader.
  • Mutation 2, signed-zero tie line removed from min16_num: SURVIVED the Linux run. Only the Windows draw cases can see it, so the WARP result on Windows is what actually covers that behaviour.
  • Both mutations were reverted; the checkout was clean afterwards.

Verification is Linux-only.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043677491 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#pullrequestreview-6043677491). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T16:55:32Z. **Review:** COMMENTED --- Re-review of head 46704ada. **Previous blocker** - The earlier gate run failed because `"draw-f16-ternary"` was missing from the `mode in (...)` guard in `main()`. It is now in that tuple and in the `draw` dispatch (`tests/pixel_aot_check.py`), and `CMakeLists.txt` registers the `draw-f16-ternary` runs. I could not run those on Windows, so the fix is confirmed by reading and by the Linux run below, not by the WARP run. **Observations, none blocking** - `min16_num` and `max16_num` are shared helpers. The diff changes them for every user, not only the new ops: a `+0`/`-0` pair now returns `-0` for min (sign bits ORed) and `+0` for max (ANDed). That is the documented tie order and matches the new proof function, but it also changes the output of the existing `v_min_f16`/`v_max_f16` lowerings in the tie case. Worth one sentence in the PR body. - `check_f16_ternary_lowering` reads the source of `main()` with `inspect.getsource` and searches for the mode string. The draw tests already fail if the mode is missing, so this text search duplicates them and breaks on a harmless reformat. - The encodings are right: `llvm-mc-19 -mcpu=gfx1030` gives opcodes 0x351, 0x354 and 0x357 for `v_min3_f16`, `v_max3_f16` and `v_med3_f16`, the same ones `tools/disasm_rdna2.py` lists. With `clamp` set the encoding differs (bit 15 of the second byte), which the lowering refuses. **Checks run (Linux only; the draw runs need Windows and were not run)** - `git diff --check origin/main...HEAD`: clean. - `python3 tests/docs_links_check.py`: self-test passed, 16 files, 344 links. - `python3 tests/bidi_controls_check.py`: self-test passed, 1247 files, no bidirectional controls. - `python3 tests/pso_readiness_check.py`: passed. - `python3 tests/pixel_aot_check.py`: exit 0. - `python3 tests/rdna2_tools_check.py`: 141 tests, OK, 18 skipped. - Mutation 1, `med3` lowered as `min3` in `tools/pixel_aot.py`: KILLED (a lowering assertion fails). It is caught by a text assertion on the emitted HLSL, not by evaluating the shader. - Mutation 2, signed-zero tie line removed from `min16_num`: SURVIVED the Linux run. Only the Windows draw cases can see it, so the WARP result on Windows is what actually covers that behaviour. - Both mutations were reverted; the checkout was clean afterwards. Verification is Linux-only. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 13:01:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:44:23Z.


@agilesh08 could you rebase this branch onto current main and force-push?

GitHub reports head 46704ada as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (b1a644ae):

  • docs/experiments.md
  • tests/pixel_aot_check.py

Commands run locally:

git fetch origin main pull/1466/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1466 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7162788290 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1466#issuecomment-7162788290). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:44:23Z. --- @agilesh08 could you rebase this branch onto current `main` and force-push? GitHub reports head `46704ada` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`b1a644ae`): - `docs/experiments.md` - `tests/pixel_aot_check.py` Commands run locally: ``` git fetch origin main pull/1466/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 1466 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 15:01:22 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1459
No description provided.