Skip to content

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

Open
ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/gs-done-emit-cut
Open

ChalanaGimhanaX wants to merge 1 commit into
xcl-dev:mainfrom
ChalanaGimhanaX:recomp/gs-done-emit-cut

Conversation

@ChalanaGimhanaX

Copy link
Copy Markdown
Contributor

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.

…cl-dev#2412)

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.
@DarkPanda69

Copy link
Copy Markdown

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:

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.

@ahmetbagci8

Copy link
Copy Markdown

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.

@emirduran707

Copy link
Copy Markdown
Contributor

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.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@SlopTart

Copy link
Copy Markdown

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.

@Oliwettoo

Copy link
Copy Markdown

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct DXIL: s_sendmsg MSG_GS_DONE (msg == 3) silently drops emit/cut ops

7 participants