Skip to content

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

Merged
pigalot merged 5 commits into
R0Y00:mainfrom
SimSalabimse:pixel-compare-mask-vcc
Nov 29, 2026
Merged

pigalot merged 5 commits into
R0Y00:mainfrom
SimSalabimse:pixel-compare-mask-vcc

Conversation

@SimSalabimse

@SimSalabimse SimSalabimse commented Nov 28, 2026 •

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 s_mov_b32 of either half refuses with compare mask half overwritten.
  • Any other scalar write over that pair, including a literal or numeric s_mov_b64, s_movk_i32, scalar arithmetic, a scalar load, or a copy whose source is no longer a 64-bit mask, drops the tracked bit. A later select then refuses with unproven graphics CNDMASK source.
  • s_cselect_b64 into the same pair keeps the new full mask instead.
  • 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 below are for commit 53a8f2ab5fe80af837958bd9caee4700e7e9ce8a, rebased onto main 77d1ba4d63ba31abaf4ca3635d4159189a423201.

Windows test PC (MSVC, --preset dev, -j 1). The command was:

ctest --preset dev --no-tests=error -j 1 -R '^(native_pixel_compare_mask_(warp|hardware|container|ir)|native_fixed_mesh57_compare_vcc_(warp|hardware)|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 and _ir all passed. Container and IR refused the new scalar-write cases and validated compare-cselect-mask.
  • Fixed-mesh integration: native_fixed_mesh57_compare_vcc_warp and _hardware passed. The reviewed stage pair links and creates a color PSO. Target zero (2,0) packed RGBA was 0xffff00ff, with 1/8 non-clear pixels and argument guards intact.
  • 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. 53a8f2ab drops a tracked pair when a later scalar write the tracker does not itself rewrite overlaps it.

On Linux, at 53a8f2ab:

  • g++ and clang++ -std=c++20 -Wall -Wextra -Werror=narrowing of the lowering exited 0.
  • python3 -B tests/native_pixel_compare_mask_check.py and the same script in ir mode exited 0.
  • python3 -B tests/docs_links_check.py 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.
  • Unclaimed scalar write: on the previous lowering, a literal zero, the fixture copy of zero, a numeric s_mov_b64, s_movk_i32, s_add_u32, a scalar load, and a mismatched copy all compiled. They now refuse.

The mask map is still not stored per edge, and a later s_cmp_* does not clear an unknown SCC from a varying combine. 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)

@Leyukaka Leyukaka 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.

Request changes at ed447c29. Reviewed by reading the diff and the sources at that head; one mutant result from a local run is noted below.

Blocking:

  • A stale tracked pair gives a wrong select where main refuses. compare_masks / broken_compare_masks are only updated by v_cmp_* (src/gfx1013_direct_graphics.inl:2126-2129), by s_mov_b64 from a tracked or tagged pair (:2187-2203), by s_mov_b32 (:2204-2209) and by a combine (:2224-2225). No other SGPR writer in lower_graphics touches them, and v_cndmask_b32 takes the map entry before graphics_lane_mask (:2143-2149).
  • Smallest case, all in whole-quad mode: s_mov_b64 s[20:21], exec; s_wqm_b64 exec, exec; v_cmp_gt_f32 s[4:5], v1, 1.0; s_mov_b64 s[4:5], 0; v_cndmask_b32 v4, 0, 1.0, s[4:5]. The literal source is operand 128, so the move skips :2187 (i.src[0] <= 104) and is lowered as a numeric move that leaves compare_masks[4]. The select then uses the old compare bit, while the guest mask is 0 on every lane. On main the select goes through graphics_lane_mask (main:2115), sees a constant in the analysis state and refuses with unproven graphics CNDMASK source. The fixture tail has the same hole: add s_mov_b64 s[8:9], 0 after the copy.
  • Same for a s_mov_b64 from an untagged numeric pair (known is false at :2188-2190), for s_movk_i32, SOP2 arithmetic and SMEM loads into either half, and for s_cselect_b64 into a tracked pair (:2265-2277). In the last case main selects with the new full mask, and the head selects with the old compare bit. So "a later 32-bit write to either half refuses" holds only for s_mov_b32.
  • In the tracked s_mov_b64 path, when compare_mask_bit returns nothing (:2195, tagged source with an offset or a mismatched high half), the destination keeps its old entry.
  • Suggested fix: before the generic lowering, drop (or mark broken) any tracked pair overlapped by the destination of an instruction the tracker did not handle itself, using the width computation already at :1991-1992. Alternatively use the map entry in v_cndmask_b32 only when state[src] is still the tagged pair. Add a container control with s_mov_b64 s[8:9], 0 after the copy that expects a refusal.

Non-blocking:

  • compare_masks is not part of the per-edge state (graphics_registers is restored per edge at :1127 and merged at :1182), so an entry made in one block is visible in a sibling block. All fixtures are straight-line.
  • compare_scc_unknown is cleared only by a uniform combine (:2231). After a later s_cmp_* defines SCC, s_cselect still refuses at :2026.
  • The branch refusal at :2424-2425 is redundant while SCC is still undefined (alu.read(128) already refuses with graphics register undefined on an incoming path: 128), and once SCC is redefined it is the same false refusal as above.
  • Not covered by any case, so deleting them passes the tests: the broken check in compare_mask_bit (:2167-2168), broken propagation through s_mov_b64 (:2192-2194), the refusal at :2242-2243, and :2424-2425.
  • The fixed-mesh shader uses a uniform-true mask and reads one pixel, (2,0), where VCC is also 1. AND, OR, the mask alone and VCC alone all give the same result there.

Checked:

  • Combine semantics (:2220-2222): OR, AND, and ANDN2 as S0 & ~S1 with xor bit, 1 on 0/1 values. SCC is written only for a uniform result (:2229-2235).
  • Fixture references: (4,0) is covered (4.5 + 0.5 < 5.5), (4,1) and (5,0) are not; the mask at (4,0) is 0 and the quad read from (4,1) is 1; the two ANDN2 orders give different images. The fixed-mesh words decode to s_and_b64 s[6:7], s[4:5], vcc, s_mov_b64 s[8:9], s[6:7], v_cndmask_b32 v0, 0, 1.0, s[8:9].
  • In a local run (this head merged onto 212d4b5f together with other open PRs), removing the xor from the ANDN2 lowering (:2222) failed native_pixel_compare_mask_warp, _hardware and _ir; _container, native_direct_container and native_fixed_mesh57_compare_vcc_warp still passed.
  • CI passes but does not run these tests on a PR: none match the pr preset filter (CMakePresets.json), and the new script is not in tests/checks/python-linux. The evidence is the author's run in the PR body.
  • CMake changes are add_test/set_tests_properties only. git merge-tree against main (212d4b5f) is clean.

cursoragent and others added 3 commits November 29, 2026 12:29
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>
A literal or numeric s_mov_b64, s_movk_i32, scalar arithmetic, a scalar
load, or a copy of a pair that is no longer a mask left the old compare
bit for v_cndmask. s_cselect_b64 into that pair keeps the new full mask.

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@cursor
cursor Bot force-pushed the pixel-compare-mask-vcc branch from ed447c2 to 53a8f2a Compare November 29, 2026 12:37
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Fixed at 53a8f2ab5fe80af837958bd9caee4700e7e9ce8a. A scalar write the tracker does not itself rewrite now drops any compare-mask pair it overlaps, so v_cndmask cannot keep the old bit. That covers a literal or numeric s_mov_b64, s_movk_i32, scalar arithmetic, a scalar load, and a copy whose source is no longer a 64-bit mask. s_mov_b32 still refuses as a half overwrite. s_cselect_b64 into that pair keeps the new full mask, and the IR select reads that mask rather than the replaced compare. The branch is rebased onto main 77d1ba4d.

Windows test PC (MSVC, --preset dev, -j 1), at that head:

  • ctest --preset dev --no-tests=error -j 1 -R '^(native_pixel_compare_mask_(warp|hardware|container|ir)|native_fixed_mesh57_compare_vcc_(warp|hardware)|native_direct_container)$' -E 'startup_audio_(output|pacing|provider)': 7/7 passed, exit 0 (native_fixed_mesh57_compare_vcc_warp, native_fixed_mesh57_compare_vcc_hardware, native_direct_container, native_pixel_compare_mask_warp, native_pixel_compare_mask_hardware, native_pixel_compare_mask_container, native_pixel_compare_mask_ir)
  • Container and IR refused the new cases (compare-literal-zero, compare-literal-copy-zero, compare-numeric-mov, compare-movk-high, compare-add-high, compare-smem-low, compare-mismatched-copy, compare-broken-copy, compare-broken-combine, compare-missing-vcc) and validated compare-cselect-mask.

Not done in this head: the mask map is still not stored per edge, and a later s_cmp_* does not clear an unknown SCC from a varying combine.

