Recompiler: coalesce GS header and vertex attribute stores in direct DXIL #2273

Manually merged
github merged 1 commit from gh-pr/2273/head into gh-pr/2273/base 2026-11-26 05:25:13 +00:00
Owner

@⁠ramon-victor on GitHub · 2026-11-25 12:00 UTC · original
ramon-victor:opt/dxil-geom-coalesce-stores → main · +24 −9 · 2 files · 1 commits · merged 2026-11-25 18:38 UTC

Coalesces scalar dx.op.rawBufferStore calls in the direct DXIL geometry-shader epilogue (Lw::geom_epilogue):

  • Replaces the two 1-dword header stores ([nv] at rec * 4 and [np] at rec * 4 + 4) with a single 2-dword rawBufferStore (mask = 3) at rec << 2.
  • Replaces each vertex output register's four 1-dword stores (dst + 4*slot + 0..3) with a single 4-dword rawBufferStore (mask = 15) at (dst + 4*slot) << 2, reducing vertex UAV stores and store-offset arithmetic by 4x.

Part of #1269.

What is in it

  • crates/xcl/src/gpu/dxil/lower_geom.rs: coalesce the 2-dword header store and each 4-dword per-register vertex attribute store in Lw::geom_epilogue (+8/-10 lines).
  • crates/xcl/src/gpu/dxil/geometry_tests.rs: add geometry_epilogue_coalesces_header_and_vertex_stores verifying DXIL validation and disassembly (1 mask-3 header store, 2 mask-15 vertex register stores, 1 mask-1 triangle store = 4 total instead of 11).

On a seeded 600-program sample (xcl shaders <archive> --direct --sample 600 --seed 3 --max-bytes 40000 --validate --threads 8, 573 programs including 8 GS programs), all 573/573 (8/8 GS) validate cleanly (0 validator failures):

  • Total emitted DXIL: 41,323,736 B -> 41,320,436 B (-3,300 B across the 8 GS programs, ~412 B per GS)

Tested

  • Hardware and toolchain: NVIDIA GeForce RTX 3070 (8 GiB, driver 621.24, wave32), AMD Ryzen 7 5700X, Windows 11 Pro 26300, rustc 1.99.0 (x86_64-pc-windows-msvc), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0).
  • cargo test -p xcl --lib gpu::dxil::geometry_tests (debug): 3 passed; 0 failed (geometry_forms_validate, geometry_epilogue_coalesces_header_and_vertex_stores, and gpu_geometry_direct_records running the GS + mesh pass-through draw on the RTX 3070).
  • .\scripts\test.ps1 (debug, full workspace): 1251 passed; 0 failed; 46 ignored (25 GPU sub-checks skipped on this wave32 adapter: 21 no wave64, 1 no heap windows, 3 per-lane #1426 refusals).
  • cargo build --release -p xcl + direct DXIL validation sweep on 573 sampled retail shader programs: 573/573 translated and dxil.dll-validated (0 failures).

Regression run

xcl-smoke v1
commit: f087b998d0d51a9f11bbfa0761967a63e778edd9
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14467 MB
xcl-smoke v1
commit: a4deccec4ee132b386d968af8446fda4f497b57b
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1621 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14465 MB

Not tested

  • Native wave64 GPU hardware (AMD/Intel): RTX 3070 only supports wave32, so native wave64 tests skip on this adapter.
  • Sample-gated tests (XCL_SAMPLE_* env vars unset).

AI use

  • Antigravity (Gemini 4 Neon): coalesced header and vertex attribute stores in lower_geom.rs, added the store-mask disassembly test in geometry_tests.rs, and ran geometry_tests (including GPU mesh draw), the full workspace test suite, the 573-shader validation sweep, and the 60 s smoke regression run.
**@⁠ramon-victor** on GitHub · 2026-11-25 12:00 UTC · [original](https://github.com/xcl-dev/xcl/pull/2273) `ramon-victor:opt/dxil-geom-coalesce-stores` → `main` · +24 −9 · 2 files · 1 commits · merged 2026-11-25 18:38 UTC Coalesces scalar `dx.op.rawBufferStore` calls in the direct DXIL geometry-shader epilogue (`Lw::geom_epilogue`): - Replaces the two 1-dword header stores (`[nv]` at `rec * 4` and `[np]` at `rec * 4 + 4`) with a single 2-dword `rawBufferStore` (`mask = 3`) at `rec << 2`. - Replaces each vertex output register's four 1-dword stores (`dst + 4*slot + 0..3`) with a single 4-dword `rawBufferStore` (`mask = 15`) at `(dst + 4*slot) << 2`, reducing vertex UAV stores and store-offset arithmetic by 4x. Part of #1269. **What is in it** - `crates/xcl/src/gpu/dxil/lower_geom.rs`: coalesce the 2-dword header store and each 4-dword per-register vertex attribute store in `Lw::geom_epilogue` (`+8/-10` lines). - `crates/xcl/src/gpu/dxil/geometry_tests.rs`: add `geometry_epilogue_coalesces_header_and_vertex_stores` verifying DXIL validation and disassembly (`1` mask-3 header store, `2` mask-15 vertex register stores, `1` mask-1 triangle store = `4` total instead of `11`). On a seeded 600-program sample (`xcl shaders <archive> --direct --sample 600 --seed 3 --max-bytes 40000 --validate --threads 8`, 573 programs including 8 GS programs), all 573/573 (8/8 GS) validate cleanly (`0` validator failures): - Total emitted DXIL: `41,323,736 B -> 41,320,436 B` (`-3,300 B` across the 8 GS programs, `~412 B` per GS) **Tested** - Hardware and toolchain: NVIDIA GeForce RTX 3070 (8 GiB, driver `621.24`, wave32), AMD Ryzen 7 5700X, Windows 11 Pro `26300`, `rustc 1.99.0` (`x86_64-pc-windows-msvc`), DXC/DXIL `1.8.2502.11` (Windows SDK `10.0.26100.0`). - `cargo test -p xcl --lib gpu::dxil::geometry_tests` (debug): `3 passed; 0 failed` (`geometry_forms_validate`, `geometry_epilogue_coalesces_header_and_vertex_stores`, and `gpu_geometry_direct_records` running the GS + mesh pass-through draw on the RTX 3070). - `.\scripts\test.ps1` (debug, full workspace): `1251 passed; 0 failed; 46 ignored` (25 GPU sub-checks skipped on this wave32 adapter: 21 `no wave64`, 1 `no heap windows`, 3 per-lane `#1426` refusals). - `cargo build --release -p xcl` + direct DXIL validation sweep on 573 sampled retail shader programs: `573/573` translated and `dxil.dll`-validated (`0` failures). **Regression run** ``` xcl-smoke v1 commit: f087b998d0d51a9f11bbfa0761967a63e778edd9 gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14467 MB ``` ``` xcl-smoke v1 commit: a4deccec4ee132b386d968af8446fda4f497b57b gpu: NVIDIA GeForce RTX 3070 title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1621 (PresentX 1622) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14465 MB ``` **Not tested** - Native wave64 GPU hardware (AMD/Intel): RTX 3070 only supports wave32, so native wave64 tests skip on this adapter. - Sample-gated tests (`XCL_SAMPLE_*` env vars unset). **AI use** - Antigravity (Gemini 4 Neon): coalesced header and vertex attribute stores in `lower_geom.rs`, added the store-mask disassembly test in `geometry_tests.rs`, and ran `geometry_tests` (including GPU mesh draw), the full workspace test suite, the 573-shader validation sweep, and the 60 s smoke regression run.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:25:11 +00:00
github manually merged commit a4deccec4e into gh-pr/2273/base 2026-11-26 05:25:13 +00:00
Author
Owner

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

The AMD native wave64 run listed as untested, plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite.

Head a4decce applied on main 1a0bbe3, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) 629 passed, 2 failed, 22 ignored, 6 SKIPPED 630 passed, 2 failed, 22 ignored, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32, split wave64) 631 passed, 0 failed, 22 ignored, 23 SKIPPED 632 passed, 0 failed, 22 ignored, 23 SKIPPED

Per-test comparison: on both cards the only difference is the new geometry_epilogue_coalesces_header_and_vertex_stores (ok). No existing test changes result or skip state. The 2 RX 9070 XT failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, the same on main.

Not tested: geometry shader GPU output in a title, XCL_SAMPLE_*.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

**@⁠DarkPanda69** on GitHub · 2026-11-25 12:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/2273#issuecomment-7162248754) The AMD native wave64 run listed as untested, plus an RTX 3060, paired against `main` with the direct translator on for the whole GPU suite. Head `a4decce` applied on `main` `1a0bbe3`, debug, Windows 11 Pro 26200, `XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4`, on `main` and on this PR for each card: | | `main` | this PR | |---|---|---| | RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) | 629 passed, 2 failed, 22 ignored, 6 SKIPPED | 630 passed, 2 failed, 22 ignored, 6 SKIPPED | | RTX 3060 (32.0.16.1088, wave32, split wave64) | 631 passed, 0 failed, 22 ignored, 23 SKIPPED | 632 passed, 0 failed, 22 ignored, 23 SKIPPED | Per-test comparison: on both cards the only difference is the new `geometry_epilogue_coalesces_header_and_vertex_stores` (ok). No existing test changes result or skip state. The 2 RX 9070 XT failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, the same on `main`. Not tested: geometry shader GPU output in a title, `XCL_SAMPLE_*`. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
Author
Owner

@⁠itsSio on GitHub · 2026-11-25 12:24 UTC · original

Tested

Complementing the paired GPU-library results above: clean, unmodified PR head a4deccec4ee132b386d968af8446fda4f497b57b, Windows 11 Pro build 26200, x64 MSVC, unoptimized dev/test profiles with debug info off. cargo build --workspace --locked and cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture exited 0 on both PCs, with default shader options.

GPU / driver CPU, RAM, toolchain Passed / failed / ignored Runtime SKIPPED
RTX 5080 / 32.0.16.1088 Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC/DXIL 1.9.2609.5 1251 / 0 / 46 25
RTX 2080 SUPER / 32.0.16.1088 Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC/DXIL 1.8.2502.11 1251 / 0 / 46 27

cargo test -p xcl --lib --locked gpu::dxil::geometry_tests:: -- --test-threads=1 --nocapture: 3 / 0 / 0, zero runtime skips, on both RTX cards and a Radeon RDNA2 iGPU (32.0.21043.5001, same Ryzen 7 system and toolchain). The structural test verified one two-dword header store, two four-dword vertex stores and one scalar triangle-index store. The separate direct/HLSL draw and readback fixture passed as well.

Not tested

Exact parent, full AMD workspace, retail geometry output, or GPU performance.

AI use

Ran via Samaritan:

  • OpenCode with OpenAI GPT-6.2 Sol (openai/gpt-6.2-sol): scoped and ran the two-PC checks, audited logs and fixture coverage, and wrote this report. No subagents contributed.
**@⁠itsSio** on GitHub · 2026-11-25 12:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/2273#issuecomment-7162341629) **Tested** Complementing the paired GPU-library results above: clean, unmodified PR head `a4deccec4ee132b386d968af8446fda4f497b57b`, Windows 11 Pro build 26200, x64 MSVC, unoptimized dev/test profiles with debug info off. `cargo build --workspace --locked` and `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture` exited 0 on both PCs, with default shader options. | GPU / driver | CPU, RAM, toolchain | Passed / failed / ignored | Runtime `SKIPPED` | | --- | --- | ---: | ---: | | RTX 5080 / `32.0.16.1088` | Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC/DXIL 1.9.2609.5 | 1251 / 0 / 46 | 25 | | RTX 2080 SUPER / `32.0.16.1088` | Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC/DXIL 1.8.2502.11 | 1251 / 0 / 46 | 27 | `cargo test -p xcl --lib --locked gpu::dxil::geometry_tests:: -- --test-threads=1 --nocapture`: **3 / 0 / 0**, zero runtime skips, on both RTX cards and a Radeon RDNA2 iGPU (`32.0.21043.5001`, same Ryzen 7 system and toolchain). The structural test verified one two-dword header store, two four-dword vertex stores and one scalar triangle-index store. The separate direct/HLSL draw and readback fixture passed as well. **Not tested** Exact parent, full AMD workspace, retail geometry output, or GPU performance. **AI use** Ran via Samaritan: - OpenCode with OpenAI GPT-6.2 Sol (`openai/gpt-6.2-sol`): scoped and ran the two-PC checks, audited logs and fixture coverage, and wrote this report. No subagents contributed.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 17:05 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 17:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/2273#issuecomment-7168979305) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.