Recompiler: handle MSG_GS_DONE emit and cut ops in geometry shaders (#2412) #2494

Open
github-bot wants to merge 1 commit from github-bot/gh-2494 into main AGit
Owner

@⁠ChalanaGimhanaX on GitHub · 2026-11-25 20:17 UTC · original
ChalanaGimhanaX:recomp/gs-done-emit-cut → main · +134 −4 · 3 files · 1 commits · open

Handle s_sendmsg MSG_GS_DONE (msg == 3) emit and cut operations (op 1..=3 on stream 0) in geometry shaders instead of silently dropping them, in both Direct DXIL (lower_geom.rs) and HLSL (emit.rs) backends. RDNA2 compilers fold the final vertex emit/cut into MSG_GS_DONE; keeping op == 0 as a no-op preserves plain termination messages.

Fixes #2412. Part of #1833.

What is in it

  • crates/xcl/src/gpu/dxil/lower_geom.rs: process s_sendmsg on msg == 2 | 3 when op != 0 && stream == 0.
  • crates/xcl/src/gpu/recomp/emit.rs: apply the same MSG_GS / MSG_GS_DONE (op 1..=3) handling in the HLSL geometry backend.
  • crates/xcl/src/gpu/dxil/geometry_tests.rs: added CPU codegen/DXIL-validation tests (0x33, 0x23, 0x03) and a GPU mesh_draw test verifying both backends emit all 4 vertices and 2 strip triangles per primitive (before the fix, the test fails with 3 vertices / 1 triangle).

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, rustc 1.100.0 (0ef1bc386 2026-11-09), release build.
  • cargo test -p xcl --lib gpu::dxil::geometry_tests -- --test-threads=1 (pre-rebase debug): 5 passed, 0 failed; cargo test -p xcl --lib gpu_geometry_mode_es_gs_strip -- --test-threads=1: 2 passed, 0 failed.
  • cargo build --release --workspace + cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture (3da50b0): 1425 passed, 0 failed, 46 ignored.
  • SKIPPED GPU/adapter tests (26): 21 no wave64, 3 refused f16 forms (#1426), 1 no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required for driver cache disable).
  • cargo test --release -p xcl --test e2e -- --test-threads=1 (3da50b0): 4 passed, 0 failed.

Regression run

main (6d051da):

xcl-smoke v1
commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1473)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14348 MB

this PR (3da50b0):

xcl-smoke v1
commit: 3da50b09541792d98a03a2b90cb38dc8252a5624
gpu: NVIDIA GeForce RTX 3060
title: 37fe04ab
seconds: 60
exit: 0x0
frames shown: 1490 (PresentX 1490)
presents per 2 s (last 3): 51 18 61
device removals: 0
crashes: 0
peak commit: 14099 MB

Not tested

  • Native wave64 hardware (split = false GPU execution path), AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second menu smoke run.

AI use

  • Antigravity (Gemini 4 Neon) implemented the MSG_GS_DONE emit/cut fix across both backends and tests, ran the test suite and regression smoke runs, and drafted this description.
**@⁠ChalanaGimhanaX** on GitHub · 2026-11-25 20:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494) `ChalanaGimhanaX:recomp/gs-done-emit-cut` → `main` · +134 −4 · 3 files · 1 commits · open Handle `s_sendmsg` `MSG_GS_DONE` (`msg == 3`) emit and cut operations (`op` 1..=3 on stream 0) in geometry shaders instead of silently dropping them, in both Direct DXIL (`lower_geom.rs`) and HLSL (`emit.rs`) backends. RDNA2 compilers fold the final vertex emit/cut into `MSG_GS_DONE`; keeping `op == 0` as a no-op preserves plain termination messages. Fixes #2412. Part of #1833. **What is in it** - `crates/xcl/src/gpu/dxil/lower_geom.rs`: process `s_sendmsg` on `msg == 2 | 3` when `op != 0 && stream == 0`. - `crates/xcl/src/gpu/recomp/emit.rs`: apply the same `MSG_GS` / `MSG_GS_DONE` (`op` 1..=3) handling in the HLSL geometry backend. - `crates/xcl/src/gpu/dxil/geometry_tests.rs`: added CPU codegen/DXIL-validation tests (`0x33`, `0x23`, `0x03`) and a GPU `mesh_draw` test verifying both backends emit all 4 vertices and 2 strip triangles per primitive (before the fix, the test fails with 3 vertices / 1 triangle). **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.1714), Intel Core i5-10400F, Windows 11 Pro Build 26200, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, release build. - `cargo test -p xcl --lib gpu::dxil::geometry_tests -- --test-threads=1` (pre-rebase debug): 5 passed, 0 failed; `cargo test -p xcl --lib gpu_geometry_mode_es_gs_strip -- --test-threads=1`: 2 passed, 0 failed. - `cargo build --release --workspace` + `cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture` (`3da50b0`): 1425 passed, 0 failed, 46 ignored. - `SKIPPED` GPU/adapter tests (26): 21 no wave64, 3 refused f16 forms (`#1426`), 1 `no heap windows`, 1 `pso_measurement_compiles_an_exact_synthetic_record` (Windows Developer Mode required for driver cache disable). - `cargo test --release -p xcl --test e2e -- --test-threads=1` (`3da50b0`): 4 passed, 0 failed. **Regression run** main (`6d051da`): ``` xcl-smoke v1 commit: 6d051da51ba3fe7ba7d4ef542da71f544646e3ba gpu: NVIDIA GeForce RTX 3060 title: 37fe04ab seconds: 60 exit: 0x0 frames shown: 1473 (PresentX 1473) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14348 MB ``` this PR (`3da50b0`): ``` xcl-smoke v1 commit: 3da50b09541792d98a03a2b90cb38dc8252a5624 gpu: NVIDIA GeForce RTX 3060 title: 37fe04ab seconds: 60 exit: 0x0 frames shown: 1490 (PresentX 1490) presents per 2 s (last 3): 51 18 61 device removals: 0 crashes: 0 peak commit: 14099 MB ``` **Not tested** - Native wave64 hardware (`split = false` GPU execution path), AMD / Intel GPUs, Linux / Wine, and retail gameplay beyond the 60-second menu smoke run. **AI use** - Antigravity (Gemini 4 Neon) implemented the `MSG_GS_DONE` emit/cut fix across both backends and tests, ran the test suite and regression smoke runs, and drafted this description.
RDNA2 geometry shaders can fold the final emit and/or cut into s_sendmsg MSG_GS_DONE (msg == 3, op in 1..=3), which was previously ignored by both the Direct DXIL lowering (lower_geom.rs) and the HLSL geometry backend (emit.rs).

