Struct vulkano::memory::DeviceMemory
source · pub struct DeviceMemory { /* private fields */ }
Expand description
Represents memory that has been allocated.
The destructor of DeviceMemory
automatically frees the memory.
Example
use vulkano::memory::DeviceMemory;
let mem_ty = device.physical_device().memory_types().next().unwrap();
// Allocates 1KB of memory.
let memory = DeviceMemory::alloc(device.clone(), mem_ty, 1024).unwrap();
Implementations
sourceimpl DeviceMemory
impl DeviceMemory
sourcepub fn alloc(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize
) -> Result<DeviceMemory, DeviceMemoryAllocError>
pub fn alloc(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize
) -> Result<DeviceMemory, DeviceMemoryAllocError>
Allocates a chunk of memory from the device.
Some platforms may have a limit on the maximum size of a single allocation. For example, certain systems may fail to create allocations with a size greater than or equal to 4GB.
Panic
- Panics if
size
is 0. - Panics if
memory_type
doesn’t belong to the same physical device asdevice
.
sourcepub fn dedicated_alloc(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize,
resource: DedicatedAlloc<'_>
) -> Result<DeviceMemory, DeviceMemoryAllocError>
pub fn dedicated_alloc(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize,
resource: DedicatedAlloc<'_>
) -> Result<DeviceMemory, DeviceMemoryAllocError>
Same as alloc
, but allows specifying a resource that will be bound to the memory.
If a buffer or an image is specified in resource
, then the returned memory must not be
bound to a different buffer or image.
If the VK_KHR_dedicated_allocation
extension is enabled on the device, then it will be
used by this method. Otherwise the resource
parameter will be ignored.
sourcepub fn alloc_and_map(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
pub fn alloc_and_map(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
Allocates a chunk of memory and maps it.
Panic
- Panics if
memory_type
doesn’t belong to the same physical device asdevice
. - Panics if the memory type is not host-visible.
sourcepub fn dedicated_alloc_and_map(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize,
resource: DedicatedAlloc<'_>
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
pub fn dedicated_alloc_and_map(
device: Arc<Device>,
memory_type: MemoryType<'_>,
size: usize,
resource: DedicatedAlloc<'_>
) -> Result<MappedDeviceMemory, DeviceMemoryAllocError>
Equivalent of dedicated_alloc
for alloc_and_map
.
sourcepub fn memory_type(&self) -> MemoryType<'_>
pub fn memory_type(&self) -> MemoryType<'_>
Returns the memory type this chunk was allocated on.
Trait Implementations
sourceimpl AsMut<DeviceMemory> for MappedDeviceMemory
impl AsMut<DeviceMemory> for MappedDeviceMemory
sourcefn as_mut(&mut self) -> &mut DeviceMemory
fn as_mut(&mut self) -> &mut DeviceMemory
sourceimpl AsRef<DeviceMemory> for MappedDeviceMemory
impl AsRef<DeviceMemory> for MappedDeviceMemory
sourcefn as_ref(&self) -> &DeviceMemory
fn as_ref(&self) -> &DeviceMemory
sourceimpl Debug for DeviceMemory
impl Debug for DeviceMemory
sourceimpl DeviceOwned for DeviceMemory
impl DeviceOwned for DeviceMemory
sourceimpl Drop for DeviceMemory
impl Drop for DeviceMemory
sourceimpl VulkanObject for DeviceMemory
impl VulkanObject for DeviceMemory
sourceconst TYPE: DebugReportObjectTypeEXT = 8u32
const TYPE: DebugReportObjectTypeEXT = 8u32
DebugReportObjectTypeEXT
of the internal Vulkan handle.