Skip to main content

gstreamer_vulkan/
vulkan_queue.rs

1use crate::VulkanQueue;
2use crate::ffi;
3
4use glib::{prelude::*, translate::*};
5
6// rustdoc-stripper-ignore-next
7/// Represents a locked vulkan queue that can be submitted too. The queue is unlock when this struct is dropped.
8#[derive(Debug)]
9pub struct VulkanQueueSubmitGuard<'a> {
10    obj: &'a VulkanQueue,
11}
12
13impl Drop for VulkanQueueSubmitGuard<'_> {
14    fn drop(&mut self) {
15        unsafe {
16            ffi::gst_vulkan_queue_submit_unlock(self.obj.to_glib_none().0);
17        }
18    }
19}
20impl PartialEq for VulkanQueueSubmitGuard<'_> {
21    fn eq(&self, other: &Self) -> bool {
22        self.obj == other.obj
23    }
24}
25impl Eq for VulkanQueueSubmitGuard<'_> {}
26
27pub trait VulkanQueueExtManual: IsA<VulkanQueue> + 'static {
28    // rustdoc-stripper-ignore-next
29    /// Locks the vulkan queue for submission. A struct similar to `MutexGuard` is retured that unlocks the queue once dropped.
30    // rustdoc-stripper-ignore-next-stop
31    /// Locks the queue for command submission using `vkQueueSubmit()` to meet the
32    /// Vulkan requirements for externally synchronised resources.
33    #[doc(alias = "gst_vulkan_queue_submit_lock")]
34    fn submit_lock<'a>(&'a self) -> VulkanQueueSubmitGuard<'a> {
35        unsafe {
36            ffi::gst_vulkan_queue_submit_lock(self.as_ref().to_glib_none().0);
37        }
38        VulkanQueueSubmitGuard {
39            obj: self.upcast_ref(),
40        }
41    }
42}
43impl<O: IsA<VulkanQueue>> VulkanQueueExtManual for O {}