Converted UI_State box caches to use hmap_chained
This commit is contained in:
parent
1fb011f56c
commit
9015f4ce3c
@ -354,10 +354,10 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem
|
||||
// debug.path_lorem = str_fmt("C:/projects/SectrPrototype/examples/ve_fontcache.h", allocator = persistent_slab_allocator())
|
||||
|
||||
alloc_error : AllocatorError; success : bool
|
||||
// debug.lorem_content, success = os.read_entire_file( debug.path_lorem, persistent_slab_allocator() )
|
||||
debug.lorem_content, success = os.read_entire_file( debug.path_lorem, persistent_slab_allocator() )
|
||||
|
||||
// debug.lorem_parse, alloc_error = pws_parser_parse( transmute(string) debug.lorem_content, persistent_slab_allocator() )
|
||||
// verify( alloc_error == .None, "Faield to parse due to allocation failure" )
|
||||
debug.lorem_parse, alloc_error = pws_parser_parse( transmute(string) debug.lorem_content, persistent_slab_allocator() )
|
||||
verify( alloc_error == .None, "Faield to parse due to allocation failure" )
|
||||
|
||||
// Render texture test
|
||||
// debug.viewport_rt = rl.LoadRenderTexture( 1280, 720 )
|
||||
|
@ -347,7 +347,7 @@ update :: proc( delta_time : f64 ) -> b32
|
||||
// test_draggable()
|
||||
// test_text_box()
|
||||
// test_parenting( & default_layout, & frame_style_default )
|
||||
// test_whitespace_ast( & default_layout, & frame_style_default )
|
||||
test_whitespace_ast( & default_layout, & frame_style_default )
|
||||
}
|
||||
//endregion Workspace Imgui Tick
|
||||
|
||||
|
@ -63,7 +63,8 @@ UI_Layout_Stack_Size :: 512
|
||||
UI_Style_Stack_Size :: 512
|
||||
UI_Parent_Stack_Size :: 512
|
||||
// UI_Built_Boxes_Array_Size :: 8
|
||||
UI_Built_Boxes_Array_Size :: 128 * Kilobyte
|
||||
UI_Built_Boxes_Array_Size :: 56 * Kilobyte
|
||||
UI_BoxCache_TableSize :: 4 * Kilobyte
|
||||
|
||||
UI_RenderEntry :: struct {
|
||||
info : UI_RenderBoxInfo,
|
||||
@ -72,7 +73,7 @@ UI_RenderEntry :: struct {
|
||||
layer_id : i32,
|
||||
}
|
||||
|
||||
UI_RenderLayer :: DLL_NodeFL(UI_RenderEntry)\
|
||||
UI_RenderLayer :: DLL_NodeFL(UI_RenderEntry)
|
||||
|
||||
UI_RenderBoxInfo :: struct {
|
||||
using computed : UI_Computed,
|
||||
@ -99,9 +100,9 @@ UI_State :: struct {
|
||||
|
||||
built_box_count : i32,
|
||||
|
||||
caches : [2] HMapZPL( UI_Box ),
|
||||
prev_cache : ^HMapZPL( UI_Box ),
|
||||
curr_cache : ^HMapZPL( UI_Box ),
|
||||
caches : [2] HMapChained( UI_Box ),
|
||||
prev_cache : ^HMapChained( UI_Box ),
|
||||
curr_cache : ^HMapChained( UI_Box ),
|
||||
|
||||
// For rendering via a set of layers organized into a single command list
|
||||
// render_queue_builder : SubArena,
|
||||
@ -143,7 +144,7 @@ ui_startup :: proc( ui : ^ UI_State, cache_allocator : Allocator /* , cache_rese
|
||||
ui^ = {}
|
||||
|
||||
for & cache in ui.caches {
|
||||
box_cache, allocation_error := make( HMapZPL(UI_Box), UI_Built_Boxes_Array_Size, cache_allocator )
|
||||
box_cache, allocation_error := make( HMapChained(UI_Box), UI_BoxCache_TableSize, cache_allocator )
|
||||
verify( allocation_error == AllocatorError.None, "Failed to allocate box cache" )
|
||||
cache = box_cache
|
||||
}
|
||||
@ -165,7 +166,7 @@ ui_reload :: proc( ui : ^ UI_State, cache_allocator : Allocator )
|
||||
{
|
||||
// We need to repopulate Allocator references
|
||||
for & cache in ui.caches {
|
||||
hmap_zpl_reload( & cache, cache_allocator)
|
||||
hmap_chained_reload( cache, cache_allocator)
|
||||
}
|
||||
ui.render_queue.backing = cache_allocator
|
||||
ui.render_list.backing = cache_allocator
|
||||
@ -454,7 +455,7 @@ ui_hash_part_from_key_string :: proc ( content : string ) -> string {
|
||||
ui_key_from_string :: #force_inline proc "contextless" ( value : string ) -> UI_Key
|
||||
{
|
||||
// profile(#procedure)
|
||||
USE_RAD_DEBUGGERS_METHOD :: true
|
||||
USE_RAD_DEBUGGERS_METHOD :: false
|
||||
|
||||
key : UI_Key
|
||||
|
||||
|
@ -61,8 +61,8 @@ ui_box_equal :: #force_inline proc "contextless" ( a, b : ^ UI_Box ) -> b32 {
|
||||
return result
|
||||
}
|
||||
|
||||
ui_box_from_key :: #force_inline proc ( cache : ^HMapZPL(UI_Box), key : UI_Key ) -> (^UI_Box) {
|
||||
return hmap_zpl_get( cache, cast(u64) key )
|
||||
ui_box_from_key :: #force_inline proc ( cache : ^HMapChained(UI_Box), key : UI_Key ) -> (^UI_Box) {
|
||||
return hmap_chained_get( cache ^, cast(u64) key )
|
||||
}
|
||||
|
||||
ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box)
|
||||
@ -72,7 +72,7 @@ ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box)
|
||||
key := ui_key_from_string( label )
|
||||
|
||||
curr_box : (^ UI_Box)
|
||||
prev_box := hmap_zpl_get( prev_cache, cast(u64) key )
|
||||
prev_box := hmap_chained_get( prev_cache ^, cast(u64) key )
|
||||
{
|
||||
// profile("Assigning current box")
|
||||
set_result : ^ UI_Box
|
||||
@ -80,13 +80,13 @@ ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box)
|
||||
if prev_box != nil
|
||||
{
|
||||
// Previous history was found, copy over previous state.
|
||||
set_result, set_error = hmap_zpl_set( curr_cache, cast(u64) key, (prev_box ^) )
|
||||
set_result, set_error = hmap_chained_set( curr_cache ^, cast(u64) key, (prev_box ^) )
|
||||
}
|
||||
else {
|
||||
box : UI_Box
|
||||
box.key = key
|
||||
box.label = str_intern( label )
|
||||
set_result, set_error = hmap_zpl_set( curr_cache, cast(u64) key, box )
|
||||
set_result, set_error = hmap_chained_set( curr_cache ^, cast(u64) key, box )
|
||||
}
|
||||
|
||||
verify( set_error == AllocatorError.None, "Failed to set hmap_zpl due to allocator error" )
|
||||
@ -114,7 +114,7 @@ ui_box_make :: proc( flags : UI_BoxFlags, label : string ) -> (^ UI_Box)
|
||||
return curr_box
|
||||
}
|
||||
|
||||
ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return hmap_zpl_get( ui_context().prev_cache, cast(u64) box.key ) }
|
||||
ui_prev_cached_box :: #force_inline proc( box : ^UI_Box ) -> ^UI_Box { return hmap_chained_get( ui_context().prev_cache ^, cast(u64) box.key ) }
|
||||
|
||||
// TODO(Ed): Rename to ui_box_tranverse_view_next
|
||||
// Traveral pritorizes immeidate children
|
||||
|
Loading…
Reference in New Issue
Block a user