startup: keep sample_b and get_lod past a divergent EXEC with a per-quad vote #2728

Merged
tedin7 merged 20 commits from upstream-pr/2736 into main 2026-11-26 09:08:38 +00:00
tedin7 commented 2026-11-26 04:35:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:35:26Z.


Part of #1723

What this unblocks: image_sample_b and image_get_lod in pixel shaders that clear or narrow EXEC per lane (v_cmpx, saveexec) or branch on EXEC, which were refused whole.
Source: AMD "RDNA 2" Instruction Set Architecture reference guide, MIMG instructions IMAGE_SAMPLE_B and IMAGE_GET_LOD, and the EXEC mask / whole-quad (WQM) rules for derivatives; Microsoft DirectX-Specs, D3D11 functional specification, shader instructions sample_b and lod.

Builds on #2659 (entry EXEC + uniform_cf).

What changed

  • A derivative op after a per-lane EXEC write is accepted when the program has no backward branch: the one-lane model follows that write exactly, and a lane with EXEC off still offers the address it last wrote to its quad.
  • s_cbranch_execz / execnz are decided per quad (x2w_quad_any(exec), the OR of the four lanes' EXEC bits via ddx_fine/ddy_fine), so the wave-wide branch the guest takes is the one the quad takes, and uniform_cf stays set.
  • Refused, as before or newly explicit: a VCC branch (inside or before the op), a VCC loop, an s_wqm of a narrowed EXEC, a discard under an unknown EXEC. Each records a lane-EXEC break.
  • s_wqm_b64 exec, exec on a narrowed EXEC is not in this slice.
  • Two #2659 checks that expected a cleared EXEC to refuse now expect it accepted.

Why it is correct: the guest wave runs EXEC as one mask; a branch on it is taken for the whole wave. The quad vote gives each quad the same outcome, and implicit derivatives need only the 2x2 quad.

Tests

  • New startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py: pure-Python controls and refusals, plus a D3D12 draw (WARP and hardware adapters) compared with a CPU reference, with mutants of the translated text that must fail the draw.
  • Registered in CMake next to the startup_image_sample_b draw tests.

Verification (Linux only):

python3 -B tests/startup_image_sample_b_flow_check.py        rc=0
python3 -B tests/startup_image_get_lod_flow_check.py         rc=0
python3 -B tests/startup_image_sample_b_check.py             rc=0
python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py     rc=0
for every tests/startup_gfx2hlsl_*_check.py (no arguments)   109 of 111 rc=0; the 2 others are draw-only checks that need adapter arguments (untouched)

Win2025 (dev + release, head 083b949d2): x2w_pipe.py win2025 2736 --host aws-1 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py --targets offscreen_check --regex 'startup_image_(sample_b|get_lod)|startup_gfx2hlsl_(image|cmp|lane|mask|compute)': 63/63 passed in both presets, including startup_image_sample_b_flow_{warp,hardware} and startup_image_get_lod_flow_{warp,hardware} with their mutations.
Real GPU: RTX 3090 through vkd3d-proton (Linux) on head 5c907ddec: both flow checks pass on the hardware adapter (the later commits only add refusals and merges of main).
Independent pass by @R0Y00 (2026-11-26 07:15Z, head ef786354, Windows 11 build 26200): startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py with controls and draw <dxc> <offscreen_check> <warp|hardware> <fxc>: 60/60 GPU comparisons matched the CPU references on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, no skips; DXC hardware inside case passed for both instructions; fixtures still detect wrong lane writes, dropped branch writes and ignored bias controls.
Build and run: cmake --build --preset dev --target offscreen_check then ctest --preset dev --no-tests=error -R '^startup_image_(sample_b|get_lod)_flow' -V.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6619589612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:35:26Z. --- Part of #1723 What this unblocks: `image_sample_b` and `image_get_lod` in pixel shaders that clear or narrow EXEC per lane (`v_cmpx`, saveexec) or branch on EXEC, which were refused whole. Source: AMD "RDNA 2" Instruction Set Architecture reference guide, MIMG instructions IMAGE_SAMPLE_B and IMAGE_GET_LOD, and the EXEC mask / whole-quad (WQM) rules for derivatives; Microsoft DirectX-Specs, D3D11 functional specification, shader instructions `sample_b` and `lod`. Builds on #2659 (entry EXEC + `uniform_cf`). What changed - A derivative op after a per-lane EXEC write is accepted when the program has no backward branch: the one-lane model follows that write exactly, and a lane with EXEC off still offers the address it last wrote to its quad. - `s_cbranch_execz` / `execnz` are decided per quad (`x2w_quad_any(exec)`, the OR of the four lanes' EXEC bits via `ddx_fine`/`ddy_fine`), so the wave-wide branch the guest takes is the one the quad takes, and `uniform_cf` stays set. - Refused, as before or newly explicit: a VCC branch (inside or before the op), a VCC loop, an `s_wqm` of a narrowed EXEC, a discard under an unknown EXEC. Each records a lane-EXEC break. - `s_wqm_b64 exec, exec` on a narrowed EXEC is not in this slice. - Two #2659 checks that expected a cleared EXEC to refuse now expect it accepted. Why it is correct: the guest wave runs EXEC as one mask; a branch on it is taken for the whole wave. The quad vote gives each quad the same outcome, and implicit derivatives need only the 2x2 quad. Tests - New `startup_image_sample_b_flow_check.py` and `startup_image_get_lod_flow_check.py`: pure-Python controls and refusals, plus a D3D12 draw (WARP and hardware adapters) compared with a CPU reference, with mutants of the translated text that must fail the draw. - Registered in CMake next to the `startup_image_sample_b` draw tests. Verification (Linux only): ``` python3 -B tests/startup_image_sample_b_flow_check.py rc=0 python3 -B tests/startup_image_get_lod_flow_check.py rc=0 python3 -B tests/startup_image_sample_b_check.py rc=0 python3 -B tests/startup_gfx2hlsl_image_get_lod_check.py rc=0 for every tests/startup_gfx2hlsl_*_check.py (no arguments) 109 of 111 rc=0; the 2 others are draw-only checks that need adapter arguments (untouched) ``` Win2025 (dev + release, head 083b949d2): `x2w_pipe.py win2025 2736 --host aws-1 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py --targets offscreen_check --regex 'startup_image_(sample_b|get_lod)|startup_gfx2hlsl_(image|cmp|lane|mask|compute)'`: 63/63 passed in both presets, including `startup_image_sample_b_flow_{warp,hardware}` and `startup_image_get_lod_flow_{warp,hardware}` with their mutations. Real GPU: RTX 3090 through vkd3d-proton (Linux) on head 5c907ddec: both flow checks pass on the hardware adapter (the later commits only add refusals and merges of main). Independent pass by @R0Y00 (2026-11-26 07:15Z, head ef786354, Windows 11 build 26200): `startup_image_sample_b_flow_check.py` and `startup_image_get_lod_flow_check.py` with controls and `draw <dxc> <offscreen_check> <warp|hardware> <fxc>`: 60/60 GPU comparisons matched the CPU references on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, no skips; DXC hardware inside case passed for both instructions; fixtures still detect wrong lane writes, dropped branch writes and ignored bias controls. Build and run: `cmake --build --preset dev --target offscreen_check` then `ctest --preset dev --no-tests=error -R '^startup_image_(sample_b|get_lod)_flow' -V`. AI-assisted; commands listed were executed locally.
RonLogic commented 2026-11-26 04:40:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:40:32Z.


Follow-up on the same head: replacing the original vote with the arithmetic helper above, in memory, passed both complete flow scripts and their mutations on WARP and RTX 4070 with both DXC and FXC.

There is a separate correctness gate for the per-quad branch transform. It keeps each participating quad together, but the scalar effects of an EXEC branch still follow the guest wave. For example, I spliced the following into the existing join_pixel program, keeping its prologue and SampleBias/export tail:

s_mov_b32 s28, -1.0
v_cmp_eq_u32_e32 vcc, 2, v8
s_and_saveexec_b64 s[0:1], vcc
s_cbranch_execz 1
s_mov_b32 s28, 0
s_or_b64 exec, exec, s[0:1]
v_mov_b32_e32 v1, s28

Encoded replacement for 8010847d6a2480be010088bff10404067e00fe88: f3039cbe8210847d6a2480be010088bf80039cbe7e00fe881c02027e. The decoder and translator accept it, and the emitted PC block writes s28 only in a quad with X=2. In a guest wave containing both X=0 and X=2, the X=2 lane keeps the wave from taking the EXECZ branch. The scalar write happens once for the wave and the X=0 lane later reads bias 0 after EXEC is restored. In the emitted shader the X=0 quad instead skips the scalar write and reads bias -1. This is a source/semantics counterexample, separate from the measured RTX failures above. Please gate voting on a proof that scalar/control effects cannot be observed from a quad that skips the block, or keep those shapes refused by name. A regression fixture can use these same bytes.

4×2 readback update: I widened the existing synthetic renderer's target, viewport and scissor to 4×2 and printed the first row, keeping the same source texture and sampler. With the arithmetic vote in both arms, the accepted translation returned 3d200000,00000000,3f800000,00000000 at X=0 on WARP and RTX 4070. A reference arm using the expected guest wave's bias 0 returned 3e840000,00000000,00000000,40000000. X=1 also changed, and X=2/3 were identical. Both GPUs reported zero debug errors and warnings. This measures the visible effect of losing the scalar across quads; the guest reference assumes both quads belong to the same wave, as in the counterexample.

Verified after merge: b505c32b includes the arithmetic vote and the scalar_in_block refusal covering the synthetic program above. Both complete flow suites pass with DXC and FXC on in-box WARP and physical RTX 4070. The complete runs include 26 SampleBias and 14 GetLOD GPU/reference matches per adapter and their negative controls. The previous inside failures no longer reproduce.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182803516 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7182803516). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-26T04:40:32Z. --- Follow-up on the same head: replacing the original vote with the arithmetic helper above, in memory, passed both complete flow scripts and their mutations on WARP and RTX 4070 with both DXC and FXC. There is a separate correctness gate for the per-quad branch transform. It keeps each participating quad together, but the scalar effects of an EXEC branch still follow the guest wave. For example, I spliced the following into the existing `join_pixel` program, keeping its prologue and SampleBias/export tail: ```asm s_mov_b32 s28, -1.0 v_cmp_eq_u32_e32 vcc, 2, v8 s_and_saveexec_b64 s[0:1], vcc s_cbranch_execz 1 s_mov_b32 s28, 0 s_or_b64 exec, exec, s[0:1] v_mov_b32_e32 v1, s28 ``` Encoded replacement for `8010847d6a2480be010088bff10404067e00fe88`: `f3039cbe8210847d6a2480be010088bf80039cbe7e00fe881c02027e`. The decoder and translator accept it, and the emitted PC block writes `s28` only in a quad with X=2. In a guest wave containing both X=0 and X=2, the X=2 lane keeps the wave from taking the EXECZ branch. The scalar write happens once for the wave and the X=0 lane later reads bias 0 after EXEC is restored. In the emitted shader the X=0 quad instead skips the scalar write and reads bias -1. This is a source/semantics counterexample, separate from the measured RTX failures above. Please gate voting on a proof that scalar/control effects cannot be observed from a quad that skips the block, or keep those shapes refused by name. A regression fixture can use these same bytes. **4×2 readback update:** I widened the existing synthetic renderer's target, viewport and scissor to 4×2 and printed the first row, keeping the same source texture and sampler. With the arithmetic vote in both arms, the accepted translation returned `3d200000,00000000,3f800000,00000000` at X=0 on WARP and RTX 4070. A reference arm using the expected guest wave's bias 0 returned `3e840000,00000000,00000000,40000000`. X=1 also changed, and X=2/3 were identical. Both GPUs reported zero debug errors and warnings. This measures the visible effect of losing the scalar across quads; the guest reference assumes both quads belong to the same wave, as in the counterexample. **Verified after merge:** `b505c32b` includes the arithmetic vote and the `scalar_in_block` refusal covering the synthetic program above. Both complete flow suites pass with DXC and FXC on in-box WARP and physical RTX 4070. The complete runs include 26 SampleBias and 14 GetLOD GPU/reference matches per adapter and their negative controls. The previous `inside` failures no longer reproduce.
RonLogic commented 2026-11-26 05:02:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:39:10Z.