AI-Assisted

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Review of head 53a8f2ab (rebased onto 77d1ba4d). git merge-tree --write-tree --name-only origin/main 53a8f2ab against main af1cab5c exits 0. CI at the head passes. Read only, nothing built or run.

Checked:

  • By reading, 53a8f2ab closes the blocking point from the review at ed447c29. UnclaimedMaskRelease runs when instruction returns or throws. In the compare tail, it erases every pair that overlaps GraphicsMaskRegions::scalar_width(i) dwords from i.dst, unless the tracker set claimed. The width covers SMEM, VOPC, SOP1/SOP2/SOPK and v_readlane_b32/v_readfirstlane_b32. A literal or numeric s_mov_b64, s_movk_i32, SOP2 arithmetic, an SMEM load, s_cselect_b64 and a tracked copy whose compare_mask_bit comes back empty therefore drop the stale bit. The claimed = true sites are exactly the four tracker writes: v_cmp, tracked s_mov_b64 (two branches), s_mov_b32 broken, and the combine.
  • The cases asked for exist as container controls: compare-literal-copy-zero is tail(15, 4, 106, after=[sop1(4, 8, 128)]), the s_mov_b64 s[8:9], 0 after the copy. Next to it are compare-literal-zero, -numeric-mov, -movk-high, -add-high, -smem-low and -mismatched-copy, all expecting the unproven graphics CNDMASK source refusal. compare-cselect-mask checks in IR that the icmp ne reads the new select ... 4294967295, i32 0. Dropping the release body would make the UNPROVEN cases lower, so the container check pins it.
  • VOP3B carry-outs into an SGPR pair are not a hole here: v_mad_u64_u32 is refused in pixel_stage, and v_add_co_u32 has no C++ lowering.

MUST

  1. Leyukaka's CHANGES_REQUESTED review at ed447c29 is still the review on record. I'm leaving the merge to that re-review and have nothing else blocking.

SHOULD

  1. Default path: since runtime: default to native shaders and Opus decoding #3449, -Render runs the in-process pixel translator by default. Once this lands, these compare-mask tails are lowered in default runs, not only opt-in ones. So the two remaining gaps the author lists matter there: the mask map is not part of the per-edge state, and an unknown SCC is not cleared by a later s_cmp_*. All fixtures are straight-line. A follow-up issue, or a refusal when a tracked entry reaches a join, would bound the first gap.

NIT

  1. The release checks the tail after the instruction (!*whole_quad && !*exact_after_wqm) and skips the erase when the tail has already ended. Entries made in the tail then outlive it. That matters only if a second whole-quad region can begin later in the prologue. I found no case of that by reading and did not try to construct one.

AI-assisted.

@Leyukaka Leyukaka 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 at 53a8f2ab. My changes request on ed447c29 is resolved by UnclaimedMaskRelease (src/gfx1013_direct_graphics.inl:1683-1702). Not approving yet: item 1 below is a regression against main. I will approve once it is fixed. Reviewed by reading the diff and the sources at that head and at main 4b0586d4; nothing was built or run for this pass.

Blocking point from ed447c29: fixed (code reading).

  • src/gfx1013_direct_graphics.inl:1683-1702: UnclaimedMaskRelease runs on every exit of instruction (return or refusal). In the tail it erases each tracked or broken pair overlapped by scalar_width(i) dwords from i.dst, unless the tracker set claimed. claimed is set only where the tracker rewrites the entry itself: :2159, :2226, :2230, :2242, :2261.
  • After the erase, v_cndmask_b32 falls through to graphics_lane_mask (:2180), which is the main behavior. So a literal or numeric s_mov_b64, s_movk_i32, SOP2 arithmetic and an SMEM load refuse as on main, and s_cselect_b64 selects with the new full mask.
  • The tracked s_mov_b64 whose source gives no bit (:2227 returns nothing) no longer sets claimed, so the destination entry is erased too.
  • SOP1/SOP2/SOPK writes to VCC are still refused (:2314-2318), so register 106 read at :2213 is always a 0/1 lane bit.
  • Requested control is present: compare-literal-copy-zero (tests/native_pixel_compare_mask_check.py:92-94), plus -literal-zero, -numeric-mov, -movk-high, -add-high, -smem-low, -mismatched-copy, and compare-cselect-mask with the IR check at :303-305.

