[−][src]Crate wgpu_mipmap
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
ComputeMipmapGenerator | Generates mipmaps for textures with storage usage. |
CopyMipmapGenerator | Generates mipmaps for textures with sampled usage. |
RecommendedMipmapGenerator | Generates mipmaps for textures with any usage using the compute, render, or copy backends. |
RenderMipmapGenerator | Generates mipmaps for textures with output attachment usage. |
Enums
Error | An error that occurred during mipmap generation. |
Traits
MipmapGenerator | MipmapGenerator describes types that can generate mipmaps for a texture. |