shader: draw a per-vertex VCC across a vertex-stage join (Refs #2906) #2914

Merged
Not-Saii merged 3 commits from upstream-pr/2914 into cpp-migration 2026-11-26 21:18:03 +00:00
Not-Saii commented 2026-11-26 19:32:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-26T19:32:59Z.


Refs #2906. Part of #870 and #2618.

What this adds

A draw fixture for a per-vertex VCC that crosses a two-arm join in a translated gfx1013 vertex stage, registered as native_graphics_vertex_vcc_join_warp and native_graphics_vertex_vcc_join_hardware. No translator change was needed: both shapes below already lower correctly at 40365770.

Two source-built vertex programs are drawn:

  1. Uniform branch, per-arm compare. A root word supplied at draw time picks the arm. Each arm runs its own SV_VertexID compare into VCC and writes its own constant. After the join a CNDMASK selects that constant or 0.5 per vertex. Both branch outcomes are drawn. The test also checks that the emitted IR joins two different compares in a phi that feeds the select.
  2. Per-vertex arms. One compare writes VCC and splits the vertices between THEN and ELSE under saved EXEC. After EXEC is restored a CNDMASK on the same VCC keeps the arm's constant or its negation, so one draw holds both VCC values and both arm values. The frontend lowers these guest arms to per-vertex selects in one block, so this shape has a guest join and no IR join; the IR-level phi is in shape 1.

The pixel stage is desktop HLSL that reads the three vertex values with GetAttributeAtVertex. I chose that so each pixel reports every vertex without interpolation and the comparison with the per-vertex CPU model is bit-exact. If you want a guest PS through gfx1013-container-pair instead, say so and I will rework the readback.

Negative controls

Each control redraws a changed program against the unchanged reference and must report 8 of 8 pixels differ:

  • arm B loses its compare, so that edge carries a stale mask (arm A still passes with the same change);
  • a uniform v0 == v0 compare overwrites the joined mask, for both arms of shape 1 and for shape 2.

Reproduction

cmake --build --preset dev --target compile_dxil offscreen_check
ctest --preset dev --no-tests=error -R '^native_graphics_interface_library$' -V
ctest --preset dev --no-tests=error -R '^native_graphics_vertex_vcc_join_(warp|hardware)$' -V

Result

Revision 95f01361, Windows 11 build 26300, Debug build. Three tests ran, three passed, no capability skips.

Test Adapter Driver Debug layer Result
native_graphics_interface_library none (compile only) Passed
native_graphics_vertex_vcc_join_warp Microsoft Basic Render Driver 10.0.26100.9818 enabled, 0 errors, 0 warnings Passed
native_graphics_vertex_vcc_join_hardware NVIDIA GeForce RTX 4090 32.0.16.1088 enabled, 0 errors, 0 warnings Passed

Output, identical on both adapters:

arm A: vertices 0..2 and arm value matched [0.5, 2.0, 0.5, 2.0]
arm B: vertices 0..2 and arm value matched [4.0, 4.0, 0.5, 4.0]
per-vertex arms: THEN on vertex 1, ELSE on vertices 0 and 2 matched [-4.0, 2.0, -4.0, 4.0]
uniform mask after the per-vertex arms: pixel mismatch (0,0): expected c0800000,40000000,c0800000,40800000 actual 40800000,40000000,40800000,40800000
dropped arm B contribution: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 3f000000,3f000000,40800000,40800000
uniform mask after the join, arm A: pixel mismatch (0,0): expected 3f000000,40000000,3f000000,40000000 actual 40000000,40000000,40000000,40000000
uniform mask after the join, arm B: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 40800000,40800000,40800000,40800000

Limits

  • Branches that need a whole-wave VCC vote are not drawn. A compare inside a per-vertex masked arm is also not drawn, because its VCC on the other lanes depends on the rest of the wave.
  • An adapter without per-vertex attribute support would fail pipeline creation instead of returning 77. I have not seen that on either adapter here.
  • The note is in docs/experiments/native-vertex-vcc-join.md.
  • A passing fixture supports the behavior under test only.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5516058544 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2914). Originally posted by [Not-Saii](https://github.com/Not-Saii) on 2026-11-26T19:32:59Z. --- Refs #2906. Part of #870 and #2618. ## What this adds A draw fixture for a per-vertex VCC that crosses a two-arm join in a translated gfx1013 vertex stage, registered as `native_graphics_vertex_vcc_join_warp` and `native_graphics_vertex_vcc_join_hardware`. No translator change was needed: both shapes below already lower correctly at `40365770`. Two source-built vertex programs are drawn: 1. **Uniform branch, per-arm compare.** A root word supplied at draw time picks the arm. Each arm runs its own `SV_VertexID` compare into VCC and writes its own constant. After the join a CNDMASK selects that constant or 0.5 per vertex. Both branch outcomes are drawn. The test also checks that the emitted IR joins two different compares in a `phi` that feeds the select. 2. **Per-vertex arms.** One compare writes VCC and splits the vertices between THEN and ELSE under saved EXEC. After EXEC is restored a CNDMASK on the same VCC keeps the arm's constant or its negation, so one draw holds both VCC values and both arm values. The frontend lowers these guest arms to per-vertex selects in one block, so this shape has a guest join and no IR join; the IR-level `phi` is in shape 1. The pixel stage is desktop HLSL that reads the three vertex values with `GetAttributeAtVertex`. I chose that so each pixel reports every vertex without interpolation and the comparison with the per-vertex CPU model is bit-exact. If you want a guest PS through `gfx1013-container-pair` instead, say so and I will rework the readback. ## Negative controls Each control redraws a changed program against the unchanged reference and must report `8 of 8 pixels differ`: - arm B loses its compare, so that edge carries a stale mask (arm A still passes with the same change); - a uniform `v0 == v0` compare overwrites the joined mask, for both arms of shape 1 and for shape 2. ## Reproduction ```powershell cmake --build --preset dev --target compile_dxil offscreen_check ctest --preset dev --no-tests=error -R '^native_graphics_interface_library$' -V ctest --preset dev --no-tests=error -R '^native_graphics_vertex_vcc_join_(warp|hardware)$' -V ``` ## Result Revision `95f01361`, Windows 11 build 26300, Debug build. Three tests ran, three passed, no capability skips. | Test | Adapter | Driver | Debug layer | Result | |---|---|---|---|---| | `native_graphics_interface_library` | none (compile only) | | | Passed | | `native_graphics_vertex_vcc_join_warp` | Microsoft Basic Render Driver | 10.0.26100.9818 | enabled, 0 errors, 0 warnings | Passed | | `native_graphics_vertex_vcc_join_hardware` | NVIDIA GeForce RTX 4090 | 32.0.16.1088 | enabled, 0 errors, 0 warnings | Passed | Output, identical on both adapters: ```text arm A: vertices 0..2 and arm value matched [0.5, 2.0, 0.5, 2.0] arm B: vertices 0..2 and arm value matched [4.0, 4.0, 0.5, 4.0] per-vertex arms: THEN on vertex 1, ELSE on vertices 0 and 2 matched [-4.0, 2.0, -4.0, 4.0] uniform mask after the per-vertex arms: pixel mismatch (0,0): expected c0800000,40000000,c0800000,40800000 actual 40800000,40000000,40800000,40800000 dropped arm B contribution: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 3f000000,3f000000,40800000,40800000 uniform mask after the join, arm A: pixel mismatch (0,0): expected 3f000000,40000000,3f000000,40000000 actual 40000000,40000000,40000000,40000000 uniform mask after the join, arm B: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 40800000,40800000,40800000,40800000 ``` ## Limits - Branches that need a whole-wave VCC vote are not drawn. A compare inside a per-vertex masked arm is also not drawn, because its VCC on the other lanes depends on the rest of the wave. - An adapter without per-vertex attribute support would fail pipeline creation instead of returning 77. I have not seen that on either adapter here. - The note is in `docs/experiments/native-vertex-vcc-join.md`. - A passing fixture supports the behavior under test only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MasterDomino commented 2026-11-26 19:41:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T19:41:04Z.

Review: APPROVED


Review of head 95f01361 on cpp-migration 40365770. The PR changes no C++, so I ran its check against a release build of the base.

Encodings: I decoded each hand-written word against the gfx1013 formats, and they match the comments:

  • the v_cmp_{eq,ne}_u32 compares (0x7d040081, 0x7d040082, 0x7d0a0082, and 0x7d040100 for v0 == v0);
  • v_cndmask_b32 with S1 taken on VCC;
  • v_mul_f32 v8, -1.0, v4;
  • s_mov_b32 literal, s_xor_b32 s4, s4, s0, s_cmp_eq_i32 s4, 0, s_cbranch_scc0 +3, s_branch +2;
  • s_and_saveexec_b64 s[8:9], vcc, s_cbranch_execz, s_andn2_b64 exec, s[8:9], exec, s_mov_b64 exec, s[8:9];
  • the POS0 and PARAM0 exports.

The branch offsets land on the commented instructions, and reference() and the per-vertex table follow from them. The controls fit the claim. Dropping arm B's compare leaves the stale id == 2 mask on that edge only, and arm A still passes. The uniform v0 == v0 overwrite differs at all 8 pixels in all three places.

Run: Windows 11 build 26300.9974, release preset, Windows SDK 10.0.26100 DXC.

  • WARP (Microsoft Basic Render Driver 10.0.26100.9818, debug layer on, 0 errors, 0 warnings): passed. The output matches the PR description line for line, including all four control mismatch lines.
  • AMD Radeon RX 9070 XT, driver 32.0.32029.2010: fails on the first draw. offscreen_check.exe exits 0xC0000005 with no output. This is the same crash class as #2915, where 6 of the base branch's native_*_hardware tests crash this way on this adapter, native_graphics_wqm_hardware through the same offscreen_check path among them. native_buffered_vertex_hardware and native_sampled_pixel_hardware pass here. So this is not caused by this PR, but native_graphics_vertex_vcc_join_hardware will fail on AMD until #2915 is understood.

Checks: docs_links_check passed (30 files, 546 links), bidi_controls_check passed and git diff --check is clean. The fragment and the topic note follow tests/cmake/README.md and docs/experiments/README.md.

Nit: the description and the note say a root word supplied at draw time picks the arm. In program() the arm is the literal from int(arm_b), and it is XORed with s0, which the harness supplies as 0. So the root word keeps the branch from being known at compile time, but the literal picks the arm. One sentence would fix this. Not blocking.

CI: .github/workflows/windows.yml runs only for pull requests into main, so this PR has no CI result. The evidence is the local runs above and @Not-Saii's.

AI-assisted; the commands above were run locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6079666072 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2914#pullrequestreview-6079666072). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T19:41:04Z. **Review:** APPROVED --- Review of head `95f01361` on `cpp-migration` `40365770`. The PR changes no C++, so I ran its check against a release build of the base. **Encodings:** I decoded each hand-written word against the gfx1013 formats, and they match the comments: - the `v_cmp_{eq,ne}_u32` compares (`0x7d040081`, `0x7d040082`, `0x7d0a0082`, and `0x7d040100` for `v0 == v0`); - `v_cndmask_b32` with `S1` taken on VCC; - `v_mul_f32 v8, -1.0, v4`; - `s_mov_b32` literal, `s_xor_b32 s4, s4, s0`, `s_cmp_eq_i32 s4, 0`, `s_cbranch_scc0 +3`, `s_branch +2`; - `s_and_saveexec_b64 s[8:9], vcc`, `s_cbranch_execz`, `s_andn2_b64 exec, s[8:9], exec`, `s_mov_b64 exec, s[8:9]`; - the POS0 and PARAM0 exports. The branch offsets land on the commented instructions, and `reference()` and the per-vertex table follow from them. The controls fit the claim. Dropping arm B's compare leaves the stale `id == 2` mask on that edge only, and arm A still passes. The uniform `v0 == v0` overwrite differs at all 8 pixels in all three places. **Run:** Windows 11 build 26300.9974, release preset, Windows SDK 10.0.26100 DXC. - WARP (Microsoft Basic Render Driver 10.0.26100.9818, debug layer on, 0 errors, 0 warnings): passed. The output matches the PR description line for line, including all four control mismatch lines. - AMD Radeon RX 9070 XT, driver 32.0.32029.2010: fails on the first draw. `offscreen_check.exe` exits `0xC0000005` with no output. This is the same crash class as #2915, where 6 of the base branch's `native_*_hardware` tests crash this way on this adapter, `native_graphics_wqm_hardware` through the same `offscreen_check` path among them. `native_buffered_vertex_hardware` and `native_sampled_pixel_hardware` pass here. So this is not caused by this PR, but `native_graphics_vertex_vcc_join_hardware` will fail on AMD until #2915 is understood. **Checks:** `docs_links_check` passed (30 files, 546 links), `bidi_controls_check` passed and `git diff --check` is clean. The fragment and the topic note follow `tests/cmake/README.md` and `docs/experiments/README.md`. **Nit:** the description and the note say a root word supplied at draw time picks the arm. In `program()` the arm is the literal from `int(arm_b)`, and it is XORed with `s0`, which the harness supplies as 0. So the root word keeps the branch from being known at compile time, but the literal picks the arm. One sentence would fix this. Not blocking. **CI:** `.github/workflows/windows.yml` runs only for pull requests into `main`, so this PR has no CI result. The evidence is the local runs above and @Not-Saii's. AI-assisted; the commands above were run locally.
KelboLive commented 2026-11-26 20:58:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-26T20:58:26Z.

Review: COMMENTED


Test + doc only — no source changes. The fixture tests per-vertex VCC crossing a two-arm join in the direct DXIL frontend.

The test fixture covers three scenarios nicely:

  • Standard join where both arms contribute their own per-vertex compare to a phi node
  • Lane-split variant where the compare itself splits the wave and the frontend lowers arms to per-vertex selects
  • Uniform mask insertion after the join to verify it overwrites the joined mask

The control cases are well-structured: dropping arm B's compare to check stale mask propagation, and inserting a uniform v0==v0 compare to verify mask overwrite. The IR verification via dxc -dumpbin phi/select checks is a nice touch — it ensures the frontend emits the expected structure rather than relying on a @dx.op.wave directive.

One small note: the native_direct_container_check and native_scalar_lds_check imports suggest this shares infrastructure with other native tests. That's good for consistency. If the DXIL frontend gets a native_vertex_vcc_join variant, those tests could be reused with a different container format. Otherwise no concerns.

Looks ready.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6080413369 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2914#pullrequestreview-6080413369). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-26T20:58:26Z. **Review:** COMMENTED --- Test + doc only — no source changes. The fixture tests per-vertex VCC crossing a two-arm join in the direct DXIL frontend. The test fixture covers three scenarios nicely: - Standard join where both arms contribute their own per-vertex compare to a phi node - Lane-split variant where the compare itself splits the wave and the frontend lowers arms to per-vertex selects - Uniform mask insertion after the join to verify it overwrites the joined mask The control cases are well-structured: dropping arm B's compare to check stale mask propagation, and inserting a uniform v0==v0 compare to verify mask overwrite. The IR verification via dxc -dumpbin phi/select checks is a nice touch — it ensures the frontend emits the expected structure rather than relying on a @dx.op.wave directive. One small note: the `native_direct_container_check` and `native_scalar_lds_check` imports suggest this shares infrastructure with other native tests. That's good for consistency. If the DXIL frontend gets a `native_vertex_vcc_join` variant, those tests could be reused with a different container format. Otherwise no concerns. Looks ready.
MasterDomino commented 2026-11-26 21:17:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T21:17:58Z.


hand merging under my own discretion for us to further the work while Royoo is out.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7203590122 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2914#issuecomment-7203590122). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-26T21:17:58Z. --- hand merging under my own discretion for us to further the work while Royoo is out.
SimSalabimse commented 2026-11-26 22:18:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-26T22:18:24Z.


Hardware and WARP result for head 95f013614f1a9481be4772a7d7723f61bff7ae28 (base 40365770): both native_graphics_vertex_vcc_join tests pass on an RTX 4070 Ti and on WARP, and every negative control is detected.

Environment: Windows 11 25H2 (26200), MSVC 19.42, Windows SDK 10.0.26100 DXC, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). WARP is Microsoft Basic Render Driver 10.0.26100.8521. Clean worktree at the PR head, fresh out/pe-env, dev preset (Debug, so the D3D12 debug layer is on). Tests run serially.

