UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
UN::VulkanDeviceMemory Class Referencefinal
Inheritance diagram for UN::VulkanDeviceMemory:
UN::DeviceMemoryBase UN::DeviceObjectBase< IDeviceMemory > UN::Object< IDeviceMemory > UN::IDeviceMemory UN::IDeviceObject UN::IObject

Public Member Functions

 VulkanDeviceMemory (IComputeDevice *pDevice)
 
ResultCode Map (UInt64 byteOffset, UInt64 byteSize, void **ppData) override
 Map the device memory to access it from the host. More...
 
void Unmap () override
 Unmap the mapped memory. More...
 
bool IsCompatible (IDeviceObject *pObject, UInt64 sizeLimit) override
 Check if the memory is compatible with an object. More...
 
bool IsCompatible (IDeviceObject *pObject) override
 Check if the memory is compatible with an object. More...
 
void Reset () override
 Reset the object to uninitialized state. More...
 
VkDeviceMemory GetNativeMemory () const
 
- Public Member Functions inherited from UN::DeviceMemoryBase
ResultCode Init (const DescriptorType &desc) final
 Allocate memory with specified descriptor. More...
 
- Public Member Functions inherited from UN::DeviceObjectBase< IDeviceMemory >
const DescriptorTypeGetDesc () const override
 
std::string_view GetDebugName () const override
 
IComputeDeviceGetDevice () const override
 
UInt32 Release () override
 
- Public Member Functions inherited from UN::Object< IDeviceMemory >
UInt32 Release () override
 
 Object (const Object &)=delete
 
 Object (Object &&)=delete
 
UInt32 AddRef () override
 Add a strong reference to the object. More...
 
void AttachRefCounter (ReferenceCounter *pRefCounter) override
 Attach a reference counter to the object. More...
 
ReferenceCounterGetRefCounter () override
 Get reference counter attached to this object. More...
 
virtual const DescriptorTypeGetDesc () const =0
 
virtual ResultCode Init (const DescriptorType &desc)=0
 Allocate memory with specified descriptor. More...
 
virtual ResultCode Map (UInt64 byteOffset, UInt64 byteSize, void **ppData)=0
 Map the device memory to access it from the host. More...
 
virtual void Unmap ()=0
 Unmap the mapped memory. More...
 
virtual bool IsCompatible (IDeviceObject *pObject, UInt64 sizeLimit)=0
 Check if the memory is compatible with an object. More...
 
virtual bool IsCompatible (IDeviceObject *pObject)=0
 Check if the memory is compatible with an object. More...
 
virtual std::string_view GetDebugName () const =0
 Get debug name of the object.
 
virtual void Reset ()=0
 Reset the object to uninitialized state. More...
 
virtual IComputeDeviceGetDevice () const =0
 Get the compute device this object was created on. More...
 
virtual UInt32 AddRef ()=0
 Add a strong reference to object's reference counter. More...
 
virtual UInt32 Release ()=0
 Remove a strong reference from object's reference counter. More...
 
virtual void AttachRefCounter (ReferenceCounter *counter)=0
 Attach a ReferenceCounter to this object. More...
 
virtual ReferenceCounterGetRefCounter ()=0
 Get reference counter that belongs to this object. More...
 

Static Public Member Functions

static ResultCode Create (IComputeDevice *pDevice, IDeviceMemory **ppMemory)
 

Protected Member Functions

ResultCode InitInternal (const DescriptorType &desc) override
 
- Protected Member Functions inherited from UN::DeviceMemoryBase
virtual ResultCode InitInternal (const DescriptorType &desc)=0
 
 DeviceMemoryBase (IComputeDevice *pDevice)
 
- Protected Member Functions inherited from UN::DeviceObjectBase< IDeviceMemory >
void Init (std::string_view name, const DescriptorType &desc)
 Common device object initializer. More...
 
 DeviceObjectBase (IComputeDevice *pDevice)
 
- Protected Member Functions inherited from UN::Object< IDeviceMemory >
UInt32 Release (F &&destroyCallback)
 

Additional Inherited Members

- Public Types inherited from UN::DeviceObjectBase< IDeviceMemory >
using DescriptorType = typename TInterface::DescriptorType
 
- Public Types inherited from UN::IDeviceMemory
using DescriptorType = DeviceMemoryDesc
 
- Static Public Attributes inherited from UN::IDeviceMemory
static constexpr UInt64 WholeSize = std::numeric_limits<UInt64>::max()
 Special constant that represents the whole memory size.
 
- Protected Attributes inherited from UN::DeviceObjectBase< IDeviceMemory >
Ptr< IComputeDevicem_pDevice
 
DescriptorType m_Desc
 
std::string m_Name
 

Member Function Documentation

◆ InitInternal()

ResultCode UN::VulkanDeviceMemory::InitInternal ( const DescriptorType desc)
overrideprotectedvirtual

Implements UN::DeviceMemoryBase.

◆ IsCompatible() [1/2]

bool UN::VulkanDeviceMemory::IsCompatible ( IDeviceObject pObject)
overridevirtual

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.

Implements UN::IDeviceMemory.

◆ IsCompatible() [2/2]

bool UN::VulkanDeviceMemory::IsCompatible ( IDeviceObject pObject,
UInt64  sizeLimit 
)
overridevirtual

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 checks backend's memory type, e.g. Vulkan's memory type bits to be compatible.

Parameters
pObject- The object to check the memory for.
sizeLimit- Maximum size of memory in bytes allowed for the object to occupy.
Returns
True if the memory is compatible.

Implements UN::IDeviceMemory.

◆ Map()

ResultCode UN::VulkanDeviceMemory::Map ( UInt64  byteOffset,
UInt64  byteSize,
void **  ppData 
)
overridevirtual

Map the device memory to access it from the host.

Parameters
byteOffset- Byte offset of the memory to map.
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.
Note
This function is only valid to use if the memory was allocated with MemoryKindFlags::HostAccessible flag.
Returns
ResultCode::Success or an error node.

Implements UN::IDeviceMemory.

◆ Reset()

void UN::VulkanDeviceMemory::Reset ( )
overridevirtual

Reset the object to uninitialized state.

Implements UN::IDeviceObject.

◆ Unmap()

void UN::VulkanDeviceMemory::Unmap ( )
overridevirtual

Unmap the mapped memory.

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

Implements UN::IDeviceMemory.


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