#[non_exhaustive]
#[repr(i32)]
pub enum ImageLayout {
Show 16 variants Undefined = 0, General = 1, ColorAttachmentOptimal = 2, DepthStencilAttachmentOptimal = 3, DepthStencilReadOnlyOptimal = 4, ShaderReadOnlyOptimal = 5, TransferSrcOptimal = 6, TransferDstOptimal = 7, Preinitialized = 8, DepthReadOnlyStencilAttachmentOptimal = 1_000_117_000, DepthAttachmentStencilReadOnlyOptimal = 1_000_117_001, DepthAttachmentOptimal = 1_000_241_000, DepthReadOnlyOptimal = 1_000_241_001, StencilAttachmentOptimal = 1_000_241_002, StencilReadOnlyOptimal = 1_000_241_003, PresentSrc = 1_000_001_002,
}
Expand description

In-memory layout of the pixel data of an image.

The pixel data of a Vulkan image is arranged in a particular way, which is called its layout. Each image subresource (mipmap level and array layer) in an image can have a different layout, but usually the whole image has its data in the same layout. Layouts are abstract in the sense that the user does not know the specific details of each layout; the device driver is free to implement each layout in the way it sees fit.

The layout of a newly created image is either Undefined or Preinitialized. Every operation that can be performed on an image is only possible with specific layouts, so before the operation is performed, the user must perform a layout transition on the image. This rearranges the pixel data from one layout into another. Layout transitions are performed as part of pipeline barriers in a command buffer.

The General layout is compatible with any operation, so layout transitions are never needed. However, the other layouts, while more restricted, are usually better optimised for a particular type of operation than General, so they are usually preferred.

Vulkan does not keep track of layouts itself, so it is the responsibility of the user to keep track of this information. When performing a layout transition, the previous layout must be specified as well. Some operations allow for different layouts, but require the user to specify which one. Vulkano helps with this by providing sensible defaults, automatically tracking the layout of each image when creating a command buffer, and adding layout transitions where needed.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Undefined = 0

The layout of the data is unknown, and the image is treated as containing no valid data. Transitioning from Undefined will discard any existing pixel data.

§

General = 1

A general-purpose layout that can be used for any operation. Some operations may only allow General, such as storage images, but many have a more specific layout that is better optimized for that purpose.

§

ColorAttachmentOptimal = 2

For a color image used as a color or resolve attachment in a framebuffer. Images that are transitioned into this layout must have the color_attachment usage enabled.

§

DepthStencilAttachmentOptimal = 3

A combination of DepthAttachmentOptimal for the depth aspect of the image, and StencilAttachmentOptimal for the stencil aspect of the image.

§

DepthStencilReadOnlyOptimal = 4

A combination of DepthReadOnlyOptimal for the depth aspect of the image, and StencilReadOnlyOptimal for the stencil aspect of the image.

§

ShaderReadOnlyOptimal = 5

For a color image used as a (combined) sampled image or input attachment in a shader. Images that are transitioned into this layout must have the sampled or input_attachment usages enabled.

§

TransferSrcOptimal = 6

For operations that transfer data from an image (copy, blit).

§

TransferDstOptimal = 7

For operations that transfer data to an image (copy, blit, clear).

§

Preinitialized = 8

When creating an image, this specifies that the initial data is going to be directly written to from the CPU. Unlike Undefined, the image is assumed to contain valid data when transitioning from this layout. However, this only works right when the image has linear tiling, optimal tiling gives undefined results.

§

DepthReadOnlyStencilAttachmentOptimal = 1_000_117_000

A combination of DepthReadOnlyOptimal for the depth aspect of the image, and StencilAttachmentOptimal for the stencil aspect of the image.

§

DepthAttachmentStencilReadOnlyOptimal = 1_000_117_001

A combination of DepthAttachmentOptimal for the depth aspect of the image, and StencilReadOnlyOptimal for the stencil aspect of the image.

§

DepthAttachmentOptimal = 1_000_241_000

For a depth image used as a depth attachment in a framebuffer.

§

DepthReadOnlyOptimal = 1_000_241_001

For a depth image used as a read-only depth attachment in a framebuffer, or as a (combined) sampled image or input attachment in a shader.

§

StencilAttachmentOptimal = 1_000_241_002

For a stencil image used as a stencil attachment in a framebuffer.

§

StencilReadOnlyOptimal = 1_000_241_003

For a stencil image used as a read-only stencil attachment in a framebuffer, or as a (combined) sampled image or input attachment in a shader.

§

PresentSrc = 1_000_001_002

The layout of images that are held in a swapchain. Images are in this layout when they are acquired from the swapchain, and must be transitioned back into this layout before presenting them.

Implementations§

source§

impl ImageLayout

source

pub fn is_writable(self, aspect: ImageAspect) -> bool

If the layout can be used for aspect, returns whether aspect can be written to if an image is in that layout.

Trait Implementations§

source§

impl Clone for ImageLayout

source§

fn clone(&self) -> ImageLayout

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ImageLayout

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for ImageLayout

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<ImageLayout> for ImageLayout

source§

fn from(val: ImageLayout) -> Self

Converts to this type from the input type.
source§

impl Hash for ImageLayout

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq for ImageLayout

source§

fn eq(&self, other: &ImageLayout) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<ImageLayout> for ImageLayout

§

type Error = ()

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

fn try_from(val: ImageLayout) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for ImageLayout

source§

impl Eq for ImageLayout

source§

impl StructuralEq for ImageLayout

source§

impl StructuralPartialEq for ImageLayout

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.