Shaders: link mesh and pixel programs whose mesh outputs pass 32 KiB #1563
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1563
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1563/head"
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?
@claude-GTA6 on GitHub · 2026-11-24 19:12 UTC · original
claude-GTA6:pr-mesh-link→main· +531 −14 · 13 files · 4 commits · closed without mergingFrom 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
Some mesh programs export more per-vertex components than fit D3D12's 32 KiB even at one vertex per lane (65-68 components from 128 lanes). dxil.dll refuses them ("vertex plus primitive output size is greater than 32768"), and drivers that build the pipeline anyway run undefined behaviour. The prologue measures the outputs as the validator does (4 bytes per component of every vertex and primitive element, times the maxima rounded up to 32) and, past the cap, brings the maxima down to the lane count: lane n writes only vertex n and primitive n. This part is AnoHunted's, from the closed #459; on its own it clears none of these programs, but a linked program needs it to fit. emit::translate_linked re-emits such a mesh program and its pixel program for each other: arbitrary values the pixel program never reads leave both signatures, read ones end after their last read component. D3D12 links equal masks only, so both sides change together. Elements stay in the program while it is lowered (16-bit halves are placed from every element of a row); exports past the linked columns are dropped and the signature is cut when the module is finished (lower::Parts::linked_cols). The pipeline uses the linked pair when its bindings equal the originals; otherwise nothing changes. Co-authored-by: AnoHunted <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>@claude-GTA6 on GitHub · 2026-11-24 19:47 UTC · original
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.@Marvisak on GitHub · 2026-11-25 01:30 UTC · original · edited 2026-11-25 03:23 UTC
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
@reboot0000-cmd on GitHub · 2026-11-25 01:50 UTC · original
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.@claude-GTA6 on GitHub · 2026-11-25 02:51 UTC · original
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
@claude-GTA6 on GitHub · 2026-11-25 02:55 UTC · original
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.@StExpeditus on GitHub · 2026-11-25 09:22 UTC · original
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.@KainanP on GitHub · 2026-11-25 10:01 UTC · original
@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.
@KainanP on GitHub · 2026-11-25 19:03 UTC · original
#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