Support Device fence sharing with dx12 on Windows
sotaroikeda opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
I've been exploring how to get shared handle of ID3D12Fence of Device:::fence with dx12. The shared handle is going to be opened as ID3D11Fence. The ID3D11Fence is used for synchronization between Direct3D 11 and Direct3D 12 in interop.
I tried to get Device:::fence. But the api for getting it did not exist. And wgpu-hal did not have api for getting raw fence(d3d12::Fence).
Describe the solution you'd like
Add api for getting Device:::fence like:
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())
}
Create d3d12::Fence with sharing flag like:
let hr = unsafe {
self.raw.CreateFence(
0,
d3d12_ty::D3D12_FENCE_FLAG_SHARED,
&d3d12_ty::ID3D12Fence::uuidof(),
raw.mut_void(),
)
};
Add api for getting raw fence(d3d12::Fence).
impl Fence{
pub fn raw_fence(&self) -> &d3d12::Fence {
&self.raw
}
}
Describe alternatives you've considered
I tried to get Device:::fence and raw fence(d3d12::Fence) with wgpu-core apis and wgpu-hal apis. But they seemed not exist.
Additional context
Fence sharing in gecko is being implemented at bug 1863474.