Shaders: link mesh and pixel programs whose mesh outputs pass 32 KiB #1562
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1563"
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?
Imported from Marvisak/VIctory. Originally posted by claude-GTA6 on 2026-11-24T19:12:36Z.
From a tester working with Claude (AI-assisted); measured on my own machine.
Why
dxil.dll refuses 53 mesh programs of this title with "vertex plus primitive output size is greater than 32768". They export 65-68 output components from 128 lanes: 68 × 128 × 4 = 34,816 bytes, past 32 KiB even at one vertex per lane. NVIDIA builds such pipelines anyway, which is undefined behaviour on the GPU.
#459 lowered the declared maxima to the lane count. That lowering is correct, but it was closed because it cleared none of the 53: at the lane count they are still too big. Getting them under the cap needs fewer components, and a mesh program on its own cannot tell which of its outputs are unused. The pixel program it is drawn with can.
What
emit::translate_linkedre-emits such a mesh program and its pixel program for each other when the pipeline is made:D3D12 links equal masks only. I checked on the debug layer that both sides have to change together: a pruned mesh side alone is refused ("hardware register component mask that does not match the output of the previous stage"), and so are masks narrowed on one side.
The elements stay in the program while it is lowered, because packed 16-bit halves are placed from every element of a row. Removing them first moved halves onto other elements; the debug layer reported that as "always read by the downstream shader, but never written". Exports past the linked columns are dropped, and the signature is cut when the module is finished (
lower::Parts::linked_cols). Reads past them stop the program, so the pair falls back to the original shaders.The fewer components still have to fit at the lane count, so this keeps #459's measurement and lowering (
container::mesh_output_bytes, the maxima inmesh_prologue, and its tests), credited to AnoHunted in the commit.The GPU side (
pipeline/host.rs,linked) uses the linked pair only when its bindings equal the originals' (the root signature is built from those). Otherwise, and for every mesh program that already fits, nothing changes.Measured
Offline, on this branch (upstream main plus this change), with the title's
shaders.rpfand executable. The validator was dxil.dll from SDK 10.0.26100 and the GPU an RTX 5090.Mesh programs refused for the output size are still 53, because
translatesees each program alone. To count what happens at pipeline creation, a scratch harness (not part of this PR) paired each of the 53 with every pixel program of the same effect, the shared suffix in the names. That made 3,505 pairs. For each pair it rantranslate_linked, validated both programs, and built the mesh pipeline:All 53 mesh programs link with at least one pixel program of their effect, and 6 of them link with every one. The 1,517 refused pairs are refused just the same without linking, so they look like pairs the effect never draws together, not a fault of the link.
On an RTX 5090, with the over-limit pair this title's world actually binds (a mesh program with 68 components and its pixel program):
This does not fix the world hang on NVIDIA (DRED still stops at the same pixel-loop draw as before); it only removes one source of invalid modules.
Other programs are unchanged: the linked path is off unless a pipeline needs it. On our fork, with this change, I compared every emitted program over the title's shaders before and after, and all programs that validated before are byte-identical.
Tests: five in
victory-shader. Three are #459's (output size, maxima lowering, maxima still past the cap), and two are new:a_linked_mesh_program_leaves_out_what_the_pixel_program_never_readsuses #459's synthetic mesh fixture (16 rows past the cap). The linked program declares 61 components and validates.linked_elements_keep_system_values_and_read_columnscovers the element rules.cargo test -p victory-shader(125 pass) andcargo clippy --workspace --all-targets -- -D warningsare clean on this branch.Not covered
Which pixel program a mesh program is drawn with is only known at pipeline creation. The offline count pairs by effect, which may include pairs the title never draws and miss ones it does. In game I have seen one over-limit pair bound. The
translatetool does not link pairs on this branch.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T19:20:49Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e),cargo test -p victory-shader --locked→ 101. Execution/valu tests are#[cfg(all(test, windows))]and were not run here.Mesh+pixel programs whose mesh outputs exceed 32 KiB are now linked (
linked(ms, ps)) and the linked bytecode is what the D3D12 pipeline state receives for both stages; non-mesh pipelines are untouched. The shader-sidelinked()has unit tests that run on macOS (101 passed, +5). Thevictory-gpuhost side is Windows-only and was not built here — the change is small and mirrors the existing bytecode selection, but please confirm on Windows before merge.Imported from Marvisak/VIctory. Originally posted by claude-GTA6 on 2026-11-24T19:47:43Z.
From a tester working with Claude (AI-assisted); measured on my own machine.
@catminou4 thanks. Confirmed on Windows 11 / RTX 5090 at this head (
4df3d0edonffe310e):cargo clippy --workspace --all-targets -- -D warnings, which buildsvictory-gpu's Windows-only host side, is clean, andcargo test -p victory-shaderpasses 125 there, including the Windows-only execution tests. The linked pair the title's world binds validates on both sides, its pipeline is created, and the D3D12 debug layer reports nothing.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:30:52Z.
Automated triage for the maintainers.
Merge candidate. When a mesh program's outputs pass 32 KiB even at one vertex per lane,
emit::translate_linkedre-emits it together with its pixel program, dropping the arbitrary values the pixel side never reads and narrowing the ones it does.pipeline/host.rs::linkeduses that pair only when every binding field matches the original shaders. I checked that:mesh_prologuelowers the maxima to the lane count, which matchesmesh_threadbeing the vertex and primitive index;usageis set, so thelinked_colscheck does not refuse ordinary linked programs;pixel_readstakes the rw-mask byte at offset 25 of each ISG1 element.The evidence is validator output, the debug layer and an in-game run. Two follow-ups: the pair is re-translated on every pipeline creation, so a cache keyed by the pair would help, and the pair counts in the description come from an older
main. This also editshost_shader's options next to #1931, so whichever merges second needs a small rebase.CI: no check runs reported for this head.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by reboot0000-cmd on 2026-11-25T01:50:11Z.
Heads-up on the engine behind these numbers, useful for the rebase the triage bot is asking for: the counts here (and in #1247's leaderboard) are taken with
dxil.dllfrom SDK 10.0.26100, which is the validator 1.7.2308 engine - itsFileVersionresource prints1.8.2502, which is easy to read as 1.8. That engine regeneratesPSV0from the module and byte-compares it, and our writer deduplicates the PSV0 semantic-name string table, so it rejects roughly 15k emitted modules withContainer part 'Pipeline State Validation' does not match expected for moduleon this archive even when the shader is fine. DXC 1.8+ replaced that with a content verifier that never rebuilds the table. Full write-up and the mechanical proof in #1945.That matters specifically for this PR: it rewrites both mesh and pixel signatures, so a linked pair can look like a regression or no gain purely because of the PSV0 comparison, and #1208's string-table change is exactly what a linked pair needs to read as a win on a current engine. Worth re-measuring with
VICTORY_DXILpointed at DXC 1.8.2502's or 1.9.2609'sdxil.dll.Our own measurement on main
70564ae0with the 1.8 engine: 71 mesh programs fail withvertex plus primitive output size is greater than 32768(this description's 53 were counted on an older main), and once the compute stage/dx.valverclass is cleared by #1065 these 71 are the only mesh validator failures left - i.e. this is the last outstanding validation gap for mesh, and the two output-size families (71 mesh now, 12,231 VS/PS before #1208) are the only things standing between the corpus and a clean--validaterun. Happy to re-measure a rebased branch here with the 1.8 engine and report program-by-program.Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-25T02:47:40Z.
Review: APPROVED
Tested
93f718dported onto our fork's main (upstream70564aeplus our merges) on Windows 11, RTX 5070, MSVC: builds, clippy-D warningsclean with and without--all-features, and the diagnostics build compiles.cargo test --workspace --no-fail-fast: 720 passed.mesh_output_size_counts_components_and_aligned_maxima,linked_elements_keep_system_values_and_read_columnsandmesh_outputs_past_32_kib_at_the_lane_count_keep_the_lane_maximapass.a_linked_mesh_program_leaves_out_what_the_pixel_program_never_readsandmesh_maxima_past_the_lanes_come_down_to_fitfail here with "Container part 'Pipeline State Validation' does not match expected for module". They fail the same way at this PR's own head on upstream, as does the existingelements_sharing_a_row_keep_their_orderon plain upstream main, with this host's dxil.dll 101.7.2308.24 (SDK 10.0.26100). So it's a PSV0/validator mismatch on this machine that predates the PR, not the port. It may still be worth checking which validator you ran them with. I didn't re-measure pipeline creation: offlinetranslatesees each program alone, as the PR says.On reading:
mesh_output_bytesmeasures what the validator measures: components, not rows, with the maxima rounded up to 32. Lowering the maxima to the lane count only when they don't fit leaves every program that already fits untouched.translate_linkedreturnsNoneearly unless the mesh program is over the cap at the lane count and the pruned outputs would fit, so ordinary pipelines pay only a container and signature parse. The re-emit happens only for the over-limit programs.pipeline/host.rsuses the linked pair only whenuser_data, samplers, root CBVs and root SRVs equal the originals'. The root signature is built from those, so a linked pair can't bind differently.shortcut:, and I agree it's better than dropping draws that drivers accept.Small things:
/// The bytes of shader code (none for an absent stage).now sits above the newlinkedfunction instead ofcode_bytes(pipeline/host.rs). Move it back down.Porting notes:
emit/mod.rstests, next to the new min-precision signature test.translatebecametranslate_program(container, wanted, missing)and the pipeline picks bytecode by visibility. There,translate_programtakes thelinkargument too, and the linked pair replaces theMESHandPIXELstages by visibility instead of by index.Merged into our fork's main as a port.
AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by claude-GTA6 on 2026-11-25T02:51:44Z.
From a tester working with Claude (AI-assisted); measured on my own machine.
Merged current main (
940d32f6) into the branch; the head is now132eda67and the PR shows as mergeable again.What the merge needed:
lower::Partshasview_marksnext tolinked_colsnow (the conflict the triage named), inlower.rsand in the test literals.translate_linkedtakesOptions, and the GPU side passes the ones it translates every shader with (shader_cache::OPTIONS), so a linked pair is made like the pair it stands in for.Checks on this head:
cargo clippy --workspace --all-targets -- -D warnings: clean.cargo test -p victory-shaderon WARP (VICTORY_WARP=1): 250 pass, 2 fail (gathers_at_a_level_match_the_hardware,permutes_read_the_lane_named_and_zero_from_lanes_left_out). Plain main940d32f6fails the same two on WARP (245 pass), so they are not from this PR. The run on the GPU itself is still queued; I will add it.On the validator question from reboot0000-cmd, thank you for the write-up in #1945. What I see here:
dxil.dllmy counts use is the Windows SDK one,Windows Kits\10\bin\10.0.26100.0\x64\dxil.dll. Its FileVersion and ProductVersion are both 1.8.2502.11 (239921522), anddxc --versionfrom the same folder printsdxil.dll: 1.8(1.8.2502.11).fxc.exebeside it is 10.0.26100.8249.dxil.dllon this machine (no 1.9.2609), so I have not compared engines myself.Counts on this head with that DLL, over the title's executable and shader archive (26,148 programs):
The validator failures are 867 "Flags must match usage" (#1973), 735 compute "incompatible with the shader stage", and 71 mesh "vertex plus primitive output size is greater than 32768".
So I agree with your 71: the description's 53 was counted on
ffe310e, when fewer mesh programs emitted. They stay 71 in this offline count becausetranslatesees each program alone; the link happens when a pipeline is made. The pair numbers in the description (3,505 pairs for the 53) are from that older main and I have not re-run them on this merge. A program-by-program re-measure from you would be welcome.🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by claude-GTA6 on 2026-11-25T02:55:04Z.
From a tester working with Claude (AI-assisted); measured on my own machine.
Thank you for the port and the point-by-point read. The
code_bytesdoc comment is back oncode_bytesincd0da11b;linkedkeeps its own.On a cache for the (mesh, pixel) pair:
translate_linkedreturns early for every mesh program whose outputs fit, after parsing the container and measuring the signature, so nothing is re-emitted for those. Only pipelines of the over-limit mesh programs re-emit, both programs each time. In my runs of this title one such pair is bound, so I have not seen it in load time; a cache keyed by the pair is the right follow-up if a scene binds many.On the validator: the comment just above yours has what I ran with (the SDK's
dxil.dllhere reports 1.8.2502.11 and shows no PSV0 mismatch), which fits your finding that 101.7.2308.24 fails those tests on plainmainas well.Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:22:23Z.
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at
cd0da11.cargo test --workspace --locked --no-fail-fast-> 701 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-25T10:01:09Z.
@claude-GTA6 this was closed a few minutes before StExpeditus's report, together with your other PRs, so I wanted to ask before doing anything: is it closed on purpose (a problem you found, or another PR replacing it), or would you reopen it?
It is still the only fix I could find for the 71 mesh programs over the 32 KiB output budget that keeps them drawing (#1385 narrows the maxima but its own census shows 71 before and after; #1961 turns them into refusals). I checked the column bookkeeping and the debug-layer linking constraint and found nothing wrong, and I wrote a GPU test for it: a 128-lane mesh program with 68 output components (34,816 bytes), whose unlinked module
dxil.dll1.8 rejects with "greater than 32768", while the linked pair validates, creates a pipeline and draws the expected values on an RTX 4060 Laptop and on WARP. Oncd0da11rebased onto main940d32fwith that test: RTX 702 passed / WARP 703 passed, the only failures being main's own #1835 ones.If you'd rather not reopen it, I can open it again from my fork with your commits and authorship unchanged, the test on top as a separate commit, and a link back here — only if you're fine with that.
AI use: Claude Code (Claude Opus 5.5) reviewed the PR, wrote the test and this comment.
Imported from Marvisak/VIctory. Originally posted by KainanP on 2026-11-25T19:03:22Z.
#2398 (Texbirds) now covers this: it links over-budget mesh and pixel shaders at pipeline creation and is a merge candidate (tested on RTX, WARP, AMD and Intel UHD), so we won't revive this one from our fork. Thanks @claude-GTA6 for the original approach. AI use: Claude Code (Claude Opus 5.5) wrote this note.
Pull request closed