Shaders & GPU: support HwStage::Gs geometry shader translation and pipelines #433

Open
github-bot wants to merge 1 commit from github-bot/gh-433 into a-publier AGit
Owner

@⁠R1kkku on GitHub · 2026-11-27 01:08 UTC · original
R1kkku:pr/geometry-shader-support → a-publier · +1835 −125 · 14 files · 1 commits · open

Summary

Adds translation and host pipeline support for HwStage::Gs (Xbox/RDNA merged ES-GS) shaders, covering the remaining 195 GS_VoxelizeGeneric_* programs in shaders.rpf so all 25,889 of 25,889 shaders in the title archive translate, pass dxil.dll validation, and build D3D12 PSOs.

Scope note: As noted in README.md, the title's current rendering path does not dispatch these GS_VoxelizeGeneric_* shaders, so this PR is primarily shader-pipeline completeness rather than a runtime FPS/stability change.

Changes

  • Structurisation (crates/victory-shader/src/structure.rs):
    • Fold the merged-wave GS exec mask setup (s_bfm_b64 exec, bfe(s3), 0) to Bool::TRUE only when s_bfe_i32/s_bfe_u32 extracts the 8-bit lane count fields from entry s3 (0x0008_0008 or 0x0008_0000).
  • Resource & I/O raising (crates/victory-shader/src/resource.rs, crates/victory-shader/src/io.rs):
    • Track s[8:9] GS ring base loads (Resources::gs_ring_loads) so scalar ring loads do not fail resource resolution.
    • Trace ES-GS vertex input LDS offsets (Io::gs_loads) and GS-VS output ring writes (Io::gs_stores) with GsAddr.
  • Shader IR & DXIL emission (crates/victory-shader/src/emit/):
    • mod.rs / container.rs / rect.rs / shader.rs: Accept HwStage::Gs, extract and validate Geometry metadata (input_primitive in 1..=3, output_topology in {1, 3, 5}, stream_mask == 1, max_vertices > 0) from PSV0, normalize GS inputs and outputs via psv_interpolation, and emit DXIL geometry shader metadata.
    • lower.rs: Thread Geometry via lower_with_geometry, map Input::MergedWaveInfo active thread count, validate GS load vertex < input_primitive, GS store/emit vertex < max_vertices, stream == 0, no loop/cross-block output staging, implement load_input_at for ES-GS ds_read, flush staged outputs on s_sendmsg (storeOutput, emitStream, cutStream), zero GS ring descriptor smem loads, and gate test-only lower / lower_counted behind #[cfg(test)].
    • host.rs / gs_tests.rs: Add Host::geometry_pipeline helper plus unit/DXIL/D3D12 PSO/draw tests covering both 2-row and 5-row sparse 0xf0 layouts and unsupported-configuration refusal cases.
  • GPU runtime & CLI (crates/victory-gpu/, apps/victory/src/translate.rs):
    • Handle HwStage::Gs in TablePlan (pipeline.rs), stores_picked (picked.rs), and HostPipeline (pipeline/host.rs: "geometry" visibility, GS bytecode lookup, separate "graphics geometry" pipeline library key, and rect-GS fallback separation).
    • Track geometry shader counts and validate host GS pipelines in victory translate.

Verification

  • cargo test --locked -p xtask (9 passed, including repository_passes_policy)
  • cargo clippy --workspace --all-targets --locked -- -D warnings (passed)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings (passed)
  • cargo test --workspace --locked (passed; victory-shader: 311 passed, 4 ignored; victory-gpu: watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view passed isolated and on rerun)
  • cargo test --workspace --all-features --locked -- --test-threads=1 (all workspace test targets passed with 0 failures)
  • .\target\diag\victory.exe translate --validate --pipelines on all 195 GS_VoxelizeGeneric_* containers from shaders.rpf on AMD Radeon RX 6600 (195 emitted of 195 geometry programs; 195 validated, 195 pipelines)
