OpenBarnyard
 
Loading...
Searching...
No Matches
AMemory Class Reference

#include <AMemory.h>

Classes

struct  AllocatorList
 

Public Types

enum  POOL_ : POOL {
  POOL_None = 0 , POOL_StringPool , POOL_Misc , POOL_Collision ,
  POOL_Sound , POOL_Debug , POOL_MemTrace , POOL_Viewport ,
  POOL_NUMOF = 8
}
 
using POOL = uint32_t
 

Static Public Member Functions

static void CreatePool (POOL a_ePool)
 
static Toshi::T2Allocator * GetAllocator (POOL a_ePool)
 
static Toshi::TMemory::MemBlock * GetMemBlock (POOL a_ePool)
 

Static Public Attributes

static Toshi::TMemory::MemBlock * s_aMemBlocks [POOL_NUMOF]
 
static AllocatorList s_AllocatorList
 
static constexpr AMemoryPool s_aPools [POOL_NUMOF]
 

Detailed Description

Definition at line 27 of file AMemory.h.

Member Typedef Documentation

◆ POOL

using AMemory::POOL = uint32_t

Definition at line 30 of file AMemory.h.

Member Enumeration Documentation

◆ POOL_

Enumerator
POOL_None 
POOL_StringPool 
POOL_Misc 
POOL_Collision 
POOL_Sound 
POOL_Debug 
POOL_MemTrace 
POOL_Viewport 
POOL_NUMOF 

Definition at line 31 of file AMemory.h.

32 {
33 POOL_None = 0,
41 POOL_NUMOF = 8
42 };
@ 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

Member Function Documentation

◆ CreatePool()

void AMemory::CreatePool ( POOL a_ePool)
static

Definition at line 12 of file AMemory.cpp.

13{
14 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
15
16 auto& rPool = s_aPools[ a_ePool ];
17 TMemory::MemBlock* pAllocOnHeap = ( rPool.GetHeapIndex() == a_ePool ) ?
18 TNULL :
19 s_aMemBlocks[ rPool.GetHeapIndex() ];
20
22 rPool.GetSize(),
23 rPool.GetName(),
24 pAllocOnHeap,
25 rPool.GetUnk2()
26 );
27
28 s_AllocatorList.aAllocators[ a_ePool ].SetMemBlock( s_aMemBlocks[ a_ePool ] );
29}
#define TASSERT(X,...)
Definition Defines.h:138
#define TNULL
Definition Typedefs.h:23
TMemory * g_pMemory
Definition TMemory.cpp:131
MemBlock * CreateMemBlock(TSIZE a_uiSize, const TCHAR *a_szName, MemBlock *a_pOwnerBlock, TINT a_iUnused)
Creates a new memory block.
Definition TMemory.cpp:488
static constexpr AMemoryPool s_aPools[POOL_NUMOF]
Definition AMemory.h:53
static Toshi::TMemory::MemBlock * s_aMemBlocks[POOL_NUMOF]
Definition AMemory.h:50
static AllocatorList s_AllocatorList
Definition AMemory.h:51

◆ GetAllocator()

T2Allocator * AMemory::GetAllocator ( POOL a_ePool)
static

Definition at line 31 of file AMemory.cpp.

32{
33 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
34
35 return &s_AllocatorList.aAllocators[ a_ePool ];
36}

◆ GetMemBlock()

TMemory::MemBlock * AMemory::GetMemBlock ( POOL a_ePool)
static

Definition at line 38 of file AMemory.cpp.

39{
40 TASSERT( a_ePool >= POOL_None && a_ePool < POOL_NUMOF );
41
42 return s_aMemBlocks[ a_ePool ];
43}

Member Data Documentation

◆ s_AllocatorList

AllocatorList AMemory::s_AllocatorList
inlinestatic

Definition at line 51 of file AMemory.h.

◆ s_aMemBlocks

Toshi::TMemory::MemBlock* AMemory::s_aMemBlocks[POOL_NUMOF]
inlinestatic

Definition at line 50 of file AMemory.h.

◆ s_aPools

AMemoryPool AMemory::s_aPools[POOL_NUMOF]
inlinestaticconstexpr
Initial value:
= {
#define DEFINE_MEMORY_POOL( NAME, SIZE, UNK1, UNK2 )
AMemoryPool( "POOL_None", POOL_None, 0, 0, 0 ) ,
AMemoryPool( "POOL_StringPool", POOL_StringPool, 0x00100000, 0x00200000, 0x00200000 ) ,
AMemoryPool( "POOL_Misc", POOL_Misc, 0x00080000, 0x001c2000, 0x00096000 ) ,
AMemoryPool( "POOL_Collision", POOL_Collision, 0x00008000, 0x00008000, 0 ) ,
AMemoryPool( "POOL_Sound", POOL_Sound, 0x00040000, 0x00040000, 0x00010000 ) ,
AMemoryPool( "POOL_Debug", POOL_Debug, 0x00fa0000, 0x00fa0000, 0 ) ,
AMemoryPool( "POOL_MemTrace", POOL_MemTrace, 0x00000400, 0x00003000, 0 ) ,
AMemoryPool( "POOL_Viewport", POOL_Viewport, 0x00004000, 0x00004000, 0 ) ,
}

Definition at line 53 of file AMemory.h.

53 {
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 };
#define DEFINE_MEMORY_POOL(NAME, SIZE, UNK1, UNK2)

The documentation for this class was generated from the following files: