startup: lower v_dot2_i32_i16 and v_dot2_u32_u16 in gfx2hlsl #3036

Merged
R0D4X merged 3 commits from upstream-pr/3036 into main 2026-11-28 10:37:52 +00:00
R0D4X commented 2026-11-27 09:28:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-27T09:28:15Z.


What this changes

Adds lowering for the VOP3P 2-halfword integer dot-product instructions v_dot2_i32_i16 (0x14) and v_dot2_u32_u16 (0x15) in tools/startup/gfx2hlsl.py (already decoded by tools/disasm_rdna2.py and handled in tools/pixel_aot.py).

  • Semantics: Computes S0.lo * S1.lo + S0.hi * S1.hi + S2 in signed (int16 -> int32) or unsigned (uint16 -> uint32) arithmetic. Because two 16x16 products plus S2 can overflow 32 bits twice (e.g., (-32768)^2 + (-32768)^2 = +2^31 or 2 * 65535^2), both helpers use exact multi-step / 64-bit carry tracking so clamp saturates accurately (and exact cancellations like 2^31 + (-2^31) = 0 do not falsely saturate).
  • On-demand helpers: Emits dot2_i32_i16 / dot2_u32_u16 in common() only when the corresponding instruction is used; routes assignments through Stage.set_v so EXEC masking is preserved.
  • Safety checks: Refuses wrong operand counts, non-clamp VOP3P modifiers (op_sel, op_sel_hi, neg_lo, neg_hi), source modifiers (|...|, -..., neg(...), abs(...)), non-VGPR destinations, and out-of-range or pair register operands.

Tests added

  • tests/startup_gfx2hlsl_v_dot2_check.py: VOP3P binary decode via G.decode(), 588 cases per instruction covering wrapping and clamp saturation (including double-overflow and exact cancellation), on-demand helper emission/omission, EXEC masking, refusal cases, unlowered control, and FXC ps_5_1 + DXC ps_6_0 GPU readback draws (including a negative-control draw).
  • Registered via tests/cmake/startup_gfx2hlsl_v_dot2.cmake and tests/checks/python-linux/startup_gfx2hlsl_v_dot2.txt.

Verification

  • Commit: 3cb04f53 (on upstream/main e446b072)
  • Host: Windows 11 x64 (10.0.26300.9974), MSVC 19.44.35230, Windows SDK 10.0.26100.0, FXC + DXC 1.9.2602.17, D3D12 debug layer enabled
  • Adapters: WARP (1414:008c, driver 10.0.26100.9818) and NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2124)

Results:

  • ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_v_dot2|^startup_tools_lint$' -V -> 4/4 passed, 0 skipped (debug_errors=0 debug_warnings=0 on all draws)
  • ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_v_dot2' -> 3/3 passed, 0 skipped
  • Repo & neighbor checks (docs_links_check.py, bidi_controls_check.py, startup_gfx2hlsl_handler_arity_check.py, startup_gfx2hlsl_refusals_check.py, git diff --check) -> all passed
  • 5 live mutations on gfx2hlsl.py (dropping clamp, dropping non-clamp modifier refusal, dropping helper gates, dropping source-modifier refusal) -> 5/5 caught (rc=1)

