This commit is contained in:
Martin Slachta
2026-07-18 14:31:15 +02:00
commit a04f0dc262
3343 changed files with 1140208 additions and 0 deletions
@@ -0,0 +1,41 @@
#pragma once
#include "resources/GpuAllocator.h"
#include "vk_mem_alloc.h"
class DefaultAllocator : public GpuAllocator {
private:
VmaAllocator m_allocator;
public:
explicit DefaultAllocator(Gpu *pGpu);
int create_image(ImageCreateInfo *pImageInfo,
MemoryAllocationInfo *pAllocInfo,
Image *pOut) override;
int create_buffer(BufferCreateInfo *pBufferInfo,
MemoryAllocationInfo *pAllocInfo,
Buffer *pOut) override;
void destroy_buffer(Buffer *pBuffer) override {
}
void destroy_image(Image *pImage) override {
}
inline void map(GpuAllocation& allocation, void **pData) override {
vmaMapMemory(m_allocator, allocation.allocation, pData);
}
inline void unmap(GpuAllocation& allocation) override {
vmaUnmapMemory(m_allocator, allocation.allocation);
}
inline VkResult flush(GpuAllocation& allocation, size_t offset, size_t size) override {
vmaFlushAllocation(m_allocator, allocation.allocation, offset, size);
return vmaInvalidateAllocation(m_allocator, allocation.allocation, offset, size);
}
};