Prepping for new vmem layout

This commit is contained in:
Edward R. Gonzalez 2024-03-05 10:15:44 -05:00
parent bd6e79d005
commit 5147a53c4d
2 changed files with 46 additions and 7 deletions

View File

@ -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,

View File

@ -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 )