Shaders: seed uninitialized mesh SGPRs above user_sgprs as zero #2047

Closed
fuzeofficlal wants to merge 1 commit from upstream-pr/2049 into main
fuzeofficlal commented 2026-11-25 04:06:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T04:06:53Z.


Summary

  • Decode user_sgprs from MS_INFO[6] into MeshIo::user_sgprs and expose MeshIo::initialized_sgprs() (8 + user_sgprs, covering the 8 merged-stage system SGPRs s0..=s7 plus the user SGPR range s8..).
  • Wire StageIo::Ms(ms) => Some(ms.initialized_sgprs()) in io::raise alongside compute and pixel stages so reads of uninitialized SGPRs above 8 + user_sgprs lower to 0 instead of failing with "a hardware SGPR input", while keeping unimplemented hardware SGPRs (s0..=s7 other than s3 MergedWaveInfo) and unmapped user SGPRs (s8..s[8 + user_sgprs - 1]) strictly refused.
  • Add synthetic mesh-pipeline unit and GPU draw/readback tests.

Addresses #815

Testing

  • cargo test -p victory-shader --locked -- mesh_uninitialized_sgprs (verified with dxil.dll and executed on NVIDIA RTX 5090, AMD Radeon Graphics, and D3D12 WARP)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  • cargo xtask policy
<!-- greyfinch-sync:Marvisak/VIctory:issue:6596977841 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T04:06:53Z. --- ## Summary - Decode `user_sgprs` from `MS_INFO[6]` into `MeshIo::user_sgprs` and expose `MeshIo::initialized_sgprs()` (`8 + user_sgprs`, covering the 8 merged-stage system SGPRs `s0..=s7` plus the user SGPR range `s8..`). - Wire `StageIo::Ms(ms) => Some(ms.initialized_sgprs())` in `io::raise` alongside compute and pixel stages so reads of uninitialized SGPRs above `8 + user_sgprs` lower to `0` instead of failing with `"a hardware SGPR input"`, while keeping unimplemented hardware SGPRs (`s0..=s7` other than `s3` `MergedWaveInfo`) and unmapped user SGPRs (`s8..s[8 + user_sgprs - 1]`) strictly refused. - Add synthetic mesh-pipeline unit and GPU draw/readback tests. Addresses #815 ## Testing - `cargo test -p victory-shader --locked -- mesh_uninitialized_sgprs` (verified with `dxil.dll` and executed on NVIDIA RTX 5090, AMD Radeon Graphics, and D3D12 WARP) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` - `cargo xtask policy`
catminou4 commented 2026-11-25 05:05:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T04:26:02Z.

Review: APPROVED


Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked.

145 passed / 0 failed / 2 ignored. Uninitialized mesh SGPRs above user_sgprs seeded as zero (+1 test) — mesh-shader register initialization; relates to #1961's mesh output budget.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051847861 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#pullrequestreview-6051847861). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T04:26:02Z. **Review:** APPROVED --- Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked`. 145 passed / 0 failed / 2 ignored. Uninitialized mesh SGPRs above user_sgprs seeded as zero (+1 test) — mesh-shader register initialization; relates to #1961's mesh output budget.
jeremygold02 commented 2026-11-25 05:06:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jeremygold02 on 2026-11-25T04:17:53Z.


Triage verdict — Keep the mesh ABI support, align the live-in rule with #1261 (4f3c6a1)

Evidence

  • @fuzeofficlal brings the merged compute rule from #432 to mesh, using the eight system slots plus the user count already represented in the mesh metadata fixture. #1261 would narrow the shared rule to registers written on at least one path. The new mesh fixture writes the register on one branch, so it remains useful under the narrower rule. Mesh fixture · Boundary controls · #1261

Checks and limits

  • Both focused exact-head tests passed. WARP actually ran the mesh draw and all 16 pixels matched for each branch: 0.75 when the write was skipped and 7.75 when it executed.
  • The draw fixture can return success after every adapter is skipped. Its hardware enumeration also excludes adapters reporting zero dedicated memory before asking about mesh support. Adapter eligibility

Next step

  • Add a control for an above-boundary mesh SGPR that no instruction writes, so the intended treatment of unknown ABI inputs is explicit when reconciling #1261. Keep the valid branch-around-write case, and make actual GPU execution observable in the regression.

This verification was AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152714025 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7152714025). Originally posted by [jeremygold02](https://github.com/jeremygold02) on 2026-11-25T04:17:53Z. --- **Triage verdict — Keep the mesh ABI support, align the live-in rule with #1261** (`4f3c6a1`) **Evidence** - @fuzeofficlal brings the merged compute rule from #432 to mesh, using the eight system slots plus the user count already represented in the mesh metadata fixture. #1261 would narrow the shared rule to registers written on at least one path. The new mesh fixture writes the register on one branch, so it remains useful under the narrower rule. [Mesh fixture](https://github.com/Marvisak/VIctory/blob/4f3c6a1335b04a6f8a5a68f3272ab7147f230c1b/crates/victory-shader/src/emit/mod.rs#L1609) · [Boundary controls](https://github.com/Marvisak/VIctory/blob/4f3c6a1335b04a6f8a5a68f3272ab7147f230c1b/crates/victory-shader/src/emit/mod.rs#L1720) · [#1261](https://github.com/Marvisak/VIctory/pull/1261) **Checks and limits** - Both focused exact-head tests passed. WARP actually ran the mesh draw and all 16 pixels matched for each branch: 0.75 when the write was skipped and 7.75 when it executed. - The draw fixture can return success after every adapter is skipped. Its hardware enumeration also excludes adapters reporting zero dedicated memory before asking about mesh support. [Adapter eligibility](https://github.com/Marvisak/VIctory/blob/4f3c6a1335b04a6f8a5a68f3272ab7147f230c1b/crates/victory-shader/src/emit/mod.rs#L1935-L2020) **Next step** - Add a control for an above-boundary mesh SGPR that no instruction writes, so the intended treatment of unknown ABI inputs is explicit when reconciling #1261. Keep the valid branch-around-write case, and make actual GPU execution observable in the regression. This verification was AI-assisted.
fuzeofficlal commented 2026-11-25 06:02:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:23:12Z.


Thanks @jeremygold02 — pushed 71e4bd2a addressing both points:

  1. Aligned Lower::inputs with #1261 + added unwritten control cases: an unmapped SGPR at or above initialized_sgprs now lowers to 0 only when at least one instruction in the program writes that register, refusing registers no instruction writes with "an SGPR no instruction writes, above the initialized ones". mesh_uninitialized_sgprs_read_as_zero_while_hardware_ones_stay_refused now tests unwritten s10 and s25 controls alongside the branch-around-write s10 fixture.
  2. Adapter enumeration and execution assertion: mesh_uninitialized_sgprs_execute_on_host_gpus no longer skips UMA/software adapters on DedicatedVideoMemory == 0 before checking D3D_SHADER_MODEL_6_6 + D3D12_MESH_SHADER_TIER_1, and asserts executed > 0 (verified on RTX 5090, AMD Radeon Graphics, and WARP).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7153719915 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7153719915). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T05:23:12Z. --- Thanks @jeremygold02 — pushed `71e4bd2a` addressing both points: 1. **Aligned `Lower::inputs` with `#1261` + added unwritten control cases**: an unmapped SGPR at or above `initialized_sgprs` now lowers to `0` only when at least one instruction in the program writes that register, refusing registers no instruction writes with `"an SGPR no instruction writes, above the initialized ones"`. `mesh_uninitialized_sgprs_read_as_zero_while_hardware_ones_stay_refused` now tests unwritten `s10` and `s25` controls alongside the branch-around-write `s10` fixture. 2. **Adapter enumeration and execution assertion**: `mesh_uninitialized_sgprs_execute_on_host_gpus` no longer skips UMA/software adapters on `DedicatedVideoMemory == 0` before checking `D3D_SHADER_MODEL_6_6` + `D3D12_MESH_SHADER_TIER_1`, and asserts `executed > 0` (verified on RTX 5090, AMD Radeon Graphics, and WARP).
