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: GpuTextureHandleImplementations§
Source§impl GpuTextureAtlas
impl GpuTextureAtlas
Sourcepub fn new(
device: &GpuDevice,
width: u32,
height: u32,
format: SwapchainFormat,
) -> Self
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).
Sourcepub fn allocate(
&mut self,
req_w: u32,
req_h: u32,
current_frame: u64,
) -> Option<AtlasRegion>
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.
Sourcepub fn touch(&mut self, region_id: u64, current_frame: u64)
pub fn touch(&mut self, region_id: u64, current_frame: u64)
Touches a region to update its LRU timestamp.
Sourcepub fn upload_sub_image(&mut self, region: &AtlasRegion, pixels: &[u8])
pub fn upload_sub_image(&mut self, region: &AtlasRegion, pixels: &[u8])
Uploads CPU pixels into an allocated atlas sub-region.
Sourcepub fn allocated_region_count(&self) -> usize
pub fn allocated_region_count(&self) -> usize
Returns the number of currently active allocated regions.
Sourcepub fn deallocate(&mut self, region_id: u64) -> bool
pub fn deallocate(&mut self, region_id: u64) -> bool
Deallocates an existing region by ID.
Auto Trait Implementations§
impl Forget for GpuTextureAtlas
impl Freeze for GpuTextureAtlas
impl Move for GpuTextureAtlas
impl RefUnwindSafe for GpuTextureAtlas
impl Send for GpuTextureAtlas
impl Sync for GpuTextureAtlas
impl Unpin for GpuTextureAtlas
impl UnsafeUnpin for GpuTextureAtlas
impl UnwindSafe for GpuTextureAtlas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more