Skip to main content

GpuReadback

Struct GpuReadback 

Source
pub struct GpuReadback;
Expand description

GPU → CPU readback helper.

The current implementation operates as a CPU stub (identity copy). Replace the body of GpuReadback::download and GpuReadback::download_region with actual WGPU buffer-mapping logic when a live device is available.

Implementations§

Source§

impl GpuReadback

Source

pub fn download(width: u32, height: u32, gpu_data: &[u8]) -> Vec<u8>

Download a full frame from GPU-accessible memory to a CPU Vec<u8>.

On the CPU stub backend this is an identity copy of gpu_data.

§Arguments
  • width – Frame width in pixels.
  • height – Frame height in pixels.
  • gpu_data – GPU-accessible source buffer (RGBA packed, row-major).
§Returns

A Vec<u8> containing a copy of the readback data.

Source

pub fn download_region( src_width: u32, x: u32, y: u32, w: u32, h: u32, gpu_data: &[u8], ) -> Vec<u8>

Download a sub-region of a frame.

  • src_width – Width of the full source frame in pixels.
  • x, y – Top-left corner of the sub-region.
  • w, h – Width/height of the sub-region in pixels.
  • gpu_data – Full source frame data (RGBA, row-major).

Returns an empty Vec if the region is fully out of bounds.

Source

pub fn expected_len(width: u32, height: u32) -> usize

Compute the expected byte length for a frame of width × height pixels in RGBA format.

Source

pub fn validate_size(width: u32, height: u32, gpu_data: &[u8]) -> bool

Verify that gpu_data has exactly the expected length for a width × height RGBA frame.

Source

pub fn split_channels(gpu_data: &[u8]) -> (Vec<u8>, Vec<u8>, Vec<u8>, Vec<u8>)

Split RGBA packed data into separate R, G, B, A channel planes.

Returns (r, g, b, a) each of length width * height.

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<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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