startup: lower a loop around the v_interp_p1ll_f16 / v_interp_p2_f16 pair in the pixel stage #2754

Manually merged
github merged 1 commit from gh-pr/2754/head into gh-pr/2754/base 2026-11-27 01:20:17 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-26 06:00 UTC · original
tedin7:x2w-interp-f16-loop → main · +74 −4 · 2 files · 1 commits · merged 2026-11-26 09:29 UTC

Part of #1723

What this unblocks: pixel programs that wrap the v_interp_p1ll_f16 / v_interp_p2_f16 pair in a loop, which were refused with "a backward branch in a program with v_interp_p1ll_f16 / v_interp_p2_f16".
Source: AMD "RDNA 2" Instruction Set Architecture reference guide, VINTRP instructions V_INTERP_P1LL_F16 and V_INTERP_P2_F16 (parameter interpolation with binary16 data).

What changed

  • Stage.interp_f16_scan no longer refuses a backward branch. The scan is linear and holds three kinds of state: a p1ll result waiting for its p2, a p1ll result left stale by a p2 that wrote elsewhere, and a p2 destination whose upper half is undefined. Every branch instruction and every branch target is already a boundary where the scan refuses when any of that state is non-empty. Nothing it tracks can therefore travel along a back edge, and the loop head starts clean on every iteration.
  • The entry I/J registers are still required to be unwritten over the whole program, so the loop reads the same barycentrics every iteration.

Why it is correct

  • The pair lowers to a read of the rasterizer's interpolant (i.param0.x and so on), which is the same value on every iteration. The loop only repeats the pair and its full-width conversion.
  • A p1ll result pending across the back edge, or a p2 result not converted before it, stays refused (new controls).

What stays refused

  • A p1ll result pending at a branch or branch target, a stale p2 result, or an undefined-upper-half destination live across any branch, forward or backward.
  • Everything else the pair refused before (channels z/w of a compr export, modifiers, op_sel, clobbered I/J).

Tests

  • startup_gfx2hlsl_interp_f16_check.py: a constant-trip loop (two iterations, scalar counter) around the pair translates and evaluates to the reference words; the same loop with the high bit inverted evaluates to other words; the two loops that carry state along the back edge are refused. The fixture words are checked against llvm-mc (binary mode, back-edge fixup patched). The existing draw mode now also runs the loop on D3D12 WARP with a wrong-value control (high bit inverted must fail), and compile mode compiles it.

Verification

  • Linux: python3 -B tests/startup_gfx2hlsl_interp_f16_check.py and ... binary llvm-mc-19 pass; the same test fails on main at the loop translation (backward-branch refusal).
  • Linux: tests/startup_gfx2hlsl_interp_p2_hi_check.py passes; the full tests/startup_*check.py set has no result that differs from main.
  • Win2025 WARP dev+release: pending Stage-2.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 06:00 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2754) `tedin7:x2w-interp-f16-loop` → `main` · +74 −4 · 2 files · 1 commits · merged 2026-11-26 09:29 UTC Part of #1723 What this unblocks: pixel programs that wrap the `v_interp_p1ll_f16` / `v_interp_p2_f16` pair in a loop, which were refused with "a backward branch in a program with v_interp_p1ll_f16 / v_interp_p2_f16". Source: AMD "RDNA 2" Instruction Set Architecture reference guide, VINTRP instructions V_INTERP_P1LL_F16 and V_INTERP_P2_F16 (parameter interpolation with binary16 data). ## What changed - `Stage.interp_f16_scan` no longer refuses a backward branch. The scan is linear and holds three kinds of state: a p1ll result waiting for its p2, a p1ll result left stale by a p2 that wrote elsewhere, and a p2 destination whose upper half is undefined. Every branch instruction and every branch target is already a boundary where the scan refuses when any of that state is non-empty. Nothing it tracks can therefore travel along a back edge, and the loop head starts clean on every iteration. - The entry I/J registers are still required to be unwritten over the whole program, so the loop reads the same barycentrics every iteration. ## Why it is correct - The pair lowers to a read of the rasterizer's interpolant (`i.param0.x` and so on), which is the same value on every iteration. The loop only repeats the pair and its full-width conversion. - A p1ll result pending across the back edge, or a p2 result not converted before it, stays refused (new controls). ## What stays refused - A p1ll result pending at a branch or branch target, a stale p2 result, or an undefined-upper-half destination live across any branch, forward or backward. - Everything else the pair refused before (channels z/w of a compr export, modifiers, op_sel, clobbered I/J). ## Tests - `startup_gfx2hlsl_interp_f16_check.py`: a constant-trip loop (two iterations, scalar counter) around the pair translates and evaluates to the reference words; the same loop with the high bit inverted evaluates to other words; the two loops that carry state along the back edge are refused. The fixture words are checked against llvm-mc (`binary` mode, back-edge fixup patched). The existing `draw` mode now also runs the loop on D3D12 WARP with a wrong-value control (high bit inverted must fail), and `compile` mode compiles it. ## Verification - Linux: `python3 -B tests/startup_gfx2hlsl_interp_f16_check.py` and `... binary llvm-mc-19` pass; the same test fails on main at the loop translation (backward-branch refusal). - Linux: `tests/startup_gfx2hlsl_interp_p2_hi_check.py` passes; the full `tests/startup_*check.py` set has no result that differs from main. - Win2025 WARP dev+release: pending Stage-2. AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:20:14 +00:00
github manually merged commit 5626c049a5 into gh-pr/2754/base 2026-11-27 01:20:17 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-26 08:18 UTC · original

Independent review of head 5626c049a5: PASS.

Verification:

  • Windows Server 2025 (D3D12 WARP), ctest -R '^startup_gfx2hlsl_interp': dev 4/4 and release 4/4 (startup_gfx2hlsl_interp_p2_hi_controls, _f16_controls, _f16_warp, _f16_hardware).
  • Tested on RTX 3090 through vkd3d-proton (Linux): 4/4 on the same head.
  • The new loop test fails on main (backward-branch refusal) and passes on this head; python3 -B tests/startup_gfx2hlsl_interp_f16_check.py binary llvm-mc-19 passes.
  • Refusals kept: a p1ll result pending across the back edge, an unconverted p2 result across the back edge, and a p1ll before the loop with p2 after the label.
  • Merging current main into the head is clean; the translator break-it set is unchanged (173 same).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-26 08:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2754#issuecomment-7186437167) Independent review of head 5626c049a5d3004585a2bf98944df843ab1cc586: PASS. Verification: - Windows Server 2025 (D3D12 WARP), `ctest -R '^startup_gfx2hlsl_interp'`: dev 4/4 and release 4/4 (`startup_gfx2hlsl_interp_p2_hi_controls`, `_f16_controls`, `_f16_warp`, `_f16_hardware`). - Tested on RTX 3090 through vkd3d-proton (Linux): 4/4 on the same head. - The new loop test fails on main (backward-branch refusal) and passes on this head; `python3 -B tests/startup_gfx2hlsl_interp_f16_check.py binary llvm-mc-19` passes. - Refusals kept: a p1ll result pending across the back edge, an unconverted p2 result across the back edge, and a p1ll before the loop with p2 after the label. - Merging current main into the head is clean; the translator break-it set is unchanged (173 same). AI-assisted; commands listed were executed locally.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-26 08:18 UTC · original · edited 2026-11-26 08:22 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T08:22:23.044914Z 5626c04 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-26 08:18 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2754#issuecomment-7186441209) · edited 2026-11-26 08:22 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5626c049a5d3004585a2bf98944df843ab1cc586","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T08:22:23.044914Z">2026-11-26T08:22:23.044914Z</relative-time> | `5626c04` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 09:29 UTC · original · approved these changes

Reviewed 5626c049: the scan still requires an empty interpolation state at every branch instruction and target. The change removes only the direction-specific rejection. The independent controls refused a pending p1ll and an unconverted p2 across the latch. The source-built loop matched the DXC pixel reference on native WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 (Windows 11 build 26200), and the high-half mutation failed on both. Command: python -B tests/startup_gfx2hlsl_interp_f16_check.py draw <dxc> <offscreen_check> <warp|hardware>. I used the repository's compatible renderer built at 06574c9d; all shader inputs and lowering were from the exact PR head.

**@⁠R0Y00** on GitHub · 2026-11-26 09:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2754#pullrequestreview-6071567551) · **approved these changes** Reviewed `5626c049`: the scan still requires an empty interpolation state at every branch instruction and target. The change removes only the direction-specific rejection. The independent controls refused a pending p1ll and an unconverted p2 across the latch. The source-built loop matched the DXC pixel reference on native WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 (Windows 11 build 26200), and the high-half mutation failed on both. Command: `python -B tests/startup_gfx2hlsl_interp_f16_check.py draw <dxc> <offscreen_check> <warp|hardware>`. I used the repository's compatible renderer built at 06574c9d; all shader inputs and lowering were from the exact PR head.
This discussion has been locked. Commenting is limited to contributors.
No description provided.