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

Merged
tedin7 merged 1 commit from upstream-pr/2754 into main 2026-11-26 09:29:51 +00:00
tedin7 commented 2026-11-26 06:00:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T06:00:52Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6620575270 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2754). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:00:52Z. --- 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 commented 2026-11-26 09:04:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T08:18:29Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186437167 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2754#issuecomment-7186437167). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:18:29Z. --- 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.
chatgpt-codex-connector[bot commented 2026-11-26 09:04:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:18:42Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186441209 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2754#issuecomment-7186441209). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T08:18:42Z. --- <!-- 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>
upstream-sync closed this pull request 2026-11-26 10:03:52 +00:00
R0Y00 commented 2026-11-26 10:03:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T09:29:46Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6071567551 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2754#pullrequestreview-6071567551). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T09:29:46Z. **Review:** APPROVED --- 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.
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!2746
No description provided.