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§
source§impl Semaphore
impl Semaphore
sourcepub fn new(
device: Arc<Device>,
create_info: SemaphoreCreateInfo
) -> Result<Semaphore, Validated<VulkanError>>
pub fn new( device: Arc<Device>, create_info: SemaphoreCreateInfo ) -> Result<Semaphore, Validated<VulkanError>>
Creates a new Semaphore
.
sourcepub fn from_pool(device: Arc<Device>) -> Result<Semaphore, VulkanError>
pub fn from_pool(device: Arc<Device>) -> Result<Semaphore, VulkanError>
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_handle_types(&self) -> ExternalSemaphoreHandleTypes
pub fn export_handle_types(&self) -> ExternalSemaphoreHandleTypes
Returns the handle types that can be exported from the semaphore.
sourcepub fn export_fd(
&self,
handle_type: ExternalSemaphoreHandleType
) -> Result<File, Validated<VulkanError>>
pub fn export_fd( &self, handle_type: ExternalSemaphoreHandleType ) -> Result<File, Validated<VulkanError>>
Exports the semaphore into a POSIX file descriptor. The caller owns the returned File
.
sourcepub fn export_win32_handle(
&self,
handle_type: ExternalSemaphoreHandleType
) -> Result<*mut c_void, Validated<VulkanError>>
pub fn export_win32_handle( &self, handle_type: ExternalSemaphoreHandleType ) -> Result<*mut c_void, Validated<VulkanError>>
Exports the semaphore into a Win32 handle.
The khr_external_semaphore_win32
extension must be enabled on the device.
sourcepub fn export_zircon_handle(
&self,
handle_type: ExternalSemaphoreHandleType
) -> Result<zx_handle_t, Validated<VulkanError>>
pub fn export_zircon_handle( &self, handle_type: ExternalSemaphoreHandleType ) -> Result<zx_handle_t, Validated<VulkanError>>
Exports the semaphore into a Zircon event handle.
sourcepub unsafe fn import_fd(
&self,
import_semaphore_fd_info: ImportSemaphoreFdInfo
) -> Result<(), Validated<VulkanError>>
pub unsafe fn import_fd( &self, import_semaphore_fd_info: ImportSemaphoreFdInfo ) -> Result<(), Validated<VulkanError>>
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
.
sourcepub unsafe fn import_win32_handle(
&self,
import_semaphore_win32_handle_info: ImportSemaphoreWin32HandleInfo
) -> Result<(), Validated<VulkanError>>
pub unsafe fn import_win32_handle( &self, import_semaphore_win32_handle_info: ImportSemaphoreWin32HandleInfo ) -> Result<(), Validated<VulkanError>>
Imports a semaphore from a Win32 handle.
The khr_external_semaphore_win32
extension must be enabled on the device.
Safety
- In
import_semaphore_win32_handle_info
,handle
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
.
sourcepub unsafe fn import_zircon_handle(
&self,
import_semaphore_zircon_handle_info: ImportSemaphoreZirconHandleInfo
) -> Result<(), Validated<VulkanError>>
pub unsafe fn import_zircon_handle( &self, import_semaphore_zircon_handle_info: ImportSemaphoreZirconHandleInfo ) -> Result<(), Validated<VulkanError>>
Imports a semaphore from a Zircon event handle.
The fuchsia_external_semaphore
extension must be enabled on the device.
Safety
- In
import_semaphore_zircon_handle_info
,zircon_handle
must haveZX_RIGHTS_BASIC
andZX_RIGHTS_SIGNAL
.