pub struct RawImage { /* private fields */ }
Expand description
A raw image, with no memory backing it.
This is the basic image type, a direct translation of a VkImage
object, but it is mostly
useless in this form. After creating a raw image, you must call bind_memory
to make a
complete image object.
See also the parent module-level documentation for more information about images.
Implementations§
source§impl RawImage
impl RawImage
sourcepub fn new(
device: Arc<Device>,
create_info: ImageCreateInfo
) -> Result<RawImage, Validated<VulkanError>>
pub fn new( device: Arc<Device>, create_info: ImageCreateInfo ) -> Result<RawImage, Validated<VulkanError>>
Creates a new RawImage
.
sourcepub unsafe fn from_handle(
device: Arc<Device>,
handle: Image,
create_info: ImageCreateInfo
) -> Result<Self, VulkanError>
pub unsafe fn from_handle( device: Arc<Device>, handle: Image, create_info: ImageCreateInfo ) -> Result<Self, VulkanError>
Creates a new RawImage
from a raw object handle.
Safety
handle
must be a valid Vulkan object handle created fromdevice
.handle
must refer to an image that has not yet had memory bound to it.create_info
must match the info used to create the object.
sourcepub fn bind_memory(
self,
allocations: impl IntoIterator<Item = ResourceMemory>
) -> Result<Image, (Validated<VulkanError>, RawImage, impl ExactSizeIterator<Item = ResourceMemory>)>
pub fn bind_memory( self, allocations: impl IntoIterator<Item = ResourceMemory> ) -> Result<Image, (Validated<VulkanError>, RawImage, impl ExactSizeIterator<Item = ResourceMemory>)>
Binds device memory to this image.
- If
self.flags()
does not containImageCreateFlags::DISJOINT
, thenallocations
must contain exactly one element. - If
self.flags()
containsImageCreateFlags::DISJOINT
, andself.tiling()
isImageTiling::Linear
orImageTiling::Optimal
, thenallocations
must contain exactlyself.format().unwrap().planes().len()
elements. - If
self.flags()
containsImageCreateFlags::DISJOINT
, andself.tiling()
isImageTiling::DrmFormatModifier
, thenallocations
must contain exactlyself.drm_format_modifier().unwrap().1
elements.
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().unwrap().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 results of this function are cached, so that future calls with the same arguments do not need to make a call to the Vulkan API again.