Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Device fence sharing with dx12 on Windows #4872

Closed
sotaroikeda opened this issue Dec 13, 2023 · 0 comments · Fixed by #4900
Closed

Support Device fence sharing with dx12 on Windows #4872

sotaroikeda opened this issue Dec 13, 2023 · 0 comments · Fixed by #4900

Comments

@sotaroikeda
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant