Expand description
Generate mipmaps for wgpu textures.
§Usage
Add this to your Cargo.toml
:
[dependencies]
wgpu-mipmap = "0.1"
Example usage:
use wgpu_mipmap::*;
fn example(device: &wgpu::Device, queue: &wgpu::Queue) -> Result<(), Error> {
// create a recommended generator
let generator = RecommendedMipmapGenerator::new(&device);
// create and upload data to a texture
let texture_descriptor = wgpu::TextureDescriptor {
size: wgpu::Extent3d {
width: 512,
height: 512,
depth: 1,
},
mip_level_count: 10, // 1 + log2(512)
sample_count: 1,
format: wgpu::TextureFormat::Rgba8Unorm,
dimension: wgpu::TextureDimension::D2,
usage: wgpu::TextureUsage::STORAGE,
label: None,
};
let texture = device.create_texture(&texture_descriptor);
// upload_data_to_texture(&texture);
// create an encoder and generate mipmaps for the texture
let mut encoder = device.create_command_encoder(&Default::default());
generator.generate(&device, &mut encoder, &texture, &texture_descriptor)?;
queue.submit(std::iter::once(encoder.finish()));
Ok(())
}
Structs§
- Compute
Mipmap Generator - Generates mipmaps for textures with storage usage.
- Copy
Mipmap Generator - Generates mipmaps for textures with sampled usage.
- Recommended
Mipmap Generator - Generates mipmaps for textures with any usage using the compute, render, or copy backends.
- Render
Mipmap Generator - Generates mipmaps for textures with output attachment usage.
Enums§
- Error
- An error that occurred during mipmap generation.
Traits§
- Mipmap
Generator - MipmapGenerator describes types that can generate mipmaps for a texture.