From 0b0aa3b06fac0bcdeb31d5e2211d1ba149531692 Mon Sep 17 00:00:00 2001 From: Fox Caminiti Date: Thu, 6 Oct 2022 14:30:48 -0400 Subject: GL renderer preparation --- memory.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'memory.cpp') diff --git a/memory.cpp b/memory.cpp index 27ac266..f502eb2 100644 --- a/memory.cpp +++ b/memory.cpp @@ -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 -- cgit v1.2.3