Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion crates/victory-gpu/src/pipeline/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,35 @@ fn open(device: &ID3D12Device1, blob: Blob) -> Option<Library> {
// 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()?;
// An empty library is asked for with a null blob. An empty Rust slice
// has a dangling, non-null pointer; Windows only looks at the length,
// but the host's D3D12 on Linux (vkd3d-proton) refuses a non-null blob
// of length 0 with E_INVALIDARG, and no pipeline was ever kept there
// ("no host pipeline library" at every start). As upstream PR #1722.
let empty = || -> windows::core::Result<ID3D12PipelineLibrary1> {
use windows::core::Interface;
let mut out = std::ptr::null_mut();
// SAFETY: the method's own arguments; a null blob of length 0 makes
// an empty library, written to `out`.
unsafe {
(Interface::vtable(device).CreatePipelineLibrary)(
Interface::as_raw(device),
std::ptr::null(),
0,
&ID3D12PipelineLibrary::IID,
&mut out,
)
.ok()?;
ID3D12PipelineLibrary::from_raw(out).cast()
}
};
let library = match empty() {
Ok(library) => library,
Err(e) => {
tracing::info!(error = %e, "empty host pipeline library refused");
return None;
}
};
Some(Library {
library,
_blob: Blob::None,
Expand Down