pub struct TextureSpec {
pub width: u32,
pub height: u32,
pub format: TextureFormat,
pub data: Vec<u8>,
pub generate_mips: bool,
}Fields§
§width: u32§height: u32§format: TextureFormat§data: Vec<u8>Base (mip 0) pixel data, tightly packed, 4 bytes per texel (matching
format). Required even when format isn’t literally Rgba8* —
mip generation always treats it as 4 bytes/texel.
generate_mips: boolImplementations§
Source§impl TextureSpec
impl TextureSpec
Sourcepub fn mip_level_count(&self) -> u32
pub fn mip_level_count(&self) -> u32
Number of mip levels this texture will have: the full chain down to
1x1 if generate_mips, otherwise just the base level.
Sourcepub fn wgpu_descriptor(&self) -> TextureDescriptor<'static>
pub fn wgpu_descriptor(&self) -> TextureDescriptor<'static>
Pure conversion — you call device.create_texture(&spec.wgpu_descriptor())
yourself, then write each mip level (see downsample
for generating each one from the last).
Sourcepub fn downsample(data: &[u8], width: u32, height: u32) -> (Vec<u8>, u32, u32)
pub fn downsample(data: &[u8], width: u32, height: u32) -> (Vec<u8>, u32, u32)
Box-filter downsample to half size (minimum 1x1), 4 bytes/texel.
Pure data transform — no wgpu involved. Call this once per mip level
between your own queue.write_texture calls to build the chain
yourself; see mip_level_count for how many
levels to write in total.
Source§impl TextureSpec
impl TextureSpec
pub fn new(width: u32, height: u32, data: Vec<u8>, generate_mips: bool) -> Self
pub fn with_format(self, format: TextureFormat) -> Self
Auto Trait Implementations§
impl Freeze for TextureSpec
impl RefUnwindSafe for TextureSpec
impl Send for TextureSpec
impl Sync for TextureSpec
impl Unpin for TextureSpec
impl UnsafeUnpin for TextureSpec
impl UnwindSafe for TextureSpec
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