**@⁠R1kkku** on GitHub · 2026-11-27 01:08 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/433) `R1kkku:pr/geometry-shader-support` → `a-publier` · +1835 −125 · 14 files · 1 commits · open ## Summary Adds translation and host pipeline support for `HwStage::Gs` (Xbox/RDNA merged ES-GS) shaders, covering the remaining 195 `GS_VoxelizeGeneric_*` programs in `shaders.rpf` so all 25,889 of 25,889 shaders in the title archive translate, pass `dxil.dll` validation, and build D3D12 PSOs. > **Scope note:** As noted in `README.md`, the title's current rendering path does not dispatch these `GS_VoxelizeGeneric_*` shaders, so this PR is primarily shader-pipeline completeness rather than a runtime FPS/stability change. ### Changes - **Structurisation (`crates/victory-shader/src/structure.rs`):** - Fold the merged-wave GS exec mask setup (`s_bfm_b64 exec, bfe(s3), 0`) to `Bool::TRUE` only when `s_bfe_i32`/`s_bfe_u32` extracts the 8-bit lane count fields from entry `s3` (`0x0008_0008` or `0x0008_0000`). - **Resource & I/O raising (`crates/victory-shader/src/resource.rs`, `crates/victory-shader/src/io.rs`):** - Track `s[8:9]` GS ring base loads (`Resources::gs_ring_loads`) so scalar ring loads do not fail resource resolution. - Trace ES-GS vertex input LDS offsets (`Io::gs_loads`) and GS-VS output ring writes (`Io::gs_stores`) with `GsAddr`. - **Shader IR & DXIL emission (`crates/victory-shader/src/emit/`):** - `mod.rs` / `container.rs` / `rect.rs` / `shader.rs`: Accept `HwStage::Gs`, extract and validate `Geometry` metadata (`input_primitive` in `1..=3`, `output_topology` in `{1, 3, 5}`, `stream_mask == 1`, `max_vertices > 0`) from `PSV0`, normalize GS inputs and outputs via `psv_interpolation`, and emit DXIL geometry shader metadata. - `lower.rs`: Thread `Geometry` via `lower_with_geometry`, map `Input::MergedWaveInfo` active thread count, validate GS load vertex `< input_primitive`, GS store/emit vertex `< max_vertices`, `stream == 0`, no loop/cross-block output staging, implement `load_input_at` for ES-GS `ds_read`, flush staged outputs on `s_sendmsg` (`storeOutput`, `emitStream`, `cutStream`), zero GS ring descriptor `smem` loads, and gate test-only `lower` / `lower_counted` behind `#[cfg(test)]`. - `host.rs` / `gs_tests.rs`: Add `Host::geometry_pipeline` helper plus unit/DXIL/D3D12 PSO/draw tests covering both 2-row and 5-row sparse `0xf0` layouts and unsupported-configuration refusal cases. - **GPU runtime & CLI (`crates/victory-gpu/`, `apps/victory/src/translate.rs`):** - Handle `HwStage::Gs` in `TablePlan` (`pipeline.rs`), `stores_picked` (`picked.rs`), and `HostPipeline` (`pipeline/host.rs`: `"geometry"` visibility, GS bytecode lookup, separate `"graphics geometry"` pipeline library key, and rect-GS fallback separation). - Track geometry shader counts and validate host GS pipelines in `victory translate`. ## Verification - `cargo test --locked -p xtask` (9 passed, including `repository_passes_policy`) - `cargo clippy --workspace --all-targets --locked -- -D warnings` (passed) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` (passed) - `cargo test --workspace --locked` (passed; `victory-shader`: 311 passed, 4 ignored; `victory-gpu`: `watch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view` passed isolated and on rerun) - `cargo test --workspace --all-features --locked -- --test-threads=1` (all workspace test targets passed with 0 failures) - `.\target\diag\victory.exe translate --validate --pipelines` on all 195 `GS_VoxelizeGeneric_*` containers from `shaders.rpf` on AMD Radeon RX 6600 (`195 emitted of 195 geometry programs; 195 validated, 195 pipelines`)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:33:29 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-27 02:22 UTC · original

Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At 5807bca: cargo test --release -p victory-gpu --lib 396 passed, 0 failed, 34 ignored; cargo test --release -p victory-shader --lib 311 passed, 0 failed, 4 ignored.

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-27 02:22 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/433#issuecomment-7208062692) Tested on an RX 6950 XT (RDNA 2), driver 32.0.21045.29003, Windows 11 build 26300, Rust 1.98.1, release. At `5807bca`: `cargo test --release -p victory-gpu --lib` 396 passed, 0 failed, 34 ignored; `cargo test --release -p victory-shader --lib` 311 passed, 0 failed, 4 ignored. AI-assisted (Claude Code); no game data.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-27 12:31 UTC · original

Tested on an RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release. Head 5807bca against base 4eb6cfd (current a-publier).

Whole shaders.rpf, translate --validate --list, default wave and VICTORY_HOST_WAVE=32 (same results), head vs base:

  • All 195 refused GS (GS_VoxelizeGeneric) are now emitted and validated. They give 4 distinct host shaders (153/36/5/1).
  • 0 programs lost. CS and MS output is byte-identical. The 71 MS that fail validation (output size > 32768) still fail, so not all 25889 pass dxil.dll. They still get pipelines.
  • 13431 VS/PS outputs change bytes (all 2191 VS, 11240 of 12056 PS). All of them still validate.
  • This is the constant-order change described in #471 (vert in load_input_at is built before the args array). It is now checked by translation on this head. Building it as the last array element again makes all non-GS output byte-identical to 4eb6cfd at both waves. The 195 GS outputs do not change:
-        let vert = match vertex {
-            Some(v) => self.s.m.i32(v),
-            None => self.s.m.undef(self.s.t.i32),
-        };
         let args = [
             self.s.m.i32(id as u32),
             self.s.m.i32(0),
             self.s.m.i8(col),
-            vert,
+            match vertex {
+                Some(v) => self.s.m.i32(v),
+                None => self.s.m.undef(self.s.t.i32),
+            },
         ];
  • The s_bfm exec fold in structure.rs is not gated on GS. The structured summary line changes (guarded 790411 -> 764087, on opaque masks 28029 -> 1705). With the patch above, no non-GS output changes.

translate --validate --pipelines, whole archive, on the 7900 XT:

  • Base: 25694 pipelines. Head: 25889 (VS+PS 14247, CS 2682, MS 8765, GS 195).
  • The only change in pipeline outcome is the 195 GS, from refused to created. No pipeline refusals and nothing on stderr.
  • With the patch above, the 195 GS have the same bytes and all 195 pipelines are created.

WARP (VICTORY_WARP=1), --pipelines: the 195 GS plus 300 sampled changed VS/PS, 495/495 pipelines.

Tests, --test-threads=1:

  • a_voxelization_geometry_shader_compiles_on_the_host and a_five_row_sparse_geometry_shader_compiles_and_draws passed 3/3 each. The voxelization test printed no skip message.
  • The five-row test only builds the PSO and does not draw. It skips a missing device silently (let Ok(host) = Host::new(warp) else { continue; }), so a pass does not show that a device was used.
  • The voxelization draw gives all three vertices the same attribute, so its texel check cannot catch a wrong GS vertex index.
  • Lib suites give the same counts as already posted, also on RDNA 3. Base 4eb6cfd: victory-shader 303 passed, 0 failed, 4 ignored; victory-gpu 396 passed, 0 failed, 34 ignored.

Not tested: in game (these GS are not dispatched), debug builds, a draw with the five-row layout.

**@⁠adrianmjim** on GitHub · 2026-11-27 12:31 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/433#issuecomment-7218348594) Tested on an RX 7900 XT (RDNA 3), driver 32.0.32029.2010, Windows 11 26300, Rust 1.98.1, release. Head `5807bca` against base `4eb6cfd` (current `a-publier`). Whole `shaders.rpf`, `translate --validate --list`, default wave and `VICTORY_HOST_WAVE=32` (same results), head vs base: - All 195 refused GS (`GS_VoxelizeGeneric`) are now emitted and validated. They give 4 distinct host shaders (153/36/5/1). - 0 programs lost. CS and MS output is byte-identical. The 71 MS that fail validation (output size > 32768) still fail, so not all 25889 pass `dxil.dll`. They still get pipelines. - 13431 VS/PS outputs change bytes (all 2191 VS, 11240 of 12056 PS). All of them still validate. - This is the constant-order change described in https://git.gtahub.st/github/Belobug--VIctory-Belobug-AMD/pulls/471 (`vert` in `load_input_at` is built before the `args` array). It is now checked by translation on this head. Building it as the last array element again makes all non-GS output byte-identical to `4eb6cfd` at both waves. The 195 GS outputs do not change: ```diff - let vert = match vertex { - Some(v) => self.s.m.i32(v), - None => self.s.m.undef(self.s.t.i32), - }; let args = [ self.s.m.i32(id as u32), self.s.m.i32(0), self.s.m.i8(col), - vert, + match vertex { + Some(v) => self.s.m.i32(v), + None => self.s.m.undef(self.s.t.i32), + }, ]; ``` - The `s_bfm` exec fold in `structure.rs` is not gated on GS. The `structured` summary line changes (guarded 790411 -> 764087, on opaque masks 28029 -> 1705). With the patch above, no non-GS output changes. `translate --validate --pipelines`, whole archive, on the 7900 XT: - Base: 25694 pipelines. Head: 25889 (VS+PS 14247, CS 2682, MS 8765, GS 195). - The only change in pipeline outcome is the 195 GS, from refused to created. No pipeline refusals and nothing on stderr. - With the patch above, the 195 GS have the same bytes and all 195 pipelines are created. WARP (`VICTORY_WARP=1`), `--pipelines`: the 195 GS plus 300 sampled changed VS/PS, 495/495 pipelines. Tests, `--test-threads=1`: - `a_voxelization_geometry_shader_compiles_on_the_host` and `a_five_row_sparse_geometry_shader_compiles_and_draws` passed 3/3 each. The voxelization test printed no skip message. - The five-row test only builds the PSO and does not draw. It skips a missing device silently (`let Ok(host) = Host::new(warp) else { continue; }`), so a pass does not show that a device was used. - The voxelization draw gives all three vertices the same attribute, so its texel check cannot catch a wrong GS vertex index. - Lib suites give the same counts as already posted, also on RDNA 3. Base `4eb6cfd`: victory-shader 303 passed, 0 failed, 4 ignored; victory-gpu 396 passed, 0 failed, 34 ignored. Not tested: in game (these GS are not dispatched), debug builds, a draw with the five-row layout.
This pull request can be merged automatically.
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/433/head:github-bot/gh-433'
git switch 'github-bot/gh-433'

Merge

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