Shaders, GPU: port VIctory#2398, link over-budget mesh and pixel shaders under the 32 KiB output limit (#125) #138

Closed
github-bot wants to merge 4 commits from github-bot/gh-138 into main AGit
Owner

@⁠eIBart0 on GitHub · 2026-11-25 16:12 UTC · original
port-2398 → main · +874 −50 · 6 files · 4 commits · closed without merging

Fixes #125 on this fork: 71 character mesh shaders (MS_VS_PedTransform*, MSNC_VS_PedTransformSkin*, *Spatter_Fire_AlphaPrepass) were refused with mesh outputs beyond the host's 32 KiB, so characters were drawn without face skin.

Commits:

  • 7accb01: cherry-pick of Marvisak/VIctory#2398 (35ae33b, Texbirds, authorship kept). Conflicts in emit/lower.rs and emit/mod.rs were resolved keeping this fork's paths (Target API, compute retries, CONSOLE_FLOW / structure_console); upstream's structure::killing branch does not exist here and is not needed. The standalone translation of an over-budget mesh now emits, so HostPipeline can measure it and link it with its pixel shader.
  • 0057588: WAVE_OPS is set only where waveGetLaneIndex is emitted. Mesh shaders that use v_mbcnt(-1) as their lane id declared WaveOps without a wave op, which dxil.dll rejects ("Flags must match usage"). Adds a cross-platform test.
  • d03b06b: a mesh pipeline that is still over 32 KiB after linking is refused before the PSO is made, as before the port. Shader::from_translated keeps the source container so name() works in diagnostics builds.

Tested on RX 9070 XT (driver 32.0.31041.3013), Ryzen 7 5800X3D, Windows 11:

  • translate --list on the game's shaders: 8,765 of 8,765 mesh programs translate (71 refused before); 195 refusals left, all an address in an SGPR that is no root parameter.
  • cargo test -p victory-shader: 270 passed, 0 failed (the PR's three tests and the new one included, with dxil.dll validation). victory-gpu: the two watch:: tests fail intermittently, as in #102 (this PR does not touch watch.rs).
  • In game: faces and skin render in the opening cutscenes and the first gameplay; gameplay frame times unchanged (about 3 fps on this machine).
**@⁠eIBart0** on GitHub · 2026-11-25 16:12 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/138) `port-2398` → `main` · +874 −50 · 6 files · 4 commits · closed without merging Fixes #125 on this fork: 71 character mesh shaders (`MS_VS_PedTransform*`, `MSNC_VS_PedTransformSkin*`, `*Spatter_Fire_AlphaPrepass`) were refused with `mesh outputs beyond the host's 32 KiB`, so characters were drawn without face skin. Commits: - `7accb01`: cherry-pick of Marvisak/VIctory#2398 (`35ae33b`, Texbirds, authorship kept). Conflicts in `emit/lower.rs` and `emit/mod.rs` were resolved keeping this fork's paths (`Target` API, compute retries, `CONSOLE_FLOW` / `structure_console`); upstream's `structure::killing` branch does not exist here and is not needed. The standalone translation of an over-budget mesh now emits, so `HostPipeline` can measure it and link it with its pixel shader. - `0057588`: `WAVE_OPS` is set only where `waveGetLaneIndex` is emitted. Mesh shaders that use `v_mbcnt(-1)` as their lane id declared `WaveOps` without a wave op, which dxil.dll rejects ("Flags must match usage"). Adds a cross-platform test. - `d03b06b`: a mesh pipeline that is still over 32 KiB after linking is refused before the PSO is made, as before the port. `Shader::from_translated` keeps the source container so `name()` works in diagnostics builds. Tested on RX 9070 XT (driver 32.0.31041.3013), Ryzen 7 5800X3D, Windows 11: - `translate --list` on the game's shaders: 8,765 of 8,765 mesh programs translate (71 refused before); 195 refusals left, all `an address in an SGPR that is no root parameter`. - `cargo test -p victory-shader`: 270 passed, 0 failed (the PR's three tests and the new one included, with dxil.dll validation). `victory-gpu`: the two `watch::` tests fail intermittently, as in #102 (this PR does not touch `watch.rs`). - In game: faces and skin render in the opening cutscenes and the first gameplay; gameplay frame times unchanged (about 3 fps on this machine).
(cherry picked from commit 35ae33b521cf1ec184324ed604b34e0ced07aa85)
translate --pipelines no longer builds a pipeline of a mesh program whose
outputs exceed D3D12's 32 KiB alone (only the validator caught that DXIL):
it is listed as made only linked with its pixel program, as the runtime
does. translate_for documents that such a mesh program is emitted for
linking and is not valid DXIL alone. A failed linked translation is no
longer logged as falling back to the standalone one, and the pipeline's
refusal names both causes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:30 +00:00
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:41 UTC · original

