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

Open
github-bot wants to merge 1 commit from github-bot/gh-2439 into main AGit
Owner

@⁠makmatvey on GitHub · 2026-11-25 13:31 UTC · original
makmatvey:cursor/gpu-pipeline-desc-padding-d4e6 → main · +167 −27 · 1 files · 1 commits · open

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.

**@⁠makmatvey** on GitHub · 2026-11-25 13:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2439) `makmatvey:cursor/gpu-pipeline-desc-padding-d4e6` → `main` · +167 −27 · 1 files · 1 commits · open ## 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.
The host pipeline library matches stored pipelines by raw description bytes,
padding included. GraphicsState::read copied the title's blend and depth-
stencil descriptions as they stood, so the two bytes between StencilWriteMask
and FrontFace (and the write-mask padding in each blend target) carried 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.

Zero that padding after kinds 8, 11 and 21, and in Default. Final mesh-stream
outer padding stays with the complementary follow-up; this covers the
descriptions graphics and mesh paths share through GraphicsState.

Co-authored-by: Matsvey Makushenka <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:49 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 13:50 UTC · original

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.

**@⁠oni-swr** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2439#issuecomment-7164359710) **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._
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 14:25 UTC · original

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

@⁠Marvisak on GitHub · 2026-11-25 16:40 UTC · original · edited 2026-11-25 22:23 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 16:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2439#issuecomment-7168354730) · edited 2026-11-25 22:23 UTC <!-- 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)_
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/pipeline/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2439/head:github-bot/gh-2439'
git switch 'github-bot/gh-2439'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2439'
git switch 'github-bot/gh-2439'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2439'
git switch 'github-bot/gh-2439'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2439'
git switch 'main'
git merge --squash 'github-bot/gh-2439'
git switch 'main'
git merge --ff-only 'github-bot/gh-2439'
git switch 'main'
git merge 'github-bot/gh-2439'
git push origin 'main'
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!2439
No description provided.