Skip to content

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

Open
makmatvey wants to merge 1 commit into
Marvisak:mainfrom
makmatvey:cursor/gpu-pipeline-desc-padding-d4e6
Open

makmatvey wants to merge 1 commit into
Marvisak:mainfrom
makmatvey:cursor/gpu-pipeline-desc-padding-d4e6

Conversation

@makmatvey

Copy link
Copy Markdown
Contributor

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:

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 <matvey.myown@gmail.com>
@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown

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.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

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.

Bebrik229 pushed a commit to Bebrik229/VIctory that referenced this pull request Nov 25, 2026

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants