Skip to content

Commit

Permalink
WIP: fix: avoid mut_void for D3D12 debug layer init.
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Sep 20, 2023
1 parent 5cfeea5 commit 878649a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 7 additions & 5 deletions d3d12/src/com.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ impl<T: Interface> ComPtr<T> {
ComPtr(ptr::null_mut())
}

pub unsafe fn from_reffed(raw: *mut T) -> Self {
ComPtr(raw)
}

/// Create a ComPtr from a raw pointer. This will call AddRef on the pointer.
///
/// # Safety
Expand Down Expand Up @@ -100,11 +104,9 @@ impl<T: Interface> ComPtr<T> {
U: Interface,
{
debug_assert!(!self.is_null());
let mut obj = ComPtr::<U>::null();
let hr = self
.as_unknown()
.QueryInterface(&U::uuidof(), obj.mut_void());
(obj, hr)
let mut obj = std::ptr::null_mut();
let hr = self.as_unknown().QueryInterface(&U::uuidof(), &mut obj);
(ComPtr::from_reffed(obj.cast()), hr)
}
}

Expand Down
5 changes: 3 additions & 2 deletions d3d12/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ impl crate::D3D12Lib {
*mut *mut winapi::ctypes::c_void,
) -> crate::HRESULT;

let mut debug = Debug::null();
let mut debug = std::ptr::null_mut();
let hr = unsafe {
let func: libloading::Symbol<Fun> = self.lib.get(b"D3D12GetDebugInterface")?;
func(&d3d12sdklayers::ID3D12Debug::uuidof(), debug.mut_void())
func(&d3d12sdklayers::ID3D12Debug::uuidof(), &mut debug)
};
let debug = unsafe { ComPtr::from_reffed(debug.cast()) };

Ok((debug, hr))
}
Expand Down

0 comments on commit 878649a

Please sign in to comment.