shader: lower DPP16 quad pair broadcasts in gfx2hlsl (Part of #2125) #2132
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2140"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:29:29Z.
Part of #2125
What this unblocks: item C of #2125, the four DPP16 pair broadcasts (
quad_perm:[1,1,3,3],[0,0,2,2],[2,3,2,3],[0,1,0,1], 2,419 instructions) in pixel programs. Until now every_dppspelling stopped translation.The translator models one lane. In a pixel stage the other lane of a pair is rebuilt from
ddx_fine(horizontal pair) orddy_fine(vertical pair) of each 16-bit half of the register. Those halves are integers below 2^17, so the float32 difference is exact. The lane that takes the other word is picked from the parity ofSV_Position. The permuted word goes to a scratch register, sov_add_nc_u32_dpp v3, v1, v1still reads the pixel's own word as its second source. The quad must run together with its helper lanes, so the form is accepted only in straight-line pixel code with the full entry mask. Everything else is refused by name: other permutations (items A and B),row_*,wave_*, partial masks,fi, vertex stages, branches, a changed EXEC, scalar sources.Not covered: items A and B (separate PRs), D and E (overlap #2032). Related open PR #2038 handles the identity
quad_perm:[0,1,2,3]; the two touchlower()in different places and should merge without a semantic conflict.Verification:
python3 -B tests/startup_gfx2hlsl_dpp_pair_check.py-> PASS (CPU quad model of the emitted text for all four patterns, three mutations that must differ, 15 refusals)python3 -B tests/startup_gfx2hlsl_dpp_pair_check.py binary /usr/lib/llvm-19/bin/llvm-mc-> PASS (fixture words match the assembler for gfx1013)python3 -B tests/startup_gfx2hlsl_{swap,op_refusals,refusals,operand_count,cndmask_neg,sdwa,vopc_sdwa}_check.py-> exit 0startup_gfx2hlsl_dpp_pair_warpandstartup_gfx2hlsl_dpp_pair_hardware(16 x 16 pixels per pattern against a CPU reference; wrong sign, wrong lanes, wrong axis and permuted second source must fail). They need the Windows build and are the gate before Ready.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:43:13Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
f7257bc85dℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:35:33Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
f7257bcℹ️ About Codex in GitHub
Your 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.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:43:13Z.
Code review location:
tools/startup/gfx2hlsl.py; line 705At a primitive edge, the entry EXEC mask can leave the selected neighbour inactive even while
exec_knownis true: that flag is initialized at entry and also stays true when a saved entry mask is restored after WQM. Native DPP16 withFI=0must respect inactive-source/bound_ctrlbehavior in that case, whereas this lowering reconstructs a D3D helper-lane value and unconditionally writes it. Consequently, accepted shaders without an established WQM mask, or after an exact-mask restore, can silently produce different edge pixels. Track a proven whole-quad execution state, or refuse these cases rather than treating an unchanged entry mask as proof that every source lane is active.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:43:14Z.
Code review location:
tools/startup/gfx2hlsl.py; line 713When DPP is the only reader of a pixel-entry VGPR, constructing
worddirectly bypassesself.u()and never records that source inused_v. For example, translatingv_mov_b32_dpp v2, v0with the accepted pair controls, packed-position input inv0, and an export referencing onlyv2produces declarations forv2andv256but neither declares nor initializesv0. The newly accepted shader therefore fails during HLSL compilation. Resolve the original source throughself.u()or explicitly register its use before replacing it with the scratch operand; the current fixtures hide this because their preceding multiply already records the source register.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:20:11Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:20:13Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:22:26Z.
Review: CHANGES_REQUESTED
Independent Windows readback on
aeb7f502: WARP passes all four 16×16 pairs and the controls. On RTX 4060 Laptop (32.0.16.1656, DXC from Windows SDK 10.0.26100.0, debug layer enabled), all four positive pair cases fail. For[0,1,0,1], the first mismatch is at (0,1): expected00000000 9b5d0000 9b5d0000 00010000, actual9b5d0000 36ba0000 9b5d0000 00010000, with 128/256 differing pixels and zero debug messages. The same runner passes #2141's SM6 quad swaps and their mutations on this adapter.Please keep the integer-lane reference and check why the derivative-based pair reconstruction differs on hardware, or build the four pair mappings on the same SM6 quad-read path as the swaps, with an original vs candidate readback. Include an odd boundary or a partially covered quad in the shared follow-up so helper-lane behavior is observable.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:38:36Z.
Thanks for the independent RTX readback.
Root cause: the pair lowering rebuilt the other lane's word from
ddx_fine/ddy_fineof each 16-bit half. A hardware derivative is not required to be the exact difference of the two pixels' values, so WARP matched and RTX did not. The derivative path is gone.Fix in
d5d0ea9c: each lane now reads the four lanes of its quad with the shader model 6.0QuadReadLaneAt(constant lane arguments, all four reads unconditional, the same quad-read path as the swaps) and keeps the lanequad_permnames for its position. The integer-lane reference is unchanged. The stage compiles with DXCps_6_0through the sameneeds_sm6/find_dxcpipeline step as #2141, and the FXC leg is dropped for this test.Regression test:
tests/startup_gfx2hlsl_dpp_pair_check.pynow asserts there is no derivative in the text, models the four-lane read on the CPU, and the draw mutations (opposite lanes, the lane's own word, a transposed lane index, second source permuted) must each fail the 16x16 readback.Verification (Win2025, WARP only,
x2w_pipe.py win2025 2140 --targets offscreen_check --regex '^startup_gfx2hlsl_dpp_pair'): dev 3/3 and release 3/3 (startup_gfx2hlsl_dpp_pair,_warp,_hardware). Linux:startup_gfx2hlsl_*,startup_translator_check.py,docs_links_check.pypass. The VM has no RTX, so the hardware run here is WARP; please re-run your RTX readback ond5d0ea9c.The odd boundary / partially covered quad case is not in this change. I will add it to the shared follow-up with #2141.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:20:11Z.
Code review location:
tools/startup/gfx2hlsl.py; line 705Fixed in
aeb7f502. The DPP lowering now needs a proven whole-quad mask:s_wqm_b64/b32 exec, execon the entry mask setswhole_quad, and restoring a saved exact mask clears it. Without that proof, or after an exact restore, the shader is refused by name. Fixtures now open withs_wqm_b64 exec, exec.Regression tests in
tests/startup_gfx2hlsl_dpp_pair_check.py: refuse without WQM, refuse afters_mov_b64 exec, s[4:5]restore, accept after WQM with an unrestored saved copy. They fail on the previous commit and pass now.Verification:
python3 -B tests/startup_gfx2hlsl_dpp_pair_check.py: PASSpython3 -B tools/run_checks_parallel.py -j 4 tests/startup_gfx2hlsl_*_check.py tests/startup_translator_check.py tests/startup_buffer_address_check.py tests/docs_links_check.py tests/mesh_dynamic_geometry_check.py tests/startup_ngg_slice_check.py tests/run_checks_parallel_check.py: all 41 passedx2w_pipe.py win2025 2140 --regex '^startup_gfx2hlsl_dpp_pair': dev 3/3 and release 3/3 passed (controls, WARP draw, hardware draw)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:20:13Z.
Code review location:
tools/startup/gfx2hlsl.py; line 713Fixed in
aeb7f502. The source register now goes throughself.u(), so it is recorded inused_vand declared and initialized even when DPP is its only reader.Regression test:
v_mov_b32_dpp v2, v0with an export of onlyv2must declare and initializev0before the lowering (tests/startup_gfx2hlsl_dpp_pair_check.py). It fails on the previous commit and passes now.Verification:
python3 -B tests/startup_gfx2hlsl_dpp_pair_check.py: PASSx2w_pipe.py win2025 2140 --regex '^startup_gfx2hlsl_dpp_pair': dev 3/3 and release 3/3 passedAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:08:07Z.
Review: APPROVED
Independent RTX and WARP readbacks now match the CPU reference on the exact revised head. The three DPP forms and the LLVM 15 round-trip are covered.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T03:06:32Z.
I resolved the main conflicts at
71ec807dand kept the pair permutations, swaps, and single-lane broadcasts as separate cases. The source-built draw and mutation checks for all three passed on WARP and RTX 4060 Laptop (32.0.16.1656), with no skips. LLVM 15 also reproduced all four pair encodings and the explicit bound bit. This replaces my earlier RTX result for the derivative variant. Please keep the original narrow scope while the final CI runs.