shader: preserve the direction of dynamic SCC1 mesh branches #2434

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2442 into main 2026-11-25 20:11:33 +00:00
RavenCurseBurg commented 2026-11-25 16:56:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T16:56:29Z.


Fixes #2435.

When a constant-buffer comparison sets SCC, its value is known only at draw time. The bounded mesh lowerer already evaluated both descriptor arms for s_cbranch_scc0. It now does the same for s_cbranch_scc1, selecting the branch target when the predicate is true. Each arm still goes through the existing checks for unsupported instructions and changes to EXEC, VCC or M0.

The fixture reverses the arms and the branch sense together. The two forms produce the same HLSL for a material descriptor and a null descriptor. A new draw selects depth 1.625, clipping the triangle. Picking the other table gives depth 0.5 and covers all 1,024 pixels.

On b442b57f, I measured four failures: for the nonzero selector the SCC1 shader drew all 1,024 pixels on RTX 4060 and WARP, with and without a trace UAV. Both traced runs also reported the wrong vertex exports. The equivalent SCC0 shader passed. With this change all 16 of those comparison draws passed. The expanded tests/mesh_join_descriptor_check.py also passed on both backends (18 matching draws per backend and its existing wrong-index controls). The dynamic mesh, geometry and lane-spill host checks passed.

AI-assisted with Codex + GPT-6.2 Astra (xhigh).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6609438678 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T16:56:29Z. --- Fixes #2435. When a constant-buffer comparison sets SCC, its value is known only at draw time. The bounded mesh lowerer already evaluated both descriptor arms for `s_cbranch_scc0`. It now does the same for `s_cbranch_scc1`, selecting the branch target when the predicate is true. Each arm still goes through the existing checks for unsupported instructions and changes to EXEC, VCC or M0. The fixture reverses the arms and the branch sense together. The two forms produce the same HLSL for a material descriptor and a null descriptor. A new draw selects depth 1.625, clipping the triangle. Picking the other table gives depth 0.5 and covers all 1,024 pixels. On `b442b57f`, I measured four failures: for the nonzero selector the SCC1 shader drew all 1,024 pixels on RTX 4060 and WARP, with and without a trace UAV. Both traced runs also reported the wrong vertex exports. The equivalent SCC0 shader passed. With this change all 16 of those comparison draws passed. The expanded `tests/mesh_join_descriptor_check.py` also passed on both backends (18 matching draws per backend and its existing wrong-index controls). The dynamic mesh, geometry and lane-spill host checks passed. AI-assisted with Codex + GPT-6.2 Astra (xhigh).
tedin7 commented 2026-11-25 19:03:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:25:23Z.

Review: COMMENTED


Review of head 6e90807e. No blocking findings.

What I checked:

  • join_arms runs the fall-through arm first, then the taken arm. For s_cbranch_scc0 that is (true, false). For s_cbranch_scc1 the taken arm is the true one, so reversing the outcomes is correct.
  • The only caller is the dispatch at tools/mesh_entry_aot.py:765. Removing the unused offset argument is safe.
  • Each arm still goes through the same checks for unsupported instructions and for changes to EXEC, VCC or M0. The new test covers the refusal on the SCC1 form.
  • The new fixture swaps the arms and the branch sense together, and it asserts the HLSL is identical to the SCC0 form (also for the null descriptor). That would catch a wrong-way select.
  • I found no open or merged PR covering the same change. The change is small and additive, with no changes to CI, the launcher or hooks.

Commands run locally (Linux, in a clean worktree):

  • python3 tests/mesh_join_descriptor_check.py -> ok
  • python3 tests/docs_links_check.py -> ok
  • python3 tests/bidi_controls_check.py -> ok
  • git diff --check origin/main...HEAD -> clean
  • Mutation: disabled the branch_on_true reversal. assert build(PER_MATERIAL_SCC1) == source fails as expected. Reverted afterwards.

Not checked: the GPU draw cases (RTX / WARP readback) need Windows. I did not run them here, and I did not see author-posted Windows results tied to this head SHA in the PR comments. The author's description reports them on b442b57f. The branch is 24 commits behind main, so a Windows run on the current head is still needed before merge.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062847460 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442#pullrequestreview-6062847460). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:25:23Z. **Review:** COMMENTED --- Review of head `6e90807e`. No blocking findings. What I checked: - `join_arms` runs the fall-through arm first, then the taken arm. For `s_cbranch_scc0` that is (true, false). For `s_cbranch_scc1` the taken arm is the true one, so reversing the outcomes is correct. - The only caller is the dispatch at `tools/mesh_entry_aot.py:765`. Removing the unused `offset` argument is safe. - Each arm still goes through the same checks for unsupported instructions and for changes to EXEC, VCC or M0. The new test covers the refusal on the SCC1 form. - The new fixture swaps the arms and the branch sense together, and it asserts the HLSL is identical to the SCC0 form (also for the null descriptor). That would catch a wrong-way select. - I found no open or merged PR covering the same change. The change is small and additive, with no changes to CI, the launcher or hooks. Commands run locally (Linux, in a clean worktree): - `python3 tests/mesh_join_descriptor_check.py` -> ok - `python3 tests/docs_links_check.py` -> ok - `python3 tests/bidi_controls_check.py` -> ok - `git diff --check origin/main...HEAD` -> clean - Mutation: disabled the `branch_on_true` reversal. `assert build(PER_MATERIAL_SCC1) == source` fails as expected. Reverted afterwards. Not checked: the GPU draw cases (RTX / WARP readback) need Windows. I did not run them here, and I did not see author-posted Windows results tied to this head SHA in the PR comments. The author's description reports them on `b442b57f`. The branch is 24 commits behind main, so a Windows run on the current head is still needed before merge. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-25 19:04:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:29:46Z.


Five mutations, all caught — the direction of a dynamic scc1 is properly pinned

Baseline: mesh join descriptor lowering and refusals: ok, exit 0.

mutation of join_arms / its one caller result
the outcomes.reverse() dropped (an scc1 join built like scc0) caught
the reverse inverted (if not branch_on_true) caught
s_cbranch_scc1 no longer routed to the dynamic join caught
branch_on_true hard-wired False caught
branch_on_true hard-wired True caught

The two hard-wired variants are the ones I most wanted to see: a boolean parameter that is only ever passed one value at a call site is invisible to most fixtures, and here both constants are caught, so the parameter is genuinely exercised in both directions.

What the change gets right, and why the comment matters

# Outcomes are in fall-through, taken order. Select needs true, false.
if branch_on_true:
    outcomes.reverse()

select(c, a, b) takes the condition's true arm first, while the join collects arms in fall-through-then-taken order — so for s_cbranch_scc1 the two are already swapped relative to the condition's meaning, and for scc0 they are not. Collapsing that into one comment on the parameter is the right place, because the mistake is not in the reversal itself but in which branch needs it. The inverted-reverse mutation being caught confirms the fixture distinguishes the two, rather than merely asserting "a select appears".

One note on naming: branch_on_true reads as "the branch is taken when the condition is true", which is exactly what it means for op == "s_cbranch_scc1". Good as is; I mention it only because a reader who has the ISA's "SCC1 branches when SCC is 1" in mind may briefly read it as "the branch condition is the true arm", which is the opposite thing the reverse handles.

What I checked beyond the diff

tests/mesh_join_descriptor_check.py grows by 12 lines and the docs entry by 3 — the refusal side is unchanged, which matches a change that only reorders arms. Both scc0 and scc1 dynamic joins are now covered where previously only scc0 reached the dynamic path (the elif gained the second opcode), so the fixture had to grow in exactly that place; that it did is the reason the third mutation is caught.

AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7170986206 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442#issuecomment-7170986206). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-25T18:29:46Z. --- ## Five mutations, all caught — the direction of a dynamic `scc1` is properly pinned Baseline: `mesh join descriptor lowering and refusals: ok`, exit 0. | mutation of `join_arms` / its one caller | result | |---|---| | the `outcomes.reverse()` dropped (an `scc1` join built like `scc0`) | **caught** | | the reverse inverted (`if not branch_on_true`) | **caught** | | `s_cbranch_scc1` no longer routed to the dynamic join | **caught** | | `branch_on_true` hard-wired `False` | **caught** | | `branch_on_true` hard-wired `True` | **caught** | The two hard-wired variants are the ones I most wanted to see: a boolean parameter that is only ever passed one value at a call site is invisible to most fixtures, and here both constants are caught, so the parameter is genuinely exercised in both directions. ## What the change gets right, and why the comment matters ```python # Outcomes are in fall-through, taken order. Select needs true, false. if branch_on_true: outcomes.reverse() ``` `select(c, a, b)` takes the condition's **true** arm first, while the join collects arms in fall-through-then-taken order — so for `s_cbranch_scc1` the two are already swapped relative to the condition's meaning, and for `scc0` they are not. Collapsing that into one comment on the parameter is the right place, because the mistake is not in the reversal itself but in *which* branch needs it. The inverted-reverse mutation being caught confirms the fixture distinguishes the two, rather than merely asserting "a `select` appears". One note on naming: `branch_on_true` reads as "the branch is taken when the condition is true", which is exactly what it means for `op == "s_cbranch_scc1"`. Good as is; I mention it only because a reader who has the ISA's "SCC1 branches when SCC is 1" in mind may briefly read it as "the branch condition is the true arm", which is the opposite thing the reverse handles. ## What I checked beyond the diff `tests/mesh_join_descriptor_check.py` grows by 12 lines and the docs entry by 3 — the refusal side is unchanged, which matches a change that only reorders arms. Both `scc0` and `scc1` dynamic joins are now covered where previously only `scc0` reached the dynamic path (the `elif` gained the second opcode), so the fixture had to grow in exactly that place; that it did is the reason the third mutation is caught. AI-assisted; the five mutations were run locally on Windows 11 build 26300.9974.
RavenCurseBurg commented 2026-11-25 19:04:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-25T18:48:17Z.


I reran the GPU checks at 6e90807ebf5c0eea3391d3f5edc73f66df871bf1, the exact head reviewed here. Windows Server 2025 WARP passed ctest --preset dev -V --no-tests=error -R '^mesh_join_descriptor_warp$' and the same command with --preset release, after building offscreen_check in each configuration. Each preset recorded 18 matching 1,024-pixel images. Build and CTest logs.

On Windows 11 build 26100.9711, the same checkout also passed python -B tests/mesh_join_descriptor_check.py <dxc> <offscreen_check> hardware on RTX 4060 (32.0.15.9579) and the warp invocation on WARP 10.0.26100.9711. Each returned 0 with all 18 images matching. The local debug layer was unavailable.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171422960 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442#issuecomment-7171422960). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-25T18:48:17Z. --- I reran the GPU checks at `6e90807ebf5c0eea3391d3f5edc73f66df871bf1`, the exact head reviewed here. Windows Server 2025 WARP passed `ctest --preset dev -V --no-tests=error -R '^mesh_join_descriptor_warp$'` and the same command with `--preset release`, after building `offscreen_check` in each configuration. Each preset recorded 18 matching 1,024-pixel images. [Build and CTest logs](https://github.com/RavenCurseBurg/Xbox2Windows/actions/runs/45677390608). On Windows 11 build 26100.9711, the same checkout also passed `python -B tests/mesh_join_descriptor_check.py <dxc> <offscreen_check> hardware` on RTX 4060 (32.0.15.9579) and the `warp` invocation on WARP 10.0.26100.9711. Each returned 0 with all 18 images matching. The local debug layer was unavailable.
upstream-sync closed this pull request 2026-11-25 21:00:58 +00:00
tedin7 commented 2026-11-25 21:00:58 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:07:32Z.

Review: COMMENTED


