Struct vulkano::image::attachment::AttachmentImage
[−]
[src]
pub struct AttachmentImage<F = Format, A = StdMemoryPoolAlloc> { /* fields omitted */ }
ImageAccess whose purpose is to be used as a framebuffer attachment.
The image is always two-dimensional and has only one mipmap, but it can have any kind of
format. Trying to use a format that the backend doesn't support for rendering will result in
an error being returned when creating the image. Once you have an AttachmentImage
, you are
guaranteed that you will be able to draw on it.
The template parameter of AttachmentImage
is a type that describes the format of the image.
Regular vs transient
Calling AttachmentImage::new
will create a regular image, while calling
AttachmentImage::transient
will create a transient image. Transient image are only
relevant for images that serve as attachments, so AttachmentImage
is the only type of
image in vulkano that provides a shortcut for this.
A transient image is a special kind of image whose content is undefined outside of render passes. Once you finish drawing, reading from it will returned undefined data (which can be either valid or garbage, depending on the implementation).
This gives a hint to the Vulkan implementation that it is possible for the image's content to live exclusively in some cache memory, and that no real memory has to be allocated for it.
In other words, if you are going to read from the image after drawing to it, use a regular image. If you don't need to read from it (for example if it's some kind of intermediary color, or a depth buffer that is only used once) then use a transient image as it may improve performances.
Methods
impl<F> AttachmentImage<F>
[src]
fn new(
device: Arc<Device>,
dimensions: [u32; 2],
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Creates a new image with the given dimensions and format.
Returns an error if the dimensions are too large or if the backend doesn't support this format as a framebuffer attachment.
fn multisampled(
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Same as new
, but creates a multisampled image.
Note: You can also use this function and pass
1
for the number of samples if you want a regular image.
fn with_usage(
device: Arc<Device>,
dimensions: [u32; 2],
format: F,
usage: ImageUsage
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
format: F,
usage: ImageUsage
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Same as new
, but lets you specify additional usages.
fn multisampled_with_usage(
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F,
usage: ImageUsage
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F,
usage: ImageUsage
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Same as with_usage
, but creates a multisampled image.
Note: You can also use this function and pass
1
for the number of samples if you want a regular image.
fn transient(
device: Arc<Device>,
dimensions: [u32; 2],
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Same as new
, except that the image will be transient.
A transient image is special because its content is undefined outside of a render pass. This means that the implementation has the possibility to not allocate any memory for it.
fn transient_multisampled(
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
device: Arc<Device>,
dimensions: [u32; 2],
samples: u32,
format: F
) -> Result<Arc<AttachmentImage<F>>, ImageCreationError> where
F: FormatDesc,
Same as transient
, but creates a multisampled image.
Note: You can also use this function and pass
1
for the number of samples if you want a regular image.
impl<F, A> AttachmentImage<F, A>
[src]
fn dimensions(&self) -> [u32; 2]
Returns the dimensions of the image.
Trait Implementations
impl<F: Debug, A: Debug> Debug for AttachmentImage<F, A>
[src]
impl<F, A> ImageAccess for AttachmentImage<F, A> where
F: 'static + Send + Sync,
[src]
F: 'static + Send + Sync,
fn inner(&self) -> ImageInner
Returns the inner unsafe image object used by this image.
fn initial_layout_requirement(&self) -> ImageLayout
Returns the layout that the image has when it is first used in a primary command buffer. Read more
fn final_layout_requirement(&self) -> ImageLayout
Returns the layout that the image must be returned to before the end of the command buffer. Read more
fn conflict_key(&self, _: u32, _: u32, _: u32, _: u32) -> u64
Returns a key that uniquely identifies the range given by first_layer/num_layers/first_mipmap/num_mipmaps. Read more
fn try_gpu_lock(&self, _: bool, _: &Queue) -> Result<(), AccessError>
Locks the resource for usage on the GPU. Returns an error if the lock can't be acquired. Read more
unsafe fn increase_gpu_lock(&self)
Locks the resource for usage on the GPU. Supposes that the resource is already locked, and simply increases the lock by one. Read more
unsafe fn unlock(&self)
Unlocks the resource previously acquired with try_gpu_lock
or increase_gpu_lock
. Read more
fn format(&self) -> Format
Returns the format of this image.
fn has_color(&self) -> bool
Returns true if the image is a color image.
fn has_depth(&self) -> bool
Returns true if the image has a depth component. In other words, if it is a depth or a depth-stencil format. Read more
fn has_stencil(&self) -> bool
Returns true if the image has a stencil component. In other words, if it is a stencil or a depth-stencil format. Read more
fn mipmap_levels(&self) -> u32
Returns the number of mipmap levels of this image.
fn samples(&self) -> u32
Returns the number of samples of this image.
fn dimensions(&self) -> ImageDimensions
Returns the dimensions of the image.
fn supports_blit_source(&self) -> bool
Returns true if the image can be used as a source for blits.
fn supports_blit_destination(&self) -> bool
Returns true if the image can be used as a destination for blits.
unsafe fn forced_undefined_initial_layout(
self,
preinitialized: bool
) -> ImageAccessFromUndefinedLayout<Self> where
Self: Sized,
self,
preinitialized: bool
) -> ImageAccessFromUndefinedLayout<Self> where
Self: Sized,
Wraps around this ImageAccess
and returns an identical ImageAccess
but whose initial layout requirement is either Undefined
or Preinitialized
. Read more
fn conflicts_buffer(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
Returns true if an access to self
(as defined by self_first_layer
, self_num_layers
, self_first_mipmap
and self_num_mipmaps
) potentially overlaps the same memory as an access to other
(as defined by other_offset
and other_size
). Read more
fn conflicts_image(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
Returns true if an access to self
(as defined by self_first_layer
, self_num_layers
, self_first_mipmap
and self_num_mipmaps
) potentially overlaps the same memory as an access to other
(as defined by other_first_layer
, other_num_layers
, other_first_mipmap
and other_num_mipmaps
). Read more
fn conflicts_buffer_all(&self, other: &BufferAccess) -> bool
Shortcut for conflicts_buffer
that compares the whole buffer to another.
fn conflicts_image_all(&self, other: &ImageAccess) -> bool
Shortcut for conflicts_image
that compares the whole buffer to a whole image.
fn conflict_key_all(&self) -> u64
Shortcut for conflict_key
that grabs the key of the whole buffer.
impl<F, A> ImageViewAccess for AttachmentImage<F, A> where
F: 'static + Send + Sync,
[src]
F: 'static + Send + Sync,
fn parent(&self) -> &ImageAccess
fn dimensions(&self) -> Dimensions
Returns the dimensions of the image view.
fn inner(&self) -> &UnsafeImageView
Returns the inner unsafe image view object used by this image view.
fn descriptor_set_storage_image_layout(&self) -> ImageLayout
Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_combined_image_sampler_layout(&self) -> ImageLayout
Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_sampled_image_layout(&self) -> ImageLayout
Returns the image layout to use in a descriptor with the given subresource.
fn descriptor_set_input_attachment_layout(&self) -> ImageLayout
Returns the image layout to use in a descriptor with the given subresource.
fn identity_swizzle(&self) -> bool
Returns true if the view doesn't use components swizzling. Read more
fn format(&self) -> Format
Returns the format of this view. This can be different from the parent's format.
fn samples(&self) -> u32
fn can_be_sampled(&self, sampler: &Sampler) -> bool
Returns true if the given sampler can be used with this image view. Read more