Skip to main content

ImageStore

Struct ImageStore 

Source
pub struct ImageStore { /* private fields */ }
Expand description

ImageStore owns uploaded images, mip generation, samplers, and bind groups.

Bind groups are created once per (image, sampling) pair and reused. Dead images are swept via Weak so the store does not pin host-dropped images.

Implementations§

Source§

impl ImageStore

Source

pub fn new(device: &Device, queue: &Queue) -> Self

new creates an empty image store for device and queue.

Source

pub fn filtered_image( &mut self, image: &Image, filter: ColorFilter, ) -> (Image, bool)

filtered_image returns the immutable texture that represents image after filter.

The second return value is true when this call created the texture. The caller records the producing pass only in that case.

Source

pub fn end_frame(&mut self)

end_frame drops filtered snapshots unused this frame.

One idle frame releases a filtered snapshot even when the host keeps its source image alive, bounding retention to the visible working set.

Source

pub fn upload(&mut self, desc: ImageDesc, pixels: &[u8]) -> Image

upload creates a retained Image from RGBA8 pixels.

Premultiplies when desc.premultiplied is false, writes mip level 0, and builds the mip chain when desc.mips is true. Panics if pixels.len() is not width * height * 4.

Source

pub fn finish_external( &mut self, texture: Texture, size: [u32; 2], mip_levels: u32, ) -> Image

finish_external wraps an already-populated texture as a retained Image.

Use this when the host copied pixels itself (for example an ImageBitmap upload). Builds the mip chain when mip_levels is greater than 1.

Source

pub fn regenerate_mips(&mut self, image: &Image)

regenerate_mips rebuilds the mip chain after level 0 was rewritten in place.

Call this after each copy from a per-frame source such as a video frame.

Source

pub fn create_image_texture(&self, size: [u32; 2], mip_levels: u32) -> Texture

create_image_texture allocates an empty image texture of size and mip_levels.

The texture is bindable, copy-destination, and a render attachment so mip levels can be generated by rendering into them.

Source

pub fn bind_group( &mut self, texture_layout: &BindGroupLayout, image: &Image, sampling: Sampling, ) -> BindGroup

bind_group returns the cached (texture, sampler) bind group for a draw.

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> 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, 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 = 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> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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