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

Closed
github-bot wants to merge 1 commit from gh-pr/2049/head into gh-pr/2049/base
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 04:06 UTC · original
fuzeofficlal:fix/shader-ms-uninitialized-sgprs-815 → main · +528 −13 · 4 files · 1 commits · closed without merging

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
**@⁠fuzeofficlal** on GitHub · 2026-11-25 04:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049) `fuzeofficlal:fix/shader-ms-uninitialized-sgprs-815` → `main` · +528 −13 · 4 files · 1 commits · closed without merging ## 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`
Decode the mesh stage's user SGPR count from MS_INFO byte 6 (E+0x44e) into MeshIo::user_sgprs and wire MeshIo::initialized_sgprs (8 merged-stage system SGPRs plus user_sgprs) into Io::initialized_sgprs (#815).

Narrow Lower::inputs so an unmapped SGPR at or above initialized_sgprs reads as zero only when at least one instruction in the program writes that register, refusing registers no instruction writes as unknown inputs (matching #1261). Make the multi-adapter SM 6.6 mesh draw test enumerate UMA/software adapters directly and assert at least one adapter executes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:52:54 +00:00
github-bot closed this pull request 2026-11-26 04:52:54 +00:00
Author
Owner

@⁠jeremygold02 on GitHub · 2026-11-25 04:17 UTC · original

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.

**@⁠jeremygold02** on GitHub · 2026-11-25 04:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7152714025) **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://git.gtahub.st/github/Marvisak--VIctory/pulls/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.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 05:23 UTC · original

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).
**@⁠fuzeofficlal** on GitHub · 2026-11-25 05:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7153719915) 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).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 09:19 UTC · original

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

**@⁠Marvisak** on GitHub · 2026-11-25 09:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7158171870) <!-- 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)_
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 09:29 UTC · original

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

**@⁠sinan-cmyk** on GitHub · 2026-11-25 09:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7158394039) ### 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-25 17:20 UTC · original

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.

**@⁠fuzeofficlal** on GitHub · 2026-11-25 17:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2049#issuecomment-7169359677) 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2049
No description provided.