Repository navigation
startup: keep sample_b and get_lod past a divergent EXEC with a per-quad vote - #2736
Conversation
|
Windows readback blocker on
I isolated both compiled fixtures on the RTX 4070. Unmodified FXC 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 |
|
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 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, s28Encoded replacement for 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 Verified after merge: |
|
Thank you, both points were real. Fixed in 5c907dd.
Also added: a Verification (Linux): Win2025 WARP and hardware re-run of the new head: pending Stage-2. AI-assisted; commands listed were executed locally. |
|
Follow-up in c45dc9e: 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 AI-assisted; commands listed were executed locally. |
|
@MasterDomino Ready for review on head 083b949 (after the three review threads). Independent Stage-2 gate. 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 ( Verification:
AI-assisted; commands listed were executed locally. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
- a voted block may hold only instructions whose destinations are VGPRs (no carry-out, compare, readlane); - s_endpgm in a voted block only when no EXEC write follows the branch; - a scalar EXEC write from a non-mask source (s_mov exec, 1) records a lane-exec break. Three refused fixtures with recorded words; each fails on the previous head.
|
Independent pass at ef78635 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. |
|
Thanks @R0Y00 for the independent pass at ef78635. 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 ef78635. AI-assisted; commands listed were executed locally. |
MasterDomino
left a comment
There was a problem hiding this comment.
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:
- Shader cache revision.
quad_execis 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, thenv_cmp+s_and_saveexec_b64+s_cbranch_execzover a VGPR write +s_or_b64 exec) changes its HLSL. It gains thex2w_quad_anyhelper, andpc = ((exec & 1) == 0) ? 2 : 1;becomespc = (!x2w_quad_any(exec)) ? 2 : 1;. - Ask:
mainis now atx2w-startup-shader-22/22cs(#2768), so please move to23/23cs, or one past whatever lands first. Alternatively, vote only branches that reach a derivative op.
- Example: a program that already translates on
- Helper lanes after restoring the pre-
s_wqmmask.exec_write_exacttreats 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 withexec = 1, helpers included. So afters_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
restorefixture and addedv_add_f32_e32 v2, -0.5, v2before the sample.mainrefuses it; this PR accepts it. Drawn with your harness on WARP and an RX 9070 XT, it returns3d600000,40000000,3f800000,00000000(helpers updated u, LOD 0). With the helper keeping u = 0.625, the guest gives3e880000,3f800000,00000000,40000000. - Same problem in the vote:
x2w_quad_anycounts 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:
mainalready accepts the plains_mov_b64 exec, s[N]form of this restore. That's worth its own issue; this PR extends the case tos_and/s_or.
- Why that's wrong: the guest's entry EXEC excludes helper pixels, which is why the mask is saved before
- Coverage. Two gates have no control: removing the discard lane-exec break, or the
ddy_finehalf ofx2w_quad_any, leaves every check green. Please add a refused fixture with a kill export (exp null ... vm) underv_cmpxbefore the op, and aninsidefixture whose condition depends on y. - Minor.
exec_lo/vcc_loare accepted as exact EXEC sources. In wave64,s_mov_b32 exec_lo, vcc_lokeeps 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
mainon this adapter (#2746):startup_gfx2hlsl_fma_mix_dispatch_hardwareandstartup_gfx2hlsl_f16_alu_draw_hardware. startup_image_sample_lod_hardwarewas a capability skip in the parallel run and passed when rerun alone.- Both flow checks'
binarymodes match llvm-mc 15.
AI-assisted; commands listed were executed locally.
…s as lane-exact; shader cache revision 23 A mask saved before s_wqm exec, exec has the guest's helper lanes off, while every thread here starts with exec = 1: writing it back is now a lane-exec break. exec_lo / vcc_lo are no longer exact EXEC sources (wave64 keeps lanes 32..63). New refused fixtures restore, restore_helper, discard_break, exec_lo_mask; new inside_y fixture with a mutant that drops the vertical derivative of the vote. The voted branches change the HLSL of programs accepted on main, so the shader cache revision moves to x2w-startup-shader-23 / 23cs.
…roof to survive; refuse the 32-bit one
|
@tedin7, thanks. AI-assisted. |
…ly the vertical derivative of the vote carries the LOD
|
@tedin7, local results for Two blockers:
Mutants against
The AI-assisted; commands listed were executed locally. |
|
@MasterDomino I'm on it. I'm merging AI-assisted; commands listed were executed locally. |
…position; refuse a mov restore of a pre-s_wqm mask
MasterDomino
left a comment
There was a problem hiding this comment.
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 includesstartup_image_sample_b_flow_*andstartup_image_get_lod_flow_*on controls, WARP and hardware.inside_yand its vertical-derivative mutant now separate on both adapters.startup_image_sample_b_flow_check.py binaryandstartup_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.
|
@MasterDomino thanks for merging. Results for the merged head
AI-assisted; commands listed were executed locally. |
Part of #1723
What this unblocks:
image_sample_bandimage_get_lodin 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_bandlod.Builds on #2659 (entry EXEC +
uniform_cf).What changed
s_cbranch_execz/execnzare decided per quad (x2w_quad_any(exec), the OR of the four lanes' EXEC bits viaddx_fine/ddy_fine), so the wave-wide branch the guest takes is the one the quad takes, anduniform_cfstays set.s_wqmof a narrowed EXEC, a discard under an unknown EXEC. Each records a lane-EXEC break.s_wqm_b64 exec, execon a narrowed EXEC is not in this slice.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
startup_image_sample_b_flow_check.pyandstartup_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.startup_image_sample_bdraw tests.Verification (Linux only):
Win2025 (dev + release, head 083b949):
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, includingstartup_image_sample_b_flow_{warp,hardware}andstartup_image_get_lod_flow_{warp,hardware}with their mutations.Real GPU: RTX 3090 through vkd3d-proton (Linux) on head 5c907dd: 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 ef78635, Windows 11 build 26200):
startup_image_sample_b_flow_check.pyandstartup_image_get_lod_flow_check.pywith controls anddraw <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_checkthenctest --preset dev --no-tests=error -R '^startup_image_(sample_b|get_lod)_flow' -V.AI-assisted; commands listed were executed locally.