misc changes, hot reload is broken

This commit is contained in:
Edward R. Gonzalez 2024-03-20 00:44:43 -04:00
parent 737e8596f3
commit 2d5e308046
10 changed files with 40 additions and 29 deletions

View File

@ -231,7 +231,7 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
// Make sure to cleanup transient before continuing...
// From here on, tarnsinet usage has to be done with care.
// For most cases, the frame allocator should be more than enough.
free_all( transient_allocator() )
// free_all( transient_allocator() )
}
// For some reason odin's symbols conflict with native foreign symbols...
@ -269,6 +269,7 @@ reload :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem,
transient = transient_mem
files_buffer = files_buffer_mem
context.allocator = persistent_allocator()
context.temp_allocator = transient_allocator()
@ -282,10 +283,13 @@ reload :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem,
font_provider_data.font_cache.hashes.backing = persistent_slab_allocator()
font_provider_data.font_cache.entries.backing = persistent_slab_allocator()
slab_reload( string_cache.slab, persistent_slab_allocator() )
slab_reload( string_cache.slab, persistent_allocator() )
string_cache.table.hashes.backing = persistent_slab_allocator()
string_cache.table.entries.backing = persistent_slab_allocator()
// slab_reload( frame_slab, frame_allocator())
slab_reload( transient_slab, transient_allocator())
ui_reload( & get_state().project.workspace.ui, cache_allocator = persistent_slab_allocator() )
log("Module reloaded")
@ -382,6 +386,7 @@ clean_frame :: proc()
free_all( frame_allocator() )
transient_clear_elapsed += frametime_delta32()
if transient_clear_elapsed >= transient_clear_time && ! transinet_clear_lock
{

View File

@ -170,6 +170,8 @@ array_append_at_slice :: proc( using self : ^Array( $ Type ), items : []Type, id
return AllocatorError.None
}
// array_back :: proc( )
array_push_back :: proc( using self : Array( $ Type)) -> b32 {
if num == capacity {
return false

View File

@ -20,7 +20,7 @@ import "core:slice"
HMapZPL_MapProc :: #type proc( $ Type : typeid, key : u64, value : Type )
HMapZPL_MapMutProc :: #type proc( $ Type : typeid, key : u64, value : ^ Type )
HMapZPL_CritialLoadScale :: 0.70
HMapZPL_CritialLoadScale :: 0.50
HMapZPL_HashToEntryRatio :: 1.50
HMapZPL_FindResult :: struct {
@ -116,7 +116,7 @@ zpl_hmap_rehash :: proc( ht : ^ HMapZPL( $ Type ), new_num : u64 ) -> AllocatorE
{
profile(#procedure)
// For now the prototype should never allow this to happen.
ensure( false, "ZPL HMAP IS REHASHING" )
// ensure( false, "ZPL HMAP IS REHASHING" )
last_added_index : i64
new_ht, init_result := zpl_hmap_init_reserve( Type, ht.hashes.backing, new_num )
@ -265,6 +265,5 @@ zpl_hmap_find :: proc( using self : ^ HMapZPL( $ Type), key : u64 ) -> HMapZPL_F
zpl_hmap_full :: proc( using self : ^ HMapZPL( $ Type) ) -> b32 {
critical_load := u64(HMapZPL_CritialLoadScale * cast(f64) hashes.num)
result : b32 = entries.num > critical_load
ensure( !result, "HASHTABLE IS FULL" )
return result
}

View File

@ -163,7 +163,7 @@ pool_grab :: proc( pool : Pool, zero_memory := false ) -> ( block : []byte, allo
return
}
pool.current_bucket = pool.bucket_list.first
log( "First bucket allocation")
// log( "First bucket allocation")
}
// Compiler Bug ? (Won't work without "pool."")
@ -179,7 +179,7 @@ pool_grab :: proc( pool : Pool, zero_memory := false ) -> ( block : []byte, allo
// if current_bucket.next != nil {
if pool.current_bucket.next != nil {
// current_bucket = current_bucket.next
log( str_fmt_tmp("Bucket %p exhausted using %p", pool.current_bucket, pool.current_bucket.next))
// log( str_fmt_tmp("Bucket %p exhausted using %p", pool.current_bucket, pool.current_bucket.next))
pool.current_bucket = pool.current_bucket.next
}
else
@ -204,7 +204,7 @@ pool_grab :: proc( pool : Pool, zero_memory := false ) -> ( block : []byte, allo
pool.current_bucket.next_block += pool.block_size
next = uintptr(pool.current_bucket.blocks) + uintptr(pool.current_bucket.next_block)
log( str_fmt_tmp("grabbing block: %p blocks left: %d", raw_data(block), (end - next) / uintptr(pool.block_size) ))
// log( str_fmt_tmp("grabbing block: %p blocks left: %d", raw_data(block), (end - next) / uintptr(pool.block_size) ))
if zero_memory {
slice.zero(block)
@ -232,7 +232,7 @@ pool_release :: proc( self : Pool, block : []byte, loc := #caller_location )
self.free_list_head = new_free_block
new_free_block = new_free_block
log( str_fmt_tmp("Released block: %p %d", new_free_block, self.block_size))
// log( str_fmt_tmp("Released block: %p %d", new_free_block, self.block_size))
}
pool_reset :: proc( using pool : Pool )

View File

@ -131,7 +131,7 @@ slab_alloc :: proc( using self : Slab,
ensure(false, "Bad block from pool")
return nil, alloc_error
}
log( str_fmt_tmp("%v: Retrieved block: %p %d", dbg_name, raw_data(block), len(block) ))
// log( str_fmt_tmp("%v: Retrieved block: %p %d", dbg_name, raw_data(block), len(block) ))
data = byte_slice(raw_data(block), size)
if zero_memory {

View File

@ -335,7 +335,7 @@ main :: proc()
delta_ns = time.tick_lap_time( & host_tick )
host_tick = time.tick_now()
free_all( arena_allocator( & state.transient))
// free_all( arena_allocator( & state.transient))
}
// Determine how the run_cyle completed, if it failed due to an error,

View File

@ -449,12 +449,20 @@ update :: proc( delta_time : f64 ) -> b32
}
line_hbox.text = str_intern( to_string( builder ) )
// if len(line_hbox.text.str) == 0 {
// line_hbox.text = str_intern( " " )
// }
}
array_append( widgets_ptr, line_hbox )
if len(line_hbox.text.str) > 0 {
array_append( widgets_ptr, line_hbox )
layout_text.pos.x = text_style.layout.pos.x
layout_text.pos.y += size_range2(line_hbox.computed.bounds).y
}
else {
layout_text.pos.y += size_range2( (& widgets.data[ widgets.num - 1 ]).computed.bounds ).y
}
layout_text.pos.x = text_style.layout.pos.x
layout_text.pos.y += size_range2(line_hbox.computed.bounds).y
line_id += 1
}

View File

@ -452,7 +452,10 @@ ui_graph_build_begin :: proc( ui : ^ UI_State, bounds : Vec2 = {} )
get_state().ui_context = ui
using get_state().ui_context
curr_cache, prev_cache = swap( curr_cache, prev_cache )
temp := prev_cache
prev_cache = curr_cache
curr_cache = temp
// curr_cache, prev_cache = swap( curr_cache, prev_cache )
if ui.active == UI_Key(0) {
//ui.hot = UI_Key(0)

View File

@ -106,13 +106,7 @@ ui_compute_layout :: proc()
}
text_size : Vec2
// If the computed matches, we already have the size, don't bother.
if current.first_frame || ! size_to_text || computed.text_size.y != size_range2(computed.bounds).y {
text_size = cast(Vec2) measure_text_size( current.text.str, style.font, style.font_size, 0 )
}
else {
text_size = computed.text_size
}
text_size = cast(Vec2) measure_text_size( current.text.str, style.font, style.font_size, 0 )
if size_to_text {
adjusted_size = text_size

View File

@ -162,9 +162,9 @@ push-location $path_root
$build_args += $flag_build_mode_dll
$build_args += $flag_output_path + $module_dll
$build_args += ($flag_collection + $pkg_collection_thirdparty)
$build_args += $flag_micro_architecture_native
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
# $build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
# $build_args += $flag_optimize_speed
@ -240,9 +240,9 @@ push-location $path_root
$build_args += './host'
$build_args += $flag_output_path + $executable
$build_args += ($flag_collection + $pkg_collection_thirdparty)
$build_args += $flag_micro_architecture_native
$build_args += $flag_use_separate_modules
$build_args += $flag_thread_count + $CoreCount_Physical
# $build_args += $flag_micro_architecture_native
# $build_args += $flag_use_separate_modules
# $build_args += $flag_thread_count + $CoreCount_Physical
$build_args += $flag_optimize_none
# $build_args += $flag_optimize_minimal
# $build_args += $flag_optimize_speed
@ -253,8 +253,8 @@ push-location $path_root
# $build_args += ($flag_extra_linker_flags + $linker_args )
$build_args += $flag_show_timings
# $build_args += $flag_show_system_call
$build_args += $flag_no_bounds_check
$build_args += $flag_no_thread_checker
# $build_args += $flag_no_bounds_check
# $build_args += $flag_no_thread_checker
# $build_args += $flag_default_allocator_nil
$build_args += ($flag_max_error_count + '10')
# $build_args += $flag_sanitize_address