Shaders: refuse a mesh program over the output budget #1959
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1961"
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 Luislariosss on 2026-11-25T01:46:18Z.
Why
DXC's validator rejects a mesh shader whose outputs exceed DXIL's
kMaxMSOutputTotalBytes(32768):The translated programs that hit this are console vertex programs wrapped as mesh shaders: they keep the console's own output signatures and the console's vertex/primitive maxima, and the console has no such budget. On one title's shader pack that is 72 programs, all with "For shader 'main', vertex plus primitive output size is greater than 32768."
The existing limit check in
mesh_prologueonly tests threads ≤ 128 and vertices/primitives ≤ 256, so those programs were translated, and only the validator (or the driver) complained later.What
mesh_prologuenow applies DXC's budget next to the existing limits, withMAX_MS_OUTPUT_BYTES = 32 * 1024and the sum exactly as the validator computes it (per element, rows × columns times the declared maximum rounded up to 32, over both signatures; our elements are one row each, and component width is ignored as DXC ignores it). Over budget, it refuses with "a mesh shader whose outputs exceed the host's 32 KiB budget", the same refusal path as the other mesh limits.This does not make those programs render. Trimming outputs that nothing reads needs the paired pixel shader, so that would be a follow-up; the point here is a precise reason instead of invalid DXIL reaching the driver.
Verification
Boundary confirmed against DXC itself (
dxc -T ms_6_6, synthetic HLSL): with 100 vertices and 40 primitives, 44 vertex and 40 primitive scalars is 32768 bytes and is accepted; one more primitive scalar (33024) is rejected with the same message. The ALIGN32 rounding is confirmed by (96/96, 44/41 → 32640 accepted), (128/128, 32/33 → 33280 rejected) and (33/33, 128 → 32768 accepted). HLSL-written shaders can hit a 128-scalar/32-row limit first, but the title's signatures already have their registers assigned, so the byte budget is what triggers there.Against the real pack,
translate --validate --liston this branch: the 72 "vertex plus primitive output size" errors become 0, replaced by 72 refusals with the new reason (808 validator errors → 736, the rest being the compute sampling class addressed separately).cargo test -p victory-shader --locked: 247 passed, 3 ignored (246 baseline + 1 new).cargo build --release -p victory --locked: clean.dxil.dllis present); one byte-class over is refused. No existing test changed;triangle_meshbecame a wrapper over a sized variant with identical values.No game data, hashes or program names are included (asset policy).
Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:47:56Z.
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
f37c644applied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass, including the new mesh output budget test.cargo clippy -p victory-shader --all-targets -- -D warnings: 5 errors (4 pre-existing on main + 1 new: unused variableatin test code). The new error is in a test, not production code.Not tested: Windows MSVC build, the title itself. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:32:24Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.145 passed / 0 failed / 2 ignored. Refuse a mesh program over the output budget (+1 test) — validator-side budget enforcement; pairs with #1619's IR invariants.
Imported from Marvisak/VIctory. Originally posted by AgneyaK on 2026-11-25T03:37:16Z.
A full-corpus run of this PR (merged cleanly onto
main940d32f): offlinetranslate --validateover the title 1.0.2.1's shader pack, release build, Windows 11 26300, validator DXC 1.9.2602.mainvertex plus primitive output size is greater than 32768)emit: a mesh shader whose outputs exceed the host's 32 KiB budget)It does what it says: the same 71 programs, now refused by the translator with a reason instead of emitted as invalid DXIL. Nothing else changes (vertex + pixel and compute counts are identical to
main).AI use: Claude Code (Claude Opus 5.5) ran the builds and wrote this; counts only, no game data.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:21:38Z.
Automated triage for the maintainers.
Merge candidate (unchanged).
mesh_prologue(crates/victory-shader/src/emit/lower.rs) refuses a mesh program whose outputs exceed DXIL's 32 KiB mesh output limit. It computes the size the way the validator does: 4 × columns per element × the declared maximum rounded up to 32, summed over the vertex and primitive signatures. The refusal goes through the same path as the existing mesh limits. The formula is backed by the PR's DXC boundary measurements, and two independent corpus runs show the same ~71 programs moving from validator errors to this refusal, with nothing else changing. I rechecked the test's numbers: 44 vertex scalars × 128 × 4 plus 40 primitive scalars × 64 × 4 is exactly 32768, and the extra scalar puts the second case over the limit.What changed since the last verdict: the only new commit,
8d9b91b, fixes the unused-variable warning raised earlier. Ina_mesh_program_over_the_output_budget_is_refused, the program at the limit is now marked used undercfg(not(windows)). Nothing else changed.The question from before remains for the maintainer: these programs are now refused rather than passed to the driver.
CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:11:50Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because refusing these programs would make things worse. The formula is right, but on
mainthe 71 mesh programs over the output budget are emitted, fail only the offline validator, and get their pipelines from the AMD driver, so their draws (character skin, fire, decals) run. With this change they would be refused and those draws dropped; a report on #2398 describes characters' faces and skin missing in exactly that state. A clearer reason string is not worth losing the draws.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed