Struct NativeSwapchain

Source
pub(crate) struct NativeSwapchain {
    raw: SwapchainKHR,
    functor: Device,
    device: Arc<DeviceShared>,
    images: Vec<Image>,
    fence: Fence,
    config: SurfaceConfiguration,
    acquire_semaphores: Vec<Arc<Mutex<SwapchainAcquireSemaphore>>>,
    next_acquire_index: usize,
    present_semaphores: Vec<Arc<Mutex<SwapchainPresentSemaphores>>>,
    next_present_time: Option<PresentTimeGOOGLE>,
}

Fields§

§raw: SwapchainKHR§functor: Device§device: Arc<DeviceShared>§images: Vec<Image>§fence: Fence

Fence used to wait on the acquired image.

§config: SurfaceConfiguration§acquire_semaphores: Vec<Arc<Mutex<SwapchainAcquireSemaphore>>>

Semaphores used between image acquisition and the first submission that uses that image. This is indexed using next_acquire_index.

Because we need to provide this to vkAcquireNextImageKHR, we haven’t received the swapchain image index for the frame yet, so we cannot use that to index it.

Before we pass this to vkAcquireNextImageKHR, we ensure that we wait on the submission indicated by previously_used_submission_index. This ensures the semaphore is no longer in use before we use it.

§next_acquire_index: usize

The index of the next acquire semaphore to use.

This is incremented each time we acquire a new image, and wraps around to 0 when it reaches the end of acquire_semaphores.

§present_semaphores: Vec<Arc<Mutex<SwapchainPresentSemaphores>>>

Semaphore sets used between all submissions that write to an image and the presentation of that image.

This is indexed by the swapchain image index returned by vkAcquireNextImageKHR.

We know it is safe to use these semaphores because use them after the acquire semaphore. Because the acquire semaphore has been signaled, the previous presentation using that image is known-finished, so this semaphore is no longer in use.

§next_present_time: Option<PresentTimeGOOGLE>

The present timing information which will be set in the next call to present().

§Safety

This must only be set if wgt::Features::VULKAN_GOOGLE_DISPLAY_TIMING is enabled, and so the VK_GOOGLE_display_timing extension is present.

Implementations§

Source§

impl NativeSwapchain

Source

pub(crate) fn as_raw(&self) -> SwapchainKHR

Source

pub fn set_next_present_time(&mut self, present_timing: PresentTimeGOOGLE)

Source

fn advance_acquire_semaphore(&mut self)

Mark the current frame finished, advancing to the next acquire semaphore.

Source

fn get_acquire_semaphore(&self) -> Arc<Mutex<SwapchainAcquireSemaphore>>

Get the next acquire semaphore that should be used with this swapchain.

Source

fn get_present_semaphores( &self, index: u32, ) -> Arc<Mutex<SwapchainPresentSemaphores>>

Get the set of present semaphores that should be used with the given image index.

Trait Implementations§

Source§

impl Swapchain for NativeSwapchain

Source§

unsafe fn release_resources(&mut self, device: &Device)

Releases all resources associated with the swapchain, without destroying the swapchain itself. Must be called before calling either Surface::create_swapchain or Swapchain::delete_swapchain. Read more
Source§

unsafe fn delete_swapchain(self: Box<Self>)

Deletes the swapchain. Read more
Source§

unsafe fn acquire( &mut self, timeout: Option<Duration>, fence: &Fence, ) -> Result<Option<AcquiredSurfaceTexture<Vulkan>>, SurfaceError>

Acquires the next available surface texture for rendering. Read more
Source§

unsafe fn discard_texture( &mut self, _texture: SurfaceTexture, ) -> Result<(), SurfaceError>

Tries to discard the acquired texture without presenting it. Read more
Source§

unsafe fn present( &mut self, queue: &Queue, texture: SurfaceTexture, ) -> Result<(), SurfaceError>

Presents the given surface texture using the queue.
Source§

fn as_any(&self) -> &dyn Any

Allows downcasting to the concrete type.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Allows downcasting to the concrete type mutably.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,