Shaders: a mesh program's PSV0 counts shared memory only when it has some #2796
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-25T20:48:57Z.
Problem
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
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T21:13:41Z.
Review: COMMENTED
Matches DXC's rule: PSV0 group-shared bytes come from the module's globals, and a mesh program whose code never touches declared LDS has no such global — reporting the console's
lds_byteswould make PSV0 inconsistent with the module and fail validation. Gating onself.lds.is_some()(an actual access, not the declared size) is the right signal, and the dxil.dll validation test proves both sides. LGTM.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T21:10:47Z.
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.Imported from Marvisak/VIctory. Originally posted by AwsAli05 on 2026-11-25T23:04:43Z.
Review: COMMENTED
I compared this with #2857. Both production changes emit zero PSV0 shared bytes when there is no LDS global, and
lds_dwords * 4when the global exists. The current #2857 also has its validation test on the same module path. Please coordinate which branch should carry the fix so the same shader-container change lands once.AI-assisted static review.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:23:21Z.
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
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:47:53Z.
Review: APPROVED
Verified against
origin/main(63bcca4) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:cargo test -p victory-shader emit::tests: 18/18 passed on RTX 5090, 18/18 passed on WARP (includingunused_mesh_lds_is_not_counted_in_psv0).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:17:48Z.
Review: APPROVED
LGTM — verified
rustfmton the changed hunks,cargo xtask policy,cargo clippy(--all-targetsand--all-features), andemit::tests::(18 passed, includingunused_mesh_lds_is_not_counted_in_psv0validated againstdxil.dll).Gating
mesh_sharedonself.lds.is_some()matches DXC'sMSInfo::GroupSharedBytesUsedcheck (VerifyPSVMatchesrequires exact equality with the sum of address-space-3 groupshared globals in the DXIL module, so0is required when noldsglobal is materialized). Non-blocking note: adding a mesh test case that actually accesses LDS (ldsglobal present) would cover the nonzero path too.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.