Skip to content

Recompiler: treat untargeted S_SETPC_B64 as Term::Other and track ES-to-GS edges - #1528

Closed
OtavioTadeu wants to merge 1 commit into
xcl-dev:mainfrom
OtavioTadeu:fix/recomp-setpc-geometry-1360
Closed

OtavioTadeu wants to merge 1 commit into
xcl-dev:mainfrom
OtavioTadeu:fix/recomp-setpc-geometry-1360

Conversation

@OtavioTadeu

@OtavioTadeu OtavioTadeu commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

S_SETPC_B64 has F_BRANCH | F_INDIRECT without F_TERMINATOR, so term() misclassified untargeted S_SETPC_B64 as Term::Next, and edges omitted the ES-to-GS handoff into gs_start (and xcl_entry_pc in split_wave64), allowing structured_span to break multi-block ES+GS Mode::Geometry shaders. Fixes #1360.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs: classify untargeted F_BRANCH instructions as Term::Other in term(), include ES-to-GS S_SETPC_B64 and split_wave64 entry edges in edges, and add a multi-block ES+GS test (verified with DXC)

Tested

  • NVIDIA GeForce GTX 1660 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600G, Windows 11 build 26200, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), rustc 1.100.0 (stable-x86_64-pc-windows-msvc), debug build
  • cargo test --workspace -- --test-threads=4: 777 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask [no wave64], gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware [no wave64], heap_window_out_of_memory_falls_back_to_the_switch_form [no heap windows])
  • cargo test -p xcl --lib recomp::geometry_tests: 1 passed, 0 failed (DXC compiled)
  • cargo test -p xcl --lib recomp::attribute_tests: 3 passed, 0 failed
  • cargo test -p xcl --lib recomp::tests::geometry: 2 passed, 0 failed

Regression run

  • scripts/smoke.ps1 -Game retail_title -Seconds 60 (main baseline vs PR head on NVIDIA GeForce GTX 1660 SUPER):

xcl-smoke v1

commit: 9e3831e1f570d3646e53ab753b19ec07eb8f1485

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 631 (PresentX 631)

presents per 2 s (last 3): 47 47 49

device removals: 0

crashes: 0

peak commit: 15199 MB


xcl-smoke v1

commit: c04e60f2ab6f49eab2b349f4a353e24107749407

gpu: NVIDIA GeForce GTX 1660 SUPER

title: retail_title

seconds: 60

exit: 0x0

frames shown: 640 (PresentX 641)

presents per 2 s (last 3): 44 42 43

device removals: 0

crashes: 0

peak commit: 15203 MB

Not tested

  • AMD / native wave64 GPUs, Linux/Wine, and extended gameplay past the 60 s smoke window

AI use

  • Antigravity with Gemini 4 Neon: analyzed the issue, wrote the fix, tests, and PR description; reviewed by author.

@OtavioTadeu OtavioTadeu changed the title Recompiler: treat untargeted S_SETPC_B64 as Term::Other and track ES-… Recompiler: treat untargeted S_SETPC_B64 as Term::Other and track ES-to-GS edges Nov 24, 2026
…to-GS edges

S_SETPC_B64 has flags F_BRANCH | F_INDIRECT without F_TERMINATOR, so term() fell through to Term::Next when branch_target returned None, and edges omitted the ES-to-GS handoff into gs_start (and xcl_entry_pc in split_wave64 mode). Multi-block ES+GS geometry shaders could therefore have structured_span absorb S_SETPC_B64 or gs_start as fallthrough.

Fixes xcl-dev#1360.
Verified with cargo test -p xcl --lib recomp::geometry_tests (1 passed, DXC compiled), recomp::attribute_tests (3 passed), and recomp::tests::geometry.

Assisted-by: Antigravity (Gemini 4 Neon)
@OtavioTadeu
OtavioTadeu force-pushed the fix/recomp-setpc-geometry-1360 branch from 0fda42f to c04e60f Compare November 24, 2026 17:29
@OtavioTadeu
OtavioTadeu marked this pull request as draft November 24, 2026 17:29
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Duplicate note: #1375 (opened earlier, also a draft) fixes #1360 with the same rule. In term, an s_setpc_b64 without a known target ends its block, and an edge goes from it to gs_start. The differences:

  • Recompiler: geometry mode's ES s_setpc_b64 ends a block before gs_start (#1360) #1375 adds that edge only for an s_setpc_b64 whose target is a block start. Its test checks the emitted ES → GS handoff (pc = select(xcl_es_phase, …, gs_start)) in both forms.
  • This PR adds the edge for every s_setpc_b64 without a far target. In the split form it also adds a pseudo edge (u64::MAX, gs_start). Its test also covers a multi-block ES with two s_setpc_b64.

Both edit the same lines of recomp/mod.rs, so only one can land. Comparison only: I haven't run either.

AI use: Claude Code (Claude Opus 5.5) compared the diffs and wrote this.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@Xahinn1

Xahinn1 commented Nov 24, 2026

Copy link
Copy Markdown

Tested PR #1528 (head c04e60f) against its merge base (9e3831e, "Merge PR #680"; the PR is 0 commits behind main). This covers the AMD / native wave64 / mesh-shader hardware listed under "Not tested" in the description.

