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

Add a way to notify with Queue::submit() to Vulkan's vk::Semaphore allocated outside of wgpu #6812

Open
sotaroikeda opened this issue Dec 23, 2024 · 0 comments · May be fixed by #6813
Open
Labels
api: vulkan Issues with Vulkan area: api Issues related to API surface type: enhancement New feature or request

Comments

@sotaroikeda
Copy link
Contributor

sotaroikeda commented Dec 23, 2024

Is your feature request related to a problem? Please describe.

Like #4872 and #6575, with Vulkan, it is necessary to add a capability of sharing semaphore synchronization between gecko(outside of wgpu). See Bug 1920763

Describe the solution you'd like

Add Global::queue_as_hal() like the following for accessing hal queue.

    pub unsafe fn queue_as_hal<A: HalApi, F: FnOnce(Option<&A::Queue>) -> R, R>(
        &self,
        id: QueueId,
        hal_queue_callback: F,
    ) -> R {
        profiling::scope!("Queue::as_hal");

        let queue = self.hub.queues.get(id);
        let hal_queue = queue.raw().as_any().downcast_ref();

        hal_queue_callback(hal_queue)
    }

And Queue::add_signal_semahore() adds signal semaphore, the semaphore is submitted by next Queue::submit().

impl Queue {
    pub fn add_signal_semahore(&self, semaphore: vk::Semaphore) {
        let mut signal_semaphores = self.signal_semaphores.lock();
        signal_semaphores.push(semaphore);
    }
}

Describe alternatives you've considered

Investigated to call Device::wait_for_submit() from a different thread. But it caused to block Device::wait_for_submit() calling thread several times for taking a lock.

Also investigated to use timeline semaphore in Fence.
Timeline fence seemed not work well with gl API GL_EXT_semaphore and GL_EXT_semaphore_fd.

It seems safer to use vk::Semaphore like chromium for signaling.

Additional context

Synchronization by using vk::Semaphore in gecko is tracked in Bug 1920763.

@ErichDonGubler ErichDonGubler changed the title Add a way to notify with Queue::submit() to Vulkan's vk::Semaphore allocated outside of wgpu Add a way to notify with Queue::submit() to Vulkan's vk::Semaphore allocated outside of wgpu Dec 23, 2024
@cwfitzgerald cwfitzgerald added type: enhancement New feature or request area: api Issues related to API surface api: vulkan Issues with Vulkan labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vulkan Issues with Vulkan area: api Issues related to API surface type: enhancement New feature or request
Projects
Status: Todo
2 participants