Struct webrender::renderer::upload::UploadTexturePool
source · pub struct UploadTexturePool {
textures: [VecDeque<(Texture, u64)>; 4],
delay_texture_deallocation: [u64; 4],
current_frame: u64,
temporary_buffers: Vec<Vec<MaybeUninit<u8>>>,
min_temporary_buffers: usize,
delay_buffer_deallocation: u64,
}
Expand description
A very basic pool to avoid reallocating staging textures as well as staging CPU side buffers.
Fields§
§textures: [VecDeque<(Texture, u64)>; 4]
The textures in the pool associated with a last used frame index.
The outer array corresponds to each of teh three supported texture formats.
delay_texture_deallocation: [u64; 4]
§current_frame: u64
§temporary_buffers: Vec<Vec<MaybeUninit<u8>>>
Temporary buffers that are used when using staging uploads + glTexImage2D.
Temporary buffers aren’t used asynchronously so they can be reused every frame. To keep things simple we always allocate enough memory for formats with four bytes per pixel (more than we need for alpha-only textures but it works just as well).
min_temporary_buffers: usize
§delay_buffer_deallocation: u64
Implementations§
source§impl UploadTexturePool
impl UploadTexturePool
pub fn new() -> Self
fn format_index(&self, format: ImageFormat) -> usize
pub fn begin_frame(&mut self)
sourcepub fn get_texture(
&mut self,
device: &mut Device,
format: ImageFormat,
) -> Texture
pub fn get_texture( &mut self, device: &mut Device, format: ImageFormat, ) -> Texture
Create or reuse a staging texture.
See also return_texture.
sourcepub fn return_texture(&mut self, texture: Texture)
pub fn return_texture(&mut self, texture: Texture)
Hand the staging texture back to the pool after being done with uploads.
The texture must have been obtained from this pool via get_texture.
sourcepub fn get_temporary_buffer(&mut self) -> Vec<MaybeUninit<u8>>
pub fn get_temporary_buffer(&mut self) -> Vec<MaybeUninit<u8>>
Create or reuse a temporary CPU buffer.
These buffers are used in the batched upload path when PBOs are not supported. Content is first written to the temporary buffer and uploaded via a single glTexSubImage2D call.
sourcepub fn return_temporary_buffer(&mut self, buffer: Vec<MaybeUninit<u8>>)
pub fn return_temporary_buffer(&mut self, buffer: Vec<MaybeUninit<u8>>)
Return memory that was obtained from this pool via get_temporary_buffer.
sourcepub fn delete_textures(&mut self, device: &mut Device)
pub fn delete_textures(&mut self, device: &mut Device)
Deallocate this pool’s CPU and GPU memory.
sourcepub fn end_frame(&mut self, device: &mut Device)
pub fn end_frame(&mut self, device: &mut Device)
Deallocate some textures if there are too many for a long time.
pub fn report_memory_to( &self, report: &mut MemoryReport, size_op_funs: &MallocSizeOfOps, )
Auto Trait Implementations§
impl Freeze for UploadTexturePool
impl !RefUnwindSafe for UploadTexturePool
impl Send for UploadTexturePool
impl !Sync for UploadTexturePool
impl Unpin for UploadTexturePool
impl UnwindSafe for UploadTexturePool
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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