OpenBarnyard
 
Loading...
Searching...
No Matches
AMemory.h
Go to the documentation of this file.
1#pragma once
3
4#include <cstdint>
5
7{
8public:
9 constexpr AMemoryPool( const TCHAR* a_szName, int a_iHeapIndex, size_t a_uiSize, int a_iUnk1, int a_iUnk2 )
10 : m_szName( a_szName ), m_iHeapIndex( a_iHeapIndex ), m_uiSize( a_uiSize ), m_iUnk1( a_iUnk1 ), m_iUnk2( a_iUnk2 )
11 {
12 }
13
14 const TCHAR* GetName() const { return m_szName; }
15 int GetHeapIndex() const { return m_iHeapIndex; }
16 size_t GetSize() const { return m_uiSize; }
17 TINT GetUnk2() const { return m_iUnk2; }
18
19private:
20 const TCHAR* m_szName;
21 TINT m_iHeapIndex;
22 size_t m_uiSize;
23 TINT m_iUnk1;
24 TINT m_iUnk2;
25};
26
28{
29public:
30 using POOL = uint32_t;
43
49
50 inline static Toshi::TMemory::MemBlock* s_aMemBlocks[ POOL_NUMOF ];
52
53 inline static constexpr AMemoryPool s_aPools[ POOL_NUMOF ] = {
54#define DEFINE_MEMORY_POOL( NAME, SIZE, UNK1, UNK2 ) AMemoryPool( #NAME, NAME, SIZE, UNK1, UNK2 )
55 DEFINE_MEMORY_POOL( POOL_None, 0, 0, 0 ),
56 DEFINE_MEMORY_POOL( POOL_StringPool, 0x00100000, 0x00200000, 0x00200000 ),
57 DEFINE_MEMORY_POOL( POOL_Misc, 0x00080000, 0x001c2000, 0x00096000 ),
58 DEFINE_MEMORY_POOL( POOL_Collision, 0x00008000, 0x00008000, 0 ),
59 DEFINE_MEMORY_POOL( POOL_Sound, 0x00040000, 0x00040000, 0x00010000 ),
60 DEFINE_MEMORY_POOL( POOL_Debug, 0x00fa0000, 0x00fa0000, 0 ),
61 DEFINE_MEMORY_POOL( POOL_MemTrace, 0x00000400, 0x00003000, 0 ),
62 DEFINE_MEMORY_POOL( POOL_Viewport, 0x00004000, 0x00004000, 0 ),
63#undef DEFINE_MEMORY_POOL
64 };
65
66public:
67 static void CreatePool( POOL a_ePool );
68 static Toshi::T2Allocator* GetAllocator( POOL a_ePool );
69 static Toshi::TMemory::MemBlock* GetMemBlock( POOL a_ePool );
70};
char TCHAR
Definition Typedefs.h:20
int TINT
Definition Typedefs.h:7
#define DEFINE_MEMORY_POOL(NAME, SIZE, UNK1, UNK2)
size_t GetSize() const
Definition AMemory.h:16
int GetHeapIndex() const
Definition AMemory.h:15
const TCHAR * GetName() const
Definition AMemory.h:14
constexpr AMemoryPool(const TCHAR *a_szName, int a_iHeapIndex, size_t a_uiSize, int a_iUnk1, int a_iUnk2)
Definition AMemory.h:9
TINT GetUnk2() const
Definition AMemory.h:17
@ POOL_Viewport
Definition AMemory.h:40
@ POOL_Misc
Definition AMemory.h:35
@ POOL_MemTrace
Definition AMemory.h:39
@ POOL_Sound
Definition AMemory.h:37
@ POOL_Collision
Definition AMemory.h:36
@ POOL_None
Definition AMemory.h:33
@ POOL_NUMOF
Definition AMemory.h:41
@ POOL_StringPool
Definition AMemory.h:34
@ POOL_Debug
Definition AMemory.h:38
static Toshi::T2Allocator * GetAllocator(POOL a_ePool)
Definition AMemory.cpp:31
static constexpr AMemoryPool s_aPools[POOL_NUMOF]
Definition AMemory.h:53
static Toshi::TMemory::MemBlock * s_aMemBlocks[POOL_NUMOF]
Definition AMemory.h:50
static Toshi::TMemory::MemBlock * GetMemBlock(POOL a_ePool)
Definition AMemory.cpp:38
uint32_t POOL
Definition AMemory.h:30
static void CreatePool(POOL a_ePool)
Definition AMemory.cpp:12
static AllocatorList s_AllocatorList
Definition AMemory.h:51
AMemoryPoolAllocator aAllocators[POOL_NUMOF]
Definition AMemory.h:47