Skip to main content

TextureDescriptor

Struct TextureDescriptor 

Source
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: u32

Sample count for MSAA targets. 1 means single-sampled.

§mip_levels: u32

How 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

Source

pub fn offscreen(extent: Extent2D, format: PixelFormat) -> Self

An offscreen render target, the workhorse of the test suites.

Source

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.

Source

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.

Source

pub fn is_mipmapped(&self) -> bool

Whether this texture holds more than the image itself.

Source

pub fn is_external(&self) -> bool

Whether this describes an import rather than an allocation.

Trait Implementations§

Source§

impl Debug for TextureDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.