Skip to content

shader: lower pixel compare masks composed with VCC in a whole-quad tail (Part of #3309) - #3401

Open
SimSalabimse wants to merge 2 commits into
R0Y00:mainfrom
SimSalabimse:pixel-compare-mask-vcc
Open

SimSalabimse wants to merge 2 commits into
R0Y00:mainfrom
SimSalabimse:pixel-compare-mask-vcc

Conversation

@SimSalabimse

Copy link
Copy Markdown
Contributor

Change

Part of #3309. Refs #2413, #3210, #870, #3308. The work sits on the pixel path added in #3091.

A gfx1013 pixel tail in whole-quad mode can now combine a named two-SGPR compare mask with VCC. It handles s_and_b64, s_or_b64 and s_andn2_b64 (S0 & ~S1), and s_mov_b64 keeps the lane bit when the pair is copied. Some cases are still refused:

  • A later 32-bit write to either half refuses with compare mask half overwritten.
  • A later SCC read is lowered only when the result is uniform across the wave. Otherwise it refuses with SCC read without an established wave-wide nonzero result.

This tracking runs only in the pixel whole-quad tail (whole_quad or exact_after_wqm). A vertex class-mask high-half overwrite still refuses as unproven graphics CNDMASK source, the same as on main.

Verification

All results are for commit ed447c29cff990b278a1aaabbac9e449866759fc.

On the Windows test PC (Debug dev preset, D3D12 debug layer on), the adapters were Microsoft Basic Render Driver (WARP) and NVIDIA GeForce RTX 4070 Ti with driver 32.0.16.2135. The command was:

ctest --preset dev --no-tests=error -j 1 -R 'native_pixel_compare_mask|native_fixed_mesh57_compare_vcc|native_direct_container' -E 'startup_audio_(output|pacing|provider)' --output-on-failure

It passed 7 of 7 with ctest exit 0.

  • Fixture: native_pixel_compare_mask_warp, _hardware, _container (validated DXIL) and _ir all passed.
  • Fixed-mesh integration: native_fixed_mesh57_compare_vcc_warp and _hardware passed. The reviewed stage pair links and creates a color PSO from the captured root and attachment state.
  • Regression: native_direct_container passed.

An earlier commit, 30f6606b, failed native_direct_container on vertex-class-mask-high-overwrite because the tracker also ran on vertex compares. ed447c29 limits it to the pixel whole-quad tail.

On Linux:

  • python -m compileall -q tools tests exited 0.
  • The python-linux list passed all 258 checks.
  • tests/native_pixel_compare_mask_check.py, in both normal and ir mode, exited 0.

Evidence and follow-up

The fixture words are written by hand in tests/native_pixel_compare_mask_check.py, with no game files or dumps. The diagonal draw covers x + y < 5.5, so pixel (4,0) is covered and (4,1) is a helper lane. The mask is y > 1 under whole-quad execution, and VCC is x > 2 after exact coverage returns. Uncovered pixels stay at the clear value, -1.

Each negative control was shown to fail when its check was removed:

  • Half overwrite: disabling the v_cndmask guard let the container lower with the stale bit.
  • Varying SCC: forcing the result to look uniform let the read lower.
  • ANDN2 operand order: swapping the complement compiled s_andn2_b64 s[6:7], s[4:5], vcc as vcc & ~mask, and the draw test expects pixels differ.

The fixed-mesh readback is the slot 57 target, not the 8×2 fixture. Reproduction notes are in docs/experiments/pixel-compare-mask-vcc.md.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Cursor)

cursoragent and others added 2 commits November 28, 2026 21:38
A whole-quad pixel tail can AND, OR, or ANDN2 a two-SGPR compare with VCC, keep that pair across a 64-bit move, and refuse a half overwrite or an SCC read whose wave-wide result is not uniform.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A vertex class-mask high-half overwrite must still refuse as an unproven
CNDMASK source. The pair tracker was recording every graphics compare.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.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.

2 participants