Commands

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^native_graphics_vertex_vcc_join_(warp|hardware)$" -V --output-on-failure -j 1 --timeout 300
ctest --preset dev --no-tests=error -R "^native_graphics_interface_library$" --output-on-failure -j 1 --timeout 300

Result (measured, 2 runs, same both times): 2 tests: 2 passed, 0 failed, 0 skipped. ctest exit 0 both times. native_graphics_interface_library also passed once (exit 0).

Test Adapter Driver Debug layer Result
native_graphics_vertex_vcc_join_warp Microsoft Basic Render Driver 10.0.26100.8521 enabled, 0 errors, 0 warnings Passed (1.06 s, 0.86 s)
native_graphics_vertex_vcc_join_hardware NVIDIA GeForce RTX 4070 Ti 32.0.16.2135 enabled, 0 errors, 0 warnings Passed (2.85 s, 2.70 s)

Output, identical on both adapters and in both runs:

arm A: vertices 0..2 and arm value matched [0.5, 2.0, 0.5, 2.0]
arm B: vertices 0..2 and arm value matched [4.0, 4.0, 0.5, 4.0]
per-vertex arms: THEN on vertex 1, ELSE on vertices 0 and 2 matched [-4.0, 2.0, -4.0, 4.0]
uniform mask after the per-vertex arms: pixel mismatch (0,0): expected c0800000,40000000,c0800000,40800000 actual 40800000,40000000,40800000,40800000
dropped arm B contribution: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 3f000000,3f000000,40800000,40800000
uniform mask after the join, arm A: pixel mismatch (0,0): expected 3f000000,40000000,3f000000,40000000 actual 40000000,40000000,40000000,40000000
uniform mask after the join, arm B: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 40800000,40800000,40800000,40800000