Review of head c9fc20ee (main merged in, PR's own diff unchanged).

Findings: none blocking.

  • join_arms takes outcomes in fall-through/taken order and reverses them for s_cbranch_scc1, so the select is (true, false) as before. s_cbranch_scc1 goes through the same EXEC/VCC/M0 checks as scc0 (new refusal case in the check).
  • The new test reverses the arms and the branch sense together and requires identical HLSL to the scc0 form, plus a GPU draw case where the wrong arm gives depth 1.625 (clipped) vs 0.5 (covered).
  • Sibling callsite: the only caller of join_arms is the scc0/scc1 branch in exec_range; no other table or opcode list needed an edit.

Commands run in a worktree at c9fc20ee:

  • python3 tests/mesh_join_descriptor_check.py -> ok
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD -> pass
  • Mutation 1 (disable the outcome reversal for scc1) -> check fails (AssertionError)
  • Mutation 2 (dispatch only scc0 again) -> check fails (AssertionError)

This does not claim to advance game startup; no executable results are claimed. Win2025 WARP receipt follows separately.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064226975 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442#pullrequestreview-6064226975). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:07:32Z. **Review:** COMMENTED --- Review of head c9fc20ee (main merged in, PR's own diff unchanged). Findings: none blocking. - `join_arms` takes outcomes in fall-through/taken order and reverses them for `s_cbranch_scc1`, so the select is (true, false) as before. `s_cbranch_scc1` goes through the same EXEC/VCC/M0 checks as scc0 (new refusal case in the check). - The new test reverses the arms and the branch sense together and requires identical HLSL to the scc0 form, plus a GPU draw case where the wrong arm gives depth 1.625 (clipped) vs 0.5 (covered). - Sibling callsite: the only caller of `join_arms` is the scc0/scc1 branch in `exec_range`; no other table or opcode list needed an edit. Commands run in a worktree at c9fc20ee: - `python3 tests/mesh_join_descriptor_check.py` -> ok - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD` -> pass - Mutation 1 (disable the outcome reversal for scc1) -> check fails (AssertionError) - Mutation 2 (dispatch only scc0 again) -> check fails (AssertionError) This does not claim to advance game startup; no executable results are claimed. Win2025 WARP receipt follows separately. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:01:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:11:22Z.


Win2025 WARP receipt for head c9fc20ee after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit c9fc20ee475d85f5176c80d089485b3b6d13f3ec:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset dev -R '^mesh_join_descriptor_' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (3.03s: mesh_join_descriptor_hardware 2.78s, mesh_join_descriptor_warp 2.82s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 0.00s (configure 0.00s)
    • Test (ctest --preset release -R '^mesh_join_descriptor_' --parallel 2 --no-tests=error --output-on-failure): 2/2 passed (3.06s: mesh_join_descriptor_hardware 2.81s, mesh_join_descriptor_warp 2.87s)
  • Windows Python checks: tests/mesh_clip_cull_check.py ok (8.4s), tests/mesh_dynamic_aot_check.py ok (1.6s), tests/mesh_dynamic_geometry_check.py ok (0.4s), tests/mesh_join_descriptor_check.py ok (0.5s), tests/mesh_lane_spill_check.py ok (0.3s), tests/startup_ngg_slice_check.py ok (0.6s)
  • sccache: 0/14 hits; wall 25.3s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173310392 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2442#issuecomment-7173310392). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:11:22Z. --- Win2025 WARP receipt for head c9fc20ee after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `c9fc20ee475d85f5176c80d089485b3b6d13f3ec`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset dev -R '^mesh_join_descriptor_' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`3.03s`: `mesh_join_descriptor_hardware` `2.78s`, `mesh_join_descriptor_warp` `2.82s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `0.00s` (configure `0.00s`) - Test (`ctest --preset release -R '^mesh_join_descriptor_' --parallel 2 --no-tests=error --output-on-failure`): **2/2 passed** (`3.06s`: `mesh_join_descriptor_hardware` `2.81s`, `mesh_join_descriptor_warp` `2.87s`) - **Windows Python checks**: `tests/mesh_clip_cull_check.py` ok (`8.4s`), `tests/mesh_dynamic_aot_check.py` ok (`1.6s`), `tests/mesh_dynamic_geometry_check.py` ok (`0.4s`), `tests/mesh_join_descriptor_check.py` ok (`0.5s`), `tests/mesh_lane_spill_check.py` ok (`0.3s`), `tests/startup_ngg_slice_check.py` ok (`0.6s`) - `sccache`: 0/14 hits; wall `25.3s` AI-assisted; commands listed were executed locally.
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!2434
No description provided.