pub struct TextureDescriptor {
pub extent: Extent2D,
pub format: PixelFormat,
pub usage: TextureUsage,
pub sample_count: u32,
pub mip_levels: u32,
pub external: Option<ExternalImageDesc>,
}Expand description
What to allocate, or what to import.
Fields§
§extent: Extent2D§format: PixelFormat§usage: TextureUsage§sample_count: u32Sample count for MSAA targets. 1 means single-sampled.
mip_levels: u32How many mip levels this texture holds. 1 is the image alone.
A chain is not made for every texture, because it costs a third again
in memory and a pass of downsampling on upload, and most textures here
are drawn at or above their own size where it would never be read. A
caller who will minify states it, and Self::mipmapped works out how
many levels that takes.
Levels past the first are filled by the backend when the texture is written, not by the caller: there is no way to hand them in, because a chain a caller built by some other rule would sample differently on the two backends and this renderer’s whole test model is that they agree.
external: Option<ExternalImageDesc>When present, import this existing image instead of allocating.
Implementations§
Source§impl TextureDescriptor
impl TextureDescriptor
Sourcepub fn offscreen(extent: Extent2D, format: PixelFormat) -> Self
pub fn offscreen(extent: Extent2D, format: PixelFormat) -> Self
An offscreen render target, the workhorse of the test suites.
Sourcepub fn sampled(extent: Extent2D, format: PixelFormat) -> Self
pub fn sampled(extent: Extent2D, format: PixelFormat) -> Self
A texture only ever read by a shader.
A baked gradient ramp and an uploaded image are both this: written once from the processor, sampled many times, never drawn into. Saying so costs a backend nothing and saves it a color attachment – which is not merely tidiness on GLES, where a format can be filterable as a texture and not renderable as an attachment. Asking for a target a caller does not need is how a texture that would have worked fails to be created.
Sourcepub fn mipmapped(extent: Extent2D, format: PixelFormat) -> Self
pub fn mipmapped(extent: Extent2D, format: PixelFormat) -> Self
The same, with a full mip chain.
Every level down to a single texel, which is what a caller minifying by an unknown amount needs and is only a third again in memory however far it goes – each level is a quarter of the one above, and a quarter summed forever is a third.
Sourcepub fn is_mipmapped(&self) -> bool
pub fn is_mipmapped(&self) -> bool
Whether this texture holds more than the image itself.
Sourcepub fn is_external(&self) -> bool
pub fn is_external(&self) -> bool
Whether this describes an import rather than an allocation.