Abstraction for memory allocation in different address spaces. More...
#include <memspace.h>
Classes | |
| struct | Ops |
| Function table for memory space operations. More... | |
Public Types | |
| enum | ID { System = 0 , SystemSecure , Default = System } |
| Identifies a memory space. More... | |
Public Member Functions | |
| MemSpace (ID id=Default) | |
| Constructs a MemSpace for the given memory space ID. | |
| const String & | name () const |
| Returns the human-readable name of this memory space. | |
| ID | id () const |
| Returns the memory space identifier. | |
| bool | isHostAccessible (const MemAllocation &alloc) const |
| Returns true if the given allocation is directly accessible from the host CPU. | |
| MemAllocation | alloc (size_t bytes, size_t align) const |
| Allocates memory in this memory space. | |
| void | release (MemAllocation &alloc) const |
| Releases a previously allocated memory region. | |
| bool | copy (const MemAllocation &src, const MemAllocation &dst, size_t bytes) const |
| Copies bytes from a source allocation to a destination allocation. | |
| Error | fill (void *ptr, size_t bytes, char value) const |
| Fills memory with a byte value. | |
Abstraction for memory allocation in different address spaces.
Provides a uniform interface for allocating, releasing, copying, and setting memory that may reside in different memory spaces (e.g. system RAM, GPU memory). Each memory space is identified by an ID and provides its own set of operations.
Memory spaces handle their own lifecycle concerns internally. For example, SystemSecure performs page locking on allocation and secure zeroing on release without exposing those details through the MemSpace API.
Constructs a MemSpace for the given memory space ID.
| id | The memory space to use (default: Default). |
|
inline |
Allocates memory in this memory space.
| bytes | Number of bytes to allocate. |
| align | Required alignment in bytes. |
|
inline |
Copies bytes from a source allocation to a destination allocation.
Called on the source's MemSpace. The source and destination may reside in different memory spaces.
| src | The source allocation. |
| dst | The destination allocation. |
| bytes | Number of bytes to copy. |
Fills memory with a byte value.
| ptr | Destination pointer. |
| bytes | Number of bytes to fill. |
| value | The byte value to fill with. |
ptr is nullptr.
|
inline |
Returns the memory space identifier.
|
inline |
Returns true if the given allocation is directly accessible from the host CPU.
| alloc | The allocation to check. |
Returns the human-readable name of this memory space.
|
inline |
Releases a previously allocated memory region.
| alloc | The allocation to release. Cleared on return. |