Windows readback blocker on b2a1957d42110d2dfda983bc98ef0d4c6cd861cb. Both full draw scripts pass with DXC and FXC on in-box WARP 10.0.26100.10068. On RTX 4070 32.0.16.2124 with SDK DXC 1.9.2602.17, each fails in its existing inside case after the earlier cases pass:

  • SampleBias expects 3e880000,3f800000,00000000,40000000, reads 3d600000,40000000,3f800000,00000000.
  • GetLOD expects (2.0, 2.0), reads (0.0, -32.0).

I isolated both compiled fixtures on the RTX 4070. Unmodified FXC ps_5_1 passes both. Adding [flatten] to the DXC pixel shader's if (pc == 1) still fails both. Changing only the quad-vote helper to evaluate the derivatives as arithmetic operands fixes both original DXC cases in this focused probe:

bool x2w_quad_any(uint bit) {
    float lane = (bit & 1u) != 0u ? 1.0 : 0.0;
    float row = (lane + abs(ddx_fine(lane)) != 0.0) ? 1.0 : 0.0;
    return row + abs(ddy_fine(row)) != 0.0;
}

This isolates an emission change worth trying in the branch. Windows 26300.10075, Release, D3D12 debug layer enabled. Reproduction uses tests/startup_image_sample_b_flow_check.py and tests/startup_image_get_lod_flow_check.py, each with draw <dxc> <offscreen_check> hardware <fxc>.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182783474 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7182783474). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-26T04:39:10Z. --- Windows readback blocker on `b2a1957d42110d2dfda983bc98ef0d4c6cd861cb`. Both full draw scripts pass with DXC and FXC on in-box WARP `10.0.26100.10068`. On RTX 4070 `32.0.16.2124` with SDK DXC `1.9.2602.17`, each fails in its existing `inside` case after the earlier cases pass: - SampleBias expects `3e880000,3f800000,00000000,40000000`, reads `3d600000,40000000,3f800000,00000000`. - GetLOD expects `(2.0, 2.0)`, reads `(0.0, -32.0)`. I isolated both compiled fixtures on the RTX 4070. Unmodified FXC `ps_5_1` passes both. Adding `[flatten]` to the DXC pixel shader's `if (pc == 1)` still fails both. Changing only the quad-vote helper to evaluate the derivatives as arithmetic operands fixes both original DXC cases in this focused probe: ```hlsl bool x2w_quad_any(uint bit) { float lane = (bit & 1u) != 0u ? 1.0 : 0.0; float row = (lane + abs(ddx_fine(lane)) != 0.0) ? 1.0 : 0.0; return row + abs(ddy_fine(row)) != 0.0; } ``` This isolates an emission change worth trying in the branch. Windows `26300.10075`, Release, D3D12 debug layer enabled. Reproduction uses `tests/startup_image_sample_b_flow_check.py` and `tests/startup_image_get_lod_flow_check.py`, each with `draw <dxc> <offscreen_check> hardware <fxc>`.
tedin7 commented 2026-11-26 05:02:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:58:47Z.


Thank you, both points were real. Fixed in 5c907ddec.

  1. RTX 4070 failure (inside case): the || vote let DXC move a derivative under the condition, where only some lanes ran it. The helper now uses your arithmetic form (lane + abs(ddx_fine(lane)) != 0.0, then row + abs(ddy_fine(row)) != 0.0), with a comment saying why. The existing inside draw fixtures are the regression test; I could not run them on a hardware adapter from here, so please re-run both flow scripts with draw ... hardware on your RTX.

  2. Scalar effects inside a skipped block: confirmed from your bytes. A new gate (Stage.skipped_block_vector_only) votes an EXEC branch only when everything it can skip is per-lane vector work (VALU without compares or lane reads, image/buffer/export, waits, s_endpgm). Any scalar write, mask write or branch in the block leaves the branch un-voted and the op refused by the usual message. Your exact bytes are now the refused fixture scalar_in_block in both flow checks; it is accepted (test fails) when the gate is removed.

Also added: a restore draw fixture (exact mask saved before s_wqm, restored before the op) in both scripts.

Verification (Linux):

python3 -B tests/startup_image_sample_b_flow_check.py          rc=0
python3 -B tests/startup_image_get_lod_flow_check.py           rc=0
python3 -B tests/startup_image_sample_b_flow_check.py binary llvm-mc-19   fixtures reassemble
python3 -B tests/startup_image_get_lod_flow_check.py binary llvm-mc-19    fixtures reassemble
sweep of tests/startup_gfx2hlsl_*_check.py (no arguments)      109+ rc=0; only the two draw-only checks that need adapter arguments exit 1 (untouched)

Win2025 WARP and hardware re-run of the new head: pending Stage-2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7183070517 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7183070517). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T04:58:47Z. --- Thank you, both points were real. Fixed in 5c907ddec. 1. RTX 4070 failure (`inside` case): the `||` vote let DXC move a derivative under the condition, where only some lanes ran it. The helper now uses your arithmetic form (`lane + abs(ddx_fine(lane)) != 0.0`, then `row + abs(ddy_fine(row)) != 0.0`), with a comment saying why. The existing `inside` draw fixtures are the regression test; I could not run them on a hardware adapter from here, so please re-run both flow scripts with `draw ... hardware` on your RTX. 2. Scalar effects inside a skipped block: confirmed from your bytes. A new gate (`Stage.skipped_block_vector_only`) votes an EXEC branch only when everything it can skip is per-lane vector work (VALU without compares or lane reads, image/buffer/export, waits, `s_endpgm`). Any scalar write, mask write or branch in the block leaves the branch un-voted and the op refused by the usual message. Your exact bytes are now the refused fixture `scalar_in_block` in both flow checks; it is accepted (test fails) when the gate is removed. Also added: a `restore` draw fixture (exact mask saved before `s_wqm`, restored before the op) in both scripts. Verification (Linux): ``` python3 -B tests/startup_image_sample_b_flow_check.py rc=0 python3 -B tests/startup_image_get_lod_flow_check.py rc=0 python3 -B tests/startup_image_sample_b_flow_check.py binary llvm-mc-19 fixtures reassemble python3 -B tests/startup_image_get_lod_flow_check.py binary llvm-mc-19 fixtures reassemble sweep of tests/startup_gfx2hlsl_*_check.py (no arguments) 109+ rc=0; only the two draw-only checks that need adapter arguments exit 1 (untouched) ``` Win2025 WARP and hardware re-run of the new head: pending Stage-2. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot] commented 2026-11-26 05:58:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:58:27Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 48529eddeb

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069226062 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6069226062). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T05:58:27Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `48529eddeb` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-26 06:02:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:12:40Z.


Follow-up in c45dc9e4a: tx_join_bias_div (a bias that differs per lane past a divergent EXEC) is now refused by name, so no newly translated form is left without a readback row. The bias must be a constant v_mov_b32 that every lane ran before the op; new refused fixture bias_per_lane in startup_image_sample_b_flow_check.py (reassembles with llvm-mc). A per-lane bias fixture is a later slice.

breakit against main: 5 gains named in the readback registry (PR-local rows, pending the Win2025 re-run), 1 intended refusal, 165 unchanged. Sweep of startup_gfx2hlsl_*_check.py: all pass except the two draw-only checks that need adapter arguments (untouched).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7183279925 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7183279925). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:12:40Z. --- Follow-up in c45dc9e4a: `tx_join_bias_div` (a bias that differs per lane past a divergent EXEC) is now refused by name, so no newly translated form is left without a readback row. The bias must be a constant `v_mov_b32` that every lane ran before the op; new refused fixture `bias_per_lane` in `startup_image_sample_b_flow_check.py` (reassembles with llvm-mc). A per-lane bias fixture is a later slice. breakit against main: 5 gains named in the readback registry (PR-local rows, pending the Win2025 re-run), 1 intended refusal, 165 unchanged. Sweep of `startup_gfx2hlsl_*_check.py`: all pass except the two draw-only checks that need adapter arguments (untouched). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 06:02:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T05:51:34Z.


@MasterDomino Ready for review on head 083b949d2 (after the three review threads).

Independent Stage-2 gate. fresh_gate GO. The break-it sweep against the merge base (173 shapes) shows exactly the 5 intended gains, each backed by a passing readback row (startup_image_sample_b_flow_warp, startup_image_get_lod_flow_warp), and tx_join_bias_div (a per-lane bias past a divergent EXEC) is refused by name. I tried to break the vote and the new uniform_bias rule: a bias written inside the voted block, from a lane mask (vcc_lo, exec_lo), on one arm of a branch, or overwritten per lane (all refused); a scalar write, a v_cmp or a v_readlane inside the voted block (all refused); two voted blocks in a row and the kill shape translate as intended.

Both review points of the hardware report are answered in the code on this head: the vote is the arithmetic form, and a voted block must be vector-only (scalar_in_block is refused, with a fixture that fails without the gate). Real-GPU result on head 5c907ddec (RTX 3090, vkd3d-proton): both flow checks pass on the hardware adapter; later commits only add refusals and merges of main: the voted block is now vector-only with VGPR destinations, a lane-exact EXEC write check, and a kill shape followed by an EXEC restore is refused (fixtures carry_in_block, exec_const_mask, kill_then_restore, each failing on 48529edde).

Verification:

  • Linux: python3 -B tests/startup_image_sample_b_flow_check.py, ..._get_lod_flow_check.py, ..._sample_b_check.py, ..._gfx2hlsl_image_get_lod_check.py: pass.
  • Win2025 (dev + release): x2w_pipe.py win2025 2736 --host aws-1 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py --targets offscreen_check --regex 'startup_image_(sample_b|get_lod)|startup_gfx2hlsl_(image|cmp|lane|mask|compute)': 63/63 in both presets.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7183869607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7183869607). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T05:51:34Z. --- @MasterDomino Ready for review on head 083b949d2 (after the three review threads). Independent Stage-2 gate. `fresh_gate` GO. The break-it sweep against the merge base (173 shapes) shows exactly the 5 intended gains, each backed by a passing readback row (`startup_image_sample_b_flow_warp`, `startup_image_get_lod_flow_warp`), and `tx_join_bias_div` (a per-lane bias past a divergent EXEC) is refused by name. I tried to break the vote and the new `uniform_bias` rule: a bias written inside the voted block, from a lane mask (`vcc_lo`, `exec_lo`), on one arm of a branch, or overwritten per lane (all refused); a scalar write, a `v_cmp` or a `v_readlane` inside the voted block (all refused); two voted blocks in a row and the `kill` shape translate as intended. Both review points of the hardware report are answered in the code on this head: the vote is the arithmetic form, and a voted block must be vector-only (`scalar_in_block` is refused, with a fixture that fails without the gate). Real-GPU result on head 5c907ddec (RTX 3090, vkd3d-proton): both flow checks pass on the hardware adapter; later commits only add refusals and merges of `main`: the voted block is now vector-only with VGPR destinations, a lane-exact EXEC write check, and a kill shape followed by an EXEC restore is refused (fixtures `carry_in_block`, `exec_const_mask`, `kill_then_restore`, each failing on 48529edde). Verification: - Linux: `python3 -B tests/startup_image_sample_b_flow_check.py`, `..._get_lod_flow_check.py`, `..._sample_b_check.py`, `..._gfx2hlsl_image_get_lod_check.py`: pass. - Win2025 (dev + release): `x2w_pipe.py win2025 2736 --host aws-1 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py --targets offscreen_check --regex 'startup_image_(sample_b|get_lod)|startup_gfx2hlsl_(image|cmp|lane|mask|compute)'`: 63/63 in both presets. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 06:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:51: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-26T05:58:29.983727Z 48529ed 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:7183871757 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7183871757). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:51:42Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"48529eddeb2d3890eb9a96cd581c5a2c679ebf62","has_any_findings":true,"has_unresolved_findings":true,"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-26T05:58:29.983727Z">2026-11-26T05:58:29.983727Z</relative-time> | `48529ed` | 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>
chatgpt-codex-connector[bot commented 2026-11-26 06:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:58:27Z.

Code review location: tools/startup/gfx2hlsl.py; line 3566

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))

