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

Open
kais7654 wants to merge 1 commit from upstream-pr/2857 into main
kais7654 commented 2026-11-25 22:31:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T22:31:16Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5500301687 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T22:31:16Z. --- 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.
kotekompotek commented 2026-11-25 22:50:25 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T22:50:25Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6066063957 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#pullrequestreview-6066063957). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T22:50:25Z. **Review:** COMMENTED --- 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.
kais7654 commented 2026-11-25 23:06:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-25T22:31:32Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176469356 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#issuecomment-7176469356). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-25T22:31:32Z. --- 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.
fuzeofficlal commented 2026-11-25 23:06:31 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T23:00:36Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177040775 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#issuecomment-7177040775). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T23:00:36Z. --- 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 commented 2026-11-25 23:06:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T23:00:44Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7177043545 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#issuecomment-7177043545). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-25T23:00:44Z. --- 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).
Marvisak commented 2026-11-26 04:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-26T03:22:40Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7181664874 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#issuecomment-7181664874). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-26T03:22:40Z. --- <!-- victory-triage v1 head=9c608fce10c3c41a57f9197feea4723b289105bb verdict=proposed-close at=2026-11-26T03:22:40Z --> 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](https://claude.ai/code)_
borosf commented 2026-11-27 17:12:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T17:12:20Z.


Heads-up for coordination, not a judgement: this has the same title and the same shape as #2798 by @Moon0755, opened earlier and smaller (+35/−2 vs +45/−5). If yours is the same fix, closing one of the two saves a review; if it differs, say how and I will take this line out. Queue-wide triage is in #1633.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224145875 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2857#issuecomment-7224145875). Originally posted by [borosf](https://github.com/borosf) on 2026-11-27T17:12:20Z. --- Heads-up for coordination, not a judgement: this has the same title and the same shape as #2798 by @Moon0755, opened earlier and smaller (+35/−2 vs +45/−5). If yours is the same fix, closing one of the two saves a review; if it differs, say how and I will take this line out. Queue-wide triage is in #1633.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2857:upstream-pr/2857'
git switch 'upstream-pr/2857'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2857'
git switch 'upstream-pr/2857'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2857'
git switch 'upstream-pr/2857'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2857'
git switch 'main'
git merge --squash 'upstream-pr/2857'
git switch 'main'
git merge --ff-only 'upstream-pr/2857'
git switch 'main'
git merge 'upstream-pr/2857'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!2855
No description provided.