pub struct Image {
pub info: ImageInfo,
pub name: Option<String>,
/* private fields */
}
Expand description
Smart pointer handle to an image object.
Also contains information about the object.
§Deref
behavior
Image
automatically dereferences to vk::Image
(via the Deref
trait), so you can
call vk::Image
’s methods on a value of type Image
. To avoid name clashes with vk::Image
’s
methods, the methods of Image
itself are associated functions, called using
fully qualified syntax:
let prev = Image::access(&my_image, AccessType::AnyShaderWrite);
Fields§
§info: ImageInfo
Information used to create this object.
name: Option<String>
A name for debugging purposes.
Implementations§
source§impl Image
impl Image
sourcepub fn create(
device: &Arc<Device>,
info: impl Into<ImageInfo>
) -> Result<Self, DriverError>
pub fn create( device: &Arc<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, vk::Image::null());
assert_eq!(image.info.width, 32);
assert_eq!(image.info.height, 32);
sourcepub fn access(this: &Self, next_access: AccessType) -> AccessType
pub fn access(this: &Self, next_access: AccessType) -> AccessType
Keeps track of some next_access
which affects this object.
Returns the previous access for which a pipeline barrier should be used to prevent data corruption.
§Note
Used to maintain object state when passing a Screen 13-created vk::Image
handle to
external code such as Ash or Erupt bindings.
§Examples
Basic usage:
// Initially we want to "Read Other"
let next = AccessType::AnyShaderReadOther;
let prev = Image::access(&my_image, next);
assert_eq!(prev, AccessType::Nothing);
// External code may now "Read Other"; no barrier required
// Subsequently we want to "Write"
let next = AccessType::FragmentShaderWrite;
let prev = Image::access(&my_image, next);
assert_eq!(prev, AccessType::AnyShaderReadOther);
// A barrier on "Read Other" before "Write" is required!
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnwindSafe for Image
Blanket Implementations§
source§impl<T> Alias<ImageInfoBuilder, Image> for T
impl<T> Alias<ImageInfoBuilder, Image> for T
source§fn alias(
&mut self,
builder: ImageInfoBuilder
) -> Result<Arc<Lease<Image>>, DriverError>
fn alias( &mut self, builder: ImageInfoBuilder ) -> Result<Arc<Lease<Image>>, DriverError>
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.