Shaders: refuse a mesh program over the output budget #1961
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!1961
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1961/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?
@Luislariosss on GitHub · 2026-11-25 01:46 UTC · original
Luislariosss:shaders/mesh-output-budget→main· +83 −4 · 2 files · 2 commits · closed without mergingWhy
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).
@Headache3318 on GitHub · 2026-11-25 01:47 UTC · original
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.
@AgneyaK on GitHub · 2026-11-25 03:37 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 08:21 UTC · original · edited 2026-11-25 20:20 UTC
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
@Marvisak on GitHub · 2026-11-25 22:11 UTC · original
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