From 5147a53c4dd903b9b9d16dbff5e0d8a136721290 Mon Sep 17 00:00:00 2001
From: Ed_ <edwardgz@gmail.com>
Date: Tue, 5 Mar 2024 10:15:44 -0500
Subject: [PATCH] Prepping for new vmem layout

---
 code/env.odin       | 31 +++++++++++++++++++++++++++++++
 code/host/host.odin | 22 +++++++++++++++-------
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/code/env.odin b/code/env.odin
index 101f1a5..4134eae 100644
--- a/code/env.odin
+++ b/code/env.odin
@@ -10,11 +10,28 @@ import rl "vendor:raylib"
 
 Memory_App : Memory
 
+// TODO(Ed) : Make this obsolete
 Memory_Base_Address    :: Terabyte * 1
 Memory_Chunk_Size      :: 2 * Gigabyte
 Memory_Persistent_Size :: 256 * Megabyte
 Memory_Trans_Temp_Szie :: (Memory_Chunk_Size - Memory_Persistent_Size ) / 2
 
+Memory_Base_Address_Persistent :: Terabyte * 1
+Memory_Base_Address_Frame      :: Memory_Base_Address_Persistent + Memory_Reserve_Persistent
+
+// TODO(Ed) : This is based off of using 32 gigs of my (Ed) as a maximum.
+// Later on this has to be adjusted to be ratios based on user's system memory.
+Memory_Reserve_Persistent  :: 8  * Gigabyte
+Memory_Reserve_Frame       :: 4  * Gigabyte
+Memory_Reserve_Transient   :: 4  * Gigabyte
+Memory_Reserve_FilesBuffer :: 16 * Gigabyte
+
+// TODO(Ed) : These are high for ease of use, they eventually need to be drastically minimized.
+Memory_Commit_Initial_Persistent :: 256 * Megabyte
+Memory_Commit_Initial_Frame      :: 1   * Gigabyte
+Memory_Commit_Initial_Transient  :: 1   * Gigabyte
+Memory_Commit_Initial_Filebuffer :: 2   * Gigabyte
+
 // TODO(Ed): There is an issue with mutex locks on the tracking allocator..
 Use_TrackingAllocator :: false
 
@@ -84,7 +101,21 @@ load_snapshot :: proc( snapshot : [^]u8 ) {
 	mem.copy_non_overlapping( live_ptr, snapshot, Memory_Chunk_Size )
 }
 
+MemoryConfig :: struct {
+	reserve_persistent : uint,
+	reserve_frame      : uint,
+	reserve_transient  : uint,
+	reserve_filebuffer : uint,
+
+	commit_initial_persistent : uint,
+	commit_initial_frame      : uint,
+	commit_initial_transient  : uint,
+	commit_initial_filebuffer : uint,
+}
+
 AppConfig :: struct {
+	using memory : MemoryConfig,
+
 	resolution_width  : uint,
 	resolution_height : uint,
 	refresh_rate      : uint,
diff --git a/code/host/host.odin b/code/host/host.odin
index 2ea88d4..08e3c39 100644
--- a/code/host/host.odin
+++ b/code/host/host.odin
@@ -1,3 +1,13 @@
+/* Sectr Host Executable
+Manages the client module (sectr) application & loads its required memory to operate.
+Reserves the virtual memory spaces for the following:
+* Persistent
+* Frame
+* Transient
+* FilesBuffer
+
+Currently the prototype has hot-reload always enabled, eventually there will be conditional compliation to omit if when desired.
+*/
 package host
 
 //region Grime & Dependencies
@@ -139,15 +149,13 @@ setup_memory :: proc() -> VMemChunk
 	return memory;
 }
 
-load_sectr_api :: proc( version_id : i32 ) -> sectr.ModuleAPI
+load_sectr_api :: proc( version_id : i32 ) -> (loaded_module : sectr.ModuleAPI)
 {
-	loaded_module : sectr.ModuleAPI
-
 	write_time, result := os.last_write_time_by_name("sectr.dll")
 	if result != os.ERROR_NONE {
 		log( "Could not resolve the last write time for sectr.dll", LogLevel.Warning )
 		runtime.debug_trap()
-		return {}
+		return
 	}
 
 	live_file := Path_Sectr_Live_Module
@@ -157,7 +165,7 @@ load_sectr_api :: proc( version_id : i32 ) -> sectr.ModuleAPI
 	if ! load_result {
 		log( "Failed to load the sectr module.", LogLevel.Warning )
 		runtime.debug_trap()
-		return {}
+		return
 	}
 
 	startup    := cast( type_of( sectr.startup        )) os_lib_get_proc( lib, "startup" )
@@ -174,7 +182,7 @@ load_sectr_api :: proc( version_id : i32 ) -> sectr.ModuleAPI
 	if clean_temp == nil do log("Failed to load sector.clean_temp symbol", LogLevel.Warning )
 	if missing_symbol {
 		runtime.debug_trap()
-		return {}
+		return
 	}
 
 	log("Loaded sectr API")
@@ -189,7 +197,7 @@ load_sectr_api :: proc( version_id : i32 ) -> sectr.ModuleAPI
 		tick       = tick,
 		clean_temp = clean_temp,
 	}
-	return loaded_module
+	return
 }
 
 unload_sectr_api :: proc( module : ^ sectr.ModuleAPI )