Struct wgpu_types::SurfaceConfiguration
source · #[repr(C)]pub struct SurfaceConfiguration<V> {
pub usage: TextureUsages,
pub format: TextureFormat,
pub width: u32,
pub height: u32,
pub present_mode: PresentMode,
pub desired_maximum_frame_latency: u32,
pub alpha_mode: CompositeAlphaMode,
pub view_formats: V,
}Expand description
Configures a Surface for presentation.
Fields§
§usage: TextureUsagesThe usage of the swap chain. The only supported usage is RENDER_ATTACHMENT.
format: TextureFormatThe texture format of the swap chain. The only formats that are guaranteed are
Bgra8Unorm and Bgra8UnormSrgb
width: u32Width of the swap chain. Must be the same size as the surface, and nonzero.
height: u32Height of the swap chain. Must be the same size as the surface, and nonzero.
present_mode: PresentModePresentation mode of the swap chain. Fifo is the only mode guaranteed to be supported. FifoRelaxed, Immediate, and Mailbox will crash if unsupported, while AutoVsync and AutoNoVsync will gracefully do a designed sets of fallbacks if their primary modes are unsupported.
desired_maximum_frame_latency: u32Desired maximum number of frames that the presentation engine should queue in advance.
This is a hint to the backend implementation and will always be clamped to the supported range. As a consequence, either the maximum frame latency is set directly on the swap chain, or waits on present are scheduled to avoid exceeding the maximum frame latency if supported, or the swap chain size is set to (max-latency + 1).
Defaults to 2 when created via wgpu::Surface::get_default_config.
Typical values range from 3 to 1, but higher values are possible:
- Choose 2 or higher for potentially smoother frame display, as it allows to be at least one frame to be queued up. This typically avoids starving the GPU’s work queue. Higher values are useful for achieving a constant flow of frames to the display under varying load.
- Choose 1 for low latency from frame recording to frame display.
⚠️ If the backend does not support waiting on present, this will cause the CPU to wait for the GPU
to finish all work related to the previous frame when calling
wgpu::Surface::get_current_texture, causing CPU-GPU serialization (i.e. whenwgpu::Surface::get_current_texturereturns, the GPU might be idle). It is currently not possible to query this. See https://github.com/gfx-rs/wgpu/issues/2869. - A value of 0 is generally not supported and always clamped to a higher value.
alpha_mode: CompositeAlphaModeSpecifies how the alpha channel of the textures should be handled during compositing.
view_formats: VSpecifies what view formats will be allowed when calling create_view() on texture returned by get_current_texture().
View formats of the same format as the texture are always allowed.
Note: currently, only the srgb-ness is allowed to change. (ex: Rgba8Unorm texture + Rgba8UnormSrgb view)
Implementations§
source§impl<V: Clone> SurfaceConfiguration<V>
impl<V: Clone> SurfaceConfiguration<V>
sourcepub fn map_view_formats<M>(
&self,
fun: impl FnOnce(V) -> M
) -> SurfaceConfiguration<M>
pub fn map_view_formats<M>( &self, fun: impl FnOnce(V) -> M ) -> SurfaceConfiguration<M>
Map view_formats of the texture descriptor into another.
Trait Implementations§
source§impl<V: Clone> Clone for SurfaceConfiguration<V>
impl<V: Clone> Clone for SurfaceConfiguration<V>
source§fn clone(&self) -> SurfaceConfiguration<V>
fn clone(&self) -> SurfaceConfiguration<V>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<V: Debug> Debug for SurfaceConfiguration<V>
impl<V: Debug> Debug for SurfaceConfiguration<V>
source§impl<V: Hash> Hash for SurfaceConfiguration<V>
impl<V: Hash> Hash for SurfaceConfiguration<V>
source§impl<V: PartialEq> PartialEq for SurfaceConfiguration<V>
impl<V: PartialEq> PartialEq for SurfaceConfiguration<V>
source§fn eq(&self, other: &SurfaceConfiguration<V>) -> bool
fn eq(&self, other: &SurfaceConfiguration<V>) -> bool
self and other values to be equal, and is used
by ==.