experimental: shader: lower wave32 compare-mask consumers (draft, do not merge) #3897

Open
github-bot wants to merge 18 commits from github-bot/gh-3895 into main AGit
Owner

@⁠SimSalabimse on GitHub · 2026-12-02 23:21 UTC · original
SimSalabimse:local/native-cmp-mask-dest → main · +7076 −110 · 38 files · 18 commits · draft

Draft, do not merge. Experimental piece of the native graphics path work (getting the native shader path to draw real frames). Do not merge until it has been tested on the Windows test PC.

What it changes

Wave32 compare-mask consumers in the native lowering (src/gfx1013_direct_graphics.inl, src/gfx1013_compute_native.cpp). An odd SGPR compare mask is now accepted when every read of it is one of:

  • a v_cndmask_b32 of that SGPR,
  • an s_and_saveexec_b32 whose EXEC is restored by an s_mov_b32 or s_or_b32,
  • an s_and_b32 with EXEC or with another mask, ahead of that restore.

A b64 consumer of the same mask stays refused. The control script tests/native_cmp_mask_dest_check.py is extended for these shapes.

Dependencies

This branch is stacked. It is 18 commits ahead of main: the 17 below the top commit are the staged native path work that is not on main yet (diagnostics, fixed pixel entry layouts, pixel EXEC arms, vertex fetch before a scalar branch, and an earlier odd-SGPR compare mask commit). Only the top commit, "Lower the three remaining compare-mask consumers", is new in this PR, so review that commit alone. The branch does not merge cleanly into current main (conflict in src/direct_compute_cache.cpp from the stack) and will be rebased once the stack below it has landed.

Tests

None yet. This has not been built or run through ctest, DXC, WARP or hardware. Planned: native_cmp_mask_dest_*, then native_direct_container, native_execz_join_mask_*, native_graphics_vertex_vcc_join_*, native_pixel_exec_arms, native_pixel_entry_* and startup_ngg_slice, one GPU test at a time.

Not measured: whether any title shader reaches the newly accepted shapes in a real run.

AI-assisted (Cursor)

**@⁠SimSalabimse** on GitHub · 2026-12-02 23:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3895) `SimSalabimse:local/native-cmp-mask-dest` → `main` · +7076 −110 · 38 files · 18 commits · draft Draft, do not merge. Experimental piece of the native graphics path work (getting the native shader path to draw real frames). Do not merge until it has been tested on the Windows test PC. ## What it changes Wave32 compare-mask consumers in the native lowering (`src/gfx1013_direct_graphics.inl`, `src/gfx1013_compute_native.cpp`). An odd SGPR compare mask is now accepted when every read of it is one of: - a `v_cndmask_b32` of that SGPR, - an `s_and_saveexec_b32` whose EXEC is restored by an `s_mov_b32` or `s_or_b32`, - an `s_and_b32` with EXEC or with another mask, ahead of that restore. A b64 consumer of the same mask stays refused. The control script `tests/native_cmp_mask_dest_check.py` is extended for these shapes. ## Dependencies This branch is stacked. It is 18 commits ahead of `main`: the 17 below the top commit are the staged native path work that is not on `main` yet (diagnostics, fixed pixel entry layouts, pixel EXEC arms, vertex fetch before a scalar branch, and an earlier odd-SGPR compare mask commit). Only the top commit, "Lower the three remaining compare-mask consumers", is new in this PR, so review that commit alone. The branch does not merge cleanly into current `main` (conflict in `src/direct_compute_cache.cpp` from the stack) and will be rebased once the stack below it has landed. ## Tests None yet. This has not been built or run through ctest, DXC, WARP or hardware. Planned: `native_cmp_mask_dest_*`, then `native_direct_container`, `native_execz_join_mask_*`, `native_graphics_vertex_vcc_join_*`, `native_pixel_exec_arms`, `native_pixel_entry_*` and `startup_ngg_slice`, one GPU test at a time. Not measured: whether any title shader reaches the newly accepted shapes in a real run. AI-assisted (Cursor)
Add opt-in lines for a graphics descriptor range that does not cover a
shader fetch and for an index view with no proven desktop buffer range.
The coverage check and both refusals are unchanged.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
A refused-table slot whose shadow id is 0 is classified from its 32 title bytes and logged as a title view kind. Native compute inputs log a source class when it changes. X2W_NATIVE_LOOP_GUARD caps scc and execnz back edges; with the variable unset the branch text is unchanged.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
X2W_NATIVE_LOOP_GUARD atomic-adds a space-3 root UAV when the cap trips and Present logs that count. X2W_NATIVE_STALE_INPUT_HOLD reuses the last accepted small snapshot when a new one is zero, leading-zero, or a four-dword splat. X2W_NATIVE_TABLE_TOKEN_EXTEND allows a past-range graphics fetch only when the heap slot is a matching stand-in view token. All three stay off unless the env var starts with 1.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
X2W_LOG_TARGET_BIND names the first target-bind failure for a key, and again when the reason changes. X2W_TARGET_BIND_FIX types a typeless render-target view from a typed resource of the same family and skips a slice outside the resource. Both stay off unless the env var starts with 1.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
Undefine pre-existing min and max macros before numeric_limits is used, with a synthetic macro regression check. Add the loop-guard and stale-input dispatch refusals to the triage allowlist.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
An integer RTV variant now gets a uint or int SV_Target as wide as the export, and the export stores the register bits. A float signature row is retyped for that format. A uint or sint signature that disagrees with the format is still refused, and a packed export to an integer target stays refused. Float targets keep the four-wide float row. Colour next to uncompressed depth translates, with the colour target still float when no variant asks.

