Files
phy/wgpu/type.SurfaceConfiguration.html
Orion Kindel 0ce894e6b0 doc
2025-03-18 10:30:23 -05:00

52 lines
12 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Describes a `Surface`."><title>SurfaceConfiguration in wgpu - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="wgpu" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../wgpu/index.html"><img src="https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../wgpu/index.html"><img src="https://raw.githubusercontent.com/gfx-rs/wgpu/trunk/logo.png" alt="logo"></a><h2><a href="../wgpu/index.html">wgpu</a><span class="version">23.0.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Surface<wbr>Configuration</a></h2><h3><a href="#aliased-type">Aliased type</a></h3><h3><a href="#fields">Fields</a></h3><ul class="block field"><li><a href="#structfield.alpha_mode" title="alpha_mode">alpha_mode</a></li><li><a href="#structfield.desired_maximum_frame_latency" title="desired_maximum_frame_latency">desired_maximum_frame_latency</a></li><li><a href="#structfield.format" title="format">format</a></li><li><a href="#structfield.height" title="height">height</a></li><li><a href="#structfield.present_mode" title="present_mode">present_mode</a></li><li><a href="#structfield.usage" title="usage">usage</a></li><li><a href="#structfield.view_formats" title="view_formats">view_formats</a></li><li><a href="#structfield.width" title="width">width</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate wgpu</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">wgpu</a></span><h1>Type Alias <span class="type">SurfaceConfiguration</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/wgpu/api/surface.rs.html#15">Source</a> </span></div><pre class="rust item-decl"><code>pub type SurfaceConfiguration = <a class="struct" href="../wgpu_types/struct.SurfaceConfiguration.html" title="struct wgpu_types::SurfaceConfiguration">SurfaceConfiguration</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="enum.TextureFormat.html" title="enum wgpu::TextureFormat">TextureFormat</a>&gt;&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Describes a <a href="struct.Surface.html" title="struct wgpu::Surface"><code>Surface</code></a>.</p>
<p>For use with <a href="struct.Surface.html#method.configure" title="method wgpu::Surface::configure"><code>Surface::configure</code></a>.</p>
<p>Corresponds to <a href="https://gpuweb.github.io/gpuweb/#canvas-configuration">WebGPU <code>GPUCanvasConfiguration</code></a>.</p>
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>struct SurfaceConfiguration {
pub usage: <a class="struct" href="struct.TextureUsages.html" title="struct wgpu::TextureUsages">TextureUsages</a>,
pub format: <a class="enum" href="enum.TextureFormat.html" title="enum wgpu::TextureFormat">TextureFormat</a>,
pub width: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>,
pub height: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>,
pub present_mode: <a class="enum" href="enum.PresentMode.html" title="enum wgpu::PresentMode">PresentMode</a>,
pub desired_maximum_frame_latency: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>,
pub alpha_mode: <a class="enum" href="enum.CompositeAlphaMode.html" title="enum wgpu::CompositeAlphaMode">CompositeAlphaMode</a>,
pub view_formats: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="enum.TextureFormat.html" title="enum wgpu::TextureFormat">TextureFormat</a>&gt;,
}</code></pre><h2 id="fields" class="fields section-header">Fields<a href="#fields" class="anchor">§</a></h2><span id="structfield.usage" class="structfield section-header"><a href="#structfield.usage" class="anchor field">§</a><code>usage: <a class="struct" href="struct.TextureUsages.html" title="struct wgpu::TextureUsages">TextureUsages</a></code></span><div class="docblock"><p>The usage of the swap chain. The only supported usage is <code>RENDER_ATTACHMENT</code>.</p>
</div><span id="structfield.format" class="structfield section-header"><a href="#structfield.format" class="anchor field">§</a><code>format: <a class="enum" href="enum.TextureFormat.html" title="enum wgpu::TextureFormat">TextureFormat</a></code></span><div class="docblock"><p>The texture format of the swap chain. The only formats that are guaranteed are
<code>Bgra8Unorm</code> and <code>Bgra8UnormSrgb</code></p>
</div><span id="structfield.width" class="structfield section-header"><a href="#structfield.width" class="anchor field">§</a><code>width: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a></code></span><div class="docblock"><p>Width of the swap chain. Must be the same size as the surface, and nonzero.</p>
<p>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).</p>
</div><span id="structfield.height" class="structfield section-header"><a href="#structfield.height" class="anchor field">§</a><code>height: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a></code></span><div class="docblock"><p>Height of the swap chain. Must be the same size as the surface, and nonzero.</p>
<p>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).</p>
</div><span id="structfield.present_mode" class="structfield section-header"><a href="#structfield.present_mode" class="anchor field">§</a><code>present_mode: <a class="enum" href="enum.PresentMode.html" title="enum wgpu::PresentMode">PresentMode</a></code></span><div class="docblock"><p>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.</p>
</div><span id="structfield.desired_maximum_frame_latency" class="structfield section-header"><a href="#structfield.desired_maximum_frame_latency" class="anchor field">§</a><code>desired_maximum_frame_latency: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a></code></span><div class="docblock"><p>Desired maximum number of frames that the presentation engine should queue in advance.</p>
<p>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).</p>
<p>Defaults to 2 when created via <code>wgpu::Surface::get_default_config</code>.</p>
<p>Typical values range from 3 to 1, but higher values are possible:</p>
<ul>
<li>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 GPUs work queue.
Higher values are useful for achieving a constant flow of frames to the display under varying load.</li>
<li>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 <code>wgpu::Surface::get_current_texture</code>,
causing CPU-GPU serialization (i.e. when <code>wgpu::Surface::get_current_texture</code> returns, the GPU might be idle).
It is currently not possible to query this. See <a href="https://github.com/gfx-rs/wgpu/issues/2869">https://github.com/gfx-rs/wgpu/issues/2869</a>.</li>
<li>A value of 0 is generally not supported and always clamped to a higher value.</li>
</ul>
</div><span id="structfield.alpha_mode" class="structfield section-header"><a href="#structfield.alpha_mode" class="anchor field">§</a><code>alpha_mode: <a class="enum" href="enum.CompositeAlphaMode.html" title="enum wgpu::CompositeAlphaMode">CompositeAlphaMode</a></code></span><div class="docblock"><p>Specifies how the alpha channel of the textures should be handled during compositing.</p>
</div><span id="structfield.view_formats" class="structfield section-header"><a href="#structfield.view_formats" class="anchor field">§</a><code>view_formats: <a class="struct" href="https://doc.rust-lang.org/1.84.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="enum.TextureFormat.html" title="enum wgpu::TextureFormat">TextureFormat</a>&gt;</code></span><div class="docblock"><p>Specifies what view formats will be allowed when calling create_view() on texture returned by get_current_texture().</p>
<p>View formats of the same format as the texture are always allowed.</p>
<p>Note: currently, only the srgb-ness is allowed to change. (ex: Rgba8Unorm texture + Rgba8UnormSrgb view)</p>
</div><script src="../type.impl/wgpu_types/struct.SurfaceConfiguration.js" data-self-path="wgpu::api::surface::SurfaceConfiguration" async></script></section></div></main></body></html>