Trait vulkano::image::traits::ImageAccess
[−]
[src]
pub unsafe trait ImageAccess { fn inner(&self) -> ImageInner; fn initial_layout_requirement(&self) -> ImageLayout; fn final_layout_requirement(&self) -> ImageLayout; fn conflict_key(
&self,
first_layer: u32,
num_layers: u32,
first_mipmap: u32,
num_mipmaps: u32
) -> u64; fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>; unsafe fn increase_gpu_lock(&self); unsafe fn unlock(&self); fn format(&self) -> Format { ... } fn has_color(&self) -> bool { ... } fn has_depth(&self) -> bool { ... } fn has_stencil(&self) -> bool { ... } fn mipmap_levels(&self) -> u32 { ... } fn samples(&self) -> u32 { ... } fn dimensions(&self) -> ImageDimensions { ... } fn supports_blit_source(&self) -> bool { ... } fn supports_blit_destination(&self) -> bool { ... } unsafe fn forced_undefined_initial_layout(
self,
preinitialized: bool
) -> ImageAccessFromUndefinedLayout<Self>
where
Self: Sized, { ... } fn conflicts_buffer(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool { ... } fn conflicts_image(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool { ... } fn conflicts_buffer_all(&self, other: &BufferAccess) -> bool { ... } fn conflicts_image_all(&self, other: &ImageAccess) -> bool { ... } fn conflict_key_all(&self) -> u64 { ... } }
Trait for types that represent the way a GPU can access an image.
Required Methods
fn inner(&self) -> ImageInner
Returns the inner unsafe image object used by this image.
fn initial_layout_requirement(&self) -> ImageLayout
Returns the layout that the image has when it is first used in a primary command buffer.
The first time you use an image in an AutoCommandBufferBuilder
, vulkano will suppose that
the image is in the layout returned by this function. Later when the command buffer is
submitted vulkano will check whether the image is actually in this layout, and if it is not
the case then an error will be returned.
TODO: ^ that check is not yet implemented
fn final_layout_requirement(&self) -> ImageLayout
Returns the layout that the image must be returned to before the end of the command buffer.
When an image is used in an AutoCommandBufferBuilder
vulkano will automatically
transition this image to the layout returned by this function at the end of the command
buffer, if necessary.
Except for special cases, this value should likely be the same as the one returned by
initial_layout_requirement
so that the user can submit multiple command buffers that use
this image one after the other.
fn conflict_key(
&self,
first_layer: u32,
num_layers: u32,
first_mipmap: u32,
num_mipmaps: u32
) -> u64
&self,
first_layer: u32,
num_layers: u32,
first_mipmap: u32,
num_mipmaps: u32
) -> u64
Returns a key that uniquely identifies the range given by first_layer/num_layers/first_mipmap/num_mipmaps.
Two ranges that potentially overlap in memory should return the same key.
The key is shared amongst all buffers and images, which means that you can make several different image objects share the same memory, or make some image objects share memory with buffers, as long as they return the same key.
Since it is possible to accidentally return the same key for memory ranges that don't
overlap, the conflicts_image
or conflicts_buffer
function should always be called to
verify whether they actually overlap.
fn try_gpu_lock(
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
&self,
exclusive_access: bool,
queue: &Queue
) -> Result<(), AccessError>
Locks the resource for usage on the GPU. Returns an error if the lock can't be acquired.
This function exists to prevent the user from causing a data race by reading and writing to the same resource at the same time.
If you call this function, you should call unlock()
once the resource is no longer in use
by the GPU. The implementation is not expected to automatically perform any unlocking and
can rely on the fact that unlock()
is going to be called.
unsafe fn increase_gpu_lock(&self)
Locks the resource for usage on the GPU. Supposes that the resource is already locked, and simply increases the lock by one.
Must only be called after try_gpu_lock()
succeeded.
If you call this function, you should call unlock()
once the resource is no longer in use
by the GPU. The implementation is not expected to automatically perform any unlocking and
can rely on the fact that unlock()
is going to be called.
unsafe fn unlock(&self)
Unlocks the resource previously acquired with try_gpu_lock
or increase_gpu_lock
.
Safety
Must only be called once per previous lock.
Provided Methods
fn format(&self) -> Format
Returns the format of this image.
fn has_color(&self) -> bool
Returns true if the image is a color image.
fn has_depth(&self) -> bool
Returns true if the image has a depth component. In other words, if it is a depth or a depth-stencil format.
fn has_stencil(&self) -> bool
Returns true if the image has a stencil component. In other words, if it is a stencil or a depth-stencil format.
fn mipmap_levels(&self) -> u32
Returns the number of mipmap levels of this image.
fn samples(&self) -> u32
Returns the number of samples of this image.
fn dimensions(&self) -> ImageDimensions
Returns the dimensions of the image.
fn supports_blit_source(&self) -> bool
Returns true if the image can be used as a source for blits.
fn supports_blit_destination(&self) -> bool
Returns true if the image can be used as a destination for blits.
unsafe fn forced_undefined_initial_layout(
self,
preinitialized: bool
) -> ImageAccessFromUndefinedLayout<Self> where
Self: Sized,
self,
preinitialized: bool
) -> ImageAccessFromUndefinedLayout<Self> where
Self: Sized,
Wraps around this ImageAccess
and returns an identical ImageAccess
but whose initial
layout requirement is either Undefined
or Preinitialized
.
fn conflicts_buffer(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &BufferAccess,
other_offset: usize,
other_size: usize
) -> bool
Returns true if an access to self
(as defined by self_first_layer
, self_num_layers
,
self_first_mipmap
and self_num_mipmaps
) potentially overlaps the same memory as an
access to other
(as defined by other_offset
and other_size
).
If this function returns false
, this means that we are allowed to access the offset/size
of self
at the same time as the offset/size of other
without causing a data race.
Note that the function must be transitive. In other words if conflicts(a, b)
is true and
conflicts(b, c)
is true, then conflicts(a, c)
must be true as well.
fn conflicts_image(
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
&self,
self_first_layer: u32,
self_num_layers: u32,
self_first_mipmap: u32,
self_num_mipmaps: u32,
other: &ImageAccess,
other_first_layer: u32,
other_num_layers: u32,
other_first_mipmap: u32,
other_num_mipmaps: u32
) -> bool
Returns true if an access to self
(as defined by self_first_layer
, self_num_layers
,
self_first_mipmap
and self_num_mipmaps
) potentially overlaps the same memory as an
access to other
(as defined by other_first_layer
, other_num_layers
,
other_first_mipmap
and other_num_mipmaps
).
If this function returns false
, this means that we are allowed to access the offset/size
of self
at the same time as the offset/size of other
without causing a data race.
Note that the function must be transitive. In other words if conflicts(a, b)
is true and
conflicts(b, c)
is true, then conflicts(a, c)
must be true as well.
fn conflicts_buffer_all(&self, other: &BufferAccess) -> bool
Shortcut for conflicts_buffer
that compares the whole buffer to another.
fn conflicts_image_all(&self, other: &ImageAccess) -> bool
Shortcut for conflicts_image
that compares the whole buffer to a whole image.
fn conflict_key_all(&self) -> u64
Shortcut for conflict_key
that grabs the key of the whole buffer.
Implementors
impl<F, A> ImageAccess for AttachmentImage<F, A> where
F: 'static + Send + Sync,impl<F, A> ImageAccess for ImmutableImage<F, A> where
F: 'static + Send + Sync,impl<F, A> ImageAccess for ImmutableImageInitialization<F, A> where
F: 'static + Send + Sync,impl<F, A> ImageAccess for StorageImage<F, A> where
F: 'static + Send + Sync,
A: MemoryPool,impl ImageAccess for SwapchainImage
impl<T> ImageAccess for T where
T: SafeDeref,
T::Target: ImageAccess,impl<I> ImageAccess for ImageAccessFromUndefinedLayout<I> where
I: ImageAccess,