Scope: Covers synthetic gfx1013 VOP3P fixtures translated by gfx2hlsl.py and run on WARP and RTX 5080; does not establish full-title startup or frame rate.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5524295430 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-27T09:28:15Z. --- ## What this changes Adds lowering for the VOP3P 2-halfword integer dot-product instructions `v_dot2_i32_i16` (`0x14`) and `v_dot2_u32_u16` (`0x15`) in `tools/startup/gfx2hlsl.py` (already decoded by `tools/disasm_rdna2.py` and handled in `tools/pixel_aot.py`). - **Semantics:** Computes `S0.lo * S1.lo + S0.hi * S1.hi + S2` in signed (`int16` -> `int32`) or unsigned (`uint16` -> `uint32`) arithmetic. Because two 16x16 products plus `S2` can overflow 32 bits twice (e.g., `(-32768)^2 + (-32768)^2 = +2^31` or `2 * 65535^2`), both helpers use exact multi-step / 64-bit carry tracking so `clamp` saturates accurately (and exact cancellations like `2^31 + (-2^31) = 0` do not falsely saturate). - **On-demand helpers:** Emits `dot2_i32_i16` / `dot2_u32_u16` in `common()` only when the corresponding instruction is used; routes assignments through `Stage.set_v` so `EXEC` masking is preserved. - **Safety checks:** Refuses wrong operand counts, non-`clamp` VOP3P modifiers (`op_sel`, `op_sel_hi`, `neg_lo`, `neg_hi`), source modifiers (`|...|`, `-...`, `neg(...)`, `abs(...)`), non-VGPR destinations, and out-of-range or pair register operands. ## Tests added - `tests/startup_gfx2hlsl_v_dot2_check.py`: VOP3P binary decode via `G.decode()`, 588 cases per instruction covering wrapping and `clamp` saturation (including double-overflow and exact cancellation), on-demand helper emission/omission, `EXEC` masking, refusal cases, unlowered control, and FXC `ps_5_1` + DXC `ps_6_0` GPU readback draws (including a negative-control draw). - Registered via `tests/cmake/startup_gfx2hlsl_v_dot2.cmake` and `tests/checks/python-linux/startup_gfx2hlsl_v_dot2.txt`. ## Verification - **Commit:** `3cb04f53` (on `upstream/main` `e446b072`) - **Host:** Windows 11 x64 (`10.0.26300.9974`), MSVC `19.44.35230`, Windows SDK `10.0.26100.0`, FXC + DXC `1.9.2602.17`, D3D12 debug layer enabled - **Adapters:** WARP (`1414:008c`, driver `10.0.26100.9818`) and NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2124`) Results: - `ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_v_dot2|^startup_tools_lint$' -V` -> **4/4 passed, 0 skipped** (`debug_errors=0 debug_warnings=0` on all draws) - `ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_v_dot2'` -> **3/3 passed, 0 skipped** - Repo & neighbor checks (`docs_links_check.py`, `bidi_controls_check.py`, `startup_gfx2hlsl_handler_arity_check.py`, `startup_gfx2hlsl_refusals_check.py`, `git diff --check`) -> **all passed** - 5 live mutations on `gfx2hlsl.py` (dropping `clamp`, dropping non-`clamp` modifier refusal, dropping helper gates, dropping source-modifier refusal) -> **5/5 caught (`rc=1`)** *Scope:* Covers synthetic gfx1013 VOP3P fixtures translated by `gfx2hlsl.py` and run on WARP and RTX 5080; does not establish full-title startup or frame rate.
tedin7 commented 2026-11-27 20:12:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T20:12:42Z.


This PR now conflicts with main after #3030 (s_bitreplicate) landed. The conflict is one block in tools/startup/gfx2hlsl.py where both PRs add lines at the same spot. Keeping both sides resolves it; I checked locally that the union gives exactly main plus this PR's own lines and that tests/startup_gfx2hlsl_v_dot2_check.py (controls) still passes.

Could you merge main into your branch (a merge commit is fine, no force push needed)? I will rerun the Windows tests on the new head and review it then.

Commands: git merge-tree --write-tree origin/main pull/3036/head, a local trial merge, python3 -B tests/startup_gfx2hlsl_v_dot2_check.py.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7227282645 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#issuecomment-7227282645). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T20:12:42Z. --- This PR now conflicts with `main` after #3030 (s_bitreplicate) landed. The conflict is one block in `tools/startup/gfx2hlsl.py` where both PRs add lines at the same spot. Keeping both sides resolves it; I checked locally that the union gives exactly main plus this PR's own lines and that `tests/startup_gfx2hlsl_v_dot2_check.py` (controls) still passes. Could you merge `main` into your branch (a merge commit is fine, no force push needed)? I will rerun the Windows tests on the new head and review it then. Commands: `git merge-tree --write-tree origin/main pull/3036/head`, a local trial merge, `python3 -B tests/startup_gfx2hlsl_v_dot2_check.py`. AI-assisted; commands listed were executed locally.
pigalot commented 2026-11-27 20:14:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T20:14:04Z.

Review: CHANGES_REQUESTED


I reviewed a416bed4. Like #3031, it now conflicts with main 3c30dc74 at one uses_bitreplicate / uses_dot2 site added by #3030. Keeping both sides resolves it. I tested on that local resolution (tree 001670be).

