Linux/Proton: host pipeline library never created - CreatePipelineLibrary(&[]) passes a non-null pointer with length 0 (E_INVALIDARG from vkd3d-proton) #136

Open
opened 2026-11-26 06:52:01 +00:00 by github-bot · 1 comment
Owner

@⁠DevLazo on GitHub · 2026-11-26 06:46 UTC · original

Under Proton/vkd3d-proton, Victory never gets a host pipeline library. Every launch logs no host pipeline library: pipelines are not kept and recompiles all host pipelines. #129 notes that "vkd3d-proton refuses the pipeline library" and keeps the early list without one. This issue gives the cause and a fix that makes the library itself work.

Cause

open() in crates/victory-gpu/src/pipeline/library.rs makes the empty library with make(&[]). The windows 0.62.2 wrapper CreatePipelineLibrary(&[u8]) passes slice.as_ptr(), which for an empty slice is a dangling non-null pointer, with length 0. vkd3d-proton rejects exactly that in d3d12_pipeline_library_init (libs/vkd3d/cache.c), both in the build in Proton Experimental experimental-11.0-20261112 (2576c0b4adfae4a) and in master (71cae091):

if (!blob_length && blob)
    return E_INVALIDARG;

Native D3D12 accepts the call, which is why it only shows up on Linux. With the HRESULT logged: CreatePipelineLibrary refused an empty blob error=Invalid parameter. (0x80070057). The .ok()? on that path hides the code, so a warning with the HRESULT would help either way.

The same fix is open as fxceless/victory-fork#885 ("GPU: pass null for empty D3D12 pipeline libraries on Proton"), tested there on an RTX 4060 with vkd3d-proton 71cae091. This is an independent confirmation on AMD/RADV.

Fix

Call the vtable entry with a real null pointer for the empty library. Only the empty path changes; loading an existing blob is untouched.

Patch against crates/victory-gpu/src/pipeline/library.rs
@@ -492,7 +492,29 @@
     // The rejected bytes are let go (a mapped file is unmapped) before the
     // empty library is made: nothing reads them any more.
     drop(blob);
-    let library = make(&[]).ok()?;
+    // Linux/vkd3d-proton: the `windows` wrapper passes an empty slice's
+    // dangling, non-null pointer with length 0, which vkd3d-proton refuses
+    // with E_INVALIDARG (native D3D12 accepts it). Call the vtable with a
+    // real null pointer for the empty library instead.
+    let mut raw = core::ptr::null_mut();
+    // SAFETY: a plain COM call on a live device; a null blob of length 0 asks
+    // for an empty library, and `raw` receives an owned reference on success.
+    let hr = unsafe {
+        (Interface::vtable(device).CreatePipelineLibrary)(
+            Interface::as_raw(device),
+            core::ptr::null(),
+            0,
+            &ID3D12PipelineLibrary1::IID,
+            &mut raw,
+        )
+    };
+    if hr.is_err() || raw.is_null() {
+        tracing::warn!(code = format_args!("{:#010x}", hr.0), "host pipeline library: CreatePipelineLibrary refused an empty library");
+        return None;
+    }
+    // SAFETY: `raw` is a non-null ID3D12PipelineLibrary1 we now own.
+    let library = unsafe { ID3D12PipelineLibrary1::from_raw(raw) };
+    tracing::info!("host pipeline library: empty library made (null blob)");
     Some(Library {
         library,
         _blob: Blob::None,

Results (RX 6800 XT 16 GB, RADV / Mesa 26.3.1, Proton Experimental 11.0-20261112, release build)

  • First launch: empty library made (null blob), then periodic saves. The last save had made=2059, and host-pipelines.bin was about 395 KB.
  • Second launch: host pipeline library loaded bytes=394808 mapped=true. The last save had made=51 loaded=2274 started_early=2278.
  • After a vkd3d-proton version change, the saved library is rejected with 0x887E0002 (D3D12_ERROR_DRIVER_VERSION_MISMATCH), and a new empty one is made through the fixed path.
  • Startup after entering the world improved somewhat (median 3.8 → 5.5 fps, no ~2 s frames). Most of the remaining stall is CPU-side copying, not pipeline compiles.

Separately, I confirm the six compute pipelines from #111/#129 on this card. With dxil-spirv 114e664e (Proton's), the standalone dxil-spirv tool recurses forever (CFGNode::recompute_immediate_dominator ↔ find_common_dominator, via flatten_subgroup_shuffles). dxil-spirv b540c8a2 (vkd3d-proton master) converts all six. With vkd3d-proton master next to victory.exe, the steady-state median here went from 11.0 to 15.9 fps.

**@⁠DevLazo** on GitHub · 2026-11-26 06:46 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/136) Under Proton/vkd3d-proton, Victory never gets a host pipeline library. Every launch logs `no host pipeline library: pipelines are not kept` and recompiles all host pipelines. #129 notes that "vkd3d-proton refuses the pipeline library" and keeps the early list without one. This issue gives the cause and a fix that makes the library itself work. ## Cause `open()` in `crates/victory-gpu/src/pipeline/library.rs` makes the empty library with `make(&[])`. The `windows` 0.62.2 wrapper `CreatePipelineLibrary(&[u8])` passes `slice.as_ptr()`, which for an empty slice is a dangling **non-null** pointer, with length 0. vkd3d-proton rejects exactly that in `d3d12_pipeline_library_init` (`libs/vkd3d/cache.c`), both in the build in Proton Experimental `experimental-11.0-20261112` (`2576c0b4adfae4a`) and in master (`71cae091`): ```c if (!blob_length && blob) return E_INVALIDARG; ``` Native D3D12 accepts the call, which is why it only shows up on Linux. With the HRESULT logged: `CreatePipelineLibrary refused an empty blob error=Invalid parameter. (0x80070057)`. The `.ok()?` on that path hides the code, so a warning with the HRESULT would help either way. The same fix is open as fxceless/victory-fork#885 ("GPU: pass null for empty D3D12 pipeline libraries on Proton"), tested there on an RTX 4060 with vkd3d-proton `71cae091`. This is an independent confirmation on AMD/RADV. ## Fix Call the vtable entry with a real null pointer for the empty library. Only the empty path changes; loading an existing blob is untouched. <details><summary>Patch against <code>crates/victory-gpu/src/pipeline/library.rs</code></summary> ```diff @@ -492,7 +492,29 @@ // The rejected bytes are let go (a mapped file is unmapped) before the // empty library is made: nothing reads them any more. drop(blob); - let library = make(&[]).ok()?; + // Linux/vkd3d-proton: the `windows` wrapper passes an empty slice's + // dangling, non-null pointer with length 0, which vkd3d-proton refuses + // with E_INVALIDARG (native D3D12 accepts it). Call the vtable with a + // real null pointer for the empty library instead. + let mut raw = core::ptr::null_mut(); + // SAFETY: a plain COM call on a live device; a null blob of length 0 asks + // for an empty library, and `raw` receives an owned reference on success. + let hr = unsafe { + (Interface::vtable(device).CreatePipelineLibrary)( + Interface::as_raw(device), + core::ptr::null(), + 0, + &ID3D12PipelineLibrary1::IID, + &mut raw, + ) + }; + if hr.is_err() || raw.is_null() { + tracing::warn!(code = format_args!("{:#010x}", hr.0), "host pipeline library: CreatePipelineLibrary refused an empty library"); + return None; + } + // SAFETY: `raw` is a non-null ID3D12PipelineLibrary1 we now own. + let library = unsafe { ID3D12PipelineLibrary1::from_raw(raw) }; + tracing::info!("host pipeline library: empty library made (null blob)"); Some(Library { library, _blob: Blob::None, ``` </details> ## Results (RX 6800 XT 16 GB, RADV / Mesa 26.3.1, Proton Experimental 11.0-20261112, release build) - First launch: `empty library made (null blob)`, then periodic saves. The last save had `made=2059`, and `host-pipelines.bin` was about 395 KB. - Second launch: `host pipeline library loaded bytes=394808 mapped=true`. The last save had `made=51 loaded=2274 started_early=2278`. - After a vkd3d-proton version change, the saved library is rejected with `0x887E0002` (`D3D12_ERROR_DRIVER_VERSION_MISMATCH`), and a new empty one is made through the fixed path. - Startup after entering the world improved somewhat (median 3.8 → 5.5 fps, no ~2 s frames). Most of the remaining stall is CPU-side copying, not pipeline compiles. Separately, I confirm the six compute pipelines from #111/#129 on this card. With dxil-spirv `114e664e` (Proton's), the standalone `dxil-spirv` tool recurses forever (`CFGNode::recompute_immediate_dominator` ↔ `find_common_dominator`, via `flatten_subgroup_shuffles`). dxil-spirv `b540c8a2` (vkd3d-proton master) converts all six. With vkd3d-proton master next to `victory.exe`, the steady-state median here went from 11.0 to 15.9 fps.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:52:01 +00:00
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-26 12:08 UTC · original

The cause is right, and the vtable call fixes it. We ported it from viyourmom/victory-8gb-linux-lowram 69cca8a and it works on this fork too, AMD/RADV:

unsafe fn create_library(
    device: &ID3D12Device1,
    bytes: &[u8],
) -> windows::core::Result<ID3D12PipelineLibrary1> {
    use windows::core::Type;
    let blob = if bytes.is_empty() { core::ptr::null() } else { bytes.as_ptr().cast() };
    let mut result = core::ptr::null_mut();
    let called = unsafe {
        (Interface::vtable(device).CreatePipelineLibrary)(
            Interface::as_raw(device),
            blob,
            bytes.len(),
            &<ID3D12PipelineLibrary1 as Interface>::IID,
            &mut result,
        )
    };
    called.ok()?;
    unsafe { Type::from_abi(result) }
}

with open()'s make calling it instead of device.CreatePipelineLibrary(&[]).

Measured (retail 1.0.2.1, RX 7600 XT 8 GB, RADV Mesa 27.0.0, Wine 11.22, vkd3d-proton master): the log goes from host pipeline library rejected; starting an empty one error=0x887E0002 and no host pipeline library: pipelines are not kept to host pipeline library loaded bytes=1912952 mapped=true, and the file survives the run. No other change was needed.

Unrelated but adjacent, and it removes a whole class of picture defects on Wine: with Microsoft's d3dcompiler_47.dll in the prefix (d3dcompiler_47=n, no dxcompiler.dll beside the exe) the indirect clamp and the card-compare build through D3DCompile as on Windows. The DXC fallback compiles them too, but under DXC we got axis-aligned rectangles of another surface over characters — a detail for issue #1270/#1285 in the parent fork.

**@⁠YaBulochka** on GitHub · 2026-11-26 12:08 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/issues/136#issuecomment-7191623859) The cause is right, and the vtable call fixes it. We ported it from `viyourmom/victory-8gb-linux-lowram` `69cca8a` and it works on this fork too, AMD/RADV: ```rust unsafe fn create_library( device: &ID3D12Device1, bytes: &[u8], ) -> windows::core::Result<ID3D12PipelineLibrary1> { use windows::core::Type; let blob = if bytes.is_empty() { core::ptr::null() } else { bytes.as_ptr().cast() }; let mut result = core::ptr::null_mut(); let called = unsafe { (Interface::vtable(device).CreatePipelineLibrary)( Interface::as_raw(device), blob, bytes.len(), &<ID3D12PipelineLibrary1 as Interface>::IID, &mut result, ) }; called.ok()?; unsafe { Type::from_abi(result) } } ``` with `open()`'s `make` calling it instead of `device.CreatePipelineLibrary(&[])`. Measured (retail 1.0.2.1, RX 7600 XT 8 GB, RADV Mesa 27.0.0, Wine 11.22, vkd3d-proton master): the log goes from `host pipeline library rejected; starting an empty one error=0x887E0002` and `no host pipeline library: pipelines are not kept` to `host pipeline library loaded bytes=1912952 mapped=true`, and the file survives the run. No other change was needed. Unrelated but adjacent, and it removes a whole class of picture defects on Wine: with **Microsoft's** `d3dcompiler_47.dll` in the prefix (`d3dcompiler_47=n`, no `dxcompiler.dll` beside the exe) the indirect clamp and the card-compare build through `D3DCompile` as on Windows. The DXC fallback compiles them too, but under DXC we got axis-aligned rectangles of another surface over characters — a detail for issue #1270/#1285 in the parent fork.
This discussion has been locked. Commenting is limited to contributors.
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/avatarmanz--VIctory-7900XTX#136
No description provided.