diff --git a/run_tree/win32/intel/debug/lumenarium_first_win32.obj b/run_tree/win32/intel/debug/lumenarium_first_win32.obj index 6284fe5..314cb7c 100644 Binary files a/run_tree/win32/intel/debug/lumenarium_first_win32.obj and b/run_tree/win32/intel/debug/lumenarium_first_win32.obj differ diff --git a/src_v2/lumenarium_first.cpp b/src_v2/lumenarium_first.cpp index b4b0b36..fa40abd 100644 --- a/src_v2/lumenarium_first.cpp +++ b/src_v2/lumenarium_first.cpp @@ -7,7 +7,7 @@ lumenarium_init() App_State* state = 0; permanent = bump_allocator_create_reserve(GB(2)); - scratch_ = bump_allocator_create_reserve(GB(8)); + global_scratch_ = bump_allocator_create_reserve(GB(8)); platform_file_jobs_init(); run_tests(); @@ -40,7 +40,7 @@ lumenarium_init() internal void lumenarium_frame_prepare(App_State* state) { - allocator_clear(scratch_); + allocator_clear(global_scratch_); input_state_swap_frames(state->input_state); diff --git a/src_v2/lumenarium_first.h b/src_v2/lumenarium_first.h index 85a5171..2dbf1b8 100644 --- a/src_v2/lumenarium_first.h +++ b/src_v2/lumenarium_first.h @@ -14,10 +14,8 @@ typedef struct App_State App_State; #include "lumenarium_hash.cpp" #include "lumenarium_geometry.h" -global Allocator* scratch_; // gets reset at frame boundaries - -#define scratch_get(ident) Allocator_Scratch ident = Allocator_Scratch(scratch_) - +global Allocator* global_scratch_; // gets reset at frame boundaries +#define scratch_get(ident) Allocator_Scratch ident = Allocator_Scratch(global_scratch_) #include "lumenarium_bsp.h" // Engine diff --git a/src_v2/lumenarium_memory.cpp b/src_v2/lumenarium_memory.cpp index a133df8..ea32b7b 100644 --- a/src_v2/lumenarium_memory.cpp +++ b/src_v2/lumenarium_memory.cpp @@ -94,6 +94,7 @@ struct Allocator_Bump u64 size_committed; u64 size_reserved; u64 page_size; + u64 high_water_mark; }; internal u8* @@ -152,7 +153,7 @@ bump_allocator_alloc_inner(Allocator* allocator, Allocator_Bump* bump, u64 size) u8* result = bump->base + bump->at; bump->at = at_after; - + bump->high_water_mark = max(bump->at, bump->high_water_mark); return result; } @@ -248,6 +249,7 @@ bump_allocator_create_child(Allocator* parent, u64 init_size) result->parent = parent; Allocator_Bump* bump = (Allocator_Bump*)result->allocator_data; + zero_struct(*bump); bump->base = allocator_alloc(result->parent, init_size); if (bump->base != 0) {