pub struct Image { /* private fields */ }
Expand description
A multi-dimensioned storage for texel data.
Unlike RawImage
, an Image
has memory backing it, and can be used normally.
See also the module-level documentation for more information about images.
Implementations§
source§impl Image
impl Image
sourcepub fn new(
allocator: Arc<dyn MemoryAllocator>,
create_info: ImageCreateInfo,
allocation_info: AllocationCreateInfo
) -> Result<Arc<Self>, Validated<AllocateImageError>>
pub fn new( allocator: Arc<dyn MemoryAllocator>, create_info: ImageCreateInfo, allocation_info: AllocationCreateInfo ) -> Result<Arc<Self>, Validated<AllocateImageError>>
Creates a new uninitialized Image
.
sourcepub fn memory(&self) -> &ImageMemory
pub fn memory(&self) -> &ImageMemory
Returns the type of memory that is backing this image.
sourcepub fn memory_requirements(&self) -> &[MemoryRequirements]
pub fn memory_requirements(&self) -> &[MemoryRequirements]
Returns the memory requirements for this image.
- If the image is a swapchain image, this returns a slice with a length of 0.
- If
self.flags().disjoint
is not set, this returns a slice with a length of 1. - If
self.flags().disjoint
is set, this returns a slice with a length equal toself.format().planes().len()
.
sourcepub fn flags(&self) -> ImageCreateFlags
pub fn flags(&self) -> ImageCreateFlags
Returns the flags the image was created with.
sourcepub fn image_type(&self) -> ImageType
pub fn image_type(&self) -> ImageType
Returns the image type of the image.
sourcepub fn format_features(&self) -> FormatFeatures
pub fn format_features(&self) -> FormatFeatures
Returns the features supported by the image’s format.
sourcepub fn view_formats(&self) -> &[Format]
pub fn view_formats(&self) -> &[Format]
Returns the formats that an image view created from this image can have.
sourcepub fn array_layers(&self) -> u32
pub fn array_layers(&self) -> u32
Returns the number of array layers in the image.
sourcepub fn mip_levels(&self) -> u32
pub fn mip_levels(&self) -> u32
Returns the number of mip levels in the image.
sourcepub fn initial_layout(&self) -> ImageLayout
pub fn initial_layout(&self) -> ImageLayout
Returns the initial layout of the image.
sourcepub fn samples(&self) -> SampleCount
pub fn samples(&self) -> SampleCount
Returns the number of samples for the image.
sourcepub fn tiling(&self) -> ImageTiling
pub fn tiling(&self) -> ImageTiling
Returns the tiling of the image.
sourcepub fn usage(&self) -> ImageUsage
pub fn usage(&self) -> ImageUsage
Returns the usage the image was created with.
sourcepub fn stencil_usage(&self) -> Option<ImageUsage>
pub fn stencil_usage(&self) -> Option<ImageUsage>
Returns the stencil usage the image was created with.
sourcepub fn sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
pub fn sharing(&self) -> &Sharing<SmallVec<[u32; 4]>>
Returns the sharing the image was created with.
sourcepub fn drm_format_modifier(&self) -> Option<(u64, u32)>
pub fn drm_format_modifier(&self) -> Option<(u64, u32)>
If self.tiling()
is ImageTiling::DrmFormatModifier
, returns the DRM format modifier
of the image, and the number of memory planes.
This was either provided in ImageCreateInfo::drm_format_modifiers
, or if
multiple modifiers were provided, selected from the list by the Vulkan implementation.
sourcepub fn external_memory_handle_types(&self) -> ExternalMemoryHandleTypes
pub fn external_memory_handle_types(&self) -> ExternalMemoryHandleTypes
Returns the external memory handle types that are supported with this image.
sourcepub fn subresource_layers(&self) -> ImageSubresourceLayers
pub fn subresource_layers(&self) -> ImageSubresourceLayers
Returns an ImageSubresourceLayers
covering the first mip level of the image. All aspects
of the image are selected, or plane0
if the image is multi-planar.
sourcepub fn subresource_range(&self) -> ImageSubresourceRange
pub fn subresource_range(&self) -> ImageSubresourceRange
Returns an ImageSubresourceRange
covering the whole image. If the image is multi-planar,
only the color
aspect is selected.
sourcepub fn subresource_layout(
&self,
aspect: ImageAspect,
mip_level: u32,
array_layer: u32
) -> Result<SubresourceLayout, Box<ValidationError>>
pub fn subresource_layout( &self, aspect: ImageAspect, mip_level: u32, array_layer: u32 ) -> Result<SubresourceLayout, Box<ValidationError>>
Queries the memory layout of a single subresource of the image.
Only images with linear tiling are supported, if they do not have a format with both a
depth and a stencil format. Images with optimal tiling have an opaque image layout that is
not suitable for direct memory accesses, and likewise for combined depth/stencil formats.
Multi-planar formats are supported, but you must specify one of the planes as the aspect
,
not ImageAspect::Color
.
The layout is invariant for each image. However it is not cached, as this would waste memory in the case of non-linear-tiling images. You are encouraged to store the layout somewhere in order to avoid calling this semi-expensive function at every single memory access.