Struct vulkano::memory::MemoryPropertyFlags
source · pub struct MemoryPropertyFlags(/* private fields */);
Expand description
Properties of a memory type.
Implementations§
source§impl MemoryPropertyFlags
impl MemoryPropertyFlags
sourcepub const DEVICE_LOCAL: Self = _
pub const DEVICE_LOCAL: Self = _
The memory is located on the device, and is allocated from a heap that also has the
DEVICE_LOCAL
flag set.
For some devices, particularly integrated GPUs, the device shares memory with the host and all memory may be device-local, so the distinction is moot. However, if the device has non-device-local memory, it is usually faster for the device to access device-local memory. Therefore, device-local memory is preferred for data that will only be accessed by the device.
If the device and host do not share memory, data transfer between host and device may involve sending the data over the data bus that connects the two. Accesses are faster if they do not have to cross this barrier: device-local memory is fast for the device to access, but slower to access by the host. However, there are devices that share memory with the host, yet have distinct device-local and non-device local memory types. In that case, the speed difference may not be large.
For data transfer between host and device, it is most efficient if the memory is located
at the destination of the transfer. Thus, if HOST_VISIBLE
versions of both are
available, device-local memory is preferred for host-to-device data transfer, while
non-device-local memory is preferred for device-to-host data transfer. This is because data
is usually written only once but potentially read several times, and because reads can take
advantage of caching while writes cannot.
Devices may have memory types that are neither DEVICE_LOCAL
nor HOST_VISIBLE
. This
is regular host memory that is made available to the device exclusively. Although it will be
slower to access from the device than DEVICE_LOCAL
memory, it can be faster than
HOST_VISIBLE
memory. It can be used as overflow space if the device is out of memory.
sourcepub const HOST_VISIBLE: Self = _
pub const HOST_VISIBLE: Self = _
The memory can be mapped into the memory space of the host and accessed as regular RAM.
Memory of this type is required to transfer data between the host and the device. If
the memory is going to be accessed by the device more than a few times, it is recommended
to copy the data to non-HOST_VISIBLE
memory first if it is available.
HOST_VISIBLE
memory is always at least either HOST_COHERENT
or HOST_CACHED
,
but it can be both.
sourcepub const HOST_COHERENT: Self = _
pub const HOST_COHERENT: Self = _
Host access to the memory does not require calling invalidate_range
to make device
writes visible to the host, nor flush_range
to flush host writes back to the device.
sourcepub const HOST_CACHED: Self = _
pub const HOST_CACHED: Self = _
The memory is cached by the host.
HOST_CACHED
memory is fast for reads and random access from the host, so it is preferred
for device-to-host data transfer. Memory that is HOST_VISIBLE
but not HOST_CACHED
is
often slow for all accesses other than sequential writing, so it is more suited for
host-to-device transfer, and it is often beneficial to write the data in sequence.
sourcepub const LAZILY_ALLOCATED: Self = _
pub const LAZILY_ALLOCATED: Self = _
Allocations made from the memory are lazy.
This means that no actual allocation is performed. Instead memory is automatically
allocated by the Vulkan implementation based on need. You can call
DeviceMemory::commitment
to query how much memory is currently committed to an
allocation.
Memory of this type can only be used on images created with a certain flag, and is never
HOST_VISIBLE
.
sourcepub const PROTECTED: Self = _
pub const PROTECTED: Self = _
The memory can only be accessed by the device, and allows protected queue access.
Memory of this type is never HOST_VISIBLE
, HOST_COHERENT
or HOST_CACHED
.
sourcepub const DEVICE_COHERENT: Self = _
pub const DEVICE_COHERENT: Self = _
Device accesses to the memory are automatically made available and visible to other device accesses.
Memory of this type is slower to access by the device, so it is best avoided for general purpose use. Because of its coherence properties, however, it may be useful for debugging.
sourcepub const DEVICE_UNCACHED: Self = _
pub const DEVICE_UNCACHED: Self = _
The memory is not cached on the device.
DEVICE_UNCACHED
memory is always also DEVICE_COHERENT
.
sourcepub const RDMA_CAPABLE: Self = _
pub const RDMA_CAPABLE: Self = _
Other devices can access the memory via remote direct memory access (RDMA).
sourcepub const fn none() -> Self
👎Deprecated since 0.31.0: use empty
instead
pub const fn none() -> Self
empty
insteadReturns a MemoryPropertyFlags
with none of the flags set.
sourcepub const fn intersects(self, other: Self) -> bool
pub const fn intersects(self, other: Self) -> bool
Returns whether any flags are set in both self
and other
.
sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
Returns whether all flags in other
are set in self
.
sourcepub const fn intersection(self, other: Self) -> Self
pub const fn intersection(self, other: Self) -> Self
Returns the intersection of self
and other
.
sourcepub const fn difference(self, other: Self) -> Self
pub const fn difference(self, other: Self) -> Self
Returns self
without the flags set in other
.
sourcepub const fn symmetric_difference(self, other: Self) -> Self
pub const fn symmetric_difference(self, other: Self) -> Self
Returns the flags that are set in self
or other
, but not in both.
Trait Implementations§
source§impl BitAnd for MemoryPropertyFlags
impl BitAnd for MemoryPropertyFlags
source§impl BitAndAssign for MemoryPropertyFlags
impl BitAndAssign for MemoryPropertyFlags
source§fn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresource§impl BitOr for MemoryPropertyFlags
impl BitOr for MemoryPropertyFlags
source§impl BitOrAssign for MemoryPropertyFlags
impl BitOrAssign for MemoryPropertyFlags
source§fn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresource§impl BitXor for MemoryPropertyFlags
impl BitXor for MemoryPropertyFlags
source§impl BitXorAssign for MemoryPropertyFlags
impl BitXorAssign for MemoryPropertyFlags
source§fn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresource§impl Clone for MemoryPropertyFlags
impl Clone for MemoryPropertyFlags
source§fn clone(&self) -> MemoryPropertyFlags
fn clone(&self) -> MemoryPropertyFlags
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MemoryPropertyFlags
impl Debug for MemoryPropertyFlags
source§impl Default for MemoryPropertyFlags
impl Default for MemoryPropertyFlags
source§impl From<MemoryPropertyFlags> for MemoryPropertyFlags
impl From<MemoryPropertyFlags> for MemoryPropertyFlags
source§fn from(val: MemoryPropertyFlags) -> Self
fn from(val: MemoryPropertyFlags) -> Self
source§impl From<MemoryPropertyFlags> for MemoryPropertyFlags
impl From<MemoryPropertyFlags> for MemoryPropertyFlags
source§fn from(val: MemoryPropertyFlags) -> Self
fn from(val: MemoryPropertyFlags) -> Self
source§impl Hash for MemoryPropertyFlags
impl Hash for MemoryPropertyFlags
source§impl PartialEq for MemoryPropertyFlags
impl PartialEq for MemoryPropertyFlags
source§fn eq(&self, other: &MemoryPropertyFlags) -> bool
fn eq(&self, other: &MemoryPropertyFlags) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Sub for MemoryPropertyFlags
impl Sub for MemoryPropertyFlags
source§impl SubAssign for MemoryPropertyFlags
impl SubAssign for MemoryPropertyFlags
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more