Struct nannou_wgpu::Surface

source ·
pub struct Surface { /* private fields */ }
Expand description

Handle to a presentable surface.

A Surface represents a platform-specific surface (e.g. a window) onto which rendered images may be presented. A Surface may be created with the unsafe function Instance::create_surface.

This type is unique to the Rust API of wgpu. In the WebGPU specification, GPUCanvasContext serves a similar role.

Implementations§

source§

impl Surface

source

pub fn get_capabilities(&self, adapter: &Adapter) -> SurfaceCapabilities

Returns the capabilities of the surface when used with the given adapter.

Returns specified values (see [SurfaceCapabilities]) if surface is incompatible with the adapter.

source

pub fn get_default_config( &self, adapter: &Adapter, width: u32, height: u32 ) -> Option<SurfaceConfiguration<Vec<TextureFormat>>>

Return a default SurfaceConfiguration from width and height to use for the Surface with this adapter.

Returns None if the surface isn’t supported by this adapter

source

pub fn configure( &self, device: &Device, config: &SurfaceConfiguration<Vec<TextureFormat>> )

Initializes Surface for presentation.

Panics
  • A old SurfaceTexture is still alive referencing an old surface.
  • Texture format requested is unsupported on the surface.
source

pub fn get_current_texture(&self) -> Result<SurfaceTexture, SurfaceError>

Returns the next texture to be presented by the swapchain for drawing.

In order to present the SurfaceTexture returned by this method, first a Queue::submit needs to be done with some work rendering to this texture. Then SurfaceTexture::present needs to be called.

If a SurfaceTexture referencing this surface is alive when the swapchain is recreated, recreating the swapchain will panic.

source

pub unsafe fn as_hal_mut<A, F, R>(&mut self, hal_surface_callback: F) -> R
where A: HalApi, F: FnOnce(Option<&mut <A as Api>::Surface>) -> R,

Returns the inner hal Surface using a callback. The hal surface will be None if the backend type argument does not match with this wgpu Surface

Safety
  • The raw handle obtained from the hal Surface must not be manually destroyed

Trait Implementations§

source§

impl Debug for Surface

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Drop for Surface

source§

fn drop(&mut self)

Executes the destructor for this type. 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<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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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>,

§

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<T> WasmNotSend for T
where T: Send,

§

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