ULRE/inc/hgl/graph/VKMemoryAllocator.h

43 lines
1.1 KiB
C
Raw Normal View History

2021-03-25 20:00:19 +08:00
#ifndef HGL_GRAPH_VULKAN_MEMORY_ALLOCATOR_INCLUDE
#define HGL_GRAPH_VULKAN_MEMORY_ALLOCATOR_INCLUDE
#include<hgl/graph/VK.h>
#include<hgl/type/MemoryAllocator.h>
VK_NAMESPACE_BEGIN
class VKMemoryAllocator:public AbstractMemoryAllocator
{
GPUDevice *device;
uint32_t buffer_usage_flag_bits;
DeviceBuffer *gpu_buffer;
2021-03-25 20:00:19 +08:00
VkDeviceSize range; //ubo之类需要一个一次访问范围
2021-03-25 20:00:19 +08:00
protected:
bool AllocMemory() override;
2021-03-25 20:00:19 +08:00
public:
const bool CanRealloc ()const override{return false;}
const uint32_t GetBufferUsageFlagBits ()const{return buffer_usage_flag_bits;}
2023-03-28 22:24:22 +08:00
DeviceBuffer * GetBuffer (){return gpu_buffer;}
2021-03-25 20:00:19 +08:00
public:
VKMemoryAllocator(GPUDevice *,const uint32_t flags,const VkDeviceSize r);
2021-03-25 20:00:19 +08:00
~VKMemoryAllocator();
void Free() override {/* DON'T RUN ANY OPERATION.*/}
void Flush(const VkDeviceSize);
bool Write(const void *source,const uint64 offset,const uint64 size) override;
2021-03-25 20:00:19 +08:00
};//class VKMemoryAllocator:public AbstractMemoryAllocator
VK_NAMESPACE_END
#endif//HGL_GRAPH_VULKAN_MEMORY_ALLOCATOR_INCLUDE