Update both backends to execute emit/cut for msg 2 or 3 when op != 0 on stream 0, keeping op == 0 as a no-op.

Verified with new CPU codegen/validation and GPU mesh_draw tests (plus existing geometry_tests and gpu_geometry_mode_es_gs_strip suites), confirming 0x33 produces 4 vertices and 2 strip triangles per primitive instead of 3 vertices and 1 triangle.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:32:06 +00:00
Author
Owner

@⁠DarkPanda69 on GitHub · 2026-11-25 20:42 UTC · original

AMD native wave64 run (listed as untested), plus an RTX 3060: the new GPU test passes on both, with the direct translator on.

Head 3da50b0 as is (on main 6d12f58), debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, card chosen with XCL_ADAPTER:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): gpu_geometry_msg_gs_done_emit_and_cut ok. 700 passed, 2 failed, 22 ignored; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on main.
  • RTX 3060 (driver 32.0.16.1088): the new test ok; 702 passed, 0 failed, 22 ignored.

For reference: #2485 covers the same MSG_GS_DONE emit/cut case, and its test also passes on both cards.

Not tested: retail geometry shaders, Intel, Linux / Wine.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 20:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7174062527) AMD native wave64 run (listed as untested), plus an RTX 3060: the new GPU test passes on both, with the direct translator on. Head `3da50b0` as is (on `main` `6d12f58`), debug, Windows 11 Pro 26200, `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4`, card chosen with `XCL_ADAPTER`: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010): `gpu_geometry_msg_gs_done_emit_and_cut` ok. 700 passed, 2 failed, 22 ignored; the 2 failures are the AMD fuzz seeds tracked in #2115, the same on `main`. - **RTX 3060** (driver 32.0.16.1088): the new test ok; 702 passed, 0 failed, 22 ignored. For reference: #2485 covers the same `MSG_GS_DONE` emit/cut case, and its test also passes on both cards. Not tested: retail geometry shaders, Intel, Linux / Wine. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠ahmetbagci8 on GitHub · 2026-11-25 20:47 UTC · original

Tested

  • Commit: 3da50b09541792d98a03a2b90cb38dc8252a5624
  • Hardware / OS: Intel Core i7-11800H, NVIDIA GeForce RTX 3070 Laptop GPU (driver 32.0.16.1714), Windows 11 Pro (Build 26300), DXC v1.9.2609
  • cargo test -j 2 -p xcl --lib geometry -- --test-threads=4: 13 passed; 0 failed; 0 ignored (3.00s)

Not tested

  • Full workspace suite and scripts/smoke.ps1 (no unpacked title locally).

AI use

  • Antigravity harness (Gemini 4 Neon) ran the targeted unit tests on this commit and drafted this report; the author reviewed it before posting.
**@⁠ahmetbagci8** on GitHub · 2026-11-25 20:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7174202563) ### Tested - **Commit:** `3da50b09541792d98a03a2b90cb38dc8252a5624` - **Hardware / OS:** Intel Core i7-11800H, NVIDIA GeForce RTX 3070 Laptop GPU (driver `32.0.16.1714`), Windows 11 Pro (Build 26300), DXC `v1.9.2609` - `cargo test -j 2 -p xcl --lib geometry -- --test-threads=4`: `13 passed; 0 failed; 0 ignored (3.00s)` ### Not tested - Full workspace suite and `scripts/smoke.ps1` (no unpacked title locally). ### AI use - Antigravity harness (Gemini 4 Neon) ran the targeted unit tests on this commit and drafted this report; the author reviewed it before posting.
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-25 20:50 UTC · original

Independent AMD RDNA4 (native wave64) test report on exact head 3da50b09541792d98a03a2b90cb38dc8252a5624 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • Both PR tests passed (no skips): gpu::dxil::geometry_tests::geometry_msg_gs_done_emit_and_cut_codegen_and_validate and gpu_geometry_msg_gs_done_emit_and_cut.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 3da50b09541792d98a03a2b90cb38dc8252a5624
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15450 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
**@⁠emirduran707** on GitHub · 2026-11-25 20:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7174252532) Independent AMD RDNA4 (native wave64) test report on exact head `3da50b09541792d98a03a2b90cb38dc8252a5624` (clean detached checkout, no local changes). **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (`stable-x86_64-pc-windows-msvc`), DXC 1.9.2602.17; tests debug, smoke release. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4`: **1423 passed, 2 failed, 46 ignored; 8 SKIPPED** (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu` refused by per-lane form; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`). All native wave64 GPU tests ran and passed. - Both PR tests passed (no skips): `gpu::dxil::geometry_tests::geometry_msg_gs_done_emit_and_cut_codegen_and_validate` and `gpu_geometry_msg_gs_done_emit_and_cut`. - The 2 failures (`gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` seed 722 and `fuzz_validate_and_gpu_3` seed 1599) are pre-existing on unmodified `main` on this GPU. **Regression run** (60 s retail-title smoke, `XCL_NETWORK=0`, release) ``` xcl-smoke v1 commit: 3da50b09541792d98a03a2b90cb38dc8252a5624 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1608 (PresentX 1608) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15450 MB ``` (Matched `main` `68a284a` baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.) **Not tested** - D3D12 debug layer; Intel GPUs. **AI use** - Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 20:53 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 20:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7174320950) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 21:00 UTC · original

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.

**@⁠SlopTart** on GitHub · 2026-11-25 21:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7174493117) `gpu_` suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Author
Owner

@⁠Oliwettoo on GitHub · 2026-11-25 22:19 UTC · original

Heads-up: #2485, #2494 and #2509 make the same change (MSG_GS_DONE runs its emit/cut op like MSG_GS, #2412). Read from the diffs (c256c7e, 3da50b0, 4bc111d), not run:

  • #2494 and #2509 change both the HLSL path (emit.rs) and Direct DXIL (lower_geom.rs). #2485 changes only Direct DXIL, so with it the HLSL path still drops GS_DONE's emit/cut.
  • The op != 0 / 1..=3 guards in #2494 and #2485 change nothing. gs_emit_cut and the HLSL arm only act on op & 1 / op & 2, so op 0 is already a no-op in #2509 too.
  • The diffs are otherwise equivalent. Merging one (#2494 is the earliest that covers both paths) and closing the other two saves duplicate review work (#1607).
**@⁠Oliwettoo** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/xcl-dev/xcl/pull/2494#issuecomment-7176212713) Heads-up: #2485, #2494 and #2509 make the same change (`MSG_GS_DONE` runs its emit/cut op like `MSG_GS`, #2412). Read from the diffs (c256c7e, 3da50b0, 4bc111d), not run: - #2494 and #2509 change both the HLSL path (`emit.rs`) and Direct DXIL (`lower_geom.rs`). #2485 changes only Direct DXIL, so with it the HLSL path still drops `GS_DONE`'s emit/cut. - The `op != 0` / `1..=3` guards in #2494 and #2485 change nothing. `gs_emit_cut` and the HLSL arm only act on `op & 1` / `op & 2`, so op 0 is already a no-op in #2509 too. - The diffs are otherwise equivalent. Merging one (#2494 is the earliest that covers both paths) and closing the other two saves duplicate review work (#1607).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2494/head:github-bot/gh-2494'
git switch 'github-bot/gh-2494'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2494'
git switch 'github-bot/gh-2494'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2494'
git switch 'github-bot/gh-2494'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2494'
git switch 'main'
git merge --squash 'github-bot/gh-2494'
git switch 'main'
git merge --ff-only 'github-bot/gh-2494'
git switch 'main'
git merge 'github-bot/gh-2494'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.