Recompiler: geometry mode's ES s_setpc_b64 ends a block before gs_start (#1360) #1365

Closed
tiagonogueiraa-bit wants to merge 1 commit from upstream-pr/1375 into main
tiagonogueiraa-bit commented 2026-11-24 15:22:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T15:22:16Z.


In geometry mode the ES hands over to the GS with an s_setpc_b64 that has no resolved target. term() took it for a fall-through, and edges had no ES → GS edge. So with branches in the ES or GS, structured_span merged the ES's last block and the first GS blocks into one stretch, dropped the s_setpc flow, and gave gs_start no pc block. In split wave64 the ES phase ran on into the GS code before the barrier, and the GS phase (xcl_entry_pc = gs_start) matched no block and emitted nothing. Fixes #1360.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs:
    • term(): an indirect branch without a known target ends its block (Term::Other), as other terminators do.
    • edges gets the ES → GS edge.
  • crates/xcl/src/gpu/recomp/tests.rs: geometry_es_setpc_ends_a_block_before_gs_start (CPU only) translates the issue's ES + GS with a branch in the GS, native and split wave64. It checks for a pc block at gs_start and the ES phase's select(xcl_es_phase, …) jump.

Tested

  • macOS, Rust stable: cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc passes (C code stubbed, nothing linked).
  • CPU translation with gpu::recomp built on its own (macOS), not a GPU run:
    • The test's program: on main, neither form has a pc block at gs_start; with this change, both do.
    • Every program of the retail pack's shaders.rpf: 5 of 8 158 change, all completely translated before and after. They are ES variants of one VS (VS_VoxelizeGeneric_*) ending in s_setpc_b64: they now end there instead of falling into their s_endpgm block, with one more pc block boundary.
  • @GonZiin, native Windows, RX 9070 XT, on this head 63ad831: geometry_es_setpc_ends_a_block_before_gs_start and #1528's multi_block_es_gs_treats_s_setpc_as_terminator_and_tracks_handoff_edge both pass. cargo test -p xcl --lib gpu_geometry passes 2 tests with no GPU skips. (review)
  • @DavidM1911, RTX 3060 Ti, Windows 11, merged with main: cargo test -p xcl --lib, all passed. (report)
  • The full workspace suite on native Windows: not run yet.

Regression run
Not run. I have no Windows machine here.

Not tested

  • GPU runs of geometry-mode programs: the existing gpu_geometry_mode_es_gs_strip and the two wave32 geometry tests, on any adapter.
  • A retail title.

AI use

  • Claude Code with Claude Opus 5.5. It reproduced the issue on the CPU, wrote the change, the test and this description, and ran the macOS checks.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5475044611 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T15:22:16Z. --- In geometry mode the ES hands over to the GS with an `s_setpc_b64` that has no resolved target. `term()` took it for a fall-through, and `edges` had no ES → GS edge. So with branches in the ES or GS, `structured_span` merged the ES's last block and the first GS blocks into one stretch, dropped the `s_setpc` flow, and gave `gs_start` no `pc` block. In split wave64 the ES phase ran on into the GS code before the barrier, and the GS phase (`xcl_entry_pc = gs_start`) matched no block and emitted nothing. Fixes #1360. **What is in it** - `crates/xcl/src/gpu/recomp/mod.rs`: - `term()`: an indirect branch without a known target ends its block (`Term::Other`), as other terminators do. - `edges` gets the ES → GS edge. - `crates/xcl/src/gpu/recomp/tests.rs`: `geometry_es_setpc_ends_a_block_before_gs_start` (CPU only) translates the issue's ES + GS with a branch in the GS, native and split wave64. It checks for a `pc` block at `gs_start` and the ES phase's `select(xcl_es_phase, …)` jump. **Tested** - macOS, Rust stable: `cargo check -p xcl --lib --tests --target x86_64-pc-windows-msvc` passes (C code stubbed, nothing linked). - CPU translation with `gpu::recomp` built on its own (macOS), not a GPU run: - The test's program: on `main`, neither form has a `pc` block at `gs_start`; with this change, both do. - Every program of the retail pack's `shaders.rpf`: 5 of 8 158 change, all completely translated before and after. They are ES variants of one VS (`VS_VoxelizeGeneric_*`) ending in `s_setpc_b64`: they now end there instead of falling into their `s_endpgm` block, with one more `pc` block boundary. - @GonZiin, native Windows, RX 9070 XT, on this head `63ad831`: `geometry_es_setpc_ends_a_block_before_gs_start` and #1528's `multi_block_es_gs_treats_s_setpc_as_terminator_and_tracks_handoff_edge` both pass. `cargo test -p xcl --lib gpu_geometry` passes 2 tests with no GPU skips. ([review](https://github.com/xcl-dev/xcl/pull/1375#pullrequestreview-6044700277)) - @DavidM1911, RTX 3060 Ti, Windows 11, merged with `main`: `cargo test -p xcl --lib`, all passed. ([report](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7138068516)) - The full workspace suite on native Windows: not run yet. **Regression run** Not run. I have no Windows machine here. **Not tested** - GPU runs of geometry-mode programs: the existing `gpu_geometry_mode_es_gs_strip` and the two wave32 geometry tests, on any adapter. - A retail title. **AI use** - Claude Code with Claude Opus 5.5. It reproduced the issue on the CPU, wrote the change, the test and this description, and ran the macOS checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
DavidM1911 commented 2026-11-24 17:06:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:41:53Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7138068516 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1375#issuecomment-7138068516). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:41:53Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. Thanks!
GonZiin commented 2026-11-24 18:04:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by GonZiin on 2026-11-24T18:04:24Z.

Review: COMMENTED


I ran the two competing fixes for #1360 against each other's regression tests. Both implementations pass both fixtures. They also pass the same two geometry GPU tests on the RX 9070 XT. The results support keeping one PR for the ES-to-GS handoff, with both regression fixtures. #1375 is the smaller implementation and a reasonable branch to consolidate into.

Tested

  • Windows 11 Pro 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), Rust 1.100.0 MSVC, SDK DXC 1.8.2502.11, debug. Used XCL_ADAPTER=RX 9070 XT and XCL_REQUIRE_GPU=wave64,mesh.
  • On each of #1375 63ad831c2147fcfada4e6247a2869106aa302644 and #1528 c04e60f2ab6f49eab2b349f4a353e24107749407, ran cargo test -p xcl --lib <filter> -- --test-threads=1 with the filters geometry_es_setpc_ends_a_block_before_gs_start and multi_block_es_gs_treats_s_setpc_as_terminator_and_tracks_handoff_edge. I copied only the other branch's fixture for each cross-check. Each command reported 1 passed, 0 failed and 0 ignored.
  • cargo test -p xcl --lib gpu_geometry -- --test-threads=1 on each clean head reported 2 passed, 0 failed, 0 ignored and 0 GPU skips.
  • Linux git merge-tree --write-tree combined each branch separately with main at 9e3831e without conflicts. Combining the two PR branches with each other conflicts in gpu/recomp/mod.rs.

Not tested

Full workspace, NVIDIA, and retail titles. These tests do not establish equivalence on all geometry shaders.

AI use

Codex (gpt-6.2-sol) compared the implementations, ran the tests and drafted this review.

<!-- greyfinch-sync:ivall/xcl:review:6044700277 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#pullrequestreview-6044700277). Originally posted by [GonZiin](https://github.com/GonZiin) on 2026-11-24T18:04:24Z. **Review:** COMMENTED --- I ran the two competing fixes for #1360 against each other's regression tests. Both implementations pass both fixtures. They also pass the same two geometry GPU tests on the RX 9070 XT. The results support keeping one PR for the ES-to-GS handoff, with both regression fixtures. #1375 is the smaller implementation and a reasonable branch to consolidate into. **Tested** - Windows 11 Pro 26300, Ryzen 7 7800X3D, Radeon RX 9070 XT (driver 32.0.32029.2010), Rust 1.100.0 MSVC, SDK DXC 1.8.2502.11, debug. Used `XCL_ADAPTER=RX 9070 XT` and `XCL_REQUIRE_GPU=wave64,mesh`. - On each of #1375 `63ad831c2147fcfada4e6247a2869106aa302644` and #1528 `c04e60f2ab6f49eab2b349f4a353e24107749407`, ran `cargo test -p xcl --lib <filter> -- --test-threads=1` with the filters `geometry_es_setpc_ends_a_block_before_gs_start` and `multi_block_es_gs_treats_s_setpc_as_terminator_and_tracks_handoff_edge`. I copied only the other branch's fixture for each cross-check. Each command reported 1 passed, 0 failed and 0 ignored. - `cargo test -p xcl --lib gpu_geometry -- --test-threads=1` on each clean head reported 2 passed, 0 failed, 0 ignored and 0 GPU skips. - Linux `git merge-tree --write-tree` combined each branch separately with `main` at `9e3831e` without conflicts. Combining the two PR branches with each other conflicts in `gpu/recomp/mod.rs`. **Not tested** Full workspace, NVIDIA, and retail titles. These tests do not establish equivalence on all geometry shaders. **AI use** Codex (`gpt-6.2-sol`) compared the implementations, ran the tests and drafted this review.
tiagonogueiraa-bit commented 2026-11-24 21:08:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T19:23:03Z.


Thank you, @GonZiin, for checking both fixtures against both implementations. That's in Tested, along with @DavidM1911's run, and the PR is ready for review. #1375 came first (15:22 vs 17:17 UTC). If the maintainer wants #1528's fixture here too, I'm happy to add it with @OtavioTadeu credited.

Written with Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:ivall/xcl:comment:7142018088 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7142018088). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T19:23:03Z. --- Thank you, @GonZiin, for checking both fixtures against both implementations. That's in **Tested**, along with @DavidM1911's run, and the PR is ready for review. #1375 came first (15:22 vs 17:17 UTC). If the maintainer wants #1528's fixture here too, I'm happy to add it with @OtavioTadeu credited. Written with Claude Code (Claude Opus 5.5).
Mischief8713 commented 2026-11-24 21:09:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Mischief8713 on 2026-11-24T20:36:49Z.


GPU run of 63ad831 on Windows (NVIDIA GTX 1660 Ti, Turing): 708 passed, 0 failed, 21 ignored

Tested

  • NVIDIA GeForce GTX 1660 Ti 6 GB (Turing, driver 32.0.16.2114), Ryzen 5 2600X, Windows 11 (10.0.26300), rustc 1.100.0, debug build
  • cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4; build exit 0, test exit 0
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64)
  • The head does not contain current main (9039900). It was run as it is.
  • lib: 708 passed, 0 failed, 21 ignored.
  • gpu::recomp::tests::gpu_geometry_mode_es_gs_strip ran on the GPU and passed (this GPU has mesh shaders). The other geometry tests passed: geometry_es_setpc_ends_a_block_before_gs_start, geometry_wave32_rejects_cross_half_operations, geometry_wave_path_selection_preserves_native_wave64, and the e2e retail_es_gs_voxelize_geometry_mode. gpu_geometry_wave32_prefix_count_over_a_mask printed SKIPPED (no wave64).

Not tested

  • No retail title and no scripts/smoke.ps1 run, so no regression run
  • AMD GPUs; only Turing was run here

AI use

  • Claude Code with Claude Sonnet 5.5 ran the commands and wrote this report. I checked the output.
<!-- greyfinch-sync:ivall/xcl:comment:7143816033 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7143816033). Originally posted by [Mischief8713](https://github.com/Mischief8713) on 2026-11-24T20:36:49Z. --- **GPU run of `63ad831` on Windows (NVIDIA GTX 1660 Ti, Turing): 708 passed, 0 failed, 21 ignored** **Tested** - NVIDIA GeForce GTX 1660 Ti 6 GB (Turing, driver 32.0.16.2114), Ryzen 5 2600X, Windows 11 (10.0.26300), rustc 1.100.0, debug build - `cargo build --workspace`, then `cargo test --workspace --no-fail-fast -- --test-threads=4`; build exit 0, test exit 0 - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64) - The head does not contain current `main` (`9039900`). It was run as it is. - lib: 708 passed, 0 failed, 21 ignored. - `gpu::recomp::tests::gpu_geometry_mode_es_gs_strip` ran on the GPU and passed (this GPU has mesh shaders). The other geometry tests passed: `geometry_es_setpc_ends_a_block_before_gs_start`, `geometry_wave32_rejects_cross_half_operations`, `geometry_wave_path_selection_preserves_native_wave64`, and the e2e `retail_es_gs_voxelize_geometry_mode`. `gpu_geometry_wave32_prefix_count_over_a_mask` printed SKIPPED (no wave64). **Not tested** - No retail title and no `scripts/smoke.ps1` run, so no regression run - AMD GPUs; only Turing was run here **AI use** - Claude Code with Claude Sonnet 5.5 ran the commands and wrote this report. I checked the output.
Toons29 commented 2026-11-25 04:10:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:27:13Z.


Regression run of 63ad831c on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 63ad831c2147fcfada4e6247a2869106aa302644
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1630 (PresentX 1630)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14817 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151928021 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7151928021). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:27:13Z. --- Regression run of `63ad831c` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 63ad831c2147fcfada4e6247a2869106aa302644 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1630 (PresentX 1630) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14817 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
github-actions[bot] commented 2026-11-29 20:44:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:44:16Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262317979 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7262317979). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:44:16Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:33:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:33:19Z.


Triage (#1607) – head 63ad831

The #1360 problem is fixed on main another way. In geometry mode, structured_span now stops at an ES s_setpc_b64 with no target and at gs_entry (= gs_start), in both split and native wave64. That came in 87d421b (#1689) and 2de1544 (#1873), with tests geometry_split_phases_with_branches_have_entry_and_exit, geometry_early_setpc_ends_the_es_in_every_wave_form and geometry_padding_before_gs_start_keeps_its_entry.
#1528 (closed) made the same term()/ES-to-GS-edge change as this PR.
Recommendation: close (superseded by main commits 87d421b and 2de1544).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7301892580 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7301892580). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:33:19Z. --- **Triage (#1607)** – head 63ad831 The #1360 problem is fixed on main another way. In geometry mode, `structured_span` now stops at an ES `s_setpc_b64` with no target and at `gs_entry` (= gs_start), in both split and native wave64. That came in 87d421b (#1689) and 2de1544 (#1873), with tests `geometry_split_phases_with_branches_have_entry_and_exit`, `geometry_early_setpc_ends_the_es_in_every_wave_form` and `geometry_padding_before_gs_start_keeps_its_entry`. #1528 (closed) made the same `term()`/ES-to-GS-edge change as this PR. Recommendation: close (superseded by main commits 87d421b and 2de1544). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:44:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:44:52Z.


Closing as superseded: this change is already on main (2de1544d). main mod.rs adds gs_start as leader and ends the block after the ES s_setpc (leaders ~1980), structured_span breaks at ES s_setpc and gs_entry (87d421b4, 2de1544d); tests geometry_early_setpc_ends_the_es_in_every_wave_form and geometry_padding_before_gs_start_keeps_its_entry cover the PR's scenario (translate not run here)

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311587546 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1375#issuecomment-7311587546). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:44:52Z. --- Closing as superseded: this change is already on `main` (2de1544d). main mod.rs adds gs_start as leader and ends the block after the ES s_setpc (leaders ~1980), structured_span breaks at ES s_setpc and gs_entry (87d421b4, 2de1544d); tests geometry_early_setpc_ends_the_es_in_every_wave_form and geometry_padding_before_gs_start_keeps_its_entry cover the PR's scenario (translate not run here) Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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
xcl-dev/xcl!1365
No description provided.