Marvisak commented 2026-11-25 10:07:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T09:19:14Z.


Automated triage for the maintainers.
Needs work.

This PR extends the compute "uninitialized SGPRs read zero" rule to mesh programs: native.rs ms_io now reads MeshIo::user_sgprs from MS_INFO[6], and MeshIo::initialized_sgprs returns 8 + user_sgprs. That changes shader semantics on two assumptions the PR does not back up:

  • crates/victory-shader/src/native.rs ms_io: main does not decode byte 6 of the mesh info. The existing fixture has 13 there, and nothing shows that it is a user-SGPR count. Please give the evidence, e.g. the title's mesh programs whose highest root-layout SGPR matches 8 + info[6], or a corpus count like the one in #1261.
  • MeshIo::initialized_sgprs assumes exactly 8 system SGPRs (s0..=s7) before the user ones, for every mesh program. The compute rule derives the count from the program's own settings (ComputeIo::initialized_sgprs); a fixed 8 needs the same kind of support.
  • crates/victory-shader/src/emit/lower.rs Lower::inputs: the "zero only if some instruction writes it" change is the same change as open #1261 (which has corpus numbers but needs a rebase), and here it also applies to compute and pixel programs. Please leave it to #1261, or coordinate with its author, so the rule lands once.

What would change the verdict: evidence for the MS_INFO[6] meaning and the 8-SGPR prefix, and the lower.rs overlap with #1261 settled.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158171870 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7158171870). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T09:19:14Z. --- <!-- victory-triage v1 head=71e4bd2a5a1435c693a6e1eb4a20dad4a5e27f11 verdict=needs-work at=2026-11-25T09:19:04Z --> Automated triage for the maintainers. **Needs work.** This PR extends the compute "uninitialized SGPRs read zero" rule to mesh programs: `native.rs` `ms_io` now reads `MeshIo::user_sgprs` from `MS_INFO[6]`, and `MeshIo::initialized_sgprs` returns `8 + user_sgprs`. That changes shader semantics on two assumptions the PR does not back up: - `crates/victory-shader/src/native.rs` `ms_io`: `main` does not decode byte 6 of the mesh info. The existing fixture has 13 there, and nothing shows that it is a user-SGPR count. Please give the evidence, e.g. the title's mesh programs whose highest root-layout SGPR matches `8 + info[6]`, or a corpus count like the one in #1261. - `MeshIo::initialized_sgprs` assumes exactly 8 system SGPRs (`s0..=s7`) before the user ones, for every mesh program. The compute rule derives the count from the program's own settings (`ComputeIo::initialized_sgprs`); a fixed 8 needs the same kind of support. - `crates/victory-shader/src/emit/lower.rs` `Lower::inputs`: the "zero only if some instruction writes it" change is the same change as open #1261 (which has corpus numbers but needs a rebase), and here it also applies to compute and pixel programs. Please leave it to #1261, or coordinate with its author, so the rule lands once. What would change the verdict: evidence for the `MS_INFO[6]` meaning and the 8-SGPR prefix, and the `lower.rs` overlap with #1261 settled. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
sinan-cmyk commented 2026-11-25 10:07:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T09:29:07Z.


Offline measurement on a retail dump

Result: no count change against main.

I merged head 71e4bd2a onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158394039 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7158394039). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-25T09:29:07Z. --- ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 71e4bd2a onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 18:01:46 +00:00
fuzeofficlal commented 2026-11-25 18:02:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T17:20:21Z.


Closing this PR: deferring Lower::inputs handling to #1261 and closing since validating the mesh MS_INFO[6] ABI requires title shader evidence I do not have locally.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7169359677 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7169359677). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T17:20:21Z. --- Closing this PR: deferring `Lower::inputs` handling to #1261 and closing since validating the mesh `MS_INFO[6]` ABI requires title shader evidence I do not have locally.

Pull request closed

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!2047
No description provided.