2019-06-26 15:18:31 +08:00
|
|
|
|
#ifndef HGL_GRAPH_VULKAN_MEMORY_INCLUDE
|
|
|
|
|
#define HGL_GRAPH_VULKAN_MEMORY_INCLUDE
|
|
|
|
|
|
2020-10-21 11:43:18 +08:00
|
|
|
|
#include<hgl/graph/VK.h>
|
2019-06-26 15:18:31 +08:00
|
|
|
|
VK_NAMESPACE_BEGIN
|
2022-10-14 17:52:35 +08:00
|
|
|
|
class DeviceMemory
|
2019-06-26 15:18:31 +08:00
|
|
|
|
{
|
|
|
|
|
VkDevice device;
|
|
|
|
|
VkDeviceMemory memory;
|
|
|
|
|
VkMemoryRequirements req;
|
|
|
|
|
uint32_t index;
|
|
|
|
|
uint32_t properties;
|
|
|
|
|
|
2020-11-30 13:58:48 +08:00
|
|
|
|
VkMappedMemoryRange memory_range;
|
2022-03-10 02:01:00 +08:00
|
|
|
|
VkDeviceSize nonCoherentAtomSize;
|
2020-11-30 13:58:48 +08:00
|
|
|
|
|
2019-06-26 15:18:31 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2020-10-21 12:39:22 +08:00
|
|
|
|
friend class GPUDevice;
|
2019-06-26 15:18:31 +08:00
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
DeviceMemory(VkDevice dev,VkDeviceMemory dm,const VkMemoryRequirements &mr,const uint32 i,const uint32_t p,const VkDeviceSize cas);
|
2019-06-26 15:18:31 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
virtual ~DeviceMemory();
|
2019-06-26 15:18:31 +08:00
|
|
|
|
|
|
|
|
|
operator VkDeviceMemory(){return memory;}
|
|
|
|
|
|
|
|
|
|
const VkMemoryRequirements &GetRequirements ()const{return req;}
|
|
|
|
|
|
|
|
|
|
const uint32_t GetType ()const{return req.memoryTypeBits;}
|
|
|
|
|
const VkDeviceSize GetSize ()const{return req.size;}
|
2021-02-10 18:53:39 +08:00
|
|
|
|
const VkDeviceSize GetAlignment ()const{return req.alignment;}
|
2019-06-26 15:18:31 +08:00
|
|
|
|
const uint32_t GetTypeIndex ()const{return index;}
|
|
|
|
|
const uint32_t GetProperties ()const{return properties;}
|
|
|
|
|
|
2020-08-08 20:12:37 +08:00
|
|
|
|
void * Map ();
|
|
|
|
|
void * Map (VkDeviceSize offset,VkDeviceSize size);
|
|
|
|
|
void Unmap ();
|
2019-06-26 15:18:31 +08:00
|
|
|
|
|
2020-08-08 20:12:37 +08:00
|
|
|
|
bool Write (const void *ptr,VkDeviceSize start, VkDeviceSize size);
|
|
|
|
|
bool Write (const void *ptr, VkDeviceSize size) {return Write(ptr,0,size);}
|
|
|
|
|
bool Write (const void *ptr) {return Write(ptr,0,req.size);}
|
2019-06-26 17:08:01 +08:00
|
|
|
|
|
2020-08-08 20:12:37 +08:00
|
|
|
|
bool BindBuffer (VkBuffer buffer);
|
|
|
|
|
bool BindImage (VkImage image);
|
2020-11-30 13:58:48 +08:00
|
|
|
|
|
|
|
|
|
void Flush (VkDeviceSize,VkDeviceSize);
|
|
|
|
|
void Flush (VkDeviceSize size){Flush(0,size);}
|
2022-10-14 17:52:35 +08:00
|
|
|
|
};//class DeviceMemory
|
2019-06-26 15:18:31 +08:00
|
|
|
|
VK_NAMESPACE_END
|
|
|
|
|
#endif//HGL_GRAPH_VULKAN_MEMORY_INCLUDE
|