Struct voodoo::DeviceMemory
[−]
[src]
pub struct DeviceMemory { /* fields omitted */ }
A region of device memory.
Destruction
Dropping this DeviceMemory
will cause Device::free_memory
to be called,
automatically releasing any resources associated with it.
Methods
impl DeviceMemory
[src]
pub fn builder<'b>() -> DeviceMemoryBuilder<'b>
[src]
Returns a new DeviceMemoryBuilder
.
pub fn new(
device: Device,
allocation_size: u64,
memory_type_index: u32
) -> VdResult<DeviceMemory>
[src]
device: Device,
allocation_size: u64,
memory_type_index: u32
) -> VdResult<DeviceMemory>
Returns a new DeviceMemory
.
pub unsafe fn map_to_ptr<T>(
&self,
offset_bytes: u64,
size_bytes: u64,
flags: MemoryMapFlags
) -> VdResult<*mut T>
[src]
&self,
offset_bytes: u64,
size_bytes: u64,
flags: MemoryMapFlags
) -> VdResult<*mut T>
Maps a region of this memory object to a pointer.
Use ::unmap_ptr
to unmap this memory.
The flags
argument is reserved for future use and is ignored.
pub unsafe fn unmap_ptr(&self)
[src]
Unmaps memory.
Do not use this unless memory was mapped using ::map_to_ptr
.
Use ::unmap
to unmap memory mapped by ::map
.
pub unsafe fn map<'m, T>(
&'m self,
offset_bytes: u64,
size_bytes: u64,
flags: MemoryMapFlags
) -> VdResult<MemoryMapping<'m, T>>
[src]
&'m self,
offset_bytes: u64,
size_bytes: u64,
flags: MemoryMapFlags
) -> VdResult<MemoryMapping<'m, T>>
Maps a region of memory and returns a mutable reference to it.
Use ::unmap
to unmap.
Use ::copy_from_slice
on the returned slice to easily copy data into
the mapped memory.
Example
let mut mem = self.uniform_buffer_memory.map(0, ubo_bytes, 0)?;
mem.copy_from_slice(&[ubo]);
self.uniform_buffer_memory.unmap(mem);
Note/Reminder: The above example uses a dedicated buffer and memory allocation for demonstration purposes. It is best practice to allocate all memory from one large buffer and use offsets to specify particular parts.
The flags
argument is reserved for future use and is ignored.
Safety
The caller must ensure that care is taken when mapping a buffer
multiple times simultaneously. Use an appropriate synchronization
mechanism such as a std::sync::atomic::AtomicBool
(in the simplest
case) to help coordinate this.
The caller must also ensure that:
offset_bytes
plussize_bytes
is less than the size of this region of memory.- This memory region has been created with the
MemoryPropertyFlags::HOST_VISIBLE
flag.
pub fn unmap<'m, T>(&self, mapping: MemoryMapping<'m, T>)
[src]
Unmaps memory.
pub fn handle(&self) -> DeviceMemoryHandle
[src]
Returns this object's handle.
pub fn device(&self) -> &Device
[src]
Returns a reference to the associated device.
Trait Implementations
impl Debug for DeviceMemory
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for DeviceMemory
[src]
fn clone(&self) -> DeviceMemory
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more