Skip to content

GPU: ask for an empty pipeline library with a null blob - #347

Open
AugustoZFJ wants to merge 1 commit into
Marvisak:mainfrom
AugustoZFJ:fix/empty-pipeline-library
Open

AugustoZFJ wants to merge 1 commit into
Marvisak:mainfrom
AugustoZFJ:fix/empty-pipeline-library

Conversation

@AugustoZFJ

@AugustoZFJ AugustoZFJ commented Nov 24, 2026 •

Copy link
Copy Markdown

Summary

Under vkd3d-proton, pipeline::library::open() never gets a pipeline library, so library() logs "no host pipeline library: pipelines are not kept" and nothing is cached between runs.

When there is no saved blob, or the saved one is rejected, open() asks for an empty library with an empty slice. An empty Rust slice still has a non-null address (0x1 here). vkd3d-proton rejects a non-null blob of length 0 and accepts null.

In outline, not the literal diff:

 open(device, blob)
   blob not empty -> CreatePipelineLibrary(blob.ptr, blob.len)   // untouched
   rejected, or nothing saved yet:
-    CreatePipelineLibrary(0x1, 0)    // E_INVALIDARG on vkd3d-proton -> None
+    CreatePipelineLibrary(null, 0)   // S_OK

Only the empty request changes. It goes through the raw vtable, because the windows wrapper takes a slice and a slice can't be null. Loading a saved blob still uses the wrapper. If the host refuses even the empty library, the error is now logged instead of dropped. Only crates/victory-gpu/src/pipeline/library.rs changes.

Evidence

Everything below ran on GE-Proton11-14 (its vkd3d-proton is v3.1-83) with an RX 6900 XT on RADV 26.2.6, built with cargo xwin for x86_64-pc-windows-msvc. No game files were used.

What CreatePipelineLibrary returns there, from a throwaway test that isn't in this PR:

Blob pointer, length Result
null, 0 S_OK
0x1, 0 E_INVALIDARG (0x80070057)
non-null, 352 arbitrary bytes D3D12_ERROR_DRIVER_VERSION_MISMATCH (0x887E0002)

The same throwaway test also ran one round trip with a trivial compute pipeline. StorePipeline and Serialize succeed (200 bytes), a second library opens from those bytes, LoadComputePipeline returns the stored pipeline, and an unknown name gives E_INVALIDARG. So the cache works for one pipeline. I haven't run the title with it.

Not checked: Windows, because I have no Windows machine. Only the empty request differs there, null instead of 0x1. Microsoft's page for CreatePipelineLibrary says an empty blob gives an empty library and doesn't say what the pointer should be, so this needs one run of that test on Windows.

Merge Danger

Door: two-way

For the code, a revert is enough. A host-pipelines.bin written under vkd3d-proton in the meantime stays in the pipelines cache folder and the reverted code would still load it, so undoing it fully also means deleting that folder.

Blast Radius: pipeline-cache

On Windows the empty-library request passes null instead of a dangling pointer. That is untested.

Under vkd3d-proton the whole cache switches on for the first time. LoadGraphicsPipeline, LoadComputePipeline and LoadPipeline are tried before every pipeline is made, and new ones are stored. save() serialises under the library lock, at most every 20 seconds, and writes host-pipelines.bin and early-pipelines.txt. On the next run the saved blob is reopened and the pipelines listed in early-pipelines.txt are started early. Of all that, only the one-pipeline round trip above has been exercised.

@AugustoZFJ
AugustoZFJ force-pushed the fix/empty-pipeline-library branch from e479df5 to c2a98e8 Compare November 24, 2026 02:31
muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
An empty slice still has an address, and vkd3d-proton answers E_INVALIDARG to a non-null blob of length 0, so under Wine no pipeline library was ever created and host pipelines were not kept.
@AugustoZFJ
AugustoZFJ force-pushed the fix/empty-pipeline-library branch from c2a98e8 to 197c7ac Compare November 24, 2026 02:51
muhammed-aksoy pushed a commit to muhammed-aksoy/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremygold02

Copy link
Copy Markdown
Contributor

Tested PR #347 at head 197c7acf1fb0a1bd51db4f54d6ae934f91edcf25 (state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged at 197c7acf1fb0a1bd51db4f54d6ae934f91edcf25.

  • cargo test --locked -p victory-gpu --lib — passed (ok. 43 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.31s ); cases: device::tests::creation_hands_out_the_device, device::tests::feature_levels_pick_the_highest_supported, device::tests::virtual_memory_configuration_reports_user_space, fence::tests::signals_set_waiting_events, and 39 more.

Behavior covered: Runs GPU library unit tests against the null-blob pipeline-library initialization change.
Code: crates/victory-gpu/src/pipeline/library.rs

@mercuryVM mercuryVM 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.

Tested 197c7ac on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed). Not tested under vkd3d-proton.

  • The root cause is right. &[] has a dangling non-null pointer, and the D3D12 contract (and vkd3d-proton's check) treats non-null with length 0 as invalid, while null with 0 means "empty library". Native D3D12 accepts both, which is why this only showed up under vkd3d-proton.
  • The raw vtable call is sound. CreatePipelineLibrary(null, 0, &IID_ID3D12PipelineLibrary, &mut raw) matches the signature, a null raw after success becomes E_POINTER, and from_raw + cast to ID3D12PipelineLibrary1 releases the base reference when it drops.
  • The non-empty-blob path is untouched.

No issues found.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…y with a null blob

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CaravelaLabs

CaravelaLabs commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Tested under vkd3d-proton, which fills the gap in @mercuryVM's review. Thanks @AugustoZFJ, the null-blob fix works there too.

Setup: Radeon 8060S (Strix Halo, RADV GFX1151, Mesa 25.2.8), Ubuntu 24.04, Wine 11.22 + vkd3d-proton 3.1 (d3d12,d3d12core,dxgi=n). cargo xwin test --locked -p victory-gpu --lib for x86_64-pc-windows-msvc, sandboxed with no network. No game files.

a_rejected_blob_gives_an_empty_library
main ffe310e fails: an empty library (library.rs:249), reproduced 3/3
main + 197c7ac passes, 2/2

The test reaches the device here (main fails on it rather than returning early), so the pass means vkd3d-proton now hands back an empty library for the null blob.

Everything else in the crate behaves the same on both. The only other failure is indirect::tests::argument_clamp_builds, which is #170 (Wine's builtin d3dcompiler_47) and unrelated to this PR. frame::tests::waits_end_on_ticks_and_count_frames also failed once in one of the two PR runs, which is the timing case #689 covers.

AI-assisted test. The runs were done on this machine.

@ThomasHFWright

Copy link
Copy Markdown

Independent NVIDIA/vkd3d-proton validation on main ffe310eb2098e52169f4c44db5ffdabf43a72622, with only this PR's pipeline/library.rs patch from 197c7acf1fb0a1bd51db4f54d6ae934f91edcf25 applied in a separate checkout.

Environment: Linux x86_64, Rust 1.98.1, Windows MSVC cross-build (x86_64-pc-windows-msvc), Wine 11.22 with app-local vkd3d-proton 3.1 (0bb64c56c8f0dcc) and DXVK 3.1.1 (97-ga78a467cadb22be-pcos), RTX 5090 / NVIDIA 620.73.4. Tests ran offscreen with networking disabled; no game files were needed.

victory-gpu tests Passed Failed Ignored
Unmodified ffe310e 48 2 1
Same base + this patch 49 1 1

pipeline::library::tests::a_rejected_blob_gives_an_empty_library fails on the base and passes with the patch. The remaining failure is indirect::tests::argument_clamp_builds (Wine's shader compiler), unchanged between runs. This confirms the fix on NVIDIA as well as the existing RADV reports.

Not checked here: native Windows, persistent-cache round trips, or gameplay with this patch. This is synthetic GPU-test validation, not an end-to-end gameplay result.

AI-assisted testing with Codex.

Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
Xeltax pushed a commit to Xeltax/VIcky that referenced this pull request Nov 24, 2026
…Marvisak#358 Marvisak#89 Marvisak#331 Marvisak#86 Marvisak#83 Marvisak#211 Marvisak#260 Marvisak#275)

Conflict in crates/victory-gpu/src/descriptor/host.rs: gpu-state (Marvisak#251)
moved the dynamic-slot search into free_table(); gpu-draw (Marvisak#86) bounds
the search by the heap's spare slots instead of DYNAMIC. free_table() works
over taken.len(), which is the spare count, so the helper is kept with
gpu-draw's spare-based cursor wrap. Both sides' tests kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0xKaji

0xKaji commented Nov 24, 2026

Copy link
Copy Markdown

Tested this PR (197c7ac) under Wine 11.22 + vkd3d-proton 3.2.0 (GE-Proton11-14, VK_EXT_descriptor_heap enabled) on an RTX 3060 8GB (driver 620.73.04, CachyOS Linux 7.3.5-2), both in unit tests and in a 120s cold-cache live title run into Stage (e) (stacked on ffe310e + #177 + #190, VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains).

Unit Tests (Windows x86_64-pc-windows-msvc under Wine)

  • victory-gpu (--test-threads=1): 50 passed, 0 failed, 1 ignored — pipeline::library::tests::a_rejected_blob_gives_an_empty_library passes (flipped from panicking at an empty library on main).

Live Title Result (Cold-Cache 120s Run)

  • Without GPU: ask for an empty pipeline library with a null blob #347 (run3), the title logged no host pipeline library: pipelines are not kept and discarded compiled pipelines.
  • With GPU: ask for an empty pipeline library with a null blob #347 (run4), victory_gpu::pipeline::library cleanly created an empty library (0 errors) and flushed 5 incremental saves during the 120s run, ending at:
    • host pipeline library saved bytes=39224 early=105 made=204 loaded=12 started_early=0
    • Disk files created cleanly: host-pipelines.bin (39,224 bytes) and early-pipelines.txt (104 lines).
  • Notably, loaded=12 cache hits occurred inside the very first cold run via vkd3d-proton's pipeline library lookup without any crashes or GPU Xids (0 crashes, 0 Xids, 512 host pipelines built total including 222 mesh pipelines).

Warm-Cache Reload (run5, Reusing host-pipelines.bin Across Launch)

  • Re-running with all caches preserved reloaded the saved library cleanly in ~55 ms (0 library errors):
    • 14:38:05.925Z: title pipelines to start early pipelines=105
    • 14:38:05.979Z: host pipeline library loaded bytes=39224
    • vkd3d-proton also promoted its write cache (vkd3d_pipeline_library_disk_cache_merge: Promoting write cache to read cache; stream archive parsed in 0.325 ms).
  • Early startup pipeline pre-warming achieved 100% cache hits (made=0):
    • +3.8 s: victory_gpu::pipeline::make: host pipelines all made made=0 loaded=80 started_early=80
    • +31 s: victory_gpu::pipeline::make: host pipelines all made made=0 loaded=112 started_early=112
  • Fresh DXIL translations fell by -82% (732 → 130), Wave64 #817 refusals dropped (58 → 2), and dropped 0 without a host pipeline held across all 11 logged FPS intervals (frames 1..1123).
  • (Transparency note: run5 terminated at +66 s (14:39:10.948Z) with an unrelated NVIDIA vkAllocateMemory Exception 0xc0000005 under 8 GB VRAM / 15 GiB RAM exhaustion (NVRM NV_ERR_NO_MEMORY in system_mem.c:555), with 0 GPU Xids and 0 pipeline library errors. On GPUs with more VRAM this OOM may not occur; on 8 GB it's the current ceiling once compilation stalls are gone.)

edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
The tester tree (upstream main ffe310e plus its PRs, update 8; see its
INTEGRATION.md) ran 11-25 minutes in the world on an RTX 5070 without a
device removal. Where both sides carry the same PR (the wave64 stack
#223/#233/#320 with #439 and #180, #454, #336, #259, #331 and others), the
tester tree's newer head is taken; our own work and the PRs only we
merged are kept.

Conflicts, file by file:

- descriptor/host.rs: the tester layout (`spare`, the guard slot after the
  dynamic slots, `free_table`, the capped sampler heap). A capped view
  heap keeps `capped_reserve()` dynamic slots, now 2^18 by default (the
  tester measurement, and our 91fed158), still `VICTORY_DYNAMIC_SLOTS` in
  diagnostics builds; uncapped hosts keep our 2^19. Our slot statistics
  (TAKEN/PEAK/SHORT), the bindless plan cache (`CommittedRegions`,
  `timed_valid_title_address`, `timed_find`, `title_bounds`) and the
  revision triple are kept beside the tester's `guard_slot`.
- Buffer states: the tester tree's buffer-state tracker (#334: every list
  moves host copies of title memory between GENERIC_READ and
  UNORDERED_ACCESS and back to common before it closes) and depth twins
  (#469) are taken. #40's enhanced/legacy indirect barriers (the indirect
  prelude, `use_indirect_buffers`, the title buffer handoff mirrored in
  `host_barrier`) cannot share buffers with that tracker and are dropped;
  #40's argument checks (`byte_len`, exact spans, overflow-safe clamp
  shader, aligned counts) stay. `indirect::bound` and #282's
  `rectangles` go through `buffer_state`, and `indirect::execute` (#334)
  replaces `done`. #178's DXC fallback compiles both of our passes.
  Our segments (#387: `close` ends the segment, `close_native` closes a
  native list) carry the tracker: each native list returns its buffers
  to common and its twins to their depth targets, and each prelude also
  holds our texture uploads.
- shadow.rs: our write flow (`queue_write`, one `snapshot` after the
  batch's refreshes, `finish_writes`, the unchanged-page cache) with
  #261's copy-back that also gives the snapshot the title's bytes; its
  tests run through our flow.
- pipeline/make.rs: #275's per-frame budget and per-pipeline wake pair,
  with our compute waits (a dispatch waits for its pipeline, up to 20 s).
- pipeline/library.rs: the tester version (#347, #275's saver thread);
  our concurrent-write test kept. shader_cache.rs: our byte-returning
  cache API with #358's "translated, only not kept".
- draw.rs: #493's root SRV tables; where no table can stand in, our
  drop of a draw whose root view is unset or outside title buffers. Our
  refusal of a table offset past the capped heap stays.
- resource.rs: `HostTexture` has both our `staged` generation and the
  depth twin.
- Shaders: the tester's lower.rs for the wave64 stack, #160's image
  sampling (it covers our #73 and #136 sample forms) and #453/#587; kept
  from our side: #136's preference for an image or buffer use of a
  descriptor read as data and its `s_buffer_` arm, #422's nearest-even
  narrowing (also for #169's d16 loads and #453's interpolation), #452's
  spin-wait limit, #391's LDS limit, #302's spilled root arguments (now in
  `NativeProgram::translation_ir`), #136's PSV0 interpolation beside the
  tester's row harmonisation. split_tests.rs, lane_read_loop_tests.rs and
  docs/wave64-on-wave32.md are the tester versions (the same PRs at newer
  heads).
- Tests: #483's heap guard dwords filled in our GPU tests of #200
  (v_div_scale) and #437 (scalar loads from a raw view), which read
  through the guard slot otherwise; #334's debug-layer test passes an
  offset to our `indirect::bound`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
…ied together

Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485
Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts.

One change of mine: three of the PRs each add a `mod tests` at the end of
pipeline/host.rs, so the merge defines `tests` three times (E0428). The
second and third are named `library_tests` and `blend_tests`; nothing else
changes.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(367 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: crates/victory-gpu/src/pipeline/library.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

PastiiJay pushed a commit to PastiiJay/klbf-lab that referenced this pull request Nov 25, 2026
…so caching works on Wine/vkd3d-proton (gmankab, based on Marvisak/VIctory#347)

An empty slice still has an address, and vkd3d-proton answers E_INVALIDARG to a non-null blob of length 0, so under Wine no pipeline library was ever created and host pipelines were not kept.

Co-authored-by: AugustoZFJ <14866271+AugustoZFJ@users.noreply.github.com>
AlvBarros pushed a commit to AlvBarros/flamingo-fork that referenced this pull request Nov 25, 2026
…so caching works on Wine/vkd3d-proton (gmankab, based on Marvisak/VIctory#347)

An empty slice still has an address, and vkd3d-proton answers E_INVALIDARG to a non-null blob of length 0, so under Wine no pipeline library was ever created and host pipelines were not kept.

Co-authored-by: AugustoZFJ <14866271+AugustoZFJ@users.noreply.github.com>
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.

7 participants