UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
UN::DeviceMemorySlice Class Referencefinal

A slice of device memory. More...

#include <IDeviceMemory.h>

Public Member Functions

 DeviceMemorySlice (IDeviceMemory *pMemory, UInt64 byteOffset=0, UInt64 byteSize=IDeviceMemory::WholeSize)
 Create a device memory slice. More...
 
IDeviceMemoryGetDeviceMemory () const
 Get the underlying device memory object.
 
UInt64 GetByteOffset () const
 Get slice offset in bytes.
 
UInt64 GetByteSize () const
 Get slice size in bytes.
 
ResultCode Map (void **ppData) const
 Map the part of device memory represented by this slice. More...
 
void * Map () const
 Map the part of device memory represented by this slice. More...
 
ResultCode Map (UInt64 byteOffset, UInt64 byteSize, void **ppData) const
 Map the part of device memory represented by this slice. More...
 
void * Map (UInt64 byteOffset, UInt64 byteSize=IDeviceMemory::WholeSize) const
 Map the part of device memory represented by this slice. More...
 
void Unmap () const
 Unmap the mapped memory. More...
 
bool IsCompatible (IDeviceObject *pObject) const
 Check if the memory is compatible with an object. More...
 

Detailed Description

A slice of device memory.

Constructor & Destructor Documentation

◆ DeviceMemorySlice()

UN::DeviceMemorySlice::DeviceMemorySlice ( IDeviceMemory pMemory,
UInt64  byteOffset = 0,
UInt64  byteSize = IDeviceMemory::WholeSize 
)
inlineexplicit

Create a device memory slice.

Parameters
pMemory- The device memory to create a slice of.
byteOffset- The byte offset of the slice.
byteSize- The byte size of the slice.

Member Function Documentation

◆ IsCompatible()

bool UN::DeviceMemorySlice::IsCompatible ( IDeviceObject pObject) const
inline

Check if the memory is compatible with an object.

The implementation is backend-specific, it not only checks if the size of device memory is greater or equal to the size of memory required by the object, but also check backend's memory type, e.g. Vulkan's memory type bits to be compatible.

Parameters
pObject- The object to check the memory for.
Returns
True if the memory is compatible.

◆ Map() [1/4]

void * UN::DeviceMemorySlice::Map ( ) const
inline

Map the part of device memory represented by this slice.

Returns
The pointer to the mapped memory.

◆ Map() [2/4]

ResultCode UN::DeviceMemorySlice::Map ( UInt64  byteOffset,
UInt64  byteSize,
void **  ppData 
) const
inline

Map the part of device memory represented by this slice.

Parameters
byteOffset- Byte offset of the memory to map within this slice.
byteSize- Size of the part of the memory to map.
ppData- A pointer to the memory where the pointer to the mapped memory will be written.
Returns
ResultCode::Success or an error node.

◆ Map() [3/4]

void * UN::DeviceMemorySlice::Map ( UInt64  byteOffset,
UInt64  byteSize = IDeviceMemory::WholeSize 
) const
inline

Map the part of device memory represented by this slice.

Parameters
byteOffset- Byte offset of the memory to map within this slice.
byteSize- Size of the part of the memory to map.
Returns
The pointer to the mapped memory.

◆ Map() [4/4]

ResultCode UN::DeviceMemorySlice::Map ( void **  ppData) const
inline

Map the part of device memory represented by this slice.

Parameters
ppData- A pointer to the memory where the pointer to the mapped memory will be written.
Returns
ResultCode::Success or an error node.

◆ Unmap()

void UN::DeviceMemorySlice::Unmap ( ) const
inline

Unmap the mapped memory.

Note
This function does nothing if the memory was not mapped by calling Map().

The documentation for this class was generated from the following file: