Struct 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.


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

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

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

Initializes Surface for presentation.

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

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.

Available on non-WebAssembly or crate feature emscripten only.

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

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

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.