GPU: zero pipeline stream padding before library comparison #3508

Open
tharun-37 wants to merge 2 commits from upstream-pr/3508 into main
tharun-37 commented 2026-11-27 11:25:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-27T11:25:42Z.


Refs #1683.

The pipeline library compares the whole description it is given, including bytes no subobject field reads. A stream built from the same state could therefore differ from the pipeline already stored under the same name, and a later load was refused.

This zeroes those unread bytes on the final stream, immediately before it is handed to LoadPipeline or CreatePipelineState. It covers the gaps after subobject types, the tails of subobjects, the padding inside blend, depth-stencil and input-layout descriptions, and the mesh and vertex stream forms. It does not change the descriptions held in GraphicsState, so it is complementary to #2439.

Two regression tests poison the computed padding with 0xaa, zero it, and check byte-for-byte that every padding byte was cleared and every field byte was left alone.

Verification:

  • cargo test -p victory-gpu --lib: the two new tests pass; the suite has the same three pre-existing adapter-specific failures as main, and one ignored test.
  • cargo clippy -p victory-gpu --all-targets -- -A clippy::undocumented_unsafe_blocks -D warnings and the same with --features diagnostics: clean.
  • git diff --check: clean.

AI assistance (OpenCode) was used to draft the change and its tests; I reviewed the layout calculations and verified them locally.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5525821846 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3508). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-27T11:25:42Z. --- Refs #1683. The pipeline library compares the whole description it is given, including bytes no subobject field reads. A stream built from the same state could therefore differ from the pipeline already stored under the same name, and a later load was refused. This zeroes those unread bytes on the final stream, immediately before it is handed to `LoadPipeline` or `CreatePipelineState`. It covers the gaps after subobject types, the tails of subobjects, the padding inside blend, depth-stencil and input-layout descriptions, and the mesh and vertex stream forms. It does not change the descriptions held in `GraphicsState`, so it is complementary to #2439. Two regression tests poison the computed padding with `0xaa`, zero it, and check byte-for-byte that every padding byte was cleared and every field byte was left alone. Verification: - `cargo test -p victory-gpu --lib`: the two new tests pass; the suite has the same three pre-existing adapter-specific failures as `main`, and one ignored test. - `cargo clippy -p victory-gpu --all-targets -- -A clippy::undocumented_unsafe_blocks -D warnings` and the same with `--features diagnostics`: clean. - `git diff --check`: clean. AI assistance (OpenCode) was used to draft the change and its tests; I reviewed the layout calculations and verified them locally.
oni-swr commented 2026-11-27 11:46:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-27T11:46:28Z.


WARP/CPU verification of #3508 (head 50043815624c873cdd2cd731546643820987a187, base 63bcca43c6a00a758510398fa43096ce7e4f7df0 = merge base = main tip). No physical GPU used. Claim on #1633.

Environment: Windows 11 Pro 10.0.26200, WARP d3d10warp.dll 10.0.26100.9818, rustc 1.98.1, VICTORY_WARP=1 + VICTORY_D3D12_WARP=1, dxil.dll from Windows SDK 10.0.26100.0 (VICTORY_DXIL). Command: cargo test -p victory-gpu --lib --locked --features diagnostics -j 4 -- --test-threads=1 (the diagnostics feature is needed, otherwise the WARP variable is ignored).

victory-gpu lib passed failed ignored
base 63bcca4 246 0 1
head 50043815 248 0 1

New tests, both pass: pipeline::host::tests::mesh_stream_padding_is_zeroed_without_touching_fields and vertex_stream_padding_is_zeroed_without_touching_fields. No new failure. I saw no failures on this lane at either commit (the PR text mentions three pre-existing adapter-specific failures; none showed up with WARP here), so there are no flakes to separate out.

Findings:

  • The diff matches the description: only host.rs; padding is zeroed on the final stream right before LoadPipeline/CreatePipelineState; GraphicsState is untouched. The two tests check byte by byte that padding is cleared and field bytes are unchanged, for the mesh and the vertex stream forms.
  • Not covered by anything I ran: the tests do not create or load a pipeline through a library, so the actual symptom (a stored pipeline refused on a later load) is not exercised on WARP. The check is layout-level only.
  • Minor: zero_padding, raw and raw_mut build a &[u8]/&mut [u8] over bytes that include uninitialised padding, which is strictly not allowed for u8; ptr::write_bytes on the padding ranges would avoid it. Part of the diff is rustfmt reflow of stream_pipeline unrelated to the change.

Numbers are WARP/CPU only; no real-GPU effect measured.

AI use: Claude Code (Claude Sonnet 5.5). No game files, dumps, install paths, shader names or hashes were used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7217458893 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3508#issuecomment-7217458893). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-27T11:46:28Z. --- WARP/CPU verification of #3508 (head `50043815624c873cdd2cd731546643820987a187`, base `63bcca43c6a00a758510398fa43096ce7e4f7df0` = merge base = main tip). No physical GPU used. Claim on #1633. **Environment:** Windows 11 Pro 10.0.26200, WARP `d3d10warp.dll` 10.0.26100.9818, rustc 1.98.1, `VICTORY_WARP=1` + `VICTORY_D3D12_WARP=1`, `dxil.dll` from Windows SDK 10.0.26100.0 (`VICTORY_DXIL`). Command: `cargo test -p victory-gpu --lib --locked --features diagnostics -j 4 -- --test-threads=1` (the `diagnostics` feature is needed, otherwise the WARP variable is ignored). | victory-gpu lib | passed | failed | ignored | |---|---|---|---| | base 63bcca4 | 246 | 0 | 1 | | head 50043815 | 248 | 0 | 1 | New tests, both pass: `pipeline::host::tests::mesh_stream_padding_is_zeroed_without_touching_fields` and `vertex_stream_padding_is_zeroed_without_touching_fields`. No new failure. I saw no failures on this lane at either commit (the PR text mentions three pre-existing adapter-specific failures; none showed up with WARP here), so there are no flakes to separate out. **Findings:** - The diff matches the description: only `host.rs`; padding is zeroed on the final stream right before `LoadPipeline`/`CreatePipelineState`; `GraphicsState` is untouched. The two tests check byte by byte that padding is cleared and field bytes are unchanged, for the mesh and the vertex stream forms. - Not covered by anything I ran: the tests do not create or load a pipeline through a library, so the actual symptom (a stored pipeline refused on a later load) is not exercised on WARP. The check is layout-level only. - Minor: `zero_padding`, `raw` and `raw_mut` build a `&[u8]`/`&mut [u8]` over bytes that include uninitialised padding, which is strictly not allowed for `u8`; `ptr::write_bytes` on the padding ranges would avoid it. Part of the diff is rustfmt reflow of `stream_pipeline` unrelated to the change. Numbers are WARP/CPU only; no real-GPU effect measured. AI use: Claude Code (Claude Sonnet 5.5). No game files, dumps, install paths, shader names or hashes were used.
passerbyyhx commented 2026-11-27 18:56:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-27T18:56:52Z.


Windows synthetic verification at 50043815624c873cdd2cd731546643820987a187.

I exercised two real D3D12 pipeline-library streams in independent processes on RTX 4090 Laptop (621.14) and WARP. One used a depth-bounds vertex pipeline (62 padding bytes), the other a mesh pipeline (46). Each adapter ran 14 processes including the comparison paths.

Both streams stored cold and loaded warm across processes after changing the filler from AA to BB through the normalized path. Changing the sample mask gave a real miss and a successful fallback creation. A raw-stream bypass with the same padding change also hit on both drivers, as did a fixed reader opening the old raw library. These data verify canonicalization and cold/warm interoperability; the padding-only miss did not reproduce on either configuration.