I ran this PR (d03b06b) on an RX 7900 XT (Windows 11 build 26300, dxil.dll from Windows Kits 10.0.26100.0) against the game's shaders.rpf, without running the game itself.

Linked pairs. The 71 over-budget mesh programs can be paired with pixel shaders whose input signature matches. I built 1178 candidate pairs that way, offline, covering all 71 mesh programs (2 to 36 pairs each) and 89 distinct pixel programs. With a local harness that follows HostPipeline::new (translate_for on each shader, then emit::translate_linked because each mesh is over 32 KiB alone, then validation and Host::mesh_pipeline), all 1178 linked pairs validate and create a mesh pipeline. The linked mesh outputs come to 21,504 to 30,720 bytes. These are signature-compatible candidates, not pairs seen in the title. Which pixel shader the title binds with each mesh can only be seen at run time.

Corpus, translated alone (victory translate --validate --list --host-lanes 32-64): VS/PS 14,247/14,247 and CS 2,682/2,682, as on 01aadd1. Mesh: 8,765 of 8,765 emitted, but still 8,694 validated. The 71 are now emitted and then fail the validator ("vertex plus primitive output size is greater than 32768") instead of being refused. No other program changes outcome. Clamping the counts to the thread count brings none of the 71 under 32 KiB, since they all have 128 threads and 128 vertices.

Two things I noticed:

  • Over-budget meshes alone. The 32 KiB check in mesh_prologue now runs only for pruned translations, so emit::translate/translate_for returns invalid DXIL for these meshes without an error. On this driver CreatePipelineState accepts them anyway: --pipelines on the 71 alone reports 71 pipelines created with the stub pixel shader. So the CLI's pipeline count overstates what is legal, and only the validator catches it. In the game path HostPipeline::new links them first, so it is safe there. A refusal, or a flag on HostShader that HostPipeline acts on, would keep other callers from getting invalid DXIL silently.
  • Log text. When translate_linked fails, pipeline.rs warns "linked mesh/pixel translation failed; using standalone translation", but pipeline/host.rs then refuses the pipeline with "mesh outputs beyond 32 KiB after linking". That is true for any failure, not just the size one.

Tests: cargo test -p victory-shader --lib -- --test-threads=1 gave 270 passed, 0 failed. The linked draw test really built the mesh PSO and drew on both the 7900 XT and WARP (no "skipped" line). victory-gpu --lib gives the same results as main (only the known intermittent watch test).

**@⁠adrianmjim** on GitHub · 2026-11-25 17:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/138#issuecomment-7169868435) I ran this PR (`d03b06b`) on an RX 7900 XT (Windows 11 build 26300, dxil.dll from Windows Kits 10.0.26100.0) against the game's `shaders.rpf`, without running the game itself. **Linked pairs.** The 71 over-budget mesh programs can be paired with pixel shaders whose input signature matches. I built 1178 candidate pairs that way, offline, covering all 71 mesh programs (2 to 36 pairs each) and 89 distinct pixel programs. With a local harness that follows `HostPipeline::new` (`translate_for` on each shader, then `emit::translate_linked` because each mesh is over 32 KiB alone, then validation and `Host::mesh_pipeline`), **all 1178 linked pairs validate and create a mesh pipeline**. The linked mesh outputs come to 21,504 to 30,720 bytes. These are signature-compatible candidates, not pairs seen in the title. Which pixel shader the title binds with each mesh can only be seen at run time. **Corpus, translated alone** (`victory translate --validate --list --host-lanes 32-64`): VS/PS 14,247/14,247 and CS 2,682/2,682, as on `01aadd1`. Mesh: 8,765 of 8,765 emitted, but still 8,694 validated. The 71 are now emitted and then fail the validator ("vertex plus primitive output size is greater than 32768") instead of being refused. No other program changes outcome. Clamping the counts to the thread count brings none of the 71 under 32 KiB, since they all have 128 threads and 128 vertices. Two things I noticed: - **Over-budget meshes alone.** The 32 KiB check in `mesh_prologue` now runs only for pruned translations, so `emit::translate`/`translate_for` returns invalid DXIL for these meshes without an error. On this driver `CreatePipelineState` accepts them anyway: `--pipelines` on the 71 alone reports 71 pipelines created with the stub pixel shader. So the CLI's pipeline count overstates what is legal, and only the validator catches it. In the game path `HostPipeline::new` links them first, so it is safe there. A refusal, or a flag on `HostShader` that `HostPipeline` acts on, would keep other callers from getting invalid DXIL silently. - **Log text.** When `translate_linked` fails, `pipeline.rs` warns "linked mesh/pixel translation failed; using standalone translation", but `pipeline/host.rs` then refuses the pipeline with "mesh outputs beyond 32 KiB after linking". That is true for any failure, not just the size one. Tests: `cargo test -p victory-shader --lib -- --test-threads=1` gave 270 passed, 0 failed. The linked draw test really built the mesh PSO and drew on both the 7900 XT and WARP (no "skipped" line). `victory-gpu --lib` gives the same results as `main` (only the known intermittent `watch` test).
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 19:40 UTC · original