P1 Badge Exclude mask-writing VALU operations from quad-voted blocks

When a wave contains an active quad and an all-zero-EXEC quad, this check admits v_add_co_u32 even though it also overwrites an SGPR or VCC mask, clearing inactive lanes' bits. For example, initialize s[28:29] from EXEC, narrow EXEC, put v_add_co_u32 v14, s28, 0, 0 inside an execz-skipped block, then OR s[28:29] back into EXEC before image_get_lod. This stream is newly accepted: the guest executes the carry instruction wave-wide and clears s[28:29], but the inactive quad votes to skip it and retains its old mask, incorrectly reactivating and exporting those pixels. Check decoded destinations/effects instead of treating every non-compare v_ instruction as vector-only.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704436607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704436607). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:58:27Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3566 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Exclude mask-writing VALU operations from quad-voted blocks** When a wave contains an active quad and an all-zero-EXEC quad, this check admits `v_add_co_u32` even though it also overwrites an SGPR or VCC mask, clearing inactive lanes' bits. For example, initialize s[28:29] from EXEC, narrow EXEC, put `v_add_co_u32 v14, s28, 0, 0` inside an execz-skipped block, then OR s[28:29] back into EXEC before `image_get_lod`. This stream is newly accepted: the guest executes the carry instruction wave-wide and clears s[28:29], but the inactive quad votes to skip it and retains its old mask, incorrectly reactivating and exporting those pixels. Check decoded destinations/effects instead of treating every non-compare `v_` instruction as vector-only. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 06:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:58:27Z.

Code review location: tools/startup/gfx2hlsl.py; line 3617

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))
+                    or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp'))
+                    or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')):
+                return False
+        return True
+
+    def uniform_bias(self, tok):
+        """Whether a VGPR holds one value in every lane at the op: its last earlier write is a v_mov_b32 of a constant
+        that every lane ran (no EXEC write and no branch before it, so no lane skipped it and the other lanes keep an
+        older value). No backward branch exists in a quad program, so later writes cannot reach the op."""
+        r = reg_range(tok)
+        if not r or r[0] != 'v' or r[1] != r[2]:
+            return False
+        last = None
+        for off, _n, name, asm in self.ins:
+            if off >= self.pc:
+                break
+            ops = parse(asm)[1]
+            first = reg_range(ops[0]) if ops else None
+            if first and first[0] == 'v' and first[1] <= r[1] <= first[2]:
+                const = (re.sub(r'_e(32|64)$', '', name) == 'v_mov_b32' and len(ops) == 2 and not reg_range(ops[1]))
+                last = off if const else None
+        if last is None:
+            return False
+        narrowed = 0
+        for off, _n, name, asm in self.ins:
+            if off >= last:
+                break
+            base = re.sub(r'_e(32|64)$', '', name)
+            ops = parse(asm)[1]
+            if name.startswith('s_cbranch') or name == 's_branch':
+                target = int(ops[0].split('_')[1], 16) if '_' in ops[0] else None
+                if target is None or target > last:
+                    return False  # the write can be skipped by some lanes
+            elif base in ('s_or_b64', 's_or_b32') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo']):
+                narrowed = max(narrowed - 1, 0)  # the restore that ends a saveexec region
+            elif base.startswith('s_and_saveexec') or (base.startswith('s_wqm') and ops[:2] not in (['exec', 'exec'], ['exec_lo', 'exec_lo'])):
+                narrowed += 1
+            elif writes_exec(name, ops) and not (base.startswith('s_wqm') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo'])):
+                return False
+        return narrowed == 0
+
+    def derivative_exec_ok(self):
+        """Whether an implicit-derivative op may rely on the EXEC the lanes hold here.
+
+        At the entry mask every lane runs the call. Past an EXEC write (v_cmpx, saveexec, a restore) the one-lane
+        model still follows the guest's bit of each lane exactly (EXEC is written per lane, set_v is EXEC guarded),
+        so a quad program (a pixel program with a derivative op and no backward branch) is proven as long as no
+        lane-exec break happened: an s_wqm of a narrowed EXEC (a no-op here, while the guest turns on the lanes of
+        every touched quad) or a discard under an unknown EXEC. The callers also need uniform_cf, which a branch
+        that parts a quad clears; an EXEC branch decided per quad (quad_vote) does not."""
+        return self.exec_known or (getattr(self, 'quad_exec', False) and not getattr(self, 'lane_exec_breaks', None))

P1 Badge Verify lane-exact EXEC writes before accepting derivatives

For an acyclic pixel program, this fallback accepts arbitrary EXEC writers because only WQM and discard currently record lane-EXEC breaks. For example, s_mov_b64 exec, 1 is emitted by scalar() as exec = (0x00000001u) & 1 in every pixel/helper lane, although the guest enables only wave lane 0. An EXEC-guarded coordinate update followed by image_get_lod now translates successfully, but updates inactive quad neighbours too, changes the derivatives, and exports pixels the guest masks out; the parent correctly refused this stream. Require a lane-exact proof for the reaching EXEC writers, or record unrepresentable writes as breaks.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704436611 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704436611). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:58:27Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3617 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) + or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp')) + or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')): + return False + return True + + def uniform_bias(self, tok): + """Whether a VGPR holds one value in every lane at the op: its last earlier write is a v_mov_b32 of a constant + that every lane ran (no EXEC write and no branch before it, so no lane skipped it and the other lanes keep an + older value). No backward branch exists in a quad program, so later writes cannot reach the op.""" + r = reg_range(tok) + if not r or r[0] != 'v' or r[1] != r[2]: + return False + last = None + for off, _n, name, asm in self.ins: + if off >= self.pc: + break + ops = parse(asm)[1] + first = reg_range(ops[0]) if ops else None + if first and first[0] == 'v' and first[1] <= r[1] <= first[2]: + const = (re.sub(r'_e(32|64)$', '', name) == 'v_mov_b32' and len(ops) == 2 and not reg_range(ops[1])) + last = off if const else None + if last is None: + return False + narrowed = 0 + for off, _n, name, asm in self.ins: + if off >= last: + break + base = re.sub(r'_e(32|64)$', '', name) + ops = parse(asm)[1] + if name.startswith('s_cbranch') or name == 's_branch': + target = int(ops[0].split('_')[1], 16) if '_' in ops[0] else None + if target is None or target > last: + return False # the write can be skipped by some lanes + elif base in ('s_or_b64', 's_or_b32') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo']): + narrowed = max(narrowed - 1, 0) # the restore that ends a saveexec region + elif base.startswith('s_and_saveexec') or (base.startswith('s_wqm') and ops[:2] not in (['exec', 'exec'], ['exec_lo', 'exec_lo'])): + narrowed += 1 + elif writes_exec(name, ops) and not (base.startswith('s_wqm') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo'])): + return False + return narrowed == 0 + + def derivative_exec_ok(self): + """Whether an implicit-derivative op may rely on the EXEC the lanes hold here. + + At the entry mask every lane runs the call. Past an EXEC write (v_cmpx, saveexec, a restore) the one-lane + model still follows the guest's bit of each lane exactly (EXEC is written per lane, set_v is EXEC guarded), + so a quad program (a pixel program with a derivative op and no backward branch) is proven as long as no + lane-exec break happened: an s_wqm of a narrowed EXEC (a no-op here, while the guest turns on the lanes of + every touched quad) or a discard under an unknown EXEC. The callers also need uniform_cf, which a branch + that parts a quad clears; an EXEC branch decided per quad (quad_vote) does not.""" + return self.exec_known or (getattr(self, 'quad_exec', False) and not getattr(self, 'lane_exec_breaks', None)) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Verify lane-exact EXEC writes before accepting derivatives** For an acyclic pixel program, this fallback accepts arbitrary EXEC writers because only WQM and discard currently record lane-EXEC breaks. For example, `s_mov_b64 exec, 1` is emitted by `scalar()` as `exec = (0x00000001u) & 1` in every pixel/helper lane, although the guest enables only wave lane 0. An EXEC-guarded coordinate update followed by `image_get_lod` now translates successfully, but updates inactive quad neighbours too, changes the derivatives, and exports pixels the guest masks out; the parent correctly refused this stream. Require a lane-exact proof for the reaching EXEC writers, or record unrepresentable writes as breaks. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-26 06:02:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T05:58:27Z.

