Skip to main content

Image

Struct Image 

Source
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: Device

The device which owns this image resource.

Note: This field is read-only.

§handle: Image

The native Vulkan resource handle of this image.

Note: This field is read-only.

§info: ImageInfo

Information used to create this resource.

Note: This field is read-only.

Implementations§

Source§

impl Image

Source

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);
Source

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.

Source

pub fn set_debug_name(&self, name: impl AsRef<str>)

Sets the debugging name assigned to this image.

Source

pub fn sync_info(&self) -> ImageSyncInfo

Returns compact synchronization information for the image’s current subresource accesses.

Source

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.

Source

pub fn with_debug_name(self, name: impl AsRef<str>) -> Self

Sets the debugging name assigned to this image.

Trait Implementations§

Source§

impl Debug for Image

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Image

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Image

Source§

impl PartialEq for Image

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Pool<ImageInfo, Image> for FifoPool

Source§

fn resource(&mut self, info: ImageInfo) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl Pool<ImageInfo, Image> for HashPool

Source§

fn resource(&mut self, info: ImageInfo) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl Pool<ImageInfo, Image> for LazyPool

Source§

fn resource(&mut self, info: ImageInfo) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl Resource for Image

Source§

type Node = ImageNode

The resource handle type.

Auto Trait Implementations§

§

impl !Freeze for Image

§

impl !RefUnwindSafe for Image

§

impl !UnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnsafeUnpin for Image

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pool<ImageInfoBuilder, Image> for T
where T: Pool<ImageInfo, Image>,

Source§

fn resource( &mut self, builder: ImageInfoBuilder, ) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.