Heads-up: at d03b06b this merges cleanly on the current main (000ffdd) but does not build there.

error[E0063]: missing fields `draws_sky` and `ends_reflections` in initializer of `Shader`
  --> crates\victory-gpu\src\pipeline.rs:364:18  (Shader::from_translated)

main added those two fields in 44dcd43. Copying them from the source shader, as hair and resolves_light already are, builds:

            resolves_light: source.resolves_light,
            draws_sky: source.draws_sky,
            ends_reflections: source.ends_reflections,
            translated: cell,

With that change, and merged together with #144 (one conflict in emit/mod.rs, around lower_pruned, where both sides are kept), cargo test -p victory-shader --lib -- --test-threads=1 gives 271 passed, 0 failed (RX 7900 XT, Windows 11). The result is on https://github.com/adrianmjim/VIctory-Belobug-AMD/tree/test/main-144-138 for #26, where an RX 7700 XT shows characters and walls missing.

**@⁠adrianmjim** on GitHub · 2026-11-25 19:40 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/138#issuecomment-7172609920) Heads-up: at `d03b06b` this merges cleanly on the current `main` (`000ffdd`) but does not build there. ``` error[E0063]: missing fields `draws_sky` and `ends_reflections` in initializer of `Shader` --> crates\victory-gpu\src\pipeline.rs:364:18 (Shader::from_translated) ``` `main` added those two fields in `44dcd43`. Copying them from the source shader, as `hair` and `resolves_light` already are, builds: ```rust resolves_light: source.resolves_light, draws_sky: source.draws_sky, ends_reflections: source.ends_reflections, translated: cell, ``` With that change, and merged together with #144 (one conflict in `emit/mod.rs`, around `lower_pruned`, where both sides are kept), `cargo test -p victory-shader --lib -- --test-threads=1` gives 271 passed, 0 failed (RX 7900 XT, Windows 11). The result is on https://github.com/adrianmjim/VIctory-Belobug-AMD/tree/test/main-144-138 for #26, where an RX 7700 XT shows characters and walls missing.
Author
Owner

@⁠eIBart0 on GitHub · 2026-11-25 20:14 UTC · original

Thanks for both reports, and for pairing the 71 with their pixel programs offline: 1178 of 1178 linked pairs validating and making a pipeline on the 7900 XT is more coverage than I had.

I rebased the branch on a59f3e5 and force-pushed it. It builds there with and without diagnostics.

  • Build on current main (your heads-up): Shader::from_translated now copies draws_sky and ends_reflections from the source shader. That change is folded into the first commit, so each commit builds on its own.
  • Over-budget meshes alone: translate --pipelines no longer makes a pipeline of an over-budget mesh program alone. It is listed as "mesh outputs over 32 KiB alone (made only linked with its pixel program)", so the CLI's pipeline count no longer includes DXIL that only the validator would reject. translate_for documents that such a program is emitted for linking and is not valid on its own. I kept it emitting rather than refusing, because the runtime needs the standalone translation to measure the size and to link it.
  • Log text: a failed linked translation is no longer logged as "using standalone translation". The refusal now says "mesh outputs over 32 KiB and no valid linked translation", and the warning just before it keeps the actual error.

Tested on an RX 9070 XT with Windows 11 26220: the cell scene draws faces and skin on top of a59f3e5.

**@⁠eIBart0** on GitHub · 2026-11-25 20:14 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/138#issuecomment-7173375437) Thanks for both reports, and for pairing the 71 with their pixel programs offline: 1178 of 1178 linked pairs validating and making a pipeline on the 7900 XT is more coverage than I had. I rebased the branch on a59f3e5 and force-pushed it. It builds there with and without `diagnostics`. - **Build on current `main`** (your heads-up): `Shader::from_translated` now copies `draws_sky` and `ends_reflections` from the source shader. That change is folded into the first commit, so each commit builds on its own. - **Over-budget meshes alone:** `translate --pipelines` no longer makes a pipeline of an over-budget mesh program alone. It is listed as "mesh outputs over 32 KiB alone (made only linked with its pixel program)", so the CLI's pipeline count no longer includes DXIL that only the validator would reject. `translate_for` documents that such a program is emitted for linking and is not valid on its own. I kept it emitting rather than refusing, because the runtime needs the standalone translation to measure the size and to link it. - **Log text:** a failed linked translation is no longer logged as "using standalone translation". The refusal now says "mesh outputs over 32 KiB and no valid linked translation", and the warning just before it keeps the actual error. Tested on an RX 9070 XT with Windows 11 26220: the cell scene draws faces and skin on top of a59f3e5.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 21:16 UTC · original