MUST

  1. Wave32 pixel program that main lowers is refused (code reading). src/gfx1013_direct_graphics.inl:2237-2243 computes base = i.dst & ~1u without looking at stage.wave32, and :2156 records the compare on wave32 as well. On a wave32 pixel stage in whole-quad mode, before the exact restore: v_cmp_gt_f32 s4, ..; s_mov_b32 s5, 0; v_cndmask_b32 .., s4. The move marks pair 4 broken and the select refuses at :2175-2176 with compare mask half overwritten. On main the compare tags only s4 (src/gfx1013_compute_native.cpp:714-715), the move changes only s5, and graphics_lane_mask accepts a wave32 mask from its low word alone (src/gfx1013_direct_compute.inl:2962-2964 at 4b0586d4), so the select lowers. The result is a refusal, not a wrong value. On wave32 s5 is an ordinary register, so the sequence is plausible. Fix: gate the s_mov_b32 pair-break branch at :2237-2243 on !stage.wave32. A wave32 container case with that sequence expecting success would pin it; no fixture in this PR is wave32.

Non-blocking:

SHOULD

  1. Control flow, unchanged from the earlier review: compare_masks is not part of the per-edge state, so an entry recorded in one block is visible in a sibling block or at a join. All fixtures are straight-line. A refusal when a tracked entry reaches a block boundary, or a follow-up issue, would bound it.
  2. compare_scc_unknown is cleared only by a uniform combine (:2265-2267). After a later s_cmp_* defines SCC, s_cselect (:2056-2057) and a scalar branch (:2460-2461) still refuse.

NIT

  1. compare-broken-copy does not pin the propagation at :2223-2226 (code reading). With that branch removed, s_mov_b64 s[8:9], s[4:5] reaches compare_mask_bit(4) at :2227, which refuses at :2198-2199 with the same message, so the case still passes. The branch only changes behavior when the broken copy is never read as a mask (then it lowers instead of refusing), and no case covers that.
  2. SCC of a uniform combine is only tested when true. scc_program(varying=False) (tests/native_pixel_compare_mask_check.py:61-70) is s_or_b64 of a true and a false compare, read by s_cselect_b32 with expected value 1.0. Writing a constant 1, or the left operand's bit, to SCC at :2266 would pass. A second uniform case with a false result (for example s_and_b64 of the same two compares, expecting 0.0) would catch both.
  3. The release at :1692 tests the tail state after the instruction, so entries recorded in the tail outlive it. They are only read inside the tail, and I found no way to re-enter whole-quad mode after a compare (:2045 requires scalar_entry, which a compare clears at :2051-2055).

Checked:

  • git merge-tree of the head against main 4b0586d4 is clean. The four later commits on main do not touch src/gfx1013_direct_graphics.inl.
  • CI passes at the head. As before, the new tests are not in the pr preset; the 7/7 result is the author's run in the PR body.
  • CMake changes are add_test/set_tests_properties only.

@pigalot pigalot 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.

Request changes at 53a8f2ab, reviewed integrated over main 4b0586d4 (tree d8bfbb92, clean merge, git diff --check clean).

What the earlier review at ed447c29 asked for. The straight-line stale pair is fixed. With the release body disabled, compare-literal-zero, -literal-copy-zero, -numeric-mov, -movk-high, -add-high, -smem-low and -mismatched-copy stop refusing and three tests fail (mutant M1 below). v_add_co_u32-style carry-outs are not a hole: gfx1013_direct_compute.inl:3535 refuses them for a pixel stage.

Blocking

  1. A tracked pair crosses a control-flow edge and gives a wrong select where main refuses. compare_masks is one map for the whole function, filled and erased in emission order, and in_compare_tail() is true for the whole-quad region before coverage returns, where branches are allowed (the edge refusal at :1975 covers only exact_after_wqm). Program, using the helpers in tests/native_pixel_compare_mask_check.py:

    SCMP = 0xBF000000 | (6 << 16) | (129 << 8) | 129          # s_cmp_eq_u32 1, 1
    br = lambda op, off: 0xBF800000 | (op << 16) | off
    with_exports(whole_quad_compare() + [                     # v_cmp_gt_f32 s[4:5], y, 1.0
        SCMP, br(4, 2),                                       # s_cbranch_scc0 else
        sop1(4, 4, 128), br(2, 1),                            # then: s_mov_b64 s[4:5], 0; s_branch join
        sop1(4, 4, 4),                                        # else: s_mov_b64 s[4:5], s[4:5]
        *cndmask(0, 128, 242, 4)])                            # join: v_cndmask_b32 v0, 0, 1.0, s[4:5]

    SCC is 1, so the guest always takes the then path and v0 is 0 on every lane. At this head compile_dxil ... gfx1013-container-ps exits 0, the DXIL validates, and the join selects on the y > 1 compare (%t9 = icmp ne i32 %t5, 0 with %t5 the compare from the entry block). Drawn with the fixture's vertex shader on WARP, offscreen_check warp --startup-pixel-words against the all-zero reference reports pixel mismatch (0,1): expected 00000000,... actual 3f800000,..., 4 of 16 pixels differ, and it matches the y > 1 image exactly. On main 4b0586d4 the same blob refuses with native compute +0x24: unproven graphics CNDMASK source. The then block erases the entry, the else block is emitted later and puts it back from the tagged state, and the join then finds an entry that only holds on one path.

  2. Same cause, invalid IR instead of a refusal. Replace the two arms with a then block that redefines the pair:

    with_exports(whole_quad_compare() + [SCMP, br(4, 2), *cmp_gt(4, 256, 244), *cndmask(0, 128, 242, 4)])

    native_pixel_ir_dump exits 0 at this head and the join reads a value defined only in the then block. compile_dxil then fails in DXC with Instruction does not dominate all uses! %t14 = zext i1 %t13 to i32. main refuses with native compute +0x20: unproven graphics CNDMASK source.

    Suggested direction (not tried): use a map entry in v_cndmask_b32 and in compare_mask_bit only when it was recorded in the current block, and clear the map at every block entry, so anything that crosses an edge falls back to graphics_lane_mask and the per-edge state, as on main. Or refuse when the whole-quad region is not straight-line. Please add both programs as container controls that expect the refusal.

  3. The title run of this head failed twice. prwatch built 53a8f2ab merged onto the baseline commit af1cab5c:

    • [fail] judgement: Judged worse than the baseline: black-frame (at before-1, after-1, before-2, after-2, before-3, after-3, before-4, after-4). Confidence medium.
    • [fail] repeat: Failed again on a re-run (job 44).

    I have not tied this to finding 1 or 2.

Non-blocking

  • compare_scc_unknown is still cleared only by a uniform combine, so a later s_cmp_* followed by s_cselect or an SCC branch is refused although SCC is defined again. The PR body says so.
  • The fixed-mesh shader still reads one pixel where the mask and VCC are both 1, so it cannot tell AND from OR or from either operand alone. The 8x2 fixture does.
  • CI does not run any of the new tests on a pull request: none match the pr preset filter, and the script is not in tests/checks/python-linux. The results below are from my machine.

What I ran

Built dev (full build), then
ctest --test-dir out/build/dev --no-tests=error -j 4 -R '^(native_pixel_compare_mask_(warp|container|ir)|native_fixed_mesh57_compare_vcc_warp|native_direct_container|native_fixed_mesh57_mask_warp)$': 6 of 6 passed.
native_pixel_compare_mask_hardware and native_fixed_mesh57_compare_vcc_hardware with -j 1 and the debug layer on: 2 of 2 passed, no skips. Release was not built, because the findings above already decide the verdict.

Mutants in src/gfx1013_direct_graphics.inl, each rebuilt and run against the five non-hardware tests of this PR:

  • Killed (13): M1 release body disabled; M2 ANDN2 operands swapped (_warp only); M3 OR lowered as AND; M4 combine always uniform; M5 broken check in compare_mask_bit off; M6 broken check in v_cndmask_b32 off; M8 compare mask is not a 64-bit lane mask refusal off; M9 in_compare_tail() always true (native_direct_container only); M10 s_cselect SCC refusal off; M12 v_cndmask_b32 dropped from exact_mask_select; M13 release erases the odd register number instead of the pair base; M14 s_mov_b32 break not claimed; M16 tracked s_mov_b64 does not record the copy.
  • Survived (2): M7 s_mov_b64 no longer propagates a broken source (the copy itself then refuses with the same message, so no case tells a broken pair that is copied and never selected from one that is selected); M11 the SCC refusal on a two-way branch removed (no case has a branch after a varying combine).
  • Equivalent for every covered case (1): M15 v_cmp_* does not record or claim. The select and the combine then reach the same bit through the tagged state, so this entry is only a second route to it.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, DXC from Windows SDK 10.0.28000.0, debug layer on for the hardware tests.
CI: Build and test on Windows passes on 53a8f2ab.

This reply was AI-assisted.

@Leyukaka

Copy link
Copy Markdown
Collaborator

@SimSalabimse Taking this over since there has been no activity for 2 h; will hand back if you resume.

Last movement here: head 53a8f2ab pushed at 12:37 UTC, your comment at 12:47 UTC. Two reviews at that head are open: mine (13:46 UTC) and pigalot's changes request (13:58 UTC).

