macro_rules! texture {
{ $struct:ident {
usage: $( $usage:ident )|+ ,
dimension: $dimension:ident,
sample_type: $sample:ident,
} } => { ... };
}Expand description
Define a type of texture - not its size or format, but a set of properties.
More specifically, its
wgpu::TextureUsages,
wgpu::TextureViewDimension,
& the binding’s
wgpu::TextureSampleType
as simplified under sample_type.
The texture’s size & format are defined on creation of the texture dynamically.
This struct also comes with a view of all layers, so you can bind to it directly.
texture! { Texture {
usage: COPY_DST | TEXTURE_BINDING,
dimension: D2,
sample_type: FLOAT,
} }
let texture: Texture = context.new_texture((64, 64, 1), wgpu::TextureFormat::Rgba8Unorm);The texture is made with 1 mip level and sample count, this will probably eventually be customizable but I haven’t made anything complex enough yet to figure out how that works.