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

Returns a MemoryPropertyFlags with none of the flags set.

👎Deprecated since 0.31.0: Use empty instead.

Returns a MemoryPropertyFlags with none of the flags set.

Returns whether no flags are set in self.

Returns whether any flags are set in both self and other.

Returns whether all flags in other are set in self.

Returns the union of self and other.

Returns the intersection of self and other.

Returns self without the flags set in other.

Returns the flags set in self or other, but not both.

Trait Implementations

The resulting type after applying the & operator.
Performs the & operation. Read more
Performs the &= operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
Performs the |= operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
Performs the ^= operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The resulting type after applying the - operator.
Performs the - operation. Read more
Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.