Struct SurfaceConfiguration
#[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,
}
unstable-wgpu-26
only.Expand description
Configures a Surface
for presentation.
Fields§
§usage: TextureUsages
The usage of the swap chain. The only usage guaranteed to be supported is TextureUsages::RENDER_ATTACHMENT
.
format: TextureFormat
The texture format of the swap chain. The only formats that are guaranteed are
TextureFormat::Bgra8Unorm
and TextureFormat::Bgra8UnormSrgb
.
width: u32
Width of the swap chain. Must be the same size as the surface, and nonzero.
If this is not the same size as the underlying surface (e.g. if it is set once, and the window is later resized), the behaviour is defined but platform-specific, and may change in the future (currently macOS scales the surface, other platforms may do something else).
height: u32
Height of the swap chain. Must be the same size as the surface, and nonzero.
If this is not the same size as the underlying surface (e.g. if it is set once, and the window is later resized), the behaviour is defined but platform-specific, and may change in the future (currently macOS scales the surface, other platforms may do something else).
present_mode: PresentMode
Presentation 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: u32
Desired 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 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
Surface::get_current_texture
, causing CPU-GPU serialization (i.e. whenSurface::get_current_texture
returns, 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: CompositeAlphaMode
Specifies how the alpha channel of the textures should be handled during compositing.
view_formats: V
Specifies what view formats will be allowed when calling Texture::create_view
on the texture returned by Surface::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§
§impl<V> SurfaceConfiguration<V>where
V: Clone,
impl<V> SurfaceConfiguration<V>where
V: Clone,
pub 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§
§impl<V> Clone for SurfaceConfiguration<V>where
V: Clone,
impl<V> Clone for SurfaceConfiguration<V>where
V: Clone,
§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 more§impl<V> Debug for SurfaceConfiguration<V>where
V: Debug,
impl<V> Debug for SurfaceConfiguration<V>where
V: Debug,
§impl<V> Hash for SurfaceConfiguration<V>where
V: Hash,
impl<V> Hash for SurfaceConfiguration<V>where
V: Hash,
§impl<V> PartialEq for SurfaceConfiguration<V>where
V: PartialEq,
impl<V> PartialEq for SurfaceConfiguration<V>where
V: PartialEq,
impl<V> Eq for SurfaceConfiguration<V>where
V: Eq,
impl<V> StructuralPartialEq for SurfaceConfiguration<V>
Auto Trait Implementations§
impl<V> Freeze for SurfaceConfiguration<V>where
V: Freeze,
impl<V> RefUnwindSafe for SurfaceConfiguration<V>where
V: RefUnwindSafe,
impl<V> Send for SurfaceConfiguration<V>where
V: Send,
impl<V> Sync for SurfaceConfiguration<V>where
V: Sync,
impl<V> Unpin for SurfaceConfiguration<V>where
V: Unpin,
impl<V> UnwindSafe for SurfaceConfiguration<V>where
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.