diff options
author | Fox Caminiti <fox@foxcam.net> | 2022-10-06 14:30:48 -0400 |
---|---|---|
committer | Fox Caminiti <fox@foxcam.net> | 2022-10-06 14:30:48 -0400 |
commit | 0b0aa3b06fac0bcdeb31d5e2211d1ba149531692 (patch) | |
tree | 91f0d9689151b7fb985de50b2c8b12ccd7a65440 /memory.cpp | |
parent | a4c1e537b0cb2540535357d880e46f63b38c134f (diff) |
GL renderer preparation
Diffstat (limited to 'memory.cpp')
-rw-r--r-- | memory.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -30,7 +30,6 @@ Memory_Block_AllocateNew(memory *Memory, memory_table_list TableName) Index++; } Memory_Zero(Address_Playhead, Table->Block_ElementSize); - *Address_Playhead = 1; return Index; } @@ -41,7 +40,6 @@ Memory_Block_AddressAtIndex(memory *Memory, memory_table_list TableName, uint32 memory_table *Table = &Memory->Slot[TableName]; Assert(Table->Block_ElementSize != 0); uint8 *Address = (uint8 *)Table->Address + (Table->Block_ElementSize * Index); - Assert(*Address == 1); return (void *)Address; } @@ -49,7 +47,36 @@ static void * Memory_Block_AllocateAddress(memory *Memory, memory_table_list TableName) { uint16 FileIndex = Memory_Block_AllocateNew(Memory, TableName); - return Memory_Block_AddressAtIndex(Memory, F_File, FileIndex); + return Memory_Block_AddressAtIndex(Memory, TableName, FileIndex); +} + +static void * +Memory_PushScratch(memory *Memory, uint64 Size) { + memory_table *Table = &Memory->Slot[B_ScratchSpace]; + uint8 *Address = ((uint8 *)Table->Address + Memory->ScratchPos); + Memory->ScratchPos += Size; +#if DEBUG + Debug.ScratchSize[Debug.ScratchState] = Size; + Debug.ScratchState++; +#endif + return (void *)Address; +} + +static void +Memory_PopScratch(memory *Memory, uint64 Size) { + memory_table *Table = &Memory->Slot[B_ScratchSpace]; + Memory->ScratchPos -= Size; +#if DEBUG + Debug.ScratchState--; + Assert(Debug.ScratchSize[Debug.ScratchState] == Size); +#endif +} + +static void * +Memory_AddressAtOffset(memory *Memory, memory_table_list TableName, uint64 Offset) +{ + memory_table *Table = &Memory->Slot[TableName]; + return (void *)((uint8 *)Table->Address + Offset); } #if 0 |