Environment

  • Windows 11 build 26300 (non-admin PowerShell 5.1)
  • AMD Radeon RX 9060 XT (RDNA4), driver 32.0.32029.2010
  • Ryzen 7 5700X, 15.9 GB RAM
  • rustc / cargo 1.100.0
  • DXC 1.9.2602.17 (21d28f72) from Windows SDK 10.0.26100.0, via XCL_DXC_DIR

I used two separate worktrees and target dirs (PR head and base) with --locked.

1. Targeted tests, native wave64 on RDNA4 (--test-threads=1, none skipped)

filter PR head base
recomp::geometry_tests (new test) 1 passed 0 tests (doesn't exist there)
recomp::attribute_tests 3 passed 3 passed
recomp::tests::geometry 2 passed 2 passed
gpu_geometry 2 passed 2 passed
gpu_wave32_program_in_wave64_hardware 1 passed 1 passed
gpu_split_wave64 5 passed 5 passed
gpu_wave64 3 passed 3 passed
gpu_mesh_mode 2 passed 2 passed
gpu_dispatch_matches_native_wave64_reference 1 passed 1 passed

2. Forced split path (XCL_SPLIT_WAVE64=1), PR head only

This runs the NVIDIA-style 32-lane split path on the RDNA GPU. recomp::geometry_tests (1), gpu_geometry (2), gpu_split_wave64 (5), gpu_wave64 (3), gpu_mesh_mode (2) and gpu_wave32_program_in_wave64_hardware (1) all passed. I did not run the forced-split set on base. gpu_split_wave64 took 1.04s vs ~0.45s native, which suggests the variable took effect, but I didn't verify that directly.

3. Full workspace (cargo test --workspace --locked --no-fail-fast -- --test-threads=4)

passed failed ignored
PR head 776 1 41
base 775 1 41

The one extra pass on the PR is the new test (lib tests: 749 vs 748). Both trees report the same failing target, -p xcl --test e2e, so it is not introduced by this PR. I haven't identified the individual e2e test or its cause on this machine. XCL_SAMPLE_RPF not set – skipping appeared on both trees.

Not tested / not done

  • scripts/smoke.ps1 on a retail title (I don't have one)
  • Linux/Wine
  • NVIDIA or other GPUs (only RDNA4 here)
  • Running the new test against base to confirm it fails without the fix
  • Running the GPU programs with a real console ES+GS pair: the new test checks the generated HLSL and that DXC compiles it, but doesn't execute it

Review questions (from reading the diff only, so I may be missing context)

  • The new edges entries are added for every S_SETPC_B64 with no far_target, assuming each is the ES→GS handoff. Could an untargeted S_SETPC_B64 appear inside GS code, and would the extra edge back to gs_start matter there?
  • The edge code matches only S_SETPC_B64 by name, while term() now keys on F_BRANCH. If S_SWAPPC_B64 or another indirect branch can be a handoff, it would be a Term::Other without the matching edge. Is that intended?
  • Is the u64::MAX sentinel edge safe for everything that consumes edges?

An AI assistant helped me run the tests and draft this comment. The commands and outputs are mine from the runs above.

@Belox17

Belox17 commented Nov 24, 2026

Copy link
Copy Markdown

Test report for 0fda42fc / c04e60f2 on NVIDIA (RTX 3060 Ti): passes, and the new test fails without the fix

Tested

  • NVIDIA GeForce RTX 3060 Ti 8 GB, driver 32.0.16.2124; Ryzen 5 5600X; Windows 11 build 26300; rustc 1.98.1 MSVC; DXC 1.8.2502.11 (Windows SDK 10.0.26100); debug build. Head 0fda42fc as is, clean tree. The current head c04e60f2 is the same patch rebased onto 9e3831e (git range-diff), and its tree is identical to my merge of 0fda42fc into 9e3831e, so the merged run below is the current head.
  • cargo test -p xcl --lib multi_block_es_gs: 1 passed (DXC present, so both forms were compiled).
  • cargo test --workspace -- --test-threads=4: 771 passed, 0 failed, 41 ignored; SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64). Its base b7aa9f3 on the same machine: 770 passed, 0 failed, 41 ignored, same skips.
  • Merged into main 9e3831e: 777 passed, 0 failed, 41 ignored (main alone: 776).
  • With the term() change and the ES→GS edges reverted (test kept), the test fails at assert_eq!(term(..), Term::Other): left Next.

Not tested

  • AMD / wave64 hardware; a real multi-block ES+GS program from a title; any retail title (no smoke run).

AI use: Claude Code (Claude Opus 5.5) ran the commands and wrote this report; I checked it before posting.

kacper-serewis pushed a commit to kacper-serewis/xcl that referenced this pull request Nov 24, 2026
Integrates xcl-dev#1528 (c04e60f) and the reviewed 47c3ec0d correction. Both ES arms reach the GS while fetch calls and S_CODE_END retain fallthrough. Independent edge-removal checks failed before correction.

Assisted-by: T3 Code (gpt-6.2-astra)
@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!

@OtavioTadeu
OtavioTadeu marked this pull request as ready for review November 24, 2026 19:53
@CalvyPZ CalvyPZ added the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ

CalvyPZ commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.

@CalvyPZ CalvyPZ closed this Nov 25, 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

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

6 participants