Re-checked 2f802e8 on the same RX 7900 XT (Windows 11 26300, dxil.dll 10.0.26100.0):

  • Build: it merges into 000ffdd without conflicts, and the merge, as well as the head as it is, builds in release.
  • Linked pairs: all 1178 pairs still translate linked, pass the validator for both shaders and create a mesh pipeline. The output (route, sizes, results) is byte-identical to d03b06b. Linked mesh outputs are 21,504–30,720 bytes, as before.
  • The 71 alone, --validate --pipelines --list: 0 pipelines (71 before), and each one is listed as pipeline: mesh outputs over 32 KiB alone (made only linked with its pixel program).
  • Corpus: translate --validate --list --host-lanes 32-64 on shaders.rpf, 000ffdd against 000ffdd + this PR. VS/PS 14,247/14,247 and CS 2,682/2,682 on both. Nothing changes outcome except the 71 meshes.
  • Tests on the merge:
    • victory-shader --lib: 270 passed, 0 failed, 6 ignored, the 4 new tests included.
    • victory-gpu --lib: 112 passed. The only failure is the intermittent watch test, which fails on main too and passes alone 3 of 3. The new linked mesh/pixel GPU test ran (no "skipped" line).

One small thing left in the CLI's report:

  • Without --pipelines. The new label sits behind checks.host (apps/victory/src/translate.rs), so under --validate alone the 71 are now emitted and listed as 71 validator failures (vertex plus primitive output size is greater than 32768). The summary reads "8765 emitted of 8765 mesh programs; 8694 validated", where before it was a clear refusal. Someone reading the summary would take them for 71 broken programs.
  • With --pipelines --validate. The over-budget branch calls t.fail(..) without returning, so each of the 71 gets both lines, the label and the validator error.

Skipping the standalone validation of an over-budget mesh, and giving it the label in both modes, would keep the report as clear as the refusal was. Not tested here: the no valid linked translation refusal never fires on this archive, since every linked translation fits.

The in-game report on #26 (RX 7700 XT) is consistent with this: with this PR merged, the mesh outputs beyond the host's 32 KiB refusal there is gone, and no mesh or vertex shader fails to translate.

**@⁠adrianmjim** on GitHub · 2026-11-25 21:16 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/138#issuecomment-7174853636) Re-checked `2f802e8` on the same RX 7900 XT (Windows 11 26300, dxil.dll 10.0.26100.0): - **Build:** it merges into `000ffdd` without conflicts, and the merge, as well as the head as it is, builds in release. - **Linked pairs:** all 1178 pairs still translate linked, pass the validator for both shaders and create a mesh pipeline. The output (route, sizes, results) is byte-identical to `d03b06b`. Linked mesh outputs are 21,504–30,720 bytes, as before. - **The 71 alone, `--validate --pipelines --list`:** 0 pipelines (71 before), and each one is listed as `pipeline: mesh outputs over 32 KiB alone (made only linked with its pixel program)`. - **Corpus:** `translate --validate --list --host-lanes 32-64` on `shaders.rpf`, `000ffdd` against `000ffdd` + this PR. VS/PS 14,247/14,247 and CS 2,682/2,682 on both. Nothing changes outcome except the 71 meshes. - **Tests on the merge:** - `victory-shader --lib`: 270 passed, 0 failed, 6 ignored, the 4 new tests included. - `victory-gpu --lib`: 112 passed. The only failure is the intermittent `watch` test, which fails on `main` too and passes alone 3 of 3. The new linked mesh/pixel GPU test ran (no "skipped" line). One small thing left in the CLI's report: - **Without `--pipelines`.** The new label sits behind `checks.host` (`apps/victory/src/translate.rs`), so under `--validate` alone the 71 are now emitted and listed as 71 validator failures (`vertex plus primitive output size is greater than 32768`). The summary reads "8765 emitted of 8765 mesh programs; 8694 validated", where before it was a clear refusal. Someone reading the summary would take them for 71 broken programs. - **With `--pipelines --validate`.** The over-budget branch calls `t.fail(..)` without returning, so each of the 71 gets both lines, the label and the validator error. Skipping the standalone validation of an over-budget mesh, and giving it the label in both modes, would keep the report as clear as the refusal was. Not tested here: the `no valid linked translation` refusal never fires on this archive, since every linked translation fits. The in-game report on #26 (RX 7700 XT) is consistent with this: with this PR merged, the `mesh outputs beyond the host's 32 KiB` refusal there is gone, and no mesh or vertex shader fails to translate.
github-bot closed this pull request 2026-11-27 12:31:21 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.