Code review location: tools/startup/gfx2hlsl.py; line 3568

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))
+                    or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp'))
+                    or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')):

P2 Badge Reject quad-local termination when later code can restore EXEC

When a wave contains both active and all-zero-EXEC quads, saving EXEC, narrowing it, branching with s_cbranch_execnz over s_endpgm, restoring the saved EXEC, and querying LOD is now accepted. The guest skips the termination for the entire wave, so the restore reactivates every quad. The generated per-quad vote instead sends an inactive quad through s_endpgm; body() sets its PC to 0xffff, preventing it from reaching the restore/query and returning zero output for pixels the guest would shade. Permit this termination shortcut only after proving those quads cannot subsequently be reactivated, or refuse such blocks.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704436614 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704436614). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T05:58:27Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3568 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) + or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp')) + or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')): ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject quad-local termination when later code can restore EXEC** When a wave contains both active and all-zero-EXEC quads, saving EXEC, narrowing it, branching with `s_cbranch_execnz` over `s_endpgm`, restoring the saved EXEC, and querying LOD is now accepted. The guest skips the termination for the entire wave, so the restore reactivates every quad. The generated per-quad vote instead sends an inactive quad through `s_endpgm`; `body()` sets its PC to `0xffff`, preventing it from reaching the restore/query and returning zero output for pixels the guest would shade. Permit this termination shortcut only after proving those quads cannot subsequently be reactivated, or refuse such blocks. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-26 07:00:19 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069521229 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6069521229). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:47Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 07:00:19 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069521648 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6069521648). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:50Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 07:00:19 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6069521946 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6069521946). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:53Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-26 07:00:29 +00:00 (Migrated from github.com)

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

Code review location: tools/startup/gfx2hlsl.py; line 3566

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))

Confirmed (repro on 48529edde: a carry-out inside the voted block, with the cleared s[28:29] ORed into EXEC afterwards, translated) and fixed in 1b7ae0200: a voted block may now hold only vector instructions whose destinations are all VGPRs (no carry-out, compare, readlane, div_scale, 64-bit mad, no SGPR/VCC/EXEC destination). New refused fixture carry_in_block in tests/startup_image_sample_b_flow_check.py (recorded words, fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704664252 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704664252). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:47Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3566 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) ~~~~ --- Confirmed (repro on 48529edde: a carry-out inside the voted block, with the cleared s[28:29] ORed into EXEC afterwards, translated) and fixed in 1b7ae0200: a voted block may now hold only vector instructions whose destinations are all VGPRs (no carry-out, compare, readlane, div_scale, 64-bit mad, no SGPR/VCC/EXEC destination). New refused fixture `carry_in_block` in `tests/startup_image_sample_b_flow_check.py` (recorded words, fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 07:00:29 +00:00 (Migrated from github.com)

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

Code review location: tools/startup/gfx2hlsl.py; line 3617

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))
+                    or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp'))
+                    or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')):
+                return False
+        return True
+
+    def uniform_bias(self, tok):
+        """Whether a VGPR holds one value in every lane at the op: its last earlier write is a v_mov_b32 of a constant
+        that every lane ran (no EXEC write and no branch before it, so no lane skipped it and the other lanes keep an
+        older value). No backward branch exists in a quad program, so later writes cannot reach the op."""
+        r = reg_range(tok)
+        if not r or r[0] != 'v' or r[1] != r[2]:
+            return False
+        last = None
+        for off, _n, name, asm in self.ins:
+            if off >= self.pc:
+                break
+            ops = parse(asm)[1]
+            first = reg_range(ops[0]) if ops else None
+            if first and first[0] == 'v' and first[1] <= r[1] <= first[2]:
+                const = (re.sub(r'_e(32|64)$', '', name) == 'v_mov_b32' and len(ops) == 2 and not reg_range(ops[1]))
+                last = off if const else None
+        if last is None:
+            return False
+        narrowed = 0
+        for off, _n, name, asm in self.ins:
+            if off >= last:
+                break
+            base = re.sub(r'_e(32|64)$', '', name)
+            ops = parse(asm)[1]
+            if name.startswith('s_cbranch') or name == 's_branch':
+                target = int(ops[0].split('_')[1], 16) if '_' in ops[0] else None
+                if target is None or target > last:
+                    return False  # the write can be skipped by some lanes
+            elif base in ('s_or_b64', 's_or_b32') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo']):
+                narrowed = max(narrowed - 1, 0)  # the restore that ends a saveexec region
+            elif base.startswith('s_and_saveexec') or (base.startswith('s_wqm') and ops[:2] not in (['exec', 'exec'], ['exec_lo', 'exec_lo'])):
+                narrowed += 1
+            elif writes_exec(name, ops) and not (base.startswith('s_wqm') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo'])):
+                return False
+        return narrowed == 0
+
+    def derivative_exec_ok(self):
+        """Whether an implicit-derivative op may rely on the EXEC the lanes hold here.
+
+        At the entry mask every lane runs the call. Past an EXEC write (v_cmpx, saveexec, a restore) the one-lane
+        model still follows the guest's bit of each lane exactly (EXEC is written per lane, set_v is EXEC guarded),
+        so a quad program (a pixel program with a derivative op and no backward branch) is proven as long as no
+        lane-exec break happened: an s_wqm of a narrowed EXEC (a no-op here, while the guest turns on the lanes of
+        every touched quad) or a discard under an unknown EXEC. The callers also need uniform_cf, which a branch
+        that parts a quad clears; an EXEC branch decided per quad (quad_vote) does not."""
+        return self.exec_known or (getattr(self, 'quad_exec', False) and not getattr(self, 'lane_exec_breaks', None))

Confirmed (repro: s_mov_b64 exec, 1, an EXEC-guarded coordinate update, a restore, then the sample translated) and fixed in 1b7ae0200: a scalar EXEC write whose sources are not lane masks (vcc, exec, a saved EXEC, a tagged mask) or the all-zero/all-ones constants now records a lane-exec break, so the derivative op after it is refused. New refused fixture exec_const_mask (fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704664566 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704664566). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:50Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3617 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) + or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp')) + or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')): + return False + return True + + def uniform_bias(self, tok): + """Whether a VGPR holds one value in every lane at the op: its last earlier write is a v_mov_b32 of a constant + that every lane ran (no EXEC write and no branch before it, so no lane skipped it and the other lanes keep an + older value). No backward branch exists in a quad program, so later writes cannot reach the op.""" + r = reg_range(tok) + if not r or r[0] != 'v' or r[1] != r[2]: + return False + last = None + for off, _n, name, asm in self.ins: + if off >= self.pc: + break + ops = parse(asm)[1] + first = reg_range(ops[0]) if ops else None + if first and first[0] == 'v' and first[1] <= r[1] <= first[2]: + const = (re.sub(r'_e(32|64)$', '', name) == 'v_mov_b32' and len(ops) == 2 and not reg_range(ops[1])) + last = off if const else None + if last is None: + return False + narrowed = 0 + for off, _n, name, asm in self.ins: + if off >= last: + break + base = re.sub(r'_e(32|64)$', '', name) + ops = parse(asm)[1] + if name.startswith('s_cbranch') or name == 's_branch': + target = int(ops[0].split('_')[1], 16) if '_' in ops[0] else None + if target is None or target > last: + return False # the write can be skipped by some lanes + elif base in ('s_or_b64', 's_or_b32') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo']): + narrowed = max(narrowed - 1, 0) # the restore that ends a saveexec region + elif base.startswith('s_and_saveexec') or (base.startswith('s_wqm') and ops[:2] not in (['exec', 'exec'], ['exec_lo', 'exec_lo'])): + narrowed += 1 + elif writes_exec(name, ops) and not (base.startswith('s_wqm') and ops[:2] in (['exec', 'exec'], ['exec_lo', 'exec_lo'])): + return False + return narrowed == 0 + + def derivative_exec_ok(self): + """Whether an implicit-derivative op may rely on the EXEC the lanes hold here. + + At the entry mask every lane runs the call. Past an EXEC write (v_cmpx, saveexec, a restore) the one-lane + model still follows the guest's bit of each lane exactly (EXEC is written per lane, set_v is EXEC guarded), + so a quad program (a pixel program with a derivative op and no backward branch) is proven as long as no + lane-exec break happened: an s_wqm of a narrowed EXEC (a no-op here, while the guest turns on the lanes of + every touched quad) or a discard under an unknown EXEC. The callers also need uniform_cf, which a branch + that parts a quad clears; an EXEC branch decided per quad (quad_vote) does not.""" + return self.exec_known or (getattr(self, 'quad_exec', False) and not getattr(self, 'lane_exec_breaks', None)) ~~~~ --- Confirmed (repro: `s_mov_b64 exec, 1`, an EXEC-guarded coordinate update, a restore, then the sample translated) and fixed in 1b7ae0200: a scalar EXEC write whose sources are not lane masks (vcc, exec, a saved EXEC, a tagged mask) or the all-zero/all-ones constants now records a lane-exec break, so the derivative op after it is refused. New refused fixture `exec_const_mask` (fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 07:00:29 +00:00 (Migrated from github.com)

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

