1#pragma once
2
3#include <common/aglGPUCommon.hpp>
4#include <common/aglGPUMemAddr.h>
5#include <heap/seadHeap.h>
6
7namespace al {
8
9class GpuMemAllocator {
10public:
11 struct Block {
12 agl::GPUMemAddrBase addr;
13 agl::GPUMemAddrBase tmpAddr;
14 sead::FixedSafeString<32> name = {""};
15 s32 usedSize = 0;
16 s32 memorySize = 0;
17 s32 tmpMemorySize = 0;
18 };
19
20 GpuMemAllocator();
21 ~GpuMemAllocator();
22
23 void createMemory(const char* name, s32 size, sead::Heap* heap, s32 alignment,
24 agl::MemoryAttribute attribute);
25 Block* findGpuMemInfo(const char* name) const;
26 void createMemoryWithTmp(const char* name, s32 size, s32 tmpSize, sead::Heap* heap,
27 s32 alignment, agl::MemoryAttribute attribute);
28 agl::GPUMemAddrBase allocMemory(const char* name, s32 size, s32 alignment);
29 agl::GPUMemAddrBase getTmpMemoryAddr(const char* name) const;
30 u32 getTmpMemorySize(const char* name) const;
31
32private:
33 sead::PtrArray<Block> mBlocks;
34};
35
36static_assert(sizeof(GpuMemAllocator::Block) == 0x78);
37static_assert(sizeof(GpuMemAllocator) == 0x10);
38
39} // namespace al
40