pub struct Semaphore { /* private fields */ }
Expand description
Used to provide synchronization between command buffers during their execution.
It is similar to a fence, except that it is purely on the GPU side. The CPU can’t query a semaphore’s status or wait for it to be signaled.
Implementations
sourceimpl Semaphore
impl Semaphore
sourcepub fn new(
device: Arc<Device>,
create_info: SemaphoreCreateInfo
) -> Result<Semaphore, SemaphoreError>
pub fn new(
device: Arc<Device>,
create_info: SemaphoreCreateInfo
) -> Result<Semaphore, SemaphoreError>
Creates a new Semaphore
.
sourcepub fn from_pool(device: Arc<Device>) -> Result<Semaphore, SemaphoreError>
pub fn from_pool(device: Arc<Device>) -> Result<Semaphore, SemaphoreError>
Takes a semaphore from the vulkano-provided semaphore pool.
If the pool is empty, a new semaphore will be allocated.
Upon drop
, the semaphore is put back into the pool.
For most applications, using the pool should be preferred, in order to avoid creating new semaphores every frame.
sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: Semaphore,
create_info: SemaphoreCreateInfo
) -> Semaphore
pub unsafe fn from_handle(
device: Arc<Device>,
handle: Semaphore,
create_info: SemaphoreCreateInfo
) -> Semaphore
Creates a new Semaphore
from a raw object handle.
Safety
handle
must be a valid Vulkan object handle created fromdevice
.create_info
must match the info used to create the object.
sourcepub fn export_fd(
&self,
handle_type: ExternalSemaphoreHandleType
) -> Result<File, SemaphoreError>
pub fn export_fd(
&self,
handle_type: ExternalSemaphoreHandleType
) -> Result<File, SemaphoreError>
Exports the semaphore into a POSIX file descriptor. The caller owns the returned File
.
sourcepub unsafe fn import_fd(
&self,
import_semaphore_fd_info: ImportSemaphoreFdInfo
) -> Result<(), SemaphoreError>
pub unsafe fn import_fd(
&self,
import_semaphore_fd_info: ImportSemaphoreFdInfo
) -> Result<(), SemaphoreError>
Imports a semaphore from a POSIX file descriptor.
The khr_external_semaphore_fd
extension must be enabled on the device.
Safety
- If in
import_semaphore_fd_info
,handle_type
isExternalHandleType::OpaqueFd
, thenfile
must represent a binary semaphore that was exported from Vulkan or a compatible API, with a driver and device UUID equal to those of the device that ownsself
.