Skip to content

gfx2hlsl: accept fi:1 on the pixel-stage DPP16 quad forms under the whole-quad proof - #2483

Merged
R0Y00 merged 3 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-pixel-dpp-quad
Nov 25, 2026
Merged

R0Y00 merged 3 commits into
R0Y00:mainfrom
NiiRoZz:startup/gfx2hlsl-pixel-dpp-quad

Conversation

@NiiRoZz

@NiiRoZz NiiRoZz commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Refs #2125, #2023 (item H), #1996 (item B).

Change

The three pixel-stage DPP16 lowerings in tools/startup/gfx2hlsl.py (quad swaps, quad broadcasts, pair broadcasts) refused every word with FI set. dpp() now drops fi:1 before it dispatches to them.

  • FI (bit 18 of the DPP dword; LLVM AMDGPU fi, Mesa ACO fetch_inactive) only chooses what a disabled source lane returns: its register instead of the bound_ctrl result.
  • All three lowerings are taken only in a straight-line pixel stage whose EXEC is still the entry mask after s_wqm exec, exec. Every lane of the quad is then active, so no source lane is disabled and FI decides nothing. This is the argument the code already uses for bound_ctrl.
  • The translation is the one without fi:1. No new HLSL is emitted.
  • Still refused: fi:1 without the proof (no s_wqm, EXEC changed, a stage with branches, a vertex stage), fi:0 as a spelling, row and wave controls, mirrors, DPP8, partial masks.

docs/experiments.md: the two sentences that listed fi among the refused forms are updated.

Verification

Pure Python, Windows 11, Python 3.13:

python -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py        # exit 0
python -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py   # exit 0
python -B tests/startup_gfx2hlsl_dpp_pair_check.py             # exit 0
python -B tests/startup_translator_check.py                    # exit 0

Every other no-argument tests/startup_gfx2hlsl_*_check.py (62 files in all), tests/docs_links_check.py and tests/bidi_controls_check.py exit 0. git diff --check is clean.

New checks:

  • The swap fixtures (or, mov, min) are rebuilt with FI set in each DPP dword. They must decode to fi:1, translate to exactly the text of the plain fixture, and be refused without s_wqm exec, exec.
  • Broadcast and pair: a fi:1 line emits the same lines as the line without it, and is refused without the whole-quad proof, after an EXEC change, with branches and in a vertex stage.
  • The broadcast check also pins the operand order of the derivative idiom: v_subrev_f32_dpp vD, vS, vS quad_perm:[0,0,0,0] emits the lane's own word minus quad lane 0 (the DPP source is SRC0 and v_subrev is SRC1 - SRC0). With the two operands exchanged in the operation table the check fails.
  • Three existing controls asserted that fi:1 is refused. They are replaced by "refused without the proof"; this is the intended behaviour change.
  • Negative control: with the dpp() line removed, each of the three checks fails (..._dpp with fi:1).

Not run: the binary (LLVM 15) and draw (DXC, WARP or hardware) modes of the three checks. The emitted HLSL is unchanged, so the existing draws cover the pixels; no GPU result is claimed for this change.

What this does not unblock

Aggregate counts from a private set of 153 pixel programs (decode only; no shader bytes can be shared). One of the 153 translates with this change. In the other 152 the DPP words sit in programs with branches, usually after EXEC writes, where the whole-quad proof does not hold:

Rows overlap: a program can contain several forms.

Form Programs What it is
v_min_u32 / v_max_u32 / v_or_b32 with quad_perm:[1,0,3,2], [2,3,0,1], row_half_mirror, row_mirror, then v_permlanex16_b32 and v_readlane_b32 ..., 31 113 whole-wave reduction under s_or_saveexec_b32 ..., -1 with an identity fill (#2125 item D), not a per-quad one
v_subrev_f32 vD, vS, vS with [0,0,0,0] (64 programs), [0,0,2,2] (35), [0,1,0,1] (19), followed by a broadcast v_mov_b32 / v_mul_f32 / v_add_f32 64 coarse and fine derivative idioms; the existing QuadReadLaneAt path is exact for them in straight-line code
v_add_f32 / v_mov_b32 / v_add_nc_u32 with the three swaps 28 sums over the 2x2 quad
v_cndmask_b32 with a quad broadcast 28 no DPP table entry
v_cmpx_gt_f32 DPP 28 the decoder prints <unsupported DPP16> for VOPC DPP

A quad read in a program with branches needs a proof that all four lanes reach the instruction together, and an emission that keeps them in step; neither exists in the per-lane pc loop. That is the follow-up, not part of this change.

AI-assisted (Claude Code); the commands listed were executed locally.

🤖 Generated with Claude Code

NiiRoZz and others added 2 commits November 25, 2026 19:01
…ole-quad proof

The quad swap, quad broadcast and pair broadcast lowerings of
tools/startup/gfx2hlsl.py refused every DPP16 word with FI set. FI (bit 18
of the DPP dword; LLVM AMDGPU `fi`, Mesa ACO `fetch_inactive`) only chooses
what a disabled source lane returns: its register instead of the
bound_ctrl result. All three lowerings are taken only in a straight-line
pixel stage whose EXEC is the entry mask after `s_wqm exec, exec`, so every
lane of the quad is active, no source lane is disabled, and FI decides
nothing, as for bound_ctrl. dpp() now drops `fi:1` before dispatching; the
translation is the one without it. Without the proof (no s_wqm, EXEC
changed, branches, vertex stage) the forms stay refused, as do `fi:0` as a
spelling, row and wave controls, mirrors, DPP8 and partial masks.

Tests: the three DPP checks build the fixtures with FI set, compare the
translated text with the plain fixture, and keep fi:1 refused without the
proof. Without the dpp() line each of the three checks fails with
`..._dpp with fi:1`.

Refs R0Y00#2125, R0Y00#2023 (item H), R0Y00#1996 (item B).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…adcast

The DPP source is SRC0 and v_subrev computes SRC1 - SRC0, so
`v_subrev_f32_dpp vD, vS, vS quad_perm:[0,0,0,0]` is the lane's own word
minus lane 0 (R0Y00#1996 item B). The broadcast check now asserts the two
emitted lines; with the operands exchanged in the table it fails.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ChazY11

ChazY11 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Three mutations, all caught by all three fixtures — and the acceptance is narrower than "fi:1 is allowed"

Baseline on this branch: the three DPP fixtures pass (dpp_pair PASS, dpp_quad_broadcast … , dpp_quad_swap PASS), and the whole startup_gfx2hlsl_* family is green.

mutation of the fi:1 drop result
mods = [m for m in mods if m != 'fi:1'] → mods = list(mods) (keep it, so it refuses) caught by all three
blanket filter (m.startswith('fi')) caught by all three
drop fi:0 instead of fi:1 caught by all three

The second and third rows are the ones worth having: a blanket fi* filter and an off-by-one on the literal both look like the same line, and all three fixtures separate them.

What the change is actually conditioned on, measured

I probed the shapes around it rather than reading only the diff:

v_mov_b32_dpp v1, v2 quad_perm:[1,0,3,2]                       accepted
v_mov_b32_dpp v1, v2 quad_perm:[1,0,3,2] fi:1                  accepted
v_mov_b32_dpp v1, v2 quad_perm:[1,0,3,2] fi:0                  refused: v_mov_b32_dpp with fi:0
… quad_perm:[1,0,3,2] fi:1 bank_mask:0x3                       refused: … with bank_mask:0x3
vertex stage with fi:1                                         refused: requires a straight-line pixel shader with …

So fi:1 is accepted only where the quad-active proof already holds and no other modifier rides along — fi:0, a bank_mask, or a vertex stage each still refuse, with the reason naming the offending token rather than fi:1. That is the right shape for "this bit decides nothing here": the acceptance is licensed by an existing proof, not by relaxing the modifier check.

One wording nit, worth one line

The fi:1 comment says it "only decides what a disabled source lane returns", which is the reason it can be dropped. What is not written is why dropping it is safer than modelling it: a fi:1 that reached a lowering without the active-quad proof would be a wrong result, not a refusal. The code does handle that (the proof gate is upstream), but a reader tracing mods will not see the connection from this comment alone; naming the gate (dpp() reaches here only with the whole-quad proof) would close it.

Also: docs/experiments.md now says "fi:1 without that proof … stay refused", which is accurate and matches the probe above — worth keeping in sync if the gate moves.

AI-assisted; the three mutations and the five probes were run locally on Windows 11 build 26300.9974.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head b5198c6 (comment only, no merge or approval).

What I checked:

  • Code: Stage.dpp() in tools/startup/gfx2hlsl.py now drops fi:1 before it dispatches to the quad swap, quad broadcast and pair lowerings. Each of those three paths still requires a straight-line pixel stage, entry EXEC and wqm_exec, and each is refused otherwise. So fi:1 only changes an outcome in the case where no source lane is disabled. That is the same argument the code already makes for bound_ctrl. No new HLSL is emitted.
  • Other controls stay refused: row shifts, mirrors, DPP8, partial masks, quad_perm forms outside the tables. They still fall into the "dpp with " refusal.
  • Tests: the three DPP checks are extended with fi:1 fixtures that must translate to the same text as the plain fixture. They must also be refused without s_wqm, after an EXEC change, with branches, and in a vertex stage. The three old "fi:1 is refused" controls were replaced, which matches the intended change.
  • Docs: docs/experiments.md and the code comments are updated to match.
  • Duplicates: I searched DPP16 fi:1. Earlier DPP PRs (#2140, #2141, #1971) are merged and refused fi, which this follows up on. #1884 is open but covers compute row_shr, a different slice.
  • Scope: five files, no .github, launcher or hook changes. The body does not claim to advance startup and says it unblocks one program of its sample, so no game result is needed or claimed.

Commands run locally (Linux, in a worktree of this head):

  • python3 -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py -> exit 0
  • python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py -> exit 0
  • python3 -B tests/startup_gfx2hlsl_dpp_pair_check.py -> exit 0
  • python3 -B tests/startup_translator_check.py -> exit 0
  • python3 tests/docs_links_check.py -> ok (19 files, 466 links)
  • python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: replaced the fi:1 filter in dpp() with a plain copy. All three DPP checks exit 1.
  • Mutation 2: disabled the wqm_exec requirement in the swap path. The swap check exits 1, so the whole-quad control is real.
  • Both mutations restored with git checkout -- ..

Windows and GPU:

  • I ran no Windows or WARP run. The author's Windows 11 results are for Python only, and the body states the binary and draw modes were not run. Because the emitted HLSL is unchanged, I think that is reasonable, but it is the author's claim and I did not check it.
  • The PR's own CI run on this head shows the Linux Python checks, the fixture assembly job and the Windows build job all passing.

No blocking findings.

AI-assisted; commands listed were executed locally.

legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head 1fe1dd3 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 1fe1dd341df0787a2a3b87fa3fd9a59fee40f6ae:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim -- -j 2): 4.33s (configure 4.35s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim -- -j 2): 5.70s (configure 5.59s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (1.0s), tests/startup_buffer_address_check.py ok (0.6s), tests/startup_compute_request_offline_check.py ok (0.9s), tests/startup_compute_translate_check.py ok (0.5s), tests/startup_flat_param_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.2s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.3s), tests/startup_gfx2hlsl_bit_alu_check.py ok (1.1s), tests/startup_gfx2hlsl_capture_check.py ok (1.3s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.3s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.6s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.2s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.2s), tests/startup_gfx2hlsl_f32_lg_check.py ok (2.3s), tests/startup_gfx2hlsl_f32_nan_check.py ok (7.5s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.2s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.3s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.4s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.3s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.4s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.6s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.6s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.5s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.8s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.3s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.3s), tests/startup_gfx2hlsl_refusals_check.py ok (1.2s), tests/startup_gfx2hlsl_root_check.py ok (1.9s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.3s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.3s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.2s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.5s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.1s), tests/startup_gfx2hlsl_shift64_check.py ok (0.2s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (6.9s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (1.1s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.2s), tests/startup_gfx2hlsl_swap_check.py ok (0.8s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (8.0s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.1s), tests/startup_gfx2hlsl_watch_check.py ok (2.9s), tests/startup_image_2d_array_check.py ok (0.3s), tests/startup_image_3d_check.py ok (0.2s), tests/startup_image_gather_lz_check.py ok (1.1s), tests/startup_image_load_d16_check.py ok (2.3s), tests/startup_image_sample_a16_check.py ok (0.5s), tests/startup_image_sample_b_check.py ok (0.3s), tests/startup_image_sample_c_check.py ok (0.4s), tests/startup_image_sample_l_check.py ok (0.4s), tests/startup_image_sample_lod_check.py ok (1.3s), tests/startup_inline_sampler_check.py ok (0.3s), tests/startup_run_ps1_check.py ok (16.0s), tests/startup_run_sh_check.py FAIL (0.1s), tests/startup_sampler_heap_check.py ok (0.1s), tests/startup_smem_address_check.py ok (0.1s), tests/startup_stream_fetch_check.py ok (0.3s), tests/startup_stream_interface_check.py ok (0.3s), tests/startup_translator_check.py ok (0.6s)
  • sccache: 0/100 hits; wall 103.3s

AI-assisted; commands listed were executed locally.

@R0Y00
R0Y00 merged commit a1d1db8 into R0Y00:main Nov 25, 2026
5 checks passed
legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
Main now carries R0Y00#2459, R0Y00#2461, R0Y00#2466, R0Y00#2483, R0Y00#2428 and others in their final form; the
conflicts take main's versions. Kept from this branch: R0Y00#2460's generalized unjoined(),
R0Y00#2432's scalar(mods), the s_setreg MODE check, the cube image kind, the
v_cvt_f64_f32 inline check. Upstream chose R0Y00#2428 for v_{add,sub,subrev}_co_ci_u32,
so the local co_ci handlers are renamed unbound_* and their two checks unregistered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants