summaryrefslogtreecommitdiff
path: root/memory.cpp
diff options
context:
space:
mode:
authorFox Caminiti <fox@foxcam.net>2022-10-06 14:30:48 -0400
committerFox Caminiti <fox@foxcam.net>2022-10-06 14:30:48 -0400
commit0b0aa3b06fac0bcdeb31d5e2211d1ba149531692 (patch)
tree91f0d9689151b7fb985de50b2c8b12ccd7a65440 /memory.cpp
parenta4c1e537b0cb2540535357d880e46f63b38c134f (diff)
GL renderer preparation
Diffstat (limited to 'memory.cpp')
-rw-r--r--memory.cpp33
1 files changed, 30 insertions, 3 deletions
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