Reproducible fixture. GTA-VI-3/EIGHT-20261127. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7226033289 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3508#issuecomment-7226033289). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-27T18:56:52Z. --- Windows synthetic verification at `50043815624c873cdd2cd731546643820987a187`. I exercised two real D3D12 pipeline-library streams in independent processes on RTX 4090 Laptop (621.14) and WARP. One used a depth-bounds vertex pipeline (62 padding bytes), the other a mesh pipeline (46). Each adapter ran 14 processes including the comparison paths. Both streams stored cold and loaded warm across processes after changing the filler from AA to BB through the normalized path. Changing the sample mask gave a real miss and a successful fallback creation. A raw-stream bypass with the same padding change **also hit** on both drivers, as did a fixed reader opening the old raw library. These data verify canonicalization and cold/warm interoperability; the padding-only miss did not reproduce on either configuration. [Reproducible fixture](https://github.com/passerbyyhx/VIctory/commit/9808b0cde00aed52b773eb7784877ad39672d78a). GTA-VI-3/EIGHT-20261127. AI-assisted with Codex.
tharun-37 commented 2026-11-28 02:49:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tharun-37 on 2026-11-28T02:49:38Z.


Addressed oni-swr's padding-safety note in \

<!-- greyfinch-sync:Marvisak/VIctory:comment:7232618785 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3508#issuecomment-7232618785). Originally posted by [tharun-37](https://github.com/tharun-37) on 2026-11-28T02:49:38Z. --- Addressed oni-swr's padding-safety note in \
passerbyyhx commented 2026-11-28 07:55:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-28T07:55:18Z.


I reran the original cross-process pipeline-library fixture on 0f999915af4033aa60c373cd0b6f9fc564fd2aee after the change to pointer-based padding writes. The vertex and mesh field-preservation tests both passed. All 28 fresh-process runs completed, 14 on the RTX 4090 Laptop (621.14) and 14 on Microsoft WARP.

The depth-bounds vertex stream checked 62 padding bytes and the mesh stream checked 46. Both adapters and both stream types gave the same outcomes:

Process pair or control Result
Cold store with AA filler, warm load with BB filler, canonicalization enabled Every checked padding byte was 00 before submission. The cold process created and stored the PSO. The warm process loaded it from disk.
Change the sample mask, keeping BB filler The cache key changed. The library missed and fallback creation succeeded.
Bypass canonicalization, write AA and then read with BB The submitted padding changed. The warm load still hit.
Open the raw AA library in a process with canonicalization enabled Both streams loaded successfully.

The pointer-write change preserved the previously observed behavior on these two adapters. Neither reproduced a cache miss from a padding-only change.

GTA-VI-3 / AU-20261127-08X. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7236246837 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3508#issuecomment-7236246837). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-28T07:55:18Z. --- I reran the [original cross-process pipeline-library fixture](https://github.com/passerbyyhx/VIctory/commit/9808b0cde00aed52b773eb7784877ad39672d78a) on `0f999915af4033aa60c373cd0b6f9fc564fd2aee` after the change to pointer-based padding writes. The vertex and mesh field-preservation tests both passed. All 28 fresh-process runs completed, 14 on the RTX 4090 Laptop (621.14) and 14 on Microsoft WARP. The depth-bounds vertex stream checked 62 padding bytes and the mesh stream checked 46. Both adapters and both stream types gave the same outcomes: | Process pair or control | Result | | --- | --- | | Cold store with AA filler, warm load with BB filler, canonicalization enabled | Every checked padding byte was 00 before submission. The cold process created and stored the PSO. The warm process loaded it from disk. | | Change the sample mask, keeping BB filler | The cache key changed. The library missed and fallback creation succeeded. | | Bypass canonicalization, write AA and then read with BB | The submitted padding changed. The warm load still hit. | | Open the raw AA library in a process with canonicalization enabled | Both streams loaded successfully. | The pointer-write change preserved the [previously observed behavior](https://github.com/Marvisak/VIctory/pull/3508#issuecomment-7226033289) on these two adapters. Neither reproduced a cache miss from a padding-only change. GTA-VI-3 / AU-20261127-08X. AI-assisted with Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3508:upstream-pr/3508'
git switch 'upstream-pr/3508'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3508'
git switch 'upstream-pr/3508'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3508'
git switch 'upstream-pr/3508'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3508'
git switch 'main'
git merge --squash 'upstream-pr/3508'
git switch 'main'
git merge --ff-only 'upstream-pr/3508'
git switch 'main'
git merge 'upstream-pr/3508'
git push origin 'main'
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!3508
No description provided.