Shaders: a mesh program's PSV0 counts shared memory only when it has some #2798
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!2798
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2798"
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?
@Moon0755 on GitHub · 2026-11-25 20:48 UTC · original
Moon0755:fix/mesh-psv-shared-bytes→main· +35 −2 · 2 files · 1 commits · openProblem
For a mesh program
Shader::finishwrites the console's LDS size into PSV0'sGroupSharedBytesUsedwhenever the mesh state declares one (lds_dwords, set from the program'slds_bytes). DXC fills that field from the module: it adds up the sizes of the globals in the group-shared address space (lib/DxilContainer/DxilPipelineStateValidation.cpp). Here the group-shared global is made lazily, byShader::lds, when an LDS instruction is lowered.So a mesh program whose state declares LDS and whose code never touches it has no such global: the validator's rebuilt PSV0 holds 0, ours holds the declared size, and the whole runtime info is compared byte for byte:
Fix
The size is written only when the global exists.
Test
emit::tests::unused_mesh_lds_is_not_counted_in_psv0: the triangle mesh program of the existing tests, withlds_bytes0 (a control) and 16, both throughdxil.dll. The program has no LDS instruction.Verification
GitHub Actions on
windows-latest, on the fork, with the jobs narrowed tovictory-shaderandxtask; the validator ran in both (the control prints that it validated):270 passed; 1 failed;271 passed; 0 failed; 3 ignored.Not checked: the title's shaders. I do not know how many mesh programs declare LDS without using it, nor whether any of the mesh programs that still fail validation (#201) are this case.
Notes
286a00e) would still declare the bytes while the module has no global. That needs the size taken from the globals written, which this does not do.emit/mod.rs, in different places; the two merge together without conflict.Credit
The mismatch came out of comparing
emit/shader.rsandemit/container.rswith DXC's PSV0 writer; Devin wrote the test and the change and ran both arms.— Devin & Fable
`finish` wrote the console's LDS size into PSV0's GroupSharedBytesUsed whenever the mesh state declared one. DXC counts the bytes of the group-shared globals in the module, and the global is made only when an LDS instruction is lowered. A mesh program that declares LDS and never touches it has no such global, so the validator's rebuilt PSV0 holds 0 and the container is refused ("Container part 'Pipeline State Validation' does not match expected for module"). The size is now written only when the global exists. Test: `unused_mesh_lds_is_not_counted_in_psv0`, the triangle mesh program with and without declared LDS through dxil.dll. Co-Authored-By: Claude Fable 5.2 <[email protected]>@fuzeofficlal on GitHub · 2026-11-25 21:10 UTC · original
Reviewed and verified
1f0061c2on Windows 11 (Windows SDK10.0.26100.0dxil.dll) againstmain(13f91ca).Shader::lds()(shader.rs:219-225) is the sole site creating theaddrspace(3)"lds"global, gating mesh PSV0GroupSharedBytesUsedonself.lds.is_some()cleanly matches emitted shared memory (with the documented caveat for DCE'd branches).unused_mesh_lds_is_not_counted_in_psv0(validated withdxil.dllfor bothlds_bytes=0andlds_bytes=16) +translated_mesh_shaders_draw_as_pc_ones: 2/2 passed.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok; cleangit merge-treevs13f91ca,#2793, and#2796.@Marvisak on GitHub · 2026-11-25 23:23 UTC · original
Automated triage for the maintainers.
In
Shader::finish(crates/victory-shader/src/emit/shader.rs) a mesh program's PSV0GroupSharedBytesUsedis nowlds_dwords * 4only whenself.ldsis set, i.e. whenShader::ldsactually created theaddrspace(3)global; onmainit is written from the declared size even when the module has no group-shared global, so the validator's rebuilt PSV0 differs. I checked thatShader::ldsis the only place outside tests that creates an address-space-3 global, so the gate matches what DXC counts; the new testunused_mesh_lds_is_not_counted_in_psv0validates both a 0-byte control and a 16-byte unused declaration throughdxil.dll. The PR itself notes the remaining limit (LDS accesses only on a path the writer drops). CI (check) passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.