Code review location: tools/startup/gfx2hlsl.py; line 3568

@@ -3521,6 +3550,72 @@ def tid_shift(self, count, source):
     def pc_index(self):
         return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None)
 
+    def skipped_block_vector_only(self, branch, target):
+        """Whether the instructions a forward EXEC branch can skip are per-lane vector work only.
+
+        The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block
+        happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while
+        a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane
+        applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends
+        reads nothing later)."""
+        if target <= branch:
+            return False
+        for off, _n, name, _asm in self.ins:
+            if branch < off < target and not (
+                    (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane',
+                                                                    'v_writelane')))
+                    or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp'))
+                    or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')):

Confirmed (repro: save EXEC, narrow it, s_cbranch_execnz over s_endpgm, restore the saved EXEC, then the sample translated) and fixed in 1b7ae0200: an s_endpgm inside a voted block is allowed only when no EXEC write follows the branch; a later restore refuses the block. The kill fixture (no later EXEC write) still translates. New refused fixture kill_then_restore (fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4704664810 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#discussion_r4704664810). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T06:30:53Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 3568 ~~~~diff @@ -3521,6 +3550,72 @@ def tid_shift(self, count, source): def pc_index(self): return next((i for i, ins in enumerate(self.ins) if ins[0] == self.pc), None) + def skipped_block_vector_only(self, branch, target): + """Whether the instructions a forward EXEC branch can skip are per-lane vector work only. + + The guest takes the branch once for the whole wave, so a scalar write, a mask write or a branch inside the block + happens once for the wave when any quad takes the block. A quad that votes to skip it would miss that effect while + a later read in the same wave sees it. Only vector ALU/memory/export instructions and waits, which each lane + applies to its own registers, are allowed between the branch and its target; s_endpgm too (a quad that ends + reads nothing later).""" + if target <= branch: + return False + for off, _n, name, _asm in self.ins: + if branch < off < target and not ( + (name.startswith('v_') and not name.startswith(('v_cmp', 'v_readlane', 'v_readfirstlane', + 'v_writelane'))) + or name.startswith(('image_', 'buffer_', 'tbuffer_', 'global_', 'flat_', 'exp')) + or name in ('s_waitcnt', 's_nop', 's_waitcnt_vscnt', 's_endpgm')): ~~~~ --- Confirmed (repro: save EXEC, narrow it, `s_cbranch_execnz` over `s_endpgm`, restore the saved EXEC, then the sample translated) and fixed in 1b7ae0200: an `s_endpgm` inside a voted block is allowed only when no EXEC write follows the branch; a later restore refuses the block. The `kill` fixture (no later EXEC write) still translates. New refused fixture `kill_then_restore` (fails on the previous head). Win2025 aws-1 dev + release: 63/63 on 083b949d2. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-26 07:35:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T07:35:28Z.

Review: CHANGES_REQUESTED


Reviewed ef786354. Its PR diff is identical to 083b949d2; the later commits only merge main, and it merges cleanly onto current main.

What checks out:

  • The vote, the vector-only gate and the three Codex fixes (carry_in_block, exec_const_mask, kill_then_restore) hold.
  • The fixtures catch these mutations: dropping the vector-only gate, accepting a constant-1 EXEC, and flipping the vote direction each fail the flow checks.
  • The quad model matches LLVM's whole-quad-mode rule: inactive lanes still supply their address inputs for derivatives.

Changes requested:

  1. Shader cache revision. quad_exec is set for any pixel program with a derivative op and no back edge, and every qualifying execz/execnz branch is then voted, including branches after the op.
    • Example: a program that already translates on main (image_sample_b, then v_cmp + s_and_saveexec_b64 + s_cbranch_execz over a VGPR write + s_or_b64 exec) changes its HLSL. It gains the x2w_quad_any helper, and pc = ((exec & 1) == 0) ? 2 : 1; becomes pc = (!x2w_quad_any(exec)) ? 2 : 1;.
    • Ask: main is now at x2w-startup-shader-22 / 22cs (#2768), so please move to 23 / 23cs, or one past whatever lands first. Alternatively, vote only branches that reach a derivative op.
  2. Helper lanes after restoring the pre-s_wqm mask. exec_write_exact treats a saved EXEC copy (('execcopy',)) as lane-exact.
    • Why that's wrong: the guest's entry EXEC excludes helper pixels, which is why the mask is saved before s_wqm_b64 exec, exec. In the translation, every thread starts with exec = 1, helpers included. So after s_and_b64 exec, exec, s[12:13], the guest's helpers are off and keep stale VGPRs, while the translation's helpers stay on.
    • Measured: I took your restore fixture and added v_add_f32_e32 v2, -0.5, v2 before the sample. main refuses it; this PR accepts it. Drawn with your harness on WARP and an RX 9070 XT, it returns 3d600000,40000000,3f800000,00000000 (helpers updated u, LOD 0). With the helper keeping u = 0.625, the guest gives 3e880000,3f800000,00000000,40000000.
    • Same problem in the vote: x2w_quad_any counts helpers that the guest has off.
    • Ask: please record a lane-exec break for a mask saved before s_wqm exec, exec, and add these words as a refused fixture. The fixtures' comment "a cleared lane still offers its address" doesn't hold in the model, where no lane is cleared.
    • Pre-existing part: main already accepts the plain s_mov_b64 exec, s[N] form of this restore. That's worth its own issue; this PR extends the case to s_and / s_or.
  3. Coverage. Two gates have no control: removing the discard lane-exec break, or the ddy_fine half of x2w_quad_any, leaves every check green. Please add a refused fixture with a kill export (exp null ... vm) under v_cmpx before the op, and an inside fixture whose condition depends on y.
  4. Minor. exec_lo / vcc_lo are accepted as exact EXEC sources. In wave64, s_mov_b32 exec_lo, vcc_lo keeps the old bits of lanes 32..63, while the model sets every lane. Please require the 64-bit forms or a wave32 proof.

Runs: Windows 11 build 26300; RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818.

  • ctest --preset dev --no-tests=error -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl': 313 passed out of 316, including all six new flow tests on controls, WARP and hardware.
  • Two hardware failures also fail on main on this adapter (#2746): startup_gfx2hlsl_fma_mix_dispatch_hardware and startup_gfx2hlsl_f16_alu_draw_hardware.
  • startup_image_sample_lod_hardware was a capability skip in the parallel run and passed when rerun alone.
  • Both flow checks' binary modes match llvm-mc 15.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6070123223 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6070123223). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T07:35:28Z. **Review:** CHANGES_REQUESTED --- Reviewed `ef786354`. Its PR diff is identical to `083b949d2`; the later commits only merge `main`, and it merges cleanly onto current `main`. **What checks out:** - The vote, the vector-only gate and the three Codex fixes (`carry_in_block`, `exec_const_mask`, `kill_then_restore`) hold. - The fixtures catch these mutations: dropping the vector-only gate, accepting a constant-1 EXEC, and flipping the vote direction each fail the flow checks. - The quad model matches LLVM's whole-quad-mode rule: inactive lanes still supply their address inputs for derivatives. **Changes requested:** 1. **Shader cache revision.** `quad_exec` is set for any pixel program with a derivative op and no back edge, and every qualifying execz/execnz branch is then voted, including branches *after* the op. - **Example:** a program that already translates on `main` (`image_sample_b`, then `v_cmp` + `s_and_saveexec_b64` + `s_cbranch_execz` over a VGPR write + `s_or_b64 exec`) changes its HLSL. It gains the `x2w_quad_any` helper, and `pc = ((exec & 1) == 0) ? 2 : 1;` becomes `pc = (!x2w_quad_any(exec)) ? 2 : 1;`. - **Ask:** `main` is now at `x2w-startup-shader-22` / `22cs` (#2768), so please move to `23` / `23cs`, or one past whatever lands first. Alternatively, vote only branches that reach a derivative op. 2. **Helper lanes after restoring the pre-`s_wqm` mask.** `exec_write_exact` treats a saved EXEC copy (`('execcopy',)`) as lane-exact. - **Why that's wrong:** the guest's entry EXEC excludes helper pixels, which is why the mask is saved before `s_wqm_b64 exec, exec`. In the translation, every thread starts with `exec = 1`, helpers included. So after `s_and_b64 exec, exec, s[12:13]`, the guest's helpers are off and keep stale VGPRs, while the translation's helpers stay on. - **Measured:** I took your `restore` fixture and added `v_add_f32_e32 v2, -0.5, v2` before the sample. `main` refuses it; this PR accepts it. Drawn with your harness on WARP and an RX 9070 XT, it returns `3d600000,40000000,3f800000,00000000` (helpers updated u, LOD 0). With the helper keeping u = 0.625, the guest gives `3e880000,3f800000,00000000,40000000`. - **Same problem in the vote:** `x2w_quad_any` counts helpers that the guest has off. - **Ask:** please record a lane-exec break for a mask saved before `s_wqm exec, exec`, and add these words as a refused fixture. The fixtures' comment "a cleared lane still offers its address" doesn't hold in the model, where no lane is cleared. - **Pre-existing part:** `main` already accepts the plain `s_mov_b64 exec, s[N]` form of this restore. That's worth its own issue; this PR extends the case to `s_and` / `s_or`. 3. **Coverage.** Two gates have no control: removing the discard lane-exec break, or the `ddy_fine` half of `x2w_quad_any`, leaves every check green. Please add a refused fixture with a kill export (`exp null ... vm`) under `v_cmpx` before the op, and an `inside` fixture whose condition depends on y. 4. **Minor.** `exec_lo` / `vcc_lo` are accepted as exact EXEC sources. In wave64, `s_mov_b32 exec_lo, vcc_lo` keeps the old bits of lanes 32..63, while the model sets every lane. Please require the 64-bit forms or a wave32 proof. **Runs:** Windows 11 build 26300; RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818. - `ctest --preset dev --no-tests=error -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl'`: 313 passed out of 316, including all six new flow tests on controls, WARP and hardware. - Two hardware failures also fail on `main` on this adapter (#2746): `startup_gfx2hlsl_fma_mix_dispatch_hardware` and `startup_gfx2hlsl_f16_alu_draw_hardware`. - `startup_image_sample_lod_hardware` was a capability skip in the parallel run and passed when rerun alone. - Both flow checks' `binary` modes match llvm-mc 15. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-26 08:01:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T07:15:53Z.


Independent pass at ef786354 on Windows 11 build 26200. I ran both startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py with controls and draw <offscreen_check> <warp|hardware> . All 60 GPU comparisons matched the CPU references on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. No skips. The DXC hardware inside case passed for both instructions, and the fixtures still detected the wrong lane writes, dropped branch writes and ignored bias controls. This covers the source-built draw and leaves the upstream review with the reviewers already in the thread.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185270277 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7185270277). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T07:15:53Z. --- Independent pass at ef786354 on Windows 11 build 26200. I ran both startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py with controls and draw <dxc> <offscreen_check> <warp|hardware> <fxc>. All 60 GPU comparisons matched the CPU references on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. No skips. The DXC hardware inside case passed for both instructions, and the fixtures still detected the wrong lane writes, dropped branch writes and ignored bias controls. This covers the source-built draw and leaves the upstream review with the reviewers already in the thread.
tedin7 commented 2026-11-26 08:01:55 +00:00 (Migrated from github.com)

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


Thanks @R0Y00 for the independent pass at ef786354. 60/60 matches on WARP and the RTX 4060 Laptop, with the mutation fixtures still failing as intended, is the result we wanted. I added it to the Verification block of the PR body, credited to you. No code change, head stays ef786354.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7185505883 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7185505883). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T07:29:01Z. --- Thanks @R0Y00 for the independent pass at ef786354. 60/60 matches on WARP and the RTX 4060 Laptop, with the mutation fixtures still failing as intended, is the result we wanted. I added it to the Verification block of the PR body, credited to you. No code change, head stays ef786354. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-26 09:04:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T08:09:48Z.


@tedin7, thanks. 706fc084 covers all four points: the pre-s_wqm restore break, 32-bit EXEC sources, and the discard_break and inside_y controls. One collision, though: #2702 merged at 07:59 and took x2w-startup-shader-23 / 23cs on main. So this needs 24 / 24cs after merging main. I'm verifying the rest of the head locally now. Once the bump is in and CI is green, I'll merge.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186261499 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7186261499). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T08:09:48Z. --- @tedin7, thanks. `706fc084` covers all four points: the pre-`s_wqm` restore break, 32-bit EXEC sources, and the `discard_break` and `inside_y` controls. One collision, though: #2702 merged at 07:59 and took `x2w-startup-shader-23` / `23cs` on `main`. So this needs `24` / `24cs` after merging `main`. I'm verifying the rest of the head locally now. Once the bump is in and CI is green, I'll merge. AI-assisted.
MasterDomino commented 2026-11-26 09:04:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T08:14:55Z.


@tedin7, local results for e4b9d1b7 on Windows 11 build 26300, WARP 10.0.26100.9818, and an RX 9070 XT (driver 32.0.32029.2010):

Two blockers:

  1. Cache revision: main is at 23 (#2702), so this needs 24 / 24cs.
  2. inside_y doesn't catch its own mutant here. ctest --preset dev --no-tests=error -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl_image|startup_inline_sampler|startup_shader_cache': 36/39. These fail:
    • startup_image_sample_b_flow_warp, ..._hardware and startup_image_get_lod_flow_warp, each with inside_y: mutant "vote without the vertical derivative" matched the reference. That's WARP with DXC, hardware with FXC, and WARP get_lod (1.0, 1.0, 0.0, 0.0).
    • At 706fc084 the positive inside_y case itself failed on both backends (GPU 3d600000,... against reference 3e880000,...; get_lod (1.0, 1.0) and (1.0, 1.49609375) against (2.0, 2.0)).
    • So the y-split draw doesn't yet tell the vote apart from the row-only vote on these adapters.
    • CI stays green because its PR preset doesn't run the flow draw tests.

Mutants against 706fc084's translator (host checks):

  • dropping helper_off_copy in exec_write_exact: caught (restore accepted);
  • re-accepting exec_lo / vcc_lo: caught (exec_lo_mask accepted);
  • dropping the lane-exec break for a s_mov_b64 exec, s[N] restore of a pre-s_wqm copy: survives. No fixture uses that main-accepted form. A restore_mov refusal, s_mov_b64 s[12:13], exec … s_mov_b64 exec, s[12:13] before the op, would pin it. That one is non-blocking, but welcome.

The binary modes of both flow checks match llvm-mc 15. Once inside_y passes on WARP and hardware and the bump is in, I'll merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7186365411 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7186365411). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T08:14:55Z. --- @tedin7, local results for `e4b9d1b7` on Windows 11 build 26300, WARP 10.0.26100.9818, and an RX 9070 XT (driver 32.0.32029.2010): **Two blockers:** 1. **Cache revision:** `main` is at `23` (#2702), so this needs `24` / `24cs`. 2. **`inside_y` doesn't catch its own mutant here.** `ctest --preset dev --no-tests=error -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl_image|startup_inline_sampler|startup_shader_cache'`: 36/39. These fail: - `startup_image_sample_b_flow_warp`, `..._hardware` and `startup_image_get_lod_flow_warp`, each with `inside_y: mutant "vote without the vertical derivative" matched the reference`. That's WARP with DXC, hardware with FXC, and WARP get_lod `(1.0, 1.0, 0.0, 0.0)`. - At `706fc084` the positive `inside_y` case itself failed on both backends (GPU `3d600000,...` against reference `3e880000,...`; get_lod `(1.0, 1.0)` and `(1.0, 1.49609375)` against `(2.0, 2.0)`). - So the y-split draw doesn't yet tell the vote apart from the row-only vote on these adapters. - CI stays green because its PR preset doesn't run the flow draw tests. **Mutants against `706fc084`'s translator (host checks):** - dropping `helper_off_copy` in `exec_write_exact`: caught (`restore accepted`); - re-accepting `exec_lo` / `vcc_lo`: caught (`exec_lo_mask accepted`); - dropping the lane-exec break for a `s_mov_b64 exec, s[N]` restore of a pre-`s_wqm` copy: survives. No fixture uses that `main`-accepted form. A `restore_mov` refusal, `s_mov_b64 s[12:13], exec` … `s_mov_b64 exec, s[12:13]` before the op, would pin it. That one is non-blocking, but welcome. The `binary` modes of both flow checks match llvm-mc 15. Once `inside_y` passes on WARP and hardware and the bump is in, I'll merge. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 09:04:55 +00:00 (Migrated from github.com)

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


@MasterDomino I'm on it. I'm merging main, moving the cache revision to the next free number after the current main, and making the inside_y mutant fail on WARP and on the hardware path you named. I'll post the new head and the commands when it is pushed.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7187254281 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7187254281). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T08:58:37Z. --- @MasterDomino I'm on it. I'm merging `main`, moving the cache revision to the next free number after the current `main`, and making the `inside_y` mutant fail on WARP and on the hardware path you named. I'll post the new head and the commands when it is pushed. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-26 09:08:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T09:08:34Z.

Review: APPROVED


Approving 74e00742. Everything from my change request at ef786354 and the two blockers on e4b9d1b7 is addressed.

Cache revision: x2w-startup-shader-26 / 26cs, one past current main (25). The head merges cleanly onto main, and CI is green at the head.

Runs:

  • Environment: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818; dev preset.
  • ctest --preset dev --no-tests=error -j6 -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl_image|startup_inline_sampler|startup_shader_cache': 39/39 passed, 0 skipped. That includes startup_image_sample_b_flow_* and startup_image_get_lod_flow_* on controls, WARP and hardware. inside_y and its vertical-derivative mutant now separate on both adapters.
  • startup_image_sample_b_flow_check.py binary and startup_image_get_lod_flow_check.py binary: every fixture reassembles to its words with llvm-mc 15.

Mutants (translator at the head, both flow host checks, each restored):

Mutant Result
Dropping helper_off_copy in exec_write_exact Caught (restore accepted)
Dropping the lane-exec break for a s_mov_b64 exec, s[N] restore of a pre-s_wqm copy Caught by the new restore_mov (restore_mov accepted)
Dropping the exec_lo destination break at the call site Caught (exec_lo_mask accepted)
Re-accepting exec_lo / vcc_lo as exact sources, alone Survives; equivalent, since every exec_lo write is already a lane-exec break at the call site

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6071230446 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#pullrequestreview-6071230446). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T09:08:34Z. **Review:** APPROVED --- Approving `74e00742`. Everything from my change request at `ef786354` and the two blockers on `e4b9d1b7` is addressed. **Cache revision:** `x2w-startup-shader-26` / `26cs`, one past current `main` (`25`). The head merges cleanly onto `main`, and CI is green at the head. **Runs:** - **Environment:** Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818; dev preset. - `ctest --preset dev --no-tests=error -j6 -R 'startup_image_sample|startup_image_get_lod|startup_gfx2hlsl_image|startup_inline_sampler|startup_shader_cache'`: 39/39 passed, 0 skipped. That includes `startup_image_sample_b_flow_*` and `startup_image_get_lod_flow_*` on controls, WARP and hardware. `inside_y` and its vertical-derivative mutant now separate on both adapters. - `startup_image_sample_b_flow_check.py binary` and `startup_image_get_lod_flow_check.py binary`: every fixture reassembles to its words with llvm-mc 15. **Mutants** (translator at the head, both flow host checks, each restored): | Mutant | Result | |---|---| | Dropping `helper_off_copy` in `exec_write_exact` | Caught (`restore accepted`) | | Dropping the lane-exec break for a `s_mov_b64 exec, s[N]` restore of a pre-`s_wqm` copy | Caught by the new `restore_mov` (`restore_mov accepted`) | | Dropping the `exec_lo` destination break at the call site | Caught (`exec_lo_mask accepted`) | | Re-accepting `exec_lo` / `vcc_lo` as exact sources, alone | Survives; equivalent, since every `exec_lo` write is already a lane-exec break at the call site | AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-26 10:03:50 +00:00
tedin7 commented 2026-11-26 10:04:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:35:24Z.


@MasterDomino thanks for merging. Results for the merged head 74e00742d, for the record:

  • Cache revision: main was at 25, so this head uses x2w-startup-shader-26 / 26cs (merge commit of main, no force-push).
  • inside_y: it stays as a translation fixture (u equal in every lane, v = 0.25 + 0.5 * y). The mutant check moved to the vote itself: VOTE_CASES draws QUAD_ANY_HLSL alone with one lane of the quad set at each position, and dropping ddx_fine or ddy_fine must change the covered pixel's answer. The drawn helper is asserted to be the text the translation emits.
  • restore_mov (s_mov_b64 exec, s[N] of a mask saved before s_wqm) is now refused; exec_lo_const (a 32-bit constant EXEC write) is refused too.
  • Win2025 (Windows Server 2025, WARP), dev and release: x2w_pipe.py win2025 2736 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py,tests/startup_image_sample_b_check.py,tests/startup_shader_cache_key_check.py,tests/startup_compute_request_offline_check.py --targets offscreen_check,startup_indirect_draw_indexed,startup_resource_retire_title --regex '^(startup_image_(sample_b|get_lod)(_flow)?_(controls|warp)|...)': 23/23 passed in both presets, including startup_image_sample_b_flow_warp and startup_image_get_lod_flow_warp with the vote mutants.
  • Not run: the real-GPU line (RTX 3090 through vkd3d-proton) for this head, the run pool was not available.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7188194037 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2736#issuecomment-7188194037). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:35:24Z. --- @MasterDomino thanks for merging. Results for the merged head `74e00742d`, for the record: - Cache revision: `main` was at `25`, so this head uses `x2w-startup-shader-26` / `26cs` (merge commit of `main`, no force-push). - `inside_y`: it stays as a translation fixture (u equal in every lane, v = 0.25 + 0.5 * y). The mutant check moved to the vote itself: `VOTE_CASES` draws `QUAD_ANY_HLSL` alone with one lane of the quad set at each position, and dropping `ddx_fine` or `ddy_fine` must change the covered pixel's answer. The drawn helper is asserted to be the text the translation emits. - `restore_mov` (`s_mov_b64 exec, s[N]` of a mask saved before `s_wqm`) is now refused; `exec_lo_const` (a 32-bit constant EXEC write) is refused too. - Win2025 (Windows Server 2025, WARP), dev and release: `x2w_pipe.py win2025 2736 --no-skip-build --py-checks tests/startup_image_sample_b_flow_check.py,tests/startup_image_get_lod_flow_check.py,tests/startup_image_sample_b_check.py,tests/startup_shader_cache_key_check.py,tests/startup_compute_request_offline_check.py --targets offscreen_check,startup_indirect_draw_indexed,startup_resource_retire_title --regex '^(startup_image_(sample_b|get_lod)(_flow)?_(controls|warp)|...)'`: 23/23 passed in both presets, including `startup_image_sample_b_flow_warp` and `startup_image_get_lod_flow_warp` with the vote mutants. - Not run: the real-GPU line (RTX 3090 through vkd3d-proton) for this head, the run pool was not available. AI-assisted; commands listed were executed locally.
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!2728
No description provided.