pub struct DepthReadbackSurface { /* private fields */ }Expand description
Reusable GPU-to-CPU Depth32Float readback surface owning a staging buffer and persistent [0.0, 1.0] cache.
Implementations§
Source§impl DepthReadbackSurface
impl DepthReadbackSurface
pub fn new(options: DepthReadbackOptions) -> Self
pub fn options(&self) -> DepthReadbackOptions
pub fn set_options(&mut self, options: DepthReadbackOptions)
pub fn width(&self) -> u32
pub fn height(&self) -> u32
pub fn cached_depths(&self) -> &[f32]
pub fn cached_bytes(&self) -> &[u8] ⓘ
Sourcepub fn ensure_dimensions(
&mut self,
device: &Device,
width: u32,
height: u32,
) -> bool
pub fn ensure_dimensions( &mut self, device: &Device, width: u32, height: u32, ) -> bool
Ensures the depth staging buffer and CPU cache match (width, height), clamping to at least 1x1.
Returns true if the staging buffer was allocated or reallocated.
Sourcepub fn copy_from_texture(
&self,
encoder: &mut CommandEncoder,
depth_texture: &Texture,
) -> Result<(), ReadbackError>
pub fn copy_from_texture( &self, encoder: &mut CommandEncoder, depth_texture: &Texture, ) -> Result<(), ReadbackError>
Encodes a DepthOnly texture-to-staging-buffer copy into encoder.
Sourcepub fn map_and_repack(
&mut self,
device: &Device,
) -> Result<&[f32], ReadbackError>
pub fn map_and_repack( &mut self, device: &Device, ) -> Result<&[f32], ReadbackError>
Synchronously maps the staging buffer, unpacks depth rows into Self::cached_depths, and unmaps.
Sourcepub fn readback_sync(
&mut self,
device: &Device,
queue: &Queue,
depth_texture: &Texture,
) -> Result<&[f32], ReadbackError>
pub fn readback_sync( &mut self, device: &Device, queue: &Queue, depth_texture: &Texture, ) -> Result<&[f32], ReadbackError>
Ensures dimensions match depth_texture, submits a copy command, and reads back depths synchronously.
Auto Trait Implementations§
impl !RefUnwindSafe for DepthReadbackSurface
impl !UnwindSafe for DepthReadbackSurface
impl Forget for DepthReadbackSurface
impl Freeze for DepthReadbackSurfacewhere
*const ArcInner<CoreBuffer> is !null: Freeze,
PhantomData<ArcInner<CoreBuffer>>: Freeze,
*const ArcInner<Mutex<MapContext>> is !null: Freeze,
PhantomData<ArcInner<Mutex<MapContext>>>: Freeze,
InternalBitFlags: Freeze,
*const u8 is !null: Freeze,
PhantomData<f32>: Freeze,
impl Move for DepthReadbackSurface
impl Send for DepthReadbackSurface
impl Sync for DepthReadbackSurface
impl Unpin for DepthReadbackSurface
impl UnsafeUnpin for DepthReadbackSurfacewhere
*const ArcInner<CoreBuffer> is !null: UnsafeUnpin,
PhantomData<ArcInner<CoreBuffer>>: UnsafeUnpin,
*const ArcInner<Mutex<MapContext>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<MapContext>>>: UnsafeUnpin,
InternalBitFlags: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<f32>: UnsafeUnpin,
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