mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Support Device fence sharing with dx12 on Windows (#4900)
Co-authored-by: Sotaro Ikeda <you@example.com>
This commit is contained in:
@@ -854,6 +854,23 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
hal_device_callback(hal_device)
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
///
|
||||
/// - The raw fence handle must not be manually destroyed
|
||||
pub unsafe fn device_fence_as_hal<A: HalApi, F: FnOnce(Option<&A::Fence>) -> R, R>(
|
||||
&self,
|
||||
id: DeviceId,
|
||||
hal_fence_callback: F,
|
||||
) -> R {
|
||||
profiling::scope!("Device::fence_as_hal");
|
||||
|
||||
let hub = A::hub(self);
|
||||
let device = hub.devices.try_get(id).ok().flatten();
|
||||
let hal_fence = device.as_ref().map(|device| device.fence.read());
|
||||
|
||||
hal_fence_callback(hal_fence.as_deref().unwrap().as_ref())
|
||||
}
|
||||
|
||||
/// # Safety
|
||||
/// - The raw surface handle must not be manually destroyed
|
||||
pub unsafe fn surface_as_hal<A: HalApi, F: FnOnce(Option<&A::Surface>) -> R, R>(
|
||||
|
||||
@@ -1514,7 +1514,7 @@ impl crate::Device<super::Api> for super::Device {
|
||||
let hr = unsafe {
|
||||
self.raw.CreateFence(
|
||||
0,
|
||||
d3d12_ty::D3D12_FENCE_FLAG_NONE,
|
||||
d3d12_ty::D3D12_FENCE_FLAG_SHARED,
|
||||
&d3d12_ty::ID3D12Fence::uuidof(),
|
||||
raw.mut_void(),
|
||||
)
|
||||
|
||||
@@ -493,6 +493,12 @@ pub struct Fence {
|
||||
unsafe impl Send for Fence {}
|
||||
unsafe impl Sync for Fence {}
|
||||
|
||||
impl Fence {
|
||||
pub fn raw_fence(&self) -> &d3d12::Fence {
|
||||
&self.raw
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BindGroupLayout {
|
||||
/// Sorted list of entries.
|
||||
|
||||
Reference in New Issue
Block a user