What I traced.

  • Unsigned: each product fits in uint32, and the two carries are counted separately, so carry != 0 is exactly "the sum exceeds UINT32_MAX".
  • Signed: the (hi, lo) pair is a correct 64-bit two's-complement accumulate. Each product is sign-extended into hi, and t < lo is the carry out of lo. The two clamp tests are the exact int32 bounds.
  • Nit: |c + p0 + p1| stays below 2^32, so hi is always 0 or −1. That makes hi > 0 and hi < -1 unreachable. They're harmless.
  • Every write goes through set_v. Every modifier except clamp is refused.

What I ran. I built offscreen_check in dev and release, then ran:
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_v_dot2'
3/3 passed in each preset, with no skips, on WARP and an RTX 5090.

Gap: the carry compare in the signed helper is untested.

  • The controls check a Python copy of the helper, so the emitted HLSL is checked only by the draws.
  • Every clamp=1 signed lane has two non-zero products.
  • So this HLSL-only mutant passes all 3 tests, in 3 runs: ((t0 < lo) ? 1 : 0) / ((t1 < lo) ? 1 : 0) changed to <=. It adds a false carry whenever a product is 0, so dot2(0x00000003, 0x00010005, 0x3f800000) clamp would return 0x7fffffff.

Suggested fix (tested locally). Add a lane set with zero products:

    ('v_dot2_i32_i16', 1, [
        (0x00000003, 0x00010005, 0x3f800000),  # p1 == 0: no carry, no saturation
        (0x00030000, 0x00050001, 0xffffffff),  # p0 == 0, c < 0: +14
        (0x00000000, 0x12345678, 0x7fffffff),  # both products 0, c = INT32_MAX
        (0x00000000, 0x00000000, 0x80000000),  # both products 0, c = INT32_MIN
    ]),
  • The PR's helper passes with it on WARP and hardware.
  • The mutant fails at expected=3f80000f,0000000e,7fffffff,80000000 actual=7fffffff,7fffffff,7fffffff,7fffffff.

Verdict: request changes on a416bed4: rebase over #3030 and add the zero-product lanes. The lowering itself looks right to me.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; debug layer on.
CI: passes on a416bed4, which predates the conflict. There are no reviews or threads.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6092966596 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#pullrequestreview-6092966596). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T20:14:04Z. **Review:** CHANGES_REQUESTED --- I reviewed `a416bed4`. Like #3031, it now conflicts with `main` `3c30dc74` at one `uses_bitreplicate` / `uses_dot2` site added by #3030. Keeping both sides resolves it. I tested on that local resolution (tree `001670be`). **What I traced.** - **Unsigned:** each product fits in uint32, and the two carries are counted separately, so `carry != 0` is exactly "the sum exceeds `UINT32_MAX`". - **Signed:** the `(hi, lo)` pair is a correct 64-bit two's-complement accumulate. Each product is sign-extended into `hi`, and `t < lo` is the carry out of `lo`. The two clamp tests are the exact int32 bounds. - **Nit:** `|c + p0 + p1|` stays below 2^32, so `hi` is always 0 or −1. That makes `hi > 0` and `hi < -1` unreachable. They're harmless. - Every write goes through `set_v`. Every modifier except `clamp` is refused. **What I ran.** I built `offscreen_check` in `dev` and `release`, then ran: `ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_v_dot2'` 3/3 passed in each preset, with no skips, on WARP and an RTX 5090. **Gap: the carry compare in the signed helper is untested.** - The controls check a Python copy of the helper, so the emitted HLSL is checked only by the draws. - Every `clamp=1` signed lane has two non-zero products. - So this HLSL-only mutant passes all 3 tests, in 3 runs: `((t0 < lo) ? 1 : 0)` / `((t1 < lo) ? 1 : 0)` changed to `<=`. It adds a false carry whenever a product is 0, so `dot2(0x00000003, 0x00010005, 0x3f800000) clamp` would return `0x7fffffff`. **Suggested fix (tested locally).** Add a lane set with zero products: ```python ('v_dot2_i32_i16', 1, [ (0x00000003, 0x00010005, 0x3f800000), # p1 == 0: no carry, no saturation (0x00030000, 0x00050001, 0xffffffff), # p0 == 0, c < 0: +14 (0x00000000, 0x12345678, 0x7fffffff), # both products 0, c = INT32_MAX (0x00000000, 0x00000000, 0x80000000), # both products 0, c = INT32_MIN ]), ``` - The PR's helper passes with it on WARP and hardware. - The mutant fails at `expected=3f80000f,0000000e,7fffffff,80000000 actual=7fffffff,7fffffff,7fffffff,7fffffff`. **Verdict:** request changes on `a416bed4`: rebase over #3030 and add the zero-product lanes. The lowering itself looks right to me. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; debug layer on. CI: passes on `a416bed4`, which predates the conflict. There are no reviews or threads. This reply was AI-assisted.
pigalot commented 2026-11-28 03:03:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T03:03:11Z.


Merged main fdb6faaa into this branch as b87eef1d. The push fast-forwards from a416bed4; there was no rebase and no force-push.

Conflict and how I resolved it.

  • tools/startup/gfx2hlsl.py, helper emission. This branch emits the dot2_u32_u16 and dot2_i32_i16 helpers. main (#3030) emits bitreplicate16 at the same place. The helpers are independent, so I kept both: the dot2 helpers first, then bitreplicate16.

    main has no v_dot2 lowering of its own. uses_dot2 and uses_bitreplicate are both still initialised in the stage state.

git diff --check origin/main...HEAD is clean.

What I ran. I built everything in dev and in release (/O2), then ran

ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '^startup_gfx2hlsl_' -E '_hardware$'
python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_gfx2hlsl_.*_hardware$'
  • Debug: 271/271 non-hardware pass; 117/117 _hardware pass.
  • Release: 271/271 non-hardware pass; 117/117 _hardware pass.
  • No skips in either preset.

The runs include this branch's startup_gfx2hlsl_v_dot2_{controls,warp,hardware} and main's startup_gfx2hlsl_s_bitreplicate_{controls,warp,hardware}.

This needs a re-review by someone else; I won't review or merge it myself.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7232762586 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#issuecomment-7232762586). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T03:03:11Z. --- Merged `main` `fdb6faaa` into this branch as `b87eef1d`. The push fast-forwards from `a416bed4`; there was no rebase and no force-push. **Conflict and how I resolved it.** - **`tools/startup/gfx2hlsl.py`, helper emission.** This branch emits the `dot2_u32_u16` and `dot2_i32_i16` helpers. `main` (#3030) emits `bitreplicate16` at the same place. The helpers are independent, so I kept both: the `dot2` helpers first, then `bitreplicate16`. `main` has no `v_dot2` lowering of its own. `uses_dot2` and `uses_bitreplicate` are both still initialised in the stage state. `git diff --check origin/main...HEAD` is clean. **What I ran.** I built everything in `dev` and in `release` (`/O2`), then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '^startup_gfx2hlsl_' -E '_hardware$' python with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^startup_gfx2hlsl_.*_hardware$' ``` - **Debug:** 271/271 non-hardware pass; 117/117 `_hardware` pass. - **Release:** 271/271 non-hardware pass; 117/117 `_hardware` pass. - No skips in either preset. The runs include this branch's `startup_gfx2hlsl_v_dot2_{controls,warp,hardware}` and `main`'s `startup_gfx2hlsl_s_bitreplicate_{controls,warp,hardware}`. This needs a re-review by someone else; I won't review or merge it myself. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 DXC (the one CTest picked up); Python 3.12.10. This reply was AI-assisted.
JohnConnorNPC commented 2026-11-28 07:18:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T07:18:20Z.


Thanks for this. The lowering looks right to me, but one change from pigalot's review is still missing on b87eef1d. Could you add it?

Addressed: the merge of main after #3030 is done (b87eef1d). A trial merge into current main (c3204a9c) is clean: git merge-tree --write-tree returns rc=0, and the merged tree adds exactly this PR's 368 lines.

Still needed: the zero-product lanes. tests/startup_gfx2hlsl_v_dot2_check.py is byte-identical to the a416bed4 version: git rev-parse a416bed4:tests/startup_gfx2hlsl_v_dot2_check.py b87eef1d:tests/startup_gfx2hlsl_v_dot2_check.py gives 2a97924b for both. If the signed carry compares ((t0 < lo) ? 1 : 0) and ((t1 < lo) ? 1 : 0) are changed to <=, the controls still pass (rc=0). The draws miss it too: under the test's own model, the mutant changes 0/4 of the signed clamp=0 lanes and 0/4 of the clamp=1 lanes. pigalot's suggested lane set catches it: expected 3f80000f,0000000e,7fffffff,80000000, mutant 7fffffff ×4. Adding that ('v_dot2_i32_i16', 1, [...]) entry to DRAW_CASES would close this.

Smaller, optional: CI doesn't see the emitted HLSL. Windows ran ctest --preset pr (70 tests, none v_dot2), and Linux ran only the controls. The controls check eval_dot2_*_hlsl, which is a Python copy of the helpers, not the helper text that translate() emits. So three mutants of the helper body pass the controls: the carry compare above, a wrong u32 saturate value, and dropping the p0 sign-extend. Evaluating the emitted helper, or asserting that it matches the copy, would let Linux CI catch them.

What I checked:

  • The lowering is exact. I read the Python copy against the HLSL strings, then compared it with an independent exact reference: 420,000 triples × wrap and clamp → 0 mismatches.
  • llvm-mc-19 -mcpu=gfx1030 -show-encoding gives opcodes 0x14 and 0x15 with the same default op_sel_hi as your encoder. The translator lowers those bytes, and op_sel_hi:[0,1,1] is refused.
  • The clamp model matches the existing dot2 helpers in pixel_aot.py: exact 64-bit accumulate, then saturate.

Not run here: the draws (this machine has no WARP or GPU).

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7235848439 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#issuecomment-7235848439). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-28T07:18:20Z. --- Thanks for this. The lowering looks right to me, but one change from pigalot's review is still missing on `b87eef1d`. Could you add it? **Addressed:** the merge of `main` after #3030 is done (`b87eef1d`). A trial merge into current `main` (`c3204a9c`) is clean: `git merge-tree --write-tree` returns rc=0, and the merged tree adds exactly this PR's 368 lines. **Still needed: the zero-product lanes.** `tests/startup_gfx2hlsl_v_dot2_check.py` is byte-identical to the `a416bed4` version: `git rev-parse a416bed4:tests/startup_gfx2hlsl_v_dot2_check.py b87eef1d:tests/startup_gfx2hlsl_v_dot2_check.py` gives `2a97924b` for both. If the signed carry compares `((t0 < lo) ? 1 : 0)` and `((t1 < lo) ? 1 : 0)` are changed to `<=`, the controls still pass (rc=0). The draws miss it too: under the test's own model, the mutant changes 0/4 of the signed `clamp=0` lanes and 0/4 of the `clamp=1` lanes. pigalot's suggested lane set catches it: expected `3f80000f,0000000e,7fffffff,80000000`, mutant `7fffffff` ×4. Adding that `('v_dot2_i32_i16', 1, [...])` entry to `DRAW_CASES` would close this. **Smaller, optional:** CI doesn't see the emitted HLSL. Windows ran `ctest --preset pr` (70 tests, none `v_dot2`), and Linux ran only the controls. The controls check `eval_dot2_*_hlsl`, which is a Python copy of the helpers, not the helper text that `translate()` emits. So three mutants of the helper body pass the controls: the carry compare above, a wrong u32 saturate value, and dropping the `p0` sign-extend. Evaluating the emitted helper, or asserting that it matches the copy, would let Linux CI catch them. **What I checked:** - The lowering is exact. I read the Python copy against the HLSL strings, then compared it with an independent exact reference: 420,000 triples × wrap and clamp → 0 mismatches. - `llvm-mc-19 -mcpu=gfx1030 -show-encoding` gives opcodes `0x14` and `0x15` with the same default `op_sel_hi` as your encoder. The translator lowers those bytes, and `op_sel_hi:[0,1,1]` is refused. - The clamp model matches the existing dot2 helpers in `pixel_aot.py`: exact 64-bit accumulate, then saturate. Not run here: the draws (this machine has no WARP or GPU). This comment was AI-assisted.
R0D4X commented 2026-11-28 09:11:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0D4X on 2026-11-28T09:11:52Z.


Added the requested zero-product signed-clamp draw lanes (3f80000f,0000000e,7fffffff,80000000) and a strict unsigned carry-compare assertion on the emitted dot2_i32_i16 HLSL helper in tests/startup_gfx2hlsl_v_dot2_check.py.

Verified on NVIDIA GeForce RTX 5080 (10de:2c02, driver 32.0.16.2140), WARP (10.0.26100.9818), Windows 11 (10.0.26300.9974), SDK DXC/FXC 10.0.26100.0:

  • startup_gfx2hlsl_v_dot2_controls: passed
  • startup_gfx2hlsl_v_dot2_warp (FXC ps_5_1 + DXC ps_6_0): passed
  • startup_gfx2hlsl_v_dot2_hardware (FXC ps_5_1 + DXC ps_6_0): passed (debug_errors=0 debug_warnings=0)

Ready for re-review!

Commit: 8c05ff2e

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7237080524 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#issuecomment-7237080524). Originally posted by [R0D4X](https://github.com/R0D4X) on 2026-11-28T09:11:52Z. --- Added the requested zero-product signed-clamp draw lanes (`3f80000f,0000000e,7fffffff,80000000`) and a strict unsigned carry-compare assertion on the emitted `dot2_i32_i16` HLSL helper in `tests/startup_gfx2hlsl_v_dot2_check.py`. Verified on NVIDIA GeForce RTX 5080 (`10de:2c02`, driver `32.0.16.2140`), WARP (`10.0.26100.9818`), Windows 11 (`10.0.26300.9974`), SDK DXC/FXC `10.0.26100.0`: - `startup_gfx2hlsl_v_dot2_controls`: passed - `startup_gfx2hlsl_v_dot2_warp` (FXC `ps_5_1` + DXC `ps_6_0`): passed - `startup_gfx2hlsl_v_dot2_hardware` (FXC `ps_5_1` + DXC `ps_6_0`): passed (`debug_errors=0 debug_warnings=0`) Ready for re-review! Commit: 8c05ff2e
pigalot commented 2026-11-28 10:36:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T10:36:26Z.

Review: APPROVED


Earlier I wrote here that this "needs a re-review by someone else; I won't review or merge it myself". That was wrong: our account's only commit on this branch is the merge of main (b87eef1d), and I'm reviewing it myself now. I will merge it once the merge gates pass.

Retested 8c05ff2e integrated over main 3926a289 (tree dfba0d32). The trial merge is clean and git diff --check is clean. This supersedes my changes-requested review on a416bed4.

Earlier findings.

  • Conflict with #3030: addressed. I merged main into this branch earlier as b87eef1d; I checked that resolution again here. git show --remerge-diff b87eef1d shows one conflict in tools/startup/gfx2hlsl.py, resolved by keeping both sides: the two dot2 helpers, then bitreplicate16. Nothing else differs from an automatic merge.
  • Signed carry compare untested: addressed. 8c05ff2e changes only the test file (+8 lines). It adds the zero-product clamp=1 lane set and a check that the emitted helper contains both strict compares.
    • <= in either compare now fails the controls, so Linux CI sees it.
    • To test the new lanes on their own, I used a mutant that keeps the checked text and adds a carry when t0 == lo. The controls pass, and the draw fails in the new lane set: expected=3f80000f,0000000e,7fffffff,80000000 actual=3f80000f,7fffffff,7fffffff,7fffffff.

What I ran. I built offscreen_check in dev and release (/O2), then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_v_dot2_(controls|warp)$' and the _hardware test on its own:
3/3 passed in each preset, with no skips, FXC ps_5_1 and DXC ps_6_0, debug_errors=0 debug_warnings=0. The tests are not registered on main.

Mutants (18, each against the controls and the WARP draws in dev).

  • Killed (15):
    • signed carry <= at t0, and at t1 (controls);
    • signed carry also on equal at t0, and at t1 (draws only);
    • the 0xffffffffu saturate value;
    • the p0 sign-extend dropped, and the p1 one;
    • the clamp flag never passed;
    • the modifier refusal dropped;
    • each unsigned carry compare as <=;
    • hi not initialised from the sign of c;
    • the signed handler using the unsigned helper;
    • the write bypassing set_v;
    • the p0 term dropped from the signed sum.
  • Equivalent (2): dropping hi > 0 || and dropping hi < -1 ||. hi is always 0 or -1, as noted in my first review.
  • Survives (1): dropping the source modifier refusal. |v0|, -v0 and neg(1) are still refused later, by the operand parser, and the test doesn't pin which message it gets. Not blocking: the behaviour is the same either way.

Other reviewers. JohnConnorNPC's comment on b87eef1d asked for the same zero-product lanes, which are now in. Their optional point (Linux CI not seeing the emitted helper) is partly covered by the new string check: of their three mutants, the carry compare now fails the controls, while the saturate value and the p0 sign-extend are still caught only by the draws. That's fine for this PR.

Verdict: approve 8c05ff2e.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on.
CI: Build and test on Windows passes on 8c05ff2e.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6097265146 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3036#pullrequestreview-6097265146). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T10:36:26Z. **Review:** APPROVED --- Earlier I wrote here that this "needs a re-review by someone else; I won't review or merge it myself". That was wrong: our account's only commit on this branch is the merge of `main` (`b87eef1d`), and I'm reviewing it myself now. I will merge it once the merge gates pass. Retested `8c05ff2e` integrated over `main` `3926a289` (tree `dfba0d32`). The trial merge is clean and `git diff --check` is clean. This supersedes my changes-requested review on `a416bed4`. **Earlier findings.** - **Conflict with #3030: addressed.** I merged `main` into this branch earlier as `b87eef1d`; I checked that resolution again here. `git show --remerge-diff b87eef1d` shows one conflict in `tools/startup/gfx2hlsl.py`, resolved by keeping both sides: the two `dot2` helpers, then `bitreplicate16`. Nothing else differs from an automatic merge. - **Signed carry compare untested: addressed.** `8c05ff2e` changes only the test file (+8 lines). It adds the zero-product `clamp=1` lane set and a check that the emitted helper contains both strict compares. - `<=` in either compare now fails the controls, so Linux CI sees it. - To test the new lanes on their own, I used a mutant that keeps the checked text and adds a carry when `t0 == lo`. The controls pass, and the draw fails in the new lane set: `expected=3f80000f,0000000e,7fffffff,80000000 actual=3f80000f,7fffffff,7fffffff,7fffffff`. **What I ran.** I built `offscreen_check` in `dev` and `release` (`/O2`), then ran `ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_gfx2hlsl_v_dot2_(controls|warp)$'` and the `_hardware` test on its own: 3/3 passed in each preset, with no skips, FXC `ps_5_1` and DXC `ps_6_0`, `debug_errors=0 debug_warnings=0`. The tests are not registered on `main`. **Mutants** (18, each against the controls and the WARP draws in `dev`). - **Killed (15):** - signed carry `<=` at `t0`, and at `t1` (controls); - signed carry also on equal at `t0`, and at `t1` (draws only); - the `0xffffffffu` saturate value; - the `p0` sign-extend dropped, and the `p1` one; - the `clamp` flag never passed; - the modifier refusal dropped; - each unsigned carry compare as `<=`; - `hi` not initialised from the sign of `c`; - the signed handler using the unsigned helper; - the write bypassing `set_v`; - the `p0` term dropped from the signed sum. - **Equivalent (2):** dropping `hi > 0 ||` and dropping `hi < -1 ||`. `hi` is always 0 or -1, as noted in my first review. - **Survives (1):** dropping the `source modifier` refusal. `|v0|`, `-v0` and `neg(1)` are still refused later, by the operand parser, and the test doesn't pin which message it gets. Not blocking: the behaviour is the same either way. **Other reviewers.** JohnConnorNPC's comment on `b87eef1d` asked for the same zero-product lanes, which are now in. Their optional point (Linux CI not seeing the emitted helper) is partly covered by the new string check: of their three mutants, the carry compare now fails the controls, while the saturate value and the `p0` sign-extend are still caught only by the draws. That's fine for this PR. **Verdict:** approve `8c05ff2e`. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on. CI: `Build and test on Windows` passes on `8c05ff2e`. This reply was AI-assisted.
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!3036
No description provided.