Plan:

  • A new PR from a branch that keeps your three commits (fd22219e, a081635b, 53a8f2ab) unchanged, with their authorship, merged with current main. It will reference this PR and shader: lower pixel compare masks composed with VCC in a whole-quad tail #3309.
  • Added commit: gate the s_mov_b32 pair-break branch (src/gfx1013_direct_graphics.inl:2237-2243) on !stage.wave32, with a wave32 container case that expects success.
  • Added commit: pigalot's blocking points 1 and 2 (a tracked pair that crosses a control-flow edge). A map entry is used only in the block that recorded it, and the map is cleared at block entry. Both programs from that review are added as container controls that expect the refusal.
  • Not covered by a code change: pigalot's point 3 (the prwatch black-frame result). It needs a new run on the new head.
  • Left open: compare_scc_unknown after a later s_cmp_*, the single-pixel fixed-mesh check, and the two surviving mutants (M7, M11).

@SimSalabimse

Copy link
Copy Markdown
Contributor Author

@Leyukaka I can take the remaining review fixes on this branch if you haven't started the follow-up. If you have, I'll leave it with you.

AI-Assisted

@Leyukaka

Copy link
Copy Markdown
Collaborator

@SimSalabimse Handing back: the PR stays with you, and I will not open a separate one.

I had started. Leyukaka:takeover-3401-pixel-compare-vcc is your three commits merged with main 5de0b114, plus two commits you can cherry-pick or merge into this branch:

  • 9193f9c4: gates the s_mov_b32 pair-break on !stage.wave32, with a wave32 container case (compare-wave32-high-write).
  • 76b760c0: clears the tracked compare masks at block entry, with pigalot's two programs as refusal controls (compare-join-after-clear, compare-join-after-redefine).

At 76b760c0, native_pixel_compare_mask_(container|ir|warp|hardware), native_direct_container, native_fixed_mesh57_compare_vcc_(warp|hardware) and native_fixed_mesh57_mask_warp pass (8 tests). Not done: the mutation checks for both commits, pigalot's point 3, and compare_scc_unknown from my 13:46 UTC review.

@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Fixed at 2211dac07b58740d1beecf8cfe5975aabb126f44. These are Leyukaka's two commits, cherry-picked onto 53a8f2ab so the earlier three commits are unchanged. 61df3c5f keeps a wave32 compare mask when its high half is written (compare-wave32-high-write). 2211dac0 clears the tracked compare masks at block entry (compare-join-after-clear, compare-join-after-redefine).

Windows test PC (MSVC, --preset dev, -j 1), at that head:

  • ctest --preset dev --no-tests=error -j 1 -R '^(native_pixel_compare_mask_(warp|hardware|container|ir)|native_fixed_mesh57_compare_vcc_(warp|hardware)|native_direct_container|native_fixed_mesh57_mask_warp)$' -E 'startup_audio_(output|pacing|provider)' --output-on-failure: 8/8 passed, exit 0, none skipped: native_fixed_mesh57_mask_warp, native_fixed_mesh57_compare_vcc_warp, native_fixed_mesh57_compare_vcc_hardware, native_direct_container, native_pixel_compare_mask_warp, native_pixel_compare_mask_hardware, native_pixel_compare_mask_container, native_pixel_compare_mask_ir.
  • Container (native_pixel_compare_mask_container): validated compare-wave32-high-write (compiles, no refusal), refused compare-join-after-clear and refused compare-join-after-redefine; the check asserts unproven graphics CNDMASK source in stderr for both. native_pixel_compare_mask_ir also prints ir refused compare-join-after-clear and ir refused compare-join-after-redefine.

Not done in this head: mutation checks for both commits, pigalot's point 3, and compare_scc_unknown after a later s_cmp_*.

AI-Assisted

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Re-review of the delta 53a8f2ab → 2211dac0 (read-only; nothing built or run here). Verdict: no new MUST from me, but not mergeable yet. Leyukaka's CHANGES_REQUESTED review (at ed447c29) and pigalot's (at 53a8f2ab) are both still the recorded state.

Delta: 61df3c5f and 2211dac0 are Leyukaka's 9193f9c4 and 76b760c0. git patch-id --stable gives the same IDs for each pair (f0cfcab5, 3ae05268).

  • Wave32 high-half write (Leyukaka's MUST at 53a8f2ab). The s_mov_b32 pair-break branch is now gated on !stage.wave32. On wave32 s5 is an ordinary register, so s_mov_b32 s5, 0 no longer marks pair 4 broken. The select then goes through UnclaimedMaskRelease and graphics_lane_mask as on main. Control: compare-wave32-high-write, expected to lower.
  • Tracked pair across a control-flow edge (pigalot's blocking 1 and 2). block_entries is filled from graphics_blocks (keys are leader pcs, the same unit as i.pc). compare_masks and broken_compare_masks are cleared at the top of instruction when pc is a block entry, before any tracker or release runs. A join or sibling block therefore reads the pair through the per-edge state, which is main's path, so the map can only add selects within one block. Controls: compare-join-after-clear (pigalot's program) and compare-join-after-redefine, both expected to be UNPROVEN.

Checks at 2211dac0: git merge-tree --write-tree origin/main 2211dac0 exits 0 (main c4b8a41b), and git diff --check exits 0. CI run 46286122842 is green: Windows 100% tests passed out of 82, gfx1013 and Linux Python pass.

SHOULD

  1. Nobody has run the new controls at this head. CI does not run native_pixel_compare_mask_check.py (0 hits for native_pixel_compare_mask or compare-join in the run's log). Leyukaka's 8/8 was at 76b760c0 on a different base (main 5de0b114). Please post native_pixel_compare_mask_(container|ir|warp|hardware) and native_direct_container at 2211dac0. Also post the two mutations Leyukaka listed as not done: dropping !stage.wave32 should red compare-wave32-high-write, and dropping the block-entry clear should red compare-join-after-clear.
  2. Still open from the reviews at 53a8f2ab: pigalot's point 3 (the black-frame result needs a run on the new head) and compare_scc_unknown not being cleared by a later s_cmp_*. If the latter stays out of scope, the PR body should say so.

AI-assisted review.

@Leyukaka Leyukaka 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.

Approve at 2211dac0. Diff reading only; nothing built or run for this pass.

  • My blocking point at 53a8f2ab is resolved: the s_mov_b32 pair-break is gated on !stage.wave32 (src/gfx1013_direct_graphics.inl:2245), with compare-wave32-high-write expecting success. pigalot's points 1-2 are resolved by the block-entry clear of compare_masks / broken_compare_masks (:1683-1686), with compare-join-after-clear and compare-join-after-redefine expecting a refusal.
  • 61df3c5f and 2211dac0 are the two commits I handed back (9193f9c4, 76b760c0): git range-diff reports both pairs as identical.
  • Still open, not mine: pigalot's point 3 (the black-frame result on 53a8f2ab, no run at this head yet), and compare_scc_unknown being cleared only by a uniform combine (it only adds refusals).

@JohnConnorNPC

Copy link
Copy Markdown
Collaborator

Status at 2211dac0 (head unchanged since my 16:54Z re-review; read-only, nothing built or run here). Not merged. Leyukaka has approved 2211dac0, so the only block left is pigalot's CHANGES_REQUESTED at 53a8f2ab. GitHub still reports reviewDecision: CHANGES_REQUESTED / mergeStateStatus: BLOCKED.

  • By my reading, pigalot's blocking points 1 and 2 (tracked pair across a control-flow edge) are covered by the block-entry clear, and compare-join-after-clear / compare-join-after-redefine are the controls for them (see my previous comment). Point 3, the black-frame title run, has not been re-run on this head.
  • git merge-tree --write-tree origin/main 2211dac0 still exits 0 on the new main 26df1826. CI at this head: SUCCESS=3, SKIPPED=2.
  • Still open from my previous comment: nobody has posted the new controls (native_pixel_compare_mask_*, native_direct_container) or the two mutations at this head.

This can merge once pigalot's review is updated or dismissed.

AI-assisted review.

@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Mutations at 2211dac07b58740d1beecf8cfe5975aabb126f44, as asked. Local only. src/gfx1013_direct_graphics.inl was restored after each mutant (git status clean, git diff empty, HEAD unchanged). The 8/8 of the new controls at this head is in #3401 (comment)

Windows test PC (MSVC, --preset dev, -j 1). Same five tests each time: native_direct_container, native_pixel_compare_mask_warp, native_pixel_compare_mask_hardware, native_pixel_compare_mask_container, native_pixel_compare_mask_ir.

Unmutated head, before and after the mutants: 5/5 passed, none skipped. Container: validated compare-wave32-high-write, refused compare-join-after-clear, refused compare-join-after-redefine. IR also ir refused both join cases.

  1. Dropped !stage.wave32 from the s_mov_b32 pair-break, leaving in_compare_tail() && i.name == "s_mov_b32" && i.dst <= 105. 3/5 passed, 2 failed, none skipped.

    • native_pixel_compare_mask_container failed on compare-wave32-high-write: native compute +0x14: compare mask half overwritten.
    • native_direct_container runs the same container_cases() and failed at that case with the same reason.
    • Warp, hardware, and IR still passed.
  2. Replaced the block-entry compare_masks.clear(); / broken_compare_masks.clear(); with comments. 2/5 passed, 3 failed, none skipped.

    • native_pixel_compare_mask_container and native_pixel_compare_mask_ir failed on compare-join-after-clear: the program compiled (empty stderr) instead of unproven graphics CNDMASK source.
    • native_direct_container failed in that same loop on a refusal assert, with empty stderr. The test stops there, so compare-join-after-redefine was not reached on this mutant.
    • compare-wave32-high-write still validated. Warp and hardware still passed.

Not done: pigalot's point 3 (the black-frame title run), and compare_scc_unknown after a later s_cmp_*. Not merging.

AI-Assisted

@pigalot pigalot 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.

Approve at 2211dac0. Retested integrated over main 26df1826 (tree de514147, clean merge, git diff --check clean). This supersedes my changes-requested review on 53a8f2ab.

Earlier blocking findings

  1. Tracked pair across a control-flow edge, wrong select: addressed. The map and the broken set are cleared at every block leader (src/gfx1013_direct_graphics.inl:1683-1686), so a join reads the pair through the per-edge state as on main. My program is now compare-join-after-clear; native_pixel_ir_dump refuses it with native compute +0x24: unproven graphics CNDMASK source, the same refusal as main.
  2. Same cause, invalid IR: addressed. compare-join-after-redefine refuses with native compute +0x20: unproven graphics CNDMASK source.
  3. Title run: addressed. prwatch ran 2211dac0 merged onto the baseline commit af1cab5c (job 52): pass, judged no worse than the baseline.

The wave32 gate on the s_mov_b32 pair-break (:2245) is right as far as I traced it: on wave32 the odd register is released as an ordinary scalar write, and the select goes back through graphics_lane_mask. compare-wave32-high-write lowers.

I also checked whether compare_scc_unknown, which is still one flag for the whole function, can let a wrong SCC read through across blocks. It cannot in the cases I tried: with a varying combine in the arm emitted first and a uniform combine in the other, a s_cselect_b32 at the join refuses with graphics register undefined on an incoming path: 128, because a varying combine also leaves register 128 empty on its edge. With the arms swapped, or both varying, it refuses with the SCC message. With both uniform it lowers.

Non-blocking

  • Mutant D below survives: no case has a broken pair that crosses an edge. As far as I can see, leaving the broken set uncleared would only add refusals.
  • Still open from the last review: compare_scc_unknown is not cleared by a later s_cmp_* (extra refusals only), the fixed-mesh shader reads a single pixel, and CI does not run the new tests on a pull request.

What I ran

Built dev (full) and release (compile_dxil, offscreen_check, native_pixel_ir_dump, startup_indirect_draw_indexed), then
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^(native_pixel_compare_mask_(warp|container|ir)|native_fixed_mesh57_compare_vcc_warp|native_direct_container|native_fixed_mesh57_mask_warp)$': 6 of 6 passed in Debug and in Release /O2.
native_pixel_compare_mask_hardware and native_fixed_mesh57_compare_vcc_hardware with -j 1 and the debug layer on: 2 of 2 passed in Debug and in Release, no skips.

Mutants of the two new commits in src/gfx1013_direct_graphics.inl, each rebuilt in dev and run against the five non-hardware tests of this PR. The file was restored afterwards, the five tests pass again and git diff --quiet is clean.

  • Killed (6): A !stage.wave32 dropped (_container, native_direct_container); B block-entry clear removed (_ir, _container, native_direct_container); C only the broken set cleared (same three); E block_entries never filled (same three); F clear on every pc that is not a leader (those three and _warp); G wave32 gate inverted (_ir, _container, native_direct_container).
  • Survived (1): D only the mask map cleared, the broken set kept.
  • Equivalent: none.

Mutants A and B are also the negative controls for the three new cases: without each fix the case behaves as it did at 53a8f2ab. The 13 killed and 2 surviving mutants from my review at 53a8f2ab cover lines these two commits do not touch; I did not rerun them.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Python 3.12.10, DXC from Windows SDK 10.0.28000.0, debug layer on for the hardware tests.
CI: Build and test on Windows passes on 2211dac0.

This reply was AI-assisted.

@pigalot
pigalot merged commit 77d63db into R0Y00:main Nov 29, 2026
5 checks passed
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.

5 participants