pub struct UnsafeImage { /* private fields */ }
Expand description
A storage for pixels or arbitrary data.
Safety
UnsafeImage
is not unsafe to create, but it is unsafe to use:
- You must manually bind memory to the image with
bind_memory
. The memory must respect the requirements returned bymemory_requirements
. - The memory that you bind to the image must be manually kept alive.
- The queue family ownership must be manually enforced.
- The usage must be manually enforced.
- The image layout must be manually enforced and transitioned.
Implementations
sourceimpl UnsafeImage
impl UnsafeImage
sourcepub fn new(
device: Arc<Device>,
create_info: UnsafeImageCreateInfo
) -> Result<UnsafeImage, ImageCreationError>
pub fn new(
device: Arc<Device>,
create_info: UnsafeImageCreateInfo
) -> Result<UnsafeImage, ImageCreationError>
Creates a new UnsafeImage
.
Panics
- Panics if one of the values in
create_info.dimensions
is zero. - Panics if
create_info.format
isNone
. - Panics if
create_info.block_texel_view_compatible
is set but notcreate_info.mutable_format
. - Panics if
create_info.mip_levels
is0
. - Panics if
create_info.sharing
isSharing::Concurrent
with less than 2 items. - Panics if
create_info.initial)layout
is something other thanImageLayout::Undefined
orImageLayout::Preinitialized
. - Panics if
create_info.usage
is empty. - Panics if
create_info.usage
containstransient_attachment
, but does not also contain at least one ofcolor_attachment
,depth_stencil_attachment
,input_attachment
, or if it contains values other than these.
sourcepub fn memory_requirements(&self) -> MemoryRequirements
pub fn memory_requirements(&self) -> MemoryRequirements
Returns the memory requirements for this image.
pub unsafe fn bind_memory(
&self,
memory: &DeviceMemory,
offset: DeviceSize
) -> Result<(), OomError>
sourcepub fn dimensions(&self) -> ImageDimensions
pub fn dimensions(&self) -> ImageDimensions
Returns the dimensions 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 mip_levels(&self) -> u32
pub fn mip_levels(&self) -> u32
Returns the number of mipmap 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 mutable_format(&self) -> bool
pub fn mutable_format(&self) -> bool
Returns whether mutable_format
is enabled on the image.
sourcepub fn cube_compatible(&self) -> bool
pub fn cube_compatible(&self) -> bool
Returns whether cube_compatible
is enabled on the image.
sourcepub fn array_2d_compatible(&self) -> bool
pub fn array_2d_compatible(&self) -> bool
Returns whether array_2d_compatible
is enabled on the image.
sourcepub fn block_texel_view_compatible(&self) -> bool
pub fn block_texel_view_compatible(&self) -> bool
Returns whether block_texel_view_compatible
is enabled on the image.
sourcepub fn key(&self) -> u64
pub fn key(&self) -> u64
Returns a key unique to each UnsafeImage
. Can be used for the conflicts_key
method.
sourcepub unsafe fn color_linear_layout(&self, mip_level: u32) -> LinearLayout
pub unsafe fn color_linear_layout(&self, mip_level: u32) -> LinearLayout
Queries the layout of an image in memory. Only valid for images with linear tiling.
This function is only valid for images with a color format. See the other similar functions for the other aspects.
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.
Note that while Vulkan allows querying the array layers other than 0, it is redundant as you can easily calculate the position of any layer.
Panic
- Panics if the mipmap level is out of range.
Safety
- The image must not have a depth, stencil or depth-stencil format.
- The image must have been created with linear tiling.
sourcepub unsafe fn depth_linear_layout(&self, mip_level: u32) -> LinearLayout
pub unsafe fn depth_linear_layout(&self, mip_level: u32) -> LinearLayout
sourcepub unsafe fn stencil_linear_layout(&self, mip_level: u32) -> LinearLayout
pub unsafe fn stencil_linear_layout(&self, mip_level: u32) -> LinearLayout
sourcepub unsafe fn multiplane_color_layout(
&self,
aspect: ImageAspect
) -> LinearLayout
pub unsafe fn multiplane_color_layout(
&self,
aspect: ImageAspect
) -> LinearLayout
Same as color_linear_layout
, except that it retrieves layout for the requested YCbCr
component too if the format is a YCbCr format.
Panic
- Panics if plane aspect is out of range.
- Panics if the aspect is not a color or planar aspect.
- Panics if the number of mipmaps is not 1.
Trait Implementations
sourceimpl Debug for UnsafeImage
impl Debug for UnsafeImage
sourceimpl DeviceOwned for UnsafeImage
impl DeviceOwned for UnsafeImage
sourceimpl Drop for UnsafeImage
impl Drop for UnsafeImage
sourceimpl Hash for UnsafeImage
impl Hash for UnsafeImage
sourceimpl PartialEq<UnsafeImage> for UnsafeImage
impl PartialEq<UnsafeImage> for UnsafeImage
sourceimpl VulkanObject for UnsafeImage
impl VulkanObject for UnsafeImage
sourcefn internal_object(&self) -> Image
fn internal_object(&self) -> Image
Returns a reference to the object.
impl Eq for UnsafeImage
Auto Trait Implementations
impl RefUnwindSafe for UnsafeImage
impl Send for UnsafeImage
impl Sync for UnsafeImage
impl Unpin for UnsafeImage
impl UnwindSafe for UnsafeImage
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more