GPU: zero pipeline library description padding #1690

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

@⁠Calvix2k on GitHub · 2026-11-24 20:46 UTC · original
Calvix2k:codex/gpu-pipeline-library-mesh-1683 → main · +194 −24 · 1 files · 1 commits · closed without merging

Rebased onto upstream 70564ae and reduced to the part that is still needed.

Why: upstream commit 9c58a1c now gives a mesh pipeline's topology explicitly, so mesh pipelines load from the library again. The two later commits here (per-kind refusal tracking and the in-flight store recheck) are therefore obsolete and were dropped; thanks @⁠andrewpozdnakov7-jpg for the race fix, it was correct for the old state.

What remains: the pipeline library compares raw description bytes, padding included. This zeroes the padding in the descriptions read from the title's stream, in the built depth-stencil description and in the mesh stream before handover. Authorship of the remaining commit stays with Pablo Barros.

Validation on 70564ae + this commit:

  • read_states_carry_no_padding and stream_subobjects_carry_no_padding — passed.
  • clippy -D warnings and cargo xtask policy — passed.
  • draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view fails on this machine, but it fails identically on plain origin/main, so it is unrelated.
**@⁠Calvix2k** on GitHub · 2026-11-24 20:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690) `Calvix2k:codex/gpu-pipeline-library-mesh-1683` → `main` · +194 −24 · 1 files · 1 commits · closed without merging Rebased onto upstream 70564ae and reduced to the part that is still needed. **Why:** upstream commit 9c58a1c now gives a mesh pipeline's topology explicitly, so mesh pipelines load from the library again. The two later commits here (per-kind refusal tracking and the in-flight store recheck) are therefore obsolete and were dropped; thanks @⁠andrewpozdnakov7-jpg for the race fix, it was correct for the old state. **What remains:** the pipeline library compares raw description bytes, padding included. This zeroes the padding in the descriptions read from the title's stream, in the built depth-stencil description and in the mesh stream before handover. Authorship of the remaining commit stays with Pablo Barros. Validation on 70564ae + this commit: - `read_states_carry_no_padding` and `stream_subobjects_carry_no_padding` — passed. - clippy `-D warnings` and `cargo xtask policy` — passed. - `draw::tests::a_texture_written_in_one_format_reads_in_another_through_a_placed_view` fails on this machine, but it fails identically on plain `origin/main`, so it is unrelated.
The host's pipeline library tells a stored pipeline apart by the bytes
of its description, padding included. Ours carried whatever lay between
the fields. The depth-stencil description is read from the title's
stream as it stands, and the two bytes between StencilWriteMask and
FrontFace are the title's stack: with the debug layer on an RTX 3070,
192 mesh pipelines of one run differed from a copy of themselves only
there, and the copy was refused as not the one that had created the
stored PSO. A mesh pipeline's stream has four unwritten bytes between
the type and each eight-byte description. The name a pipeline is stored
under is taken from the fields, so such twins share a name.

The padding is zeroed where the descriptions are read and built, and in
the stream before it is handed over. A test reads descriptions from 0xff
bytes and checks the fields against the padding; another builds a stream
with set values and checks both.

Co-Authored-By: Claude <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:42 +00:00
github-bot closed this pull request 2026-11-26 04:41:42 +00:00
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 21:29 UTC · original

A worker can miss in the library, compile outside its mutex, then reach StorePipeline after another worker has disabled that kind. I added a recheck under the library mutex immediately before storing. The worker still returns the compiled PSO.

634ecc3 is one commit directly on 1cd223804cb5edd393e8997ce64c510c9503baf2. The regression synchronizes two workers, injects the reload refusal, and uses a real WARP pipeline library for the stores. The PR head stored two entries in 10/10 runs. With the recheck, only the initial probe entry was stored in 10/10 runs. The full GPU suite passed 57 tests with one ignored. Strict GPU Clippy and cargo xtask policy passed.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 21:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145000172) A worker can miss in the library, compile outside its mutex, then reach `StorePipeline` after another worker has disabled that kind. I added a recheck under the library mutex immediately before storing. The worker still returns the compiled PSO. [634ecc3](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/634ecc320b7d3294b1f7756d2f85b389c243d539) is one commit directly on `1cd223804cb5edd393e8997ce64c510c9503baf2`. The regression synchronizes two workers, injects the reload refusal, and uses a real WARP pipeline library for the stores. The PR head stored two entries in 10/10 runs. With the recheck, only the initial probe entry was stored in 10/10 runs. The full GPU suite passed 57 tests with one ignored. Strict GPU Clippy and `cargo xtask policy` passed.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 21:40 UTC · original

Applied as ␀6487b7 on top of the PR, with your authorship preserved. Locally: cargo test -p victory-gpu 54 passed, 0 failed, 1 ignored (including the new regression), clippy -D warnings and cargo xtask policy clean.

The recheck under the library mutex before StorePipeline closes exactly the window between the miss and the store; thanks for the repro and the 10/10 before/after counts.

**@⁠Calvix2k** on GitHub · 2026-11-24 21:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145244744) Applied as ␀6487b7 on top of the PR, with your authorship preserved. Locally: cargo test -p victory-gpu **54 passed, 0 failed, 1 ignored** (including the new regression), clippy -D warnings and cargo xtask policy clean. The recheck under the library mutex before StorePipeline closes exactly the window between the miss and the store; thanks for the repro and the 10/10 before/after counts.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-24 21:45 UTC · original

A warm library can already contain a name whose descriptor differs from the current pipeline. In that case both the load and the duplicate-name store fail. At 06487b74b8dc8209c45d2653c7f23c0af3821d3a this also set the verdict for the whole kind to NO, even though the first successful store and reload were still untested.

4a53788 is directly on 06487b7. It leaves the verdict pending when the store fails. The WARP test puts a real compute PSO in the library under an occupied name and requests a different shader under that name. Before the change the kind was disabled in 10/10 runs. After it, a fresh name could be stored and loaded in 10/10 runs. The GPU suite passed 58 tests with one ignored. Strict GPU Clippy and cargo xtask policy passed.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-24 21:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145340463) A warm library can already contain a name whose descriptor differs from the current pipeline. In that case both the load and the duplicate-name store fail. At `06487b74b8dc8209c45d2653c7f23c0af3821d3a` this also set the verdict for the whole kind to `NO`, even though the first successful store and reload were still untested. [4a53788](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4a5378882265f0adfd0abd18a399af16a487cb02) is directly on `06487b7`. It leaves the verdict pending when the store fails. The WARP test puts a real compute PSO in the library under an occupied name and requests a different shader under that name. Before the change the kind was disabled in 10/10 runs. After it, a fresh name could be stored and loaded in 10/10 runs. The GPU suite passed 58 tests with one ignored. Strict GPU Clippy and `cargo xtask policy` passed.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 21:47 UTC · original

Rebased onto 70564ae and reduced to the padding fix only: upstream 9c58a1c now supplies the mesh topology, so the library loads mesh pipelines and the per-kind refusal / in-flight store commits (including your 634ecc3) are no longer needed. The padding zeroing is still required because the library compares raw bytes. See the updated PR body.

**@⁠Calvix2k** on GitHub · 2026-11-24 21:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145395218) Rebased onto 70564ae and reduced to the padding fix only: upstream 9c58a1c now supplies the mesh topology, so the library loads mesh pipelines and the per-kind refusal / in-flight store commits (including your 634ecc3) are no longer needed. The padding zeroing is still required because the library compares raw bytes. See the updated PR body.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:34 UTC · original

Automated triage for the maintainers.

Needs work. The blend (3 bytes per target) and depth-stencil (2 bytes) padding ranges in pipeline/host.rs are right. Two points:

  1. stream_padding misses the 4 bytes after Stream::blend (4 + 328 = 332, aligned to 336). The blend and depth descriptions are also moved into Stream after zeroing, which the PR's own comment says may rewrite padding.
  2. The premise that the pipeline library compares padding bytes has no evidence; the tests only check the zeroed ranges against themselves.

To change the verdict: add a WARP test that stores a pipeline built from junk-padded descriptions and shows LoadGraphicsPipeline/LoadPipeline failing before this change and succeeding after it, cover the blend tail, and drop the unrelated line re-wrapping in mesh_pipeline. CI passes.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7152034989) <!-- victory-triage v1 head=62f83bd0e5200f729737dcfe0067339e96428389 verdict=needs-work at=2026-11-25T03:38:00Z --> Automated triage for the maintainers. **Needs work.** The blend (3 bytes per target) and depth-stencil (2 bytes) padding ranges in `pipeline/host.rs` are right. Two points: 1. `stream_padding` misses the 4 bytes after `Stream::blend` (4 + 328 = 332, aligned to 336). The blend and depth descriptions are also moved into `Stream` after zeroing, which the PR's own comment says may rewrite padding. 2. The premise that the pipeline library compares padding bytes has no evidence; the tests only check the zeroed ranges against themselves. To change the verdict: add a WARP test that stores a pipeline built from junk-padded descriptions and shows `LoadGraphicsPipeline`/`LoadPipeline` failing before this change and succeeding after it, cover the blend tail, and drop the unrelated line re-wrapping in `mesh_pipeline`. CI passes. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 08:37 UTC · original

Closing this: I could not substantiate the premise, and on a closer look it does not hold for our own path either.

  • The host's pipeline identity is make::key, which hashes GraphicsState::describe(). describe formats the fields ({:?} of each struct plus explicit components), so padding bytes never reach the key; two states that differ only in padding already hash the same.
  • CreateGraphicsPipelineState and CreatePipelineLibrary/StorePipeline do not read padding; the library is loaded by name, not by comparing descriptions, so "an entry stored with other padding bytes never loads" has no mechanism behind it.
  • The triage's other two points stand on their own: stream_padding misses the four bytes after the blend subobject (4 + 328 → 336), and the tests only compare the zeroed ranges with themselves.

If a fixture exists that shows a load failing because of padding — a WARP pipeline library stored with junk in a field's padding and loaded with zeros — reopen with that and I will do the narrow fix. The sample_mask/mesh rewrap in this branch is unrelated and should not ride along either.

**@⁠Calvix2k** on GitHub · 2026-11-25 08:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7157272887) Closing this: I could not substantiate the premise, and on a closer look it does not hold for our own path either. - The host's pipeline identity is `make::key`, which hashes `GraphicsState::describe()`. `describe` formats the *fields* (`{:?}` of each struct plus explicit components), so padding bytes never reach the key; two states that differ only in padding already hash the same. - `CreateGraphicsPipelineState` and `CreatePipelineLibrary`/`StorePipeline` do not read padding; the library is loaded by name, not by comparing descriptions, so "an entry stored with other padding bytes never loads" has no mechanism behind it. - The triage's other two points stand on their own: `stream_padding` misses the four bytes after the blend subobject (`4 + 328` → 336), and the tests only compare the zeroed ranges with themselves. If a fixture exists that shows a load failing because of padding — a WARP pipeline library stored with junk in a field's padding and loaded with zeros — reopen with that and I will do the narrow fix. The `sample_mask`/mesh rewrap in this branch is unrelated and should not ride along either.

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