Skip to main content

HeadlessTarget

Struct HeadlessTarget 

Source
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

Source

pub fn new( device: &Device, width: u32, height: u32, format: TextureFormat, ) -> Self

Creates a width x height render target in format.

Source

pub fn width(&self) -> u32

Target width in texels.

Source

pub fn height(&self) -> u32

Target height in texels.

Source

pub fn format(&self) -> TextureFormat

The target’s pixel format.

Source

pub fn view(&self) -> &TextureView

The full-extent view a render pass attaches to.

Source

pub fn texture(&self) -> &Texture

The underlying texture, e.g. as a copy_texture_to_buffer source.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,