GPU: zero blend and depth-stencil padding the pipeline library compares #2437

Closed
makmatvey wants to merge 1 commit from upstream-pr/2439 into main
makmatvey commented 2026-11-25 13:31:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:31:06Z.


What's wrong

The host's pipeline library tells stored pipelines apart by the raw bytes of their descriptions, padding included. GraphicsState::read copied the title's blend (kind 8) and depth-stencil (kinds 11 and 21) descriptions as they stood, so the two bytes between StencilWriteMask and FrontFace — and the write-mask padding in each blend target — carried whatever was on the title's stack. With the debug layer on, mesh pipelines of one run then differed from a copy of themselves only in that padding, and LoadPipeline refused them (#1683).

Closed attempts (#1041, #1690) did not land. Open #1739 clears final mesh-stream outer/nested padding after typed moves; it does not clean the descriptions held in GraphicsState that the classic graphics PSO path and the stream both read from.

What the change does

In crates/victory-gpu/src/pipeline/host.rs:

  • After reading kinds 8, 11 and 21, zero the known blend and depth-stencil padding ranges in place (raw writes; no byte slices across other padding).
  • Do the same in GraphicsState::default.
  • Leave mesh-stream layout/clearing to #1739 so the two PRs stay complementary.

Tests

  • New unit test read_states_carry_no_padding: reads kinds 21/11/8 from 0xff bytes and checks padding is zero while fields keep the title's values; also checks Default.
  • Existing input-offset host tests unchanged.
  • This agent runs Linux without ml64.exe, so Windows MSVC clippy/tests are left to CI.

No game data was used.

Refs #1683. Complementary to #1739.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5492293061 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439). Originally posted by [makmatvey](https://github.com/makmatvey) on 2026-11-25T13:31:06Z. --- ## What's wrong The host's pipeline library tells stored pipelines apart by the raw bytes of their descriptions, padding included. `GraphicsState::read` copied the title's blend (kind 8) and depth-stencil (kinds 11 and 21) descriptions as they stood, so the two bytes between `StencilWriteMask` and `FrontFace` — and the write-mask padding in each blend target — carried whatever was on the title's stack. With the debug layer on, mesh pipelines of one run then differed from a copy of themselves only in that padding, and `LoadPipeline` refused them (#1683). Closed attempts (#1041, #1690) did not land. Open #1739 clears final *mesh-stream* outer/nested padding after typed moves; it does not clean the descriptions held in `GraphicsState` that the classic graphics PSO path and the stream both read from. ## What the change does In `crates/victory-gpu/src/pipeline/host.rs`: - After reading kinds 8, 11 and 21, zero the known blend and depth-stencil padding ranges in place (raw writes; no byte slices across other padding). - Do the same in `GraphicsState::default`. - Leave mesh-stream layout/clearing to #1739 so the two PRs stay complementary. ## Tests - New unit test `read_states_carry_no_padding`: reads kinds 21/11/8 from `0xff` bytes and checks padding is zero while fields keep the title's values; also checks `Default`. - Existing input-offset host tests unchanged. - This agent runs Linux without `ml64.exe`, so Windows MSVC clippy/tests are left to CI. No game data was used. Refs #1683. Complementary to #1739.
DenRakEiw commented 2026-11-25 14:01:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:01:08Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Zeroing blend and depth-stencil struct padding before pipeline library comparisons ensures deterministic cache hashing/matching.
  • cargo test -p victory-gpu pipeline::host::tests: 3/3 passed on RTX 5090, 3/3 passed on WARP (including read_states_carry_no_padding).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6059002219 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439#pullrequestreview-6059002219). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T14:01:08Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Zeroing blend and depth-stencil struct padding before pipeline library comparisons ensures deterministic cache hashing/matching. - `cargo test -p victory-gpu pipeline::host::tests`: 3/3 passed on RTX 5090, 3/3 passed on WARP (including `read_states_carry_no_padding`). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
oni-swr commented 2026-11-25 14:07:30 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T13:50:09Z.


Verification — head 23059ca23ece8439f0a550092bd66537179a9341

Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, DXC/dxil 1.8.2502.11 (Windows Kits 10.0.26100.0 x64). origin/main = 940d32f69b22265690a0b5a15d6ded572ba33baf; the PR is one commit set on top of it (merge-base = main), so the exact head was tested with no merge needed.

  • cargo test -p victory-gpu --lib --features diagnostics -- --test-threads=1: 147 passed, 0 failed, 2 ignored (+1 vs main: the new pipeline::host::tests::read_states_carry_no_padding ran and passed; it needs no device).
  • clippy -p victory-gpu --all-targets -D warnings with and without diagnostics: clean. cargo xtask policy: ok.
  • GPU tests ran with VICTORY_D3D12_WARP=1 and --features diagnostics (the switch has no effect without that feature), -- --test-threads=1; warp_adapter_accepts_only_software ran and passed (adapter vendor 0x1414, software flag). Baseline origin/main for the same command: 146 passed, 0 failed, 2 ignored.
  • Diff note: besides the padding change, the PR includes unrelated rustfmt-only reflows in pipeline/host.rs.

Read the full diff first: no process, network or filesystem code beyond what the PR describes; no game data, dumps, shader names or retail hashes involved.

Verified by Claude Code (Claude Sonnet 5.5), an AI assistant; this is a test report, not a code review or approval.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7164359710 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439#issuecomment-7164359710). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T13:50:09Z. --- **Verification — head `23059ca23ece8439f0a550092bd66537179a9341`** **Environment:** Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, DXC/dxil 1.8.2502.11 (Windows Kits 10.0.26100.0 x64). `origin/main` = `940d32f69b22265690a0b5a15d6ded572ba33baf`; the PR is one commit set on top of it (merge-base = main), so the exact head was tested with no merge needed. - `cargo test -p victory-gpu --lib --features diagnostics -- --test-threads=1`: **147 passed, 0 failed, 2 ignored** (+1 vs main: the new `pipeline::host::tests::read_states_carry_no_padding` ran and passed; it needs no device). - clippy `-p victory-gpu --all-targets -D warnings` with and without `diagnostics`: clean. `cargo xtask policy`: ok. - GPU tests ran with `VICTORY_D3D12_WARP=1` and `--features diagnostics` (the switch has no effect without that feature), `-- --test-threads=1`; `warp_adapter_accepts_only_software` ran and passed (adapter vendor 0x1414, software flag). Baseline `origin/main` for the same command: 146 passed, 0 failed, 2 ignored. - Diff note: besides the padding change, the PR includes unrelated rustfmt-only reflows in `pipeline/host.rs`. Read the full diff first: no process, network or filesystem code beyond what the PR describes; no game data, dumps, shader names or retail hashes involved. _Verified by Claude Code (Claude Sonnet 5.5), an AI assistant; this is a test report, not a code review or approval._
catminou4 commented 2026-11-25 14:11:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:16Z.

Review: COMMENTED


Zero blend/depth-stencil padding the pipeline key ignores. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.

<!-- greyfinch-sync:Marvisak/VIctory:review:6059177118 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439#pullrequestreview-6059177118). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T14:11:16Z. **Review:** COMMENTED --- Zero blend/depth-stencil padding the pipeline key ignores. Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
kotekompotek commented 2026-11-25 15:04:18 +00:00 (Migrated from github.com)

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


Reviewed — the padding analysis is exact:

  • Ranges verified against the D3D12 layout: blend = 3 bytes after each target's RenderTargetWriteMask (37..40 per 8 targets), depth-stencil = 2 bytes after StencilWriteMask (18..20, leaving StencilReadMask at 16 alone). Both computed via offset_of, so layout drift can't silently break them.
  • Sub's own 4-byte pad after the type tag is stream framing (8-byte-aligned wire format), not part of a compared description — correctly untouched.
  • Zeroing happens at Default and at every stream-read site (kinds 8, 11, 21), so no construction path carries title-stack garbage into a stored description.
  • The test feeds 0xff subobjects and asserts zeroed padding + intact fields, plus the default state — covers the whole mechanism.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7165267994 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439#issuecomment-7165267994). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T14:25:56Z. --- Reviewed — the padding analysis is exact: - Ranges verified against the D3D12 layout: blend = 3 bytes after each target's `RenderTargetWriteMask` (37..40 per 8 targets), depth-stencil = 2 bytes after `StencilWriteMask` (18..20, leaving `StencilReadMask` at 16 alone). Both computed via `offset_of`, so layout drift can't silently break them. - `Sub`'s own 4-byte pad after the type tag is stream framing (8-byte-aligned wire format), not part of a compared description — correctly untouched. - Zeroing happens at `Default` and at every stream-read site (kinds 8, 11, 21), so no construction path carries title-stack garbage into a stored description. - The test feeds `0xff` subobjects and asserts zeroed padding + intact fields, plus the default state — covers the whole mechanism.
Marvisak commented 2026-11-25 17:05:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T16:40:25Z.


Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main (conflict in crates/victory-gpu/src/pipeline/host.rs). It will be reviewed again once it is rebased.

From the earlier needs-work note, still open: drop the unrelated rustfmt reflow, and zero the padding in the final description just before it is created or stored, since moves may not keep the zeroed bytes.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7168354730 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2439#issuecomment-7168354730). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T16:40:25Z. --- <!-- victory-triage v1 head=23059ca23ece8439f0a550092bd66537179a9341 verdict=needs-rebase at=2026-11-25T22:32:30Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main` (conflict in `crates/victory-gpu/src/pipeline/host.rs`). It will be reviewed again once it is rebased. From the earlier needs-work note, still open: drop the unrelated rustfmt reflow, and zero the padding in the final description just before it is created or stored, since moves may not keep the zeroed bytes. --- _Generated by [Claude Code](https://claude.ai/code)_

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