AI-assisted (Cursor)
X2W_LOG_PIXEL_ENTRY_LAYOUT=1 writes one line per translation key with the address stored at state block A +0x58, the enable mask when one is stored, whether a reviewed sidecar was used, and that sidecar's pixel input address. Unset, the refusal text is unchanged.

AI-assisted (Cursor)
The vertex program is the shared fullscreen triangle. The draw was using a scissor the size of the 8x4 target, so every pixel was overwritten. The other slot-57 draws scissor to the left half and leave the clear on the right.

AI-assisted (Cursor)
One table in src/fixed_pixel_entry.h is what the unreflected and reflected
fixed-entry checks accept. Layouts without an I,J pair allow NUM_INTERP 0..7
when the stage reads no PARAM. The refusal line now includes in_control.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
The pixel shader's SV_Position.w is clip w (WARP and a hardware adapter agree), while the POS_W entry VGPR holds 1/w. SV_IsFrontFace is all ones when true; the entry VGPR holds 1.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
The PSI1 dword at +8 is the full control register. Packed-position and
captured-count checks now use that field, and control refusals log it.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
Those ops do not read PARAM, barycentrics, or parameter LDS. vintrp,
ds, s_swappc_b64, and WQM stay refused, and the refusal names the opcode.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
A raw stage with no position export is the pixel stage, so a stage that only
kills lanes and exports null is no longer ambiguous. A plain v_cmpx before a
skip branch to the null export lowers to a discard with no render target.

On a no-I,J fixed pixel entry, v_interp_mov_f32 from P0 reads a flat PARAM
input (nointerpolation TEXCOORD) when the attribute is below NUM_INTERP and the
vertex stage exports it. Smooth fetches stay refused. The paired vertex stage
takes the fixed vertex ABI and an SV_Position row.

Synthetic fixtures only: controls, refusal controls, and a WARP/hardware draw.
The fixed vertex fetch prologue sits before the first branch, so a VS with a later
uniform scalar branch no longer counts as non-straight. A branch back to the entry
still refuses it.

A pixel interpolation pair outside every loop body, such as the preheader behind a
zero-trip guard, still reads untouched entry barycentrics. Interpolation inside a loop
body stays refused.

Synthetic fixtures only: controls and refusal controls in native_direct_container.
s_cbranch_execz over a masked pixel arm becomes a lane branch when the
arm cannot be observed by an inactive lane, including nested arms and
non-derivative image reads. A whole-quad discard's empty-wave skip is
dropped when the export is already under the coverage mask. Read-only
uniform image loads and pure pixel ALU feed readfirstlane. Refusals keep
their prefixes and name the exec writer and the skipped effects.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <[email protected]>
A nested arm opens with s_mov_b64 sN, exec. The enclosing arm refused that as a body op, so only top-level arms translated. The enclosing arm now accepts it. A nested proof that fails still leaves the v_cmpx that follows, which the body refuses. The long-arm control now defines the colour register before the arm and builds its 24 moves with a comprehension.

AI-assisted (Cursor)
Other comparison mask destinations stay refused. The diagnostic keeps its
prefix and names the destination and the consumer that blocked it.

Co-authored-by: SimSalabimse <[email protected]>
AI-assisted (Cursor)
Accept an odd SGPR compare when every read is a v_cndmask_b32 of that
SGPR, an s_and_saveexec_b32 with an s_mov_b32 or s_or_b32 EXEC restore,
or an s_and_b32 with EXEC or another mask ahead of that restore. A b64
consumer of the same mask stays refused.

Co-authored-by: SimSalabimse <[email protected]>
AI-assisted (Cursor)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 23:23:41 +00:00
This pull request has changes conflicting with the target branch.
  • src/direct_compute_cache.cpp
  • src/gfx1013_compute_native.cpp
  • src/gfx1013_direct_compute.inl
  • src/gfx1013_direct_graphics.inl
  • src/startup_stubs/d3d12_compute_dispatch.inl
  • src/startup_stubs/d3d12_draw.inl
  • src/startup_stubs/d3d12_xs_device.cpp
  • src/startup_stubs/translated_sampler_bindings.h
  • tests/native_direct_container_check.py
  • tests/native_fixed_graphics_psi1_check.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3897/head:github-bot/gh-3895'
git switch 'github-bot/gh-3895'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3895'
git switch 'github-bot/gh-3895'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3895'
git switch 'github-bot/gh-3895'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3895'
git switch 'main'
git merge --squash 'github-bot/gh-3895'
git switch 'main'
git merge --ff-only 'github-bot/gh-3895'
git switch 'main'
git merge 'github-bot/gh-3895'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.