Surface

Struct Surface 

Source
pub struct Surface {
    swapchain: RwLock<Option<Box<dyn Swapchain>>>,
    inner: Box<dyn Surface>,
}
Available on vulkan only.

Fields§

§swapchain: RwLock<Option<Box<dyn Swapchain>>>§inner: Box<dyn Surface>

Implementations§

Source§

impl Surface

Source

pub unsafe fn raw_native_handle(&self) -> Option<SurfaceKHR>

Returns the raw Vulkan surface handle.

Returns None if the surface is a DXGI surface.

Source

pub fn raw_native_swapchain(&self) -> Option<SwapchainKHR>

Get the raw Vulkan swapchain associated with this surface.

Returns None if the surface is not configured or if the swapchain is a DXGI swapchain.

Source

pub fn set_next_present_time(&self, present_timing: PresentTimeGOOGLE)

Set the present timing information which will be used for the next presentation of this surface, using VK_GOOGLE_display_timing.

This can be used to give an id to presentations, for future use of [vk::PastPresentationTimingGOOGLE]. Note that wgpu-hal does not provide a way to use that API - you should manually access this through [ash].

This can also be used to add a “not before” timestamp to the presentation.

The exact semantics of the fields are also documented in the specification for the extension.

§Panics
  • If the surface hasn’t been configured.
  • If the surface has been configured for a DXGI swapchain.
  • If the device doesn’t support present timing.
Source

pub unsafe fn set_next_present_chain(&self, chain: *mut c_void)

Set a pNext chain of extension structs to be attached to the [vk::PresentInfoKHR] of the next presentation of this surface.

This supports presentation extensions that wgpu-hal has no dedicated support for, such as VK_NV_present_metering. The corresponding device extension must be enabled at device creation, e.g. with Adapter::open_with_callback().

The chain is consumed by the next presentation: it replaces any chain set by a previous call that hasn’t been presented yet, and is discarded unread if the surface is reconfigured first.

§Safety
  • chain must point to a valid pNext chain of structs that can extend [vk::PresentInfoKHR], whose extensions are enabled on the device.
  • The chain must stay valid, and must not be read or written, until the next presentation of this surface completes or the surface is reconfigured. Fields the driver wrote during presentation may be read afterwards.
§Panics
  • If the surface hasn’t been configured.
  • If the surface has been configured for a DXGI swapchain.
Source

pub unsafe fn set_next_swapchain_create_chain(&self, chain: *mut c_void)

Set a pNext chain of extension structs to attach to the [vk::SwapchainCreateInfoKHR] used by the next configuration of this surface.

This supports swapchain extensions that wgpu-hal has no dedicated support for. One example is VkSwapchainLatencyCreateInfoNV from VK_NV_low_latency2. The device extension itself must be enabled at device creation, for example with Adapter::open_with_callback().

The next configuration consumes the chain. A later call replaces a chain that hasn’t been consumed yet. If the surface is dropped first, the chain is discarded unread. Every configuration creates a new swapchain, so you must set the chain again before each configuration, including on resize.

§Safety
  • chain must point to a valid pNext chain of structs that can extend [vk::SwapchainCreateInfoKHR]. The extensions in the chain must be enabled on the device the surface is configured with.
  • The chain must stay valid until the configuration that consumes it returns or the surface is dropped. Don’t read or write the chain during that time. Fields the driver wrote during swapchain creation may be read afterwards.
§Panics
  • If the surface isn’t a native Vulkan surface, such as a DXGI surface.

Trait Implementations§

Source§

impl DynResource for Surface

Source§

fn as_any(&self) -> &dyn Any

Source§

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

Source§

impl Surface for Surface

Source§

type A = Api

Source§

unsafe fn configure( &self, device: &Device, config: &SurfaceConfiguration, ) -> Result<(), SurfaceError>

Configure self to use device. Read more
Source§

unsafe fn unconfigure(&self, device: &Device)

Unconfigure self on device. Read more
Source§

unsafe fn acquire_texture( &self, timeout: Option<Duration>, fence: &Fence, ) -> Result<AcquiredSurfaceTexture<Api>, SurfaceError>

Return the next texture to be presented by self, for the caller to draw on. Read more
Source§

unsafe fn discard_texture(&self, texture: SurfaceTexture)

Relinquish an acquired texture without presenting it. Read more

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<S> DynSurface for S
where S: Surface + DynResource,

Source§

unsafe fn configure( &self, device: &(dyn DynDevice + 'static), config: &SurfaceConfiguration, ) -> Result<(), SurfaceError>

Source§

unsafe fn unconfigure(&self, device: &(dyn DynDevice + 'static))

Source§

unsafe fn acquire_texture( &self, timeout: Option<Duration>, fence: &(dyn DynFence + 'static), ) -> Result<DynAcquiredSurfaceTexture, SurfaceError>

Source§

unsafe fn discard_texture(&self, texture: Box<dyn DynSurfaceTexture>)

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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>

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

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

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

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