UraniumCompute 0.1.0
A GPU accelerated parallel task scheduler
VulkanDeviceMemory.h
1#pragma once
2#include <UnCompute/Backend/DeviceMemoryBase.h>
3#include <UnCompute/Memory/Memory.h>
4#include <UnCompute/VulkanBackend/VulkanInclude.h>
5
6namespace UN
7{
9 {
10 VkDeviceMemory m_NativeMemory = VK_NULL_HANDLE;
11 UInt32 m_MemoryTypeIndex = 0;
12 bool m_Mapped = false;
13
14 protected:
15 ResultCode InitInternal(const DescriptorType& desc) override;
16
17 public:
18 explicit VulkanDeviceMemory(IComputeDevice* pDevice);
19 ~VulkanDeviceMemory() override;
20
21 ResultCode Map(UInt64 byteOffset, UInt64 byteSize, void** ppData) override;
22 void Unmap() override;
23 bool IsCompatible(IDeviceObject* pObject, UInt64 sizeLimit) override;
24 bool IsCompatible(IDeviceObject* pObject) override;
25 void Reset() override;
26
27 [[nodiscard]] inline VkDeviceMemory GetNativeMemory() const
28 {
29 return m_NativeMemory;
30 }
31
32 inline static ResultCode Create(IComputeDevice* pDevice, IDeviceMemory** ppMemory)
33 {
34 *ppMemory = AllocateObject<VulkanDeviceMemory>(pDevice);
35 (*ppMemory)->AddRef();
36 return ResultCode::Success;
37 }
38 };
39} // namespace UN
Definition: DeviceMemoryBase.h:8
Interface for all backend-specific compute devices.
Definition: IComputeDevice.h:38
This class holds a handle to backend-specific memory.
Definition: IDeviceMemory.h:31
Base interface for all compute backend objects.
Definition: IDeviceObject.h:30
Definition: VulkanDeviceMemory.h:9
void Reset() override
Reset the object to uninitialized state.
Definition: VulkanDeviceMemory.cpp:80
void Unmap() override
Unmap the mapped memory.
Definition: VulkanDeviceMemory.cpp:49
bool IsCompatible(IDeviceObject *pObject, UInt64 sizeLimit) override
Check if the memory is compatible with an object.
Definition: VulkanDeviceMemory.cpp:69
ResultCode Map(UInt64 byteOffset, UInt64 byteSize, void **ppData) override
Map the device memory to access it from the host.
Definition: VulkanDeviceMemory.cpp:26
Device memory descriptor.
Definition: IDeviceMemory.h:12