More bug fixing, All latin characters don't look corrupt anymore
HMapChained causes memory corruption in VEFontCache (not sure why yet), so I switched temporarily over to HMapZPL. Fixed bug with parser_get_glyph_shape from me tracking vertices as u16s instead of i16s. Currently a bug with the frametime example: text_test_str := str_fmt("frametime: %0.2f", frametime_avg_ms) It doesn't handle per-frame updates properly compared to C++ source
This commit is contained in:
@ -183,8 +183,9 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
|
||||
error := AllocatorError.None
|
||||
if slot.next == nil {
|
||||
block : []byte
|
||||
block, error = pool_grab(pool, true)
|
||||
block, error = pool_grab(pool, false)
|
||||
next := transmute( ^HMapChainedSlot(Type)) & block[0]
|
||||
next^ = {}
|
||||
slot.next = next
|
||||
next.prev = slot
|
||||
}
|
||||
@ -195,8 +196,9 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
|
||||
}
|
||||
|
||||
if surface_slot == nil {
|
||||
block, error := pool_grab(pool, true)
|
||||
block, error := pool_grab(pool, false)
|
||||
surface_slot := transmute( ^HMapChainedSlot(Type)) & block[0]
|
||||
surface_slot^ = {}
|
||||
surface_slot.key = key
|
||||
surface_slot.value = value
|
||||
surface_slot.occupied = true
|
||||
@ -206,8 +208,9 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
|
||||
}
|
||||
lookup[hash_index] = surface_slot
|
||||
|
||||
block, error = pool_grab(pool, true)
|
||||
block, error = pool_grab(pool, false)
|
||||
next := transmute( ^HMapChainedSlot(Type)) & block[0]
|
||||
next^ = {}
|
||||
surface_slot.next = next
|
||||
next.prev = surface_slot
|
||||
return & surface_slot.value, error
|
||||
|
@ -70,11 +70,11 @@ hmap_zpl_init :: proc
|
||||
}
|
||||
|
||||
hmap_zpl_clear :: proc( using self : ^ HMapZPL( $ Type ) ) {
|
||||
for id := 0; id < table.num; id += 1 {
|
||||
table[id] = -1
|
||||
for id := 0; id < int(table.num); id += 1 {
|
||||
table.data[id] = -1
|
||||
}
|
||||
|
||||
array_clear( table )
|
||||
// array_clear( table )
|
||||
array_clear( entries )
|
||||
}
|
||||
|
||||
@ -154,21 +154,21 @@ hmap_zpl_rehash :: proc( ht : ^ HMapZPL( $ Type ), new_num : u64 ) -> AllocatorE
|
||||
|
||||
hmap_zpl_rehash_fast :: proc( using self : ^ HMapZPL( $ Type ) )
|
||||
{
|
||||
for id := 0; id < entries.num; id += 1 {
|
||||
entries[id].Next = -1;
|
||||
for id : i64 = 0; id < i64(entries.num); id += 1 {
|
||||
entries.data[id].next = -1;
|
||||
}
|
||||
for id := 0; id < table.num; id += 1 {
|
||||
table[id] = -1
|
||||
for id : i64 = 0; id < i64(table.num); id += 1 {
|
||||
table.data[id] = -1
|
||||
}
|
||||
for id := 0; id < entries.num; id += 1 {
|
||||
entry := & entries[id]
|
||||
find_result := hmap_zpl_find( entry.key )
|
||||
for id : i64 = 0; id < i64(entries.num); id += 1 {
|
||||
entry := & entries.data[id]
|
||||
find_result := hmap_zpl_find( self, entry.key )
|
||||
|
||||
if find_result.prev_index < 0 {
|
||||
table[ find_result.hash_index ] = id
|
||||
table.data[ find_result.hash_index ] = id
|
||||
}
|
||||
else {
|
||||
entries[ find_result.prev_index ].next = id
|
||||
entries.data[ find_result.prev_index ].next = id
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -180,10 +180,10 @@ hmap_zpl_reload :: proc( using self : ^HMapZPL($Type), new_backing : Allocator )
|
||||
}
|
||||
|
||||
hmap_zpl_remove :: proc( self : ^ HMapZPL( $ Type ), key : u64 ) {
|
||||
find_result := hmap_zpl_find( key )
|
||||
find_result := hmap_zpl_find( self, key )
|
||||
|
||||
if find_result.entry_index >= 0 {
|
||||
array_remove_at( & entries, find_result.entry_index )
|
||||
array_remove_at( self.entries, u64(find_result.entry_index) )
|
||||
hmap_zpl_rehash_fast( self )
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ MemoryTracker :: struct {
|
||||
entries : Array(MemoryTrackerEntry),
|
||||
}
|
||||
|
||||
Track_Memory :: false
|
||||
Track_Memory :: true
|
||||
|
||||
memtracker_clear :: proc ( tracker : MemoryTracker ) {
|
||||
when ! Track_Memory {
|
||||
@ -51,6 +51,10 @@ memtracker_register :: proc( tracker : ^MemoryTracker, new_entry : MemoryTracker
|
||||
}
|
||||
profile(#procedure)
|
||||
|
||||
temp_arena : Arena; arena_init(& temp_arena, Logger_Allocator_Buffer[:])
|
||||
context.allocator = arena_allocator(& temp_arena)
|
||||
context.temp_allocator = arena_allocator(& temp_arena)
|
||||
|
||||
if tracker.entries.num == tracker.entries.capacity {
|
||||
ensure(false, "Memory tracker entries array full, can no longer register any more allocations")
|
||||
return
|
||||
@ -70,12 +74,12 @@ memtracker_register :: proc( tracker : ^MemoryTracker, new_entry : MemoryTracker
|
||||
memtracker_dump_entries(tracker ^)
|
||||
}
|
||||
array_append_at( & tracker.entries, new_entry, idx )
|
||||
log(str_fmt("%v : Registered: %v", tracker.name, new_entry) )
|
||||
logf("%v : Registered: %v", tracker.name, new_entry)
|
||||
return
|
||||
}
|
||||
|
||||
array_append( & tracker.entries, new_entry )
|
||||
log(str_fmt("%v : Registered: %v", tracker.name, new_entry) )
|
||||
logf("%v : Registered: %v", tracker.name, new_entry)
|
||||
}
|
||||
|
||||
memtracker_register_auto_name :: proc( tracker : ^MemoryTracker, start, end : rawptr )
|
||||
@ -103,13 +107,17 @@ memtracker_unregister :: proc( tracker : MemoryTracker, to_remove : MemoryTracke
|
||||
}
|
||||
profile(#procedure)
|
||||
|
||||
temp_arena : Arena; arena_init(& temp_arena, Logger_Allocator_Buffer[:])
|
||||
context.allocator = arena_allocator(& temp_arena)
|
||||
context.temp_allocator = arena_allocator(& temp_arena)
|
||||
|
||||
entries := array_to_slice(tracker.entries)
|
||||
for idx in 0..< tracker.entries.num
|
||||
{
|
||||
entry := & entries[idx]
|
||||
if entry.start == to_remove.start {
|
||||
if (entry.end == to_remove.end || to_remove.end == nil) {
|
||||
log(str_fmt("%v: Unregistered: %v", tracker.name, to_remove));
|
||||
logf("%v: Unregistered: %v", tracker.name, to_remove);
|
||||
array_remove_at(tracker.entries, idx)
|
||||
return
|
||||
}
|
||||
@ -130,6 +138,10 @@ memtracker_check_for_collisions :: proc ( tracker : MemoryTracker )
|
||||
}
|
||||
profile(#procedure)
|
||||
|
||||
temp_arena : Arena; arena_init(& temp_arena, Logger_Allocator_Buffer[:])
|
||||
context.allocator = arena_allocator(& temp_arena)
|
||||
context.temp_allocator = arena_allocator(& temp_arena)
|
||||
|
||||
entries := array_to_slice(tracker.entries)
|
||||
for idx in 1 ..< tracker.entries.num {
|
||||
// Check to make sure each allocations adjacent entries do not intersect
|
||||
@ -153,6 +165,6 @@ memtracker_dump_entries :: proc( tracker : MemoryTracker )
|
||||
log( "Dumping Memory Tracker:")
|
||||
for idx in 0 ..< tracker.entries.num {
|
||||
entry := & tracker.entries.data[idx]
|
||||
log( str_fmt("%v", entry) )
|
||||
logf("%v", entry)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user