Skip to content

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

Closed
tiagonogueiraa-bit wants to merge 1 commit into
xcl-dev:mainfrom
tiagonogueiraa-bit:geometry-setpc-blocks
Closed

tiagonogueiraa-bit wants to merge 1 commit into
xcl-dev:mainfrom
tiagonogueiraa-bit:geometry-setpc-blocks

Conversation

@tiagonogueiraa-bit

@tiagonogueiraa-bit tiagonogueiraa-bit commented Nov 24, 2026 •

Copy link
Copy Markdown

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 Recompiler: treat untargeted S_SETPC_B64 as Term::Other and track ES-to-GS edges #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

…rt (xcl-dev#1360)

In geometry mode the ES hands over to the GS with an s_setpc_b64 that has
no resolved target, so term() took it for a fall-through, and `edges`
had no ES -> GS edge. With branches in the ES or GS, structured_span then
merged the ES's last block and the first GS blocks into one stretch. Its
s_setpc flow was dropped and gs_start got 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.

term() now ends a block at an indirect branch without a known target, as
it does at other terminators, and `edges` gets the ES -> GS edge.

Over the retail pack (every program translated on the CPU, macOS), 5 of
8 158 programs change. All are ES variants of one VS that end in
s_setpc_b64; they now end there instead of falling into their
s_endpgm block.

geometry_es_setpc_ends_a_block_before_gs_start (CPU only) translates an
ES + GS with a branch in the GS, both native and split wave64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…v#1305-xcl-dev#1379

Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability:
- xcl-dev#1321 (xcl-dev#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB)
- xcl-dev#549, xcl-dev#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests
- xcl-dev#1365 (xcl-dev#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0
- xcl-dev#1368: translated compute PSOs use NodeMask 0
- xcl-dev#1371 (xcl-dev#105): deduplicate packed ISG1 vertex input struct fields
- xcl-dev#1375 (xcl-dev#1360): ES s_setpc_b64 ends block before gs_start
- xcl-dev#1350, xcl-dev#1351, xcl-dev#1352, xcl-dev#1353, xcl-dev#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication
- xcl-dev#1305, xcl-dev#1306, xcl-dev#1314, xcl-dev#1319, xcl-dev#1322, xcl-dev#1334, xcl-dev#1339, xcl-dev#1355, xcl-dev#1357, xcl-dev#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups
- README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap

Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0).

Assisted-by: Antigravity (Google DeepMind)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…v#1305-xcl-dev#1379

Integrate 22 open upstream PRs targeting world rendering, shader correctness, DirectStorage terrain loads, and crash/memory stability:
- xcl-dev#1321 (xcl-dev#1307): fall back to pc blocks when structured CFG HLSL grows oversized (eliminates the 148 MB HLSL / 1 GB/s commit explosion from b8b1f49 so XCL_PSO_PRELOAD=1 stays flat at ~5.4 GiB)
- xcl-dev#549, xcl-dev#1312: DirectStorage late page-array queue hold (fixes 0x89240009 terrain read failures) and 0-byte memory-source requests
- xcl-dev#1365 (xcl-dev#1361): GFX10.30 scratch SADDR 0x7F addresses the immediate offset alone instead of adding v0
- xcl-dev#1368: translated compute PSOs use NodeMask 0
- xcl-dev#1371 (xcl-dev#105): deduplicate packed ISG1 vertex input struct fields
- xcl-dev#1375 (xcl-dev#1360): ES s_setpc_b64 ends block before gs_start
- xcl-dev#1350, xcl-dev#1351, xcl-dev#1352, xcl-dev#1353, xcl-dev#1349: VS layer/viewport outputs, PS sample index/fixed-point position & SV_Coverage, depth+UAV initial states, console SetPredication
- xcl-dev#1305, xcl-dev#1306, xcl-dev#1314, xcl-dev#1319, xcl-dev#1322, xcl-dev#1334, xcl-dev#1339, xcl-dev#1355, xcl-dev#1357, xcl-dev#1379: console_list UMA hold on Release, v_cmp_class_f32 bitwise abs/neg, late_release vram queue wait, root arg clamping, empty BVH / NaN rays, NULL IASetIndexBuffer clearing, MSAA MipLevels=1, VFS lazy-page commits, coherent VirtualFree validation, cpu_writes PAGE_GUARD & stale fence wakeups
- README.md: document the integrated PRs, XCL_PSO_PRELOAD=1, and 16 GiB cap

Verified on RX 9060 XT / GE-Proton11-14: release build clean, targeted unit tests pass (75 passed, 0 failed), and 80 s run with XCL_PSO_PRELOAD=1 and XCL_MEM_LIMIT=12G stays flat at 5340-5413 MB with 512+ pipelines preloaded (1385 frames, exit 0x0).

Assisted-by: Antigravity (Google DeepMind)
@DavidM1911

Copy link
Copy Markdown
Contributor

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 GonZiin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown

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

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

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.

@CalvyPZ CalvyPZ added the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ CalvyPZ closed this Nov 25, 2026
@CalvyPZ CalvyPZ reopened this Nov 25, 2026
@CalvyPZ CalvyPZ removed the duplicate This issue or pull request already exists label Nov 25, 2026
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Closing as superseded: this change is already on main (2de1544). 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 (87d421b, 2de1544); 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.

@throny throny added the duplicate This issue or pull request already exists label Dec 1, 2026
@throny throny closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recompiler: term() misclassifies S_SETPC_B64 as Term::Next, breaking multi-block ES+GS Mode::Geometry shaders

8 participants