pub struct Backbuffer { /* private fields */ }Expand description
Manages a chain of backbuffers for rendering
This is essential for:
- Glass effects that need to sample the backdrop
- WASM targets where we can’t read from the swapchain
- Post-processing pipelines
Implementations§
Source§impl Backbuffer
impl Backbuffer
Sourcepub fn new(
device: &Device,
width: u32,
height: u32,
config: BackbufferConfig,
) -> Self
pub fn new( device: &Device, width: u32, height: u32, config: BackbufferConfig, ) -> Self
Create a new backbuffer chain
Sourcepub fn write_target(&self) -> &TextureView
pub fn write_target(&self) -> &TextureView
Get the current write target (where we render to)
Sourcepub fn read_target(&self) -> &TextureView
pub fn read_target(&self) -> &TextureView
Get the current read target (previous frame, for glass effects)
Sourcepub fn depth_target(&self) -> Option<&TextureView>
pub fn depth_target(&self) -> Option<&TextureView>
Get the depth buffer view (if enabled)
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
Get the texture format
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Get the current dimensions
Sourcepub fn swap(&mut self)
pub fn swap(&mut self)
Swap buffers - call after rendering a frame
This advances the write/read indices for the next frame
Sourcepub fn copy_to_surface(
&self,
encoder: &mut CommandEncoder,
surface_texture: &Texture,
)
pub fn copy_to_surface( &self, encoder: &mut CommandEncoder, surface_texture: &Texture, )
Copy the current write buffer to the swapchain
This is used to present the final rendered frame to the screen. Essential for WASM where we render to a backbuffer first.
Sourcepub fn write_texture(&self) -> &Texture
pub fn write_texture(&self) -> &Texture
Get the write buffer texture (for advanced use cases)
Sourcepub fn read_texture(&self) -> &Texture
pub fn read_texture(&self) -> &Texture
Get the read buffer texture (for advanced use cases)
Auto Trait Implementations§
impl Freeze for Backbuffer
impl !RefUnwindSafe for Backbuffer
impl Send for Backbuffer
impl Sync for Backbuffer
impl Unpin for Backbuffer
impl UnsafeUnpin for Backbuffer
impl !UnwindSafe for Backbuffer
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
Mutably borrows from an owned value. Read more