Control: The fixture does not exist at 40365770, so there is no base run. Its own four negative controls ran inside each test and all four were detected (each must report 8 of 8 pixels differ, and the test only passes if they do): the uniform mask after the per-vertex arms, the dropped arm B contribution, and the uniform mask after the join for arm A and for arm B.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7204556112 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2914#issuecomment-7204556112). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-26T22:18:24Z. --- Hardware and WARP result for head `95f013614f1a9481be4772a7d7723f61bff7ae28` (base `40365770`): both `native_graphics_vertex_vcc_join` tests pass on an RTX 4070 Ti and on WARP, and every negative control is detected. **Environment:** Windows 11 25H2 (26200), MSVC 19.42, Windows SDK 10.0.26100 DXC, NVIDIA GeForce RTX 4070 Ti, driver 621.35 (32.0.16.2135). WARP is Microsoft Basic Render Driver 10.0.26100.8521. Clean worktree at the PR head, fresh `out/pe-env`, `dev` preset (Debug, so the D3D12 debug layer is on). Tests run serially. **Commands** ``` cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R "^native_graphics_vertex_vcc_join_(warp|hardware)$" -V --output-on-failure -j 1 --timeout 300 ctest --preset dev --no-tests=error -R "^native_graphics_interface_library$" --output-on-failure -j 1 --timeout 300 ``` **Result (measured, 2 runs, same both times):** 2 tests: 2 passed, 0 failed, 0 skipped. ctest exit 0 both times. `native_graphics_interface_library` also passed once (exit 0). | Test | Adapter | Driver | Debug layer | Result | |---|---|---|---|---| | `native_graphics_vertex_vcc_join_warp` | Microsoft Basic Render Driver | 10.0.26100.8521 | enabled, 0 errors, 0 warnings | Passed (1.06 s, 0.86 s) | | `native_graphics_vertex_vcc_join_hardware` | NVIDIA GeForce RTX 4070 Ti | 32.0.16.2135 | enabled, 0 errors, 0 warnings | Passed (2.85 s, 2.70 s) | Output, identical on both adapters and in both runs: ``` arm A: vertices 0..2 and arm value matched [0.5, 2.0, 0.5, 2.0] arm B: vertices 0..2 and arm value matched [4.0, 4.0, 0.5, 4.0] per-vertex arms: THEN on vertex 1, ELSE on vertices 0 and 2 matched [-4.0, 2.0, -4.0, 4.0] uniform mask after the per-vertex arms: pixel mismatch (0,0): expected c0800000,40000000,c0800000,40800000 actual 40800000,40000000,40800000,40800000 dropped arm B contribution: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 3f000000,3f000000,40800000,40800000 uniform mask after the join, arm A: pixel mismatch (0,0): expected 3f000000,40000000,3f000000,40000000 actual 40000000,40000000,40000000,40000000 uniform mask after the join, arm B: pixel mismatch (0,0): expected 40800000,40800000,3f000000,40800000 actual 40800000,40800000,40800000,40800000 ``` **Control:** The fixture does not exist at `40365770`, so there is no base run. Its own four negative controls ran inside each test and all four were detected (each must report 8 of 8 pixels differ, and the test only passes if they do): the uniform mask after the per-vertex arms, the dropped arm B contribution, and the uniform mask after the join for arm A and for arm B. AI-Assisted
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2914
No description provided.