Skip to content

Shaders: a mesh program's PSV0 counts shared memory only when it has some - #2857

Open
kais7654 wants to merge 1 commit into
Marvisak:mainfrom
kais7654:shader/a-mesh-programs-lds-counts-when-it-has-some
Open

kais7654 wants to merge 1 commit into
Marvisak:mainfrom
kais7654:shader/a-mesh-programs-lds-counts-when-it-has-some

Conversation

@kais7654

Copy link
Copy Markdown

A mesh program whose state declares group-shared memory its code never touches wrote the declared size into the PSV0's GroupSharedBytesUsed: DXC fills that field from the module's group-shared globals -- ours is made lazily, by lds, when its code lowers one -- and the validator's rebuilt runtime info is compared byte for byte, so the container was refused whole. The declared size is counted now only where the global is: a program that declares LDS and never touches it has none.

(#2798)

Generated by Mistral Vibe.

A mesh program whose state declares group-shared memory its code never
touches wrote the declared size into the PSV0's GroupSharedBytesUsed:
DXC fills that field from the module's group-shared globals -- ours is
made lazily, by `lds`, when its code lowers one -- and the validator's
rebuilt runtime info is compared byte for byte, so the container was
refused whole. The declared size is counted now only where the global
is: a program that declares LDS and never touches it has none.

(Marvisak#2798)

Generated by Mistral Vibe.

Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@kais7654

Copy link
Copy Markdown
Author

The declared size is counted now only where the global is.

emit::tests::unused_mesh_lds_is_not_counted_in_psv0: the triangle mesh
program of the existing tests, with lds_bytes 0 (a control) and 16,
both read back from their PSV0 (the shared dword is 0 for each) and
through dxil.dll where there is one. Without the change it fails with
left: 16, right: 0 (verified here).

  • cargo test -p victory-shader --lib --test-threads=1 (RTX 5090; minus
    the suite's known skips): 260 passed + the new test — note 6 IEEE
    discrepancies fail on clean main 61bfc77 here (the BVH
    intersections' one-ULP, arithmetic_matches_the_hardware,
    fspx_programs_run_with_the_hardwares_dot_products,
    image_atomics_of_64_bits); reproduced on a clean tree, not this
    branch's.
  • cargo clippy -p victory-shader --all-targets --locked, and with
    --all-features: 0 warnings, both.

Generated with Mistral Vibe.

@kotekompotek kotekompotek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct DXC parity: PSV0 shared-mem comes from the module's group-shared globals, and the lazy lds() global means a declared-but-unused size contributes 0 — matching the validator's byte-compare. The 0-vs-16 lds_bytes control pair is the right coverage. LGTM.

@fuzeofficlal

Copy link
Copy Markdown
Contributor

Reviewed and verified 9c608fce on Windows 11 (RTX 5090 + WARP + dxil.dll) against main (842b0cb):

  • Gating PSV0 GroupSharedBytesUsed on self.lds.is_some() matches how Shader::lds() lazily emits the [lds_dwords x i32] global and how dxil.dll recomputes PSV0 from module globals (#2798), while keeping lds_dwords * 4 when LDS is actually lowered.
  • Local checks: unused_mesh_lds_is_not_counted_in_psv0 1/1 (PSV0[4..8] == 0 for both 0 and 16 declared bytes, dxil.dll accepted), mesh tests 6/6, lds tests 5/5 (including lds_bytes_and_halves_match_the_hardware), emit::tests:: 18/18 on RTX 5090 and WARP, cargo clippy --locked -p victory-shader --all-targets -- -D warnings 0 warnings, cargo xtask policy (186 files ok; emit/lower.rs untouched).

Looks clean and ready to merge.

@cloph-dsp

Copy link
Copy Markdown

Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.

  • cargo test --locked -p victory-shader --lib unused_mesh_lds_is_not_counted_in_psv0 --quiet -> 1 passed, 279 filtered.
  • Diff vs merge-base 61bfc77: 2 files, +45/-5; git diff --check clean.
  • Negative control: the new test name is absent on the base commit; the author also verified it fails before the fix.

AI-assisted (Hy4 flash).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Verdict: proposed close (duplicate). This is the same change as the earlier open #2798, which also has the same title and test name. Both gate mesh PSV0 GroupSharedBytesUsed in Shader::finish (crates/victory-shader/src/emit/shader.rs) on self.lds.is_some() and add unused_mesh_lds_is_not_counted_in_psv0. #2798 merges cleanly, has validator runs before and after the change, and is already a merge candidate.

If you have something #2798 lacks, please add it there as a review comment. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.

CI: check passing.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants