Skip to main content

GpuTextureAtlas

Struct GpuTextureAtlas 

Source
pub struct GpuTextureAtlas {
    pub width: u32,
    pub height: u32,
    pub format: SwapchainFormat,
    pub texture: GpuTextureHandle,
    /* private fields */
}
Expand description

High-performance GPU texture atlas with dynamic shelf bin-packing and LRU cache eviction.

Fields§

§width: u32§height: u32§format: SwapchainFormat§texture: GpuTextureHandle

Implementations§

Source§

impl GpuTextureAtlas

Source

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

Creates a new GPU texture atlas on the device with the specified dimensions (e.g. 2048x2048 or 4096x4096).

Source

pub fn allocate( &mut self, req_w: u32, req_h: u32, current_frame: u64, ) -> Option<AtlasRegion>

Allocates a sub-rectangle in the texture atlas for the given dimensions, evicting least-recently-used regions if necessary.

Source

pub fn touch(&mut self, region_id: u64, current_frame: u64)

Touches a region to update its LRU timestamp.

Source

pub fn upload_sub_image(&mut self, region: &AtlasRegion, pixels: &[u8])

Uploads CPU pixels into an allocated atlas sub-region.

Source

pub fn allocated_region_count(&self) -> usize

Returns the number of currently active allocated regions.

Source

pub fn deallocate(&mut self, region_id: u64) -> bool

Deallocates an existing region by ID.

Source

pub fn evict_lru(&mut self, current_frame: u64)

Explicitly triggers LRU cache eviction of aged regions.

Source

pub fn stats(&self) -> (usize, u64, u64)

Returns allocation statistics: (allocated_count, total_allocations, total_evictions).

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, 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> IntoInitialState<T> for T

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> 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,