pub struct Image {
pub device: Device,
pub handle: Image,
pub info: ImageInfo,
/* private fields */
}Expand description
Smart pointer handle to an image object.
Also contains information about the object.
let fmt = vk::Format::R8G8B8A8_UNORM;
let usage = vk::ImageUsageFlags::SAMPLED;
let info = ImageInfo::image_2d(320, 200, fmt, usage);
let my_img = Image::create(&device, info)?;
assert_eq!(my_img.info, info);
assert_ne!(my_img.handle, vk::Image::null());Fields§
§device: DeviceThe device which owns this image resource.
Note: This field is read-only.
handle: ImageThe native Vulkan resource handle of this image.
Note: This field is read-only.
info: ImageInfoInformation used to create this resource.
Note: This field is read-only.
Implementations§
Source§impl Image
impl Image
Sourcepub fn create(
device: &Device,
info: impl Into<ImageInfo>,
) -> Result<Self, DriverError>
pub fn create( device: &Device, info: impl Into<ImageInfo>, ) -> Result<Self, DriverError>
Creates a new image on the given device.
§Examples
Basic usage:
let info = ImageInfo::image_2d(
32,
32,
vk::Format::R8G8B8A8_UNORM,
vk::ImageUsageFlags::SAMPLED,
);
let image = Image::create(&device, info)?;
assert_ne!(image.handle, vk::Image::null());
assert_eq!(image.info.width, 32);
assert_eq!(image.info.height, 32);Sourcepub unsafe fn from_raw(
device: &Device,
handle: Image,
info: impl Into<ImageInfo>,
) -> Self
pub unsafe fn from_raw( device: &Device, handle: Image, info: impl Into<ImageInfo>, ) -> Self
Consumes a Vulkan image created by some other library.
The image is not destroyed automatically on drop, unlike images created through the
Image::create function.
§Safety
handle must be a valid vk::Image created from device, and info must accurately
describe the image’s format, extent, usage, sharing mode, and subresource counts. The caller
remains responsible for keeping the handle and its memory backing valid until all wrappers
created from this function are no longer used.
Sourcepub fn set_debug_name(&self, name: impl AsRef<str>)
pub fn set_debug_name(&self, name: impl AsRef<str>)
Sets the debugging name assigned to this image.
Sourcepub fn sync_info(&self) -> ImageSyncInfo
pub fn sync_info(&self) -> ImageSyncInfo
Returns compact synchronization information for the image’s current subresource accesses.
Sourcepub unsafe fn to_detached(&self) -> Self
pub unsafe fn to_detached(&self) -> Self
Produces a new Image sharing the same Vulkan handle with independent access tracking.
The returned image retains the handle, device, and debug name of self but starts with
no prior access history (AccessType::Nothing) and does not claim ownership of the image’s
memory backing. Internal caches are moved out of self so they are not duplicated.
This is used to create separate tracking instances for swapchain images that may be used concurrently across different graph executions.
§Safety
The caller must ensure the Vulkan image handle remains valid for the lifetime of the
returned Image. This function should only be called on swapchain images or other
platform or extension images.
Sourcepub fn with_debug_name(self, name: impl AsRef<str>) -> Self
pub fn with_debug_name(self, name: impl AsRef<str>) -> Self
Sets the debugging name assigned to this image.