pub struct HeadlessTarget { /* private fields */ }Expand description
An offscreen render target: one wgpu::Texture plus its full-extent view,
created with RENDER_ATTACHMENT | COPY_SRC usage and no STORAGE_BINDING.
Implementations§
Source§impl HeadlessTarget
impl HeadlessTarget
Sourcepub fn new(
device: &Device,
width: u32,
height: u32,
format: TextureFormat,
) -> Self
pub fn new( device: &Device, width: u32, height: u32, format: TextureFormat, ) -> Self
Creates a width x height render target in format.
Sourcepub fn format(&self) -> TextureFormat
pub fn format(&self) -> TextureFormat
The target’s pixel format.
Sourcepub fn view(&self) -> &TextureView
pub fn view(&self) -> &TextureView
The full-extent view a render pass attaches to.
Sourcepub fn texture(&self) -> &Texture
pub fn texture(&self) -> &Texture
The underlying texture, e.g. as a copy_texture_to_buffer source.
Sourcepub fn read_back(&self, device: &Device, queue: &Queue) -> Vec<u8> ⓘ
pub fn read_back(&self, device: &Device, queue: &Queue) -> Vec<u8> ⓘ
Copies the target into a mappable buffer and returns its rows with
wgpu’s row padding removed — tightly packed, width * height * bytes-per-texel bytes, top-to-bottom, left-to-right.
§Panics
Panics if Self::format has no defined block size (a compressed or
planar format an offscreen render target never uses), if the device
poll fails, or if the buffer map fails — none of which is a condition
a headless test or tool should try to recover from.