gpu(pipeline): pass NULL blob pointer on empty pipeline library creation #133

Manually merged
github merged 1 commit from gh-pr/133/head into gh-pr/133/base 2026-12-01 20:12:19 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-29 14:24 UTC · original
Androtim:feat/iter134-pipeline-library-null-empty-blob → main · +31 −1 · 1 files · 1 commits · merged 2026-11-29 16:18 UTC

Summary

Fixes empty pipeline-library creation in crates/victory-gpu/src/pipeline/library.rs under strict D3D12 / vkd3d-proton validators:

  • Adds null_when_empty(bytes: &[u8]) -> *const std::ffi::c_void so zero-length slices map to std::ptr::null().
  • Invokes ID3D12Device1::CreatePipelineLibrary via its vtable in open() so empty blobs pass (NULL, 0) instead of a Rust empty-slice non-null address.
  • Adds unit test empty_blob_uses_null_pointer.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu xtask policy (303 files ok)
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- pipeline::library:: (9 passed; 0 failed)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings (0 warnings)
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings (0 warnings)
**@⁠Androtim** on GitHub · 2026-11-29 14:24 UTC · [original](https://github.com/Androtim/MiniVI/pull/133) `Androtim:feat/iter134-pipeline-library-null-empty-blob` → `main` · +31 −1 · 1 files · 1 commits · merged 2026-11-29 16:18 UTC ### Summary Fixes empty pipeline-library creation in `crates/victory-gpu/src/pipeline/library.rs` under strict D3D12 / vkd3d-proton validators: - Adds `null_when_empty(bytes: &[u8]) -> *const std::ffi::c_void` so zero-length slices map to `std::ptr::null()`. - Invokes `ID3D12Device1::CreatePipelineLibrary` via its vtable in `open()` so empty blobs pass `(NULL, 0)` instead of a Rust empty-slice non-null address. - Adds unit test `empty_blob_uses_null_pointer`. ### Verification - `cargo +1.98.1-x86_64-pc-windows-gnu xtask policy` (`303 files ok`) - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-gpu --locked -- pipeline::library::` (`9 passed; 0 failed`) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --locked -- -D warnings` (0 warnings) - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics --locked -- -D warnings` (0 warnings)
Use `null_when_empty` and invoke `CreatePipelineLibrary` through its COM vtable so zero-length blobs pass `NULL` instead of a non-null empty Rust slice pointer (for vkd3d-proton and strict D3D12 compliance).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:12:17 +00:00
github manually merged commit fdba5cb558 into gh-pr/133/base 2026-12-01 20:12:19 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 15:02 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Review Summary

Clean, minimal fix in crates/victory-gpu/src/pipeline/library.rs for empty pipeline library creation under strict D3D12 / vkd3d-proton validators.

  • Root cause & fix: Rust empty slices (&[]) have a non-null dangling pointer, which windows-rs's ID3D12Device1::CreatePipelineLibrary wrapper forwards alongside BlobLength == 0. Adding null_when_empty(bytes) and invoking Interface::vtable(device).CreatePipelineLibrary directly in open() ensures (NULL, 0) is passed when creating an empty library while preserving the existing slice pointer and length for non-empty blobs.
  • FFI / COM safety: The vtable call matches ID3D12Device1::CreatePipelineLibrary (as_raw(device), pointer, bytes.len(), &ID3D12PipelineLibrary::IID, (&raw mut library).cast()), checks the returned HRESULT via .ok()?, guards against a null out-pointer with E_POINTER, and casts to ID3D12PipelineLibrary1. Non-empty blob lifetimes remain tied to Library._blob.
  • Tests & CI: empty_blob_uses_null_pointer covers both empty and non-empty slices, and CI is passing.

Because this replaces a windows-rs wrapper with a direct D3D12 host COM vtable call in open(), a quick real-GPU smoke test (both cold start with no host-pipelines.bin and warm start with an existing library) is recommended before merging.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-29 15:02 UTC · [original](https://github.com/Androtim/MiniVI/pull/133#issuecomment-7257775647) <!-- minivi-triage v1 head=fdba5cb55822ff8e1d47ca79e60d9ed8c51c78fd verdict=needs-gpu-test ci=passing at=2026-11-29T15:03:15Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Review Summary Clean, minimal fix in `crates/victory-gpu/src/pipeline/library.rs` for empty pipeline library creation under strict D3D12 / vkd3d-proton validators. - **Root cause & fix**: Rust empty slices (`&[]`) have a non-null dangling pointer, which `windows-rs`'s `ID3D12Device1::CreatePipelineLibrary` wrapper forwards alongside `BlobLength == 0`. Adding `null_when_empty(bytes)` and invoking `Interface::vtable(device).CreatePipelineLibrary` directly in `open()` ensures `(NULL, 0)` is passed when creating an empty library while preserving the existing slice pointer and length for non-empty blobs. - **FFI / COM safety**: The vtable call matches `ID3D12Device1::CreatePipelineLibrary` (`as_raw(device)`, `pointer`, `bytes.len()`, `&ID3D12PipelineLibrary::IID`, `(&raw mut library).cast()`), checks the returned `HRESULT` via `.ok()?`, guards against a null out-pointer with `E_POINTER`, and casts to `ID3D12PipelineLibrary1`. Non-empty blob lifetimes remain tied to `Library._blob`. - **Tests & CI**: `empty_blob_uses_null_pointer` covers both empty and non-empty slices, and CI is passing. Because this replaces a `windows-rs` wrapper with a direct D3D12 host COM vtable call in `open()`, a quick real-GPU smoke test (both cold start with no `host-pipelines.bin` and warm start with an existing library) is recommended before merging. --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-11-29 15:50 UTC · original

Verified PR #133 with both cold (empty library) and warm (existing library) Series S GPU smoke tests (--release --features diagnostics, -AutoNudgeMenu) via scripts/verify-world.ps1 using an isolated VICTORY_LIBRARY_DIR:

  1. Cold Library Run (D:\victory-data\verify-runs\pr133-library-cold, 45s in-world) — 6/6 PASS:
    • stderr.log: no host pipeline library yet; starting an empty one -> created and grew host-pipelines.bin to 28,997,028 bytes cleanly with zero D3D12 COM errors.
    • Telemetry: reached 3D world in 78s (world_windows=11, max_draws=11556), 12.2 fps, crashes=0, no_host_texture_errors=0, used_max=5547 MB (over=0 MB), visually inspected frame-11799.png and frame-11807.png.
  2. Warm Library Run (D:\victory-data\verify-runs\pr133-library-warm, 35s in-world reusing generated library) — 6/6 PASS:
    • stderr.log: host pipeline library loaded bytes=28997028 mapped=true -> host pipeline library saved bytes=29021842 early=4294 made=1750 loaded=1629 started_early=3380.
    • Telemetry: reached 3D world in 77s (world_windows=9, max_draws=11272), 12.4 fps, crashes=0, no_host_texture_errors=0, used_max=5609 MB (over=0 MB), visually inspected frame-11706.png and frame-11714.png.
**@⁠Androtim** on GitHub · 2026-11-29 15:50 UTC · [original](https://github.com/Androtim/MiniVI/pull/133#issuecomment-7258403851) Verified PR #133 with both cold (empty library) and warm (existing library) Series S GPU smoke tests (`--release --features diagnostics`, `-AutoNudgeMenu`) via `scripts/verify-world.ps1` using an isolated `VICTORY_LIBRARY_DIR`: 1. **Cold Library Run (`D:\victory-data\verify-runs\pr133-library-cold`, 45s in-world) — 6/6 PASS**: - `stderr.log`: `no host pipeline library yet; starting an empty one` -> created and grew `host-pipelines.bin` to `28,997,028` bytes cleanly with zero D3D12 COM errors. - Telemetry: reached 3D world in `78s` (`world_windows=11`, `max_draws=11556`), `12.2 fps`, `crashes=0`, `no_host_texture_errors=0`, `used_max=5547 MB` (`over=0 MB`), visually inspected `frame-11799.png` and `frame-11807.png`. 2. **Warm Library Run (`D:\victory-data\verify-runs\pr133-library-warm`, 35s in-world reusing generated library) — 6/6 PASS**: - `stderr.log`: `host pipeline library loaded bytes=28997028 mapped=true` -> `host pipeline library saved bytes=29021842 early=4294 made=1750 loaded=1629 started_early=3380`. - Telemetry: reached 3D world in `77s` (`world_windows=9`, `max_draws=11272`), `12.4 fps`, `crashes=0`, `no_host_texture_errors=0`, `used_max=5609 MB` (`over=0 MB`), visually inspected `frame-11706.png` and `frame-11714.png`.
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/Androtim--MiniVI!133
No description provided.