GPU: zero pipeline library description padding #1689

Closed
Calvix2k wants to merge 1 commit from upstream-pr/1690 into main
Calvix2k commented 2026-11-24 20:46:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T20:46:56Z.


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.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6591084362 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T20:46:56Z. --- 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.
DenRakEiw commented 2026-11-24 21:03:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:57:04Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 53 passed, 0 failed (1 ignored) on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including read_states_carry_no_padding, stream_subobjects_carry_no_padding, and kinds_are_told_apart)
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean zeroing of pipeline library description padding and per-kind refusal tracking. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047273875 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#pullrequestreview-6047273875). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T20:57:04Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — 53 passed, 0 failed (1 ignored) on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including `read_states_carry_no_padding`, `stream_subobjects_carry_no_padding`, and `kinds_are_told_apart`) - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean zeroing of pipeline library description padding and per-kind refusal tracking. Looks good. AI-assisted (Gemini 4 Neon).
upstream-sync changed title from [PR #1690] GPU: zero pipeline library description padding and stop storing a kind the host refuses to [PR #1690] GPU: zero pipeline library description padding 2026-11-24 22:01:56 +00:00
catminou4 commented 2026-11-24 22:01:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:42:14Z.

Review: COMMENTED


Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.

Pipeline library description padding is zeroed and the stored 'kind' is dropped: zero_padding writes over documented padding ranges (blend 8 ranges, depth 1, stream 4), padding_of extracts bytes for tests, and read_states_carry_no_padding/stream_subobjects_carry_no_padding assert it. Padding bytes in PSO descs are a classic source of non-deterministic pipeline cache keys — good hygiene fix.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047875367 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#pullrequestreview-6047875367). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:42:14Z. **Review:** COMMENTED --- Static review only: Windows-only code (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff. Pipeline library description padding is zeroed and the stored 'kind' is dropped: zero_padding<T> writes over documented padding ranges (blend 8 ranges, depth 1, stream 4), padding_of extracts bytes for tests, and read_states_carry_no_padding/stream_subobjects_carry_no_padding assert it. Padding bytes in PSO descs are a classic source of non-deterministic pipeline cache keys — good hygiene fix.
andrewpozdnakov7-jpg commented 2026-11-24 22:02:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-24T21:29:30Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145000172 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145000172). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-24T21:29:30Z. --- 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.
Calvix2k commented 2026-11-24 22:02:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:40:40Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145244744 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145244744). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:40:40Z. --- 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.
andrewpozdnakov7-jpg commented 2026-11-24 22:02:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-24T21:45:08Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145340463 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145340463). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-24T21:45:08Z. --- 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.
Calvix2k commented 2026-11-24 22:02:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-24T21:47:37Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145395218 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7145395218). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-24T21:47:37Z. --- 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.
Marvisak commented 2026-11-25 04:06:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:34:05Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152034989 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7152034989). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:34:05Z. --- <!-- 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)_
upstream-sync closed this pull request 2026-11-25 09:04:35 +00:00
Calvix2k commented 2026-11-25 09:06:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T08:37:42Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7157272887 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1690#issuecomment-7157272887). Originally posted by [Calvix2k](https://github.com/Calvix2k) on 2026-11-25T08:37:42Z. --- 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

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