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) -> TextureDescriptor
pub fn offscreen(extent: Extent2D, format: PixelFormat) -> TextureDescriptor
An offscreen render target, the workhorse of the test suites.
Sourcepub fn sampled(extent: Extent2D, format: PixelFormat) -> TextureDescriptor
pub fn sampled(extent: Extent2D, format: PixelFormat) -> TextureDescriptor
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) -> TextureDescriptor
pub fn mipmapped(extent: Extent2D, format: PixelFormat) -> TextureDescriptor
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.
Trait Implementations§
Auto Trait Implementations§
impl Forget for TextureDescriptor
impl Freeze for TextureDescriptor
impl Move for TextureDescriptor
impl RefUnwindSafe for TextureDescriptorwhere
I32NotAllOnes: RefUnwindSafe,
impl Send for TextureDescriptor
impl Sync for TextureDescriptor
impl Unpin for TextureDescriptor
impl UnsafeUnpin for TextureDescriptor
impl UnwindSafe for TextureDescriptorwhere
RawVecInner: UnwindSafe,
I32NotAllOnes: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more