Shaders, GPU: port VIctory#2398, link over-budget mesh and pixel shaders under the 32 KiB output limit (#125) #138
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!138
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-138"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@eIBart0 on GitHub · 2026-11-25 16:12 UTC · original
port-2398→main· +874 −50 · 6 files · 4 commits · closed without mergingFixes #125 on this fork: 71 character mesh shaders (
MS_VS_PedTransform*,MSNC_VS_PedTransformSkin*,*Spatter_Fire_AlphaPrepass) were refused withmesh 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 inemit/lower.rsandemit/mod.rswere resolved keeping this fork's paths (TargetAPI, compute retries,CONSOLE_FLOW/structure_console); upstream'sstructure::killingbranch does not exist here and is not needed. The standalone translation of an over-budget mesh now emits, soHostPipelinecan measure it and link it with its pixel shader.0057588:WAVE_OPSis set only wherewaveGetLaneIndexis emitted. Mesh shaders that usev_mbcnt(-1)as their lane id declaredWaveOpswithout 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_translatedkeeps the source container soname()works in diagnostics builds.Tested on RX 9070 XT (driver 32.0.31041.3013), Ryzen 7 5800X3D, Windows 11:
translate --liston the game's shaders: 8,765 of 8,765 mesh programs translate (71 refused before); 195 refusals left, allan 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 twowatch::tests fail intermittently, as in #102 (this PR does not touchwatch.rs).@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'sshaders.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_foron each shader, thenemit::translate_linkedbecause each mesh is over 32 KiB alone, then validation andHost::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 on01aadd1. 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:
mesh_prologuenow runs only for pruned translations, soemit::translate/translate_forreturns invalid DXIL for these meshes without an error. On this driverCreatePipelineStateaccepts them anyway:--pipelineson 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 pathHostPipeline::newlinks them first, so it is safe there. A refusal, or a flag onHostShaderthatHostPipelineacts on, would keep other callers from getting invalid DXIL silently.translate_linkedfails,pipeline.rswarns "linked mesh/pixel translation failed; using standalone translation", butpipeline/host.rsthen 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=1gave 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 --libgives the same results asmain(only the known intermittentwatchtest).@adrianmjim on GitHub · 2026-11-25 19:40 UTC · original
Heads-up: at
d03b06bthis merges cleanly on the currentmain(000ffdd) but does not build there.mainadded those two fields in44dcd43. Copying them from the source shader, ashairandresolves_lightalready are, builds:With that change, and merged together with #144 (one conflict in
emit/mod.rs, aroundlower_pruned, where both sides are kept),cargo test -p victory-shader --lib -- --test-threads=1gives 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.@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
a59f3e5and force-pushed it. It builds there with and withoutdiagnostics.main(your heads-up):Shader::from_translatednow copiesdraws_skyandends_reflectionsfrom the source shader. That change is folded into the first commit, so each commit builds on its own.translate --pipelinesno 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_fordocuments 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.Tested on an RX 9070 XT with Windows 11 26220: the cell scene draws faces and skin on top of
a59f3e5.@adrianmjim on GitHub · 2026-11-25 21:16 UTC · original
Re-checked
2f802e8on the same RX 7900 XT (Windows 11 26300, dxil.dll 10.0.26100.0):000ffddwithout conflicts, and the merge, as well as the head as it is, builds in release.d03b06b. Linked mesh outputs are 21,504–30,720 bytes, as before.--validate --pipelines --list: 0 pipelines (71 before), and each one is listed aspipeline: mesh outputs over 32 KiB alone (made only linked with its pixel program).translate --validate --list --host-lanes 32-64onshaders.rpf,000ffddagainst000ffdd+ this PR. VS/PS 14,247/14,247 and CS 2,682/2,682 on both. Nothing changes outcome except the 71 meshes.victory-shader --lib: 270 passed, 0 failed, 6 ignored, the 4 new tests included.victory-gpu --lib: 112 passed. The only failure is the intermittentwatchtest, which fails onmaintoo 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:
--pipelines. The new label sits behindchecks.host(apps/victory/src/translate.rs), so under--validatealone 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.--pipelines --validate. The over-budget branch callst.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 translationrefusal 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 KiBrefusal there is gone, and no mesh or vertex shader fails to translate.Pull request closed