Struct vulkano::memory::MemoryPropertyFlags
source · pub struct MemoryPropertyFlags {
pub device_local: bool,
pub host_visible: bool,
pub host_coherent: bool,
pub host_cached: bool,
pub lazily_allocated: bool,
pub protected: bool,
pub device_coherent: bool,
pub device_uncached: bool,
pub rdma_capable: bool,
pub _ne: NonExhaustive,
}
Expand description
Properties of a memory type.
Fields
device_local: bool
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.
host_visible: bool
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.
host_coherent: bool
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.
host_cached: bool
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.
lazily_allocated: bool
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
.
protected: bool
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
.
device_coherent: bool
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.
device_uncached: bool
The memory is not cached on the device.
device_uncached
memory is always also device_coherent
.
rdma_capable: bool
Other devices can access the memory via remote direct memory access (RDMA).
_ne: NonExhaustive
Implementations
sourceimpl MemoryPropertyFlags
impl MemoryPropertyFlags
sourcepub const fn none() -> Self
👎Deprecated since 0.31.0: Use empty
instead.
pub const fn none() -> Self
empty
instead.Returns 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 set in self
or other
, but not both.
Trait Implementations
sourceimpl BitAnd<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitAnd<MemoryPropertyFlags> for MemoryPropertyFlags
type Output = MemoryPropertyFlags
type Output = MemoryPropertyFlags
&
operator.sourceimpl BitAndAssign<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitAndAssign<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn bitand_assign(&mut self, rhs: Self)
fn bitand_assign(&mut self, rhs: Self)
&=
operation. Read moresourceimpl BitOr<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitOr<MemoryPropertyFlags> for MemoryPropertyFlags
type Output = MemoryPropertyFlags
type Output = MemoryPropertyFlags
|
operator.sourceimpl BitOrAssign<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitOrAssign<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn bitor_assign(&mut self, rhs: Self)
fn bitor_assign(&mut self, rhs: Self)
|=
operation. Read moresourceimpl BitXor<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitXor<MemoryPropertyFlags> for MemoryPropertyFlags
type Output = MemoryPropertyFlags
type Output = MemoryPropertyFlags
^
operator.sourceimpl BitXorAssign<MemoryPropertyFlags> for MemoryPropertyFlags
impl BitXorAssign<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn bitxor_assign(&mut self, rhs: Self)
fn bitxor_assign(&mut self, rhs: Self)
^=
operation. Read moresourceimpl Clone for MemoryPropertyFlags
impl Clone for MemoryPropertyFlags
sourcefn clone(&self) -> MemoryPropertyFlags
fn clone(&self) -> MemoryPropertyFlags
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for MemoryPropertyFlags
impl Debug for MemoryPropertyFlags
sourceimpl Default for MemoryPropertyFlags
impl Default for MemoryPropertyFlags
sourceimpl From<MemoryPropertyFlags> for MemoryPropertyFlags
impl From<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn from(val: MemoryPropertyFlags) -> Self
fn from(val: MemoryPropertyFlags) -> Self
sourceimpl From<MemoryPropertyFlags> for MemoryPropertyFlags
impl From<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn from(val: MemoryPropertyFlags) -> Self
fn from(val: MemoryPropertyFlags) -> Self
sourceimpl Hash for MemoryPropertyFlags
impl Hash for MemoryPropertyFlags
sourceimpl PartialEq<MemoryPropertyFlags> for MemoryPropertyFlags
impl PartialEq<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn eq(&self, other: &MemoryPropertyFlags) -> bool
fn eq(&self, other: &MemoryPropertyFlags) -> bool
sourceimpl Sub<MemoryPropertyFlags> for MemoryPropertyFlags
impl Sub<MemoryPropertyFlags> for MemoryPropertyFlags
type Output = MemoryPropertyFlags
type Output = MemoryPropertyFlags
-
operator.sourceimpl SubAssign<MemoryPropertyFlags> for MemoryPropertyFlags
impl SubAssign<MemoryPropertyFlags> for MemoryPropertyFlags
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more