Bugfixing the runtime (rendering not working yet)

This commit is contained in:
Edward R. Gonzalez 2024-06-11 22:20:19 -04:00
parent 82e7482c85
commit 5bd6519b6a
11 changed files with 31 additions and 16 deletions

Binary file not shown.

View File

@ -31,7 +31,7 @@ pool_list_init :: proc( pool : ^PoolList, capacity : u32 )
pool.free_list, error = make( Array( PoolListIter ), u64(capacity) )
assert( error == .None, "VEFontCache.pool_list_init : Failed to allocate free_list array")
array_resize( & pool.items, u64(capacity) )
array_resize( & pool.free_list, u64(capacity) )
pool.capacity = capacity
@ -172,10 +172,14 @@ LRU_put :: proc( cache : ^LRU_Cache, key : u64, value : i32 ) -> u64 {
}
pool_list_push_front( & cache.key_queue, key )
hmap_chained_set( cache.table, key, LRU_Link {
bytes := transmute( [8]byte ) key
hash_key := fnv64a( bytes[:] )
hmap_chained_set( cache.table, hash_key, LRU_Link {
value = value,
ptr = cache.key_queue.front
})
cache.num += 1
return evict
}

View File

@ -112,7 +112,7 @@ can_batch_glyph :: proc( ctx : ^Context, font : FontID, entry : ^Entry, glyph_in
cache_glyph_to_atlas( ctx, font, glyph_index )
}
assert( LRU_get( & region.state, lru_code ) != 1 )
assert( LRU_get( & region.state, lru_code ) != -1 )
set( ctx.temp_codepoint_seen, lru_code, true )
ctx.temp_codepoint_seen_num += 1
return true

View File

@ -270,7 +270,7 @@ draw_filled_path :: proc( draw_list : ^DrawList, outside_point : Vec2, path : []
draw_text :: proc( ctx : ^Context, font : FontID, text_utf8 : string, position : Vec2, scale : Vec2 ) -> b32
{
assert( ctx != nil )
assert( font > 0 && font < FontID(ctx.entries.num) )
assert( font >= 0 && font < FontID(ctx.entries.num) )
shaped := shape_text_cached( ctx, font, text_utf8 )

View File

@ -117,9 +117,11 @@ parser_find_glyph_index :: proc( font : ^ParserFontInfo, codepoint : rune ) -> (
{
case .Freetype:
glyph_index = transmute(Glyph) freetype.get_char_index( font.freetype_info, transmute(u32) codepoint )
return
case .STB_TrueType:
glyph_index = transmute(Glyph) stbtt.FindGlyphIndex( & font.stbtt_info, codepoint )
return
}
return Glyph(-1)
}

View File

@ -79,10 +79,11 @@ array_append_array :: proc( using self: ^Array( $ Type), other : Array(Type)) ->
// Note(Ed) : Original code from gencpp
// libc.memcpy( ptr_offset(data, num), raw_data(items), len(items) * size_of(Type) )
// TODO(Ed) : VERIFY VIA DEBUG THIS COPY IS FINE.
ensure(false, "time to check....")
target := ptr_offset( data, num )
copy( slice_ptr(target, int(capacity - num)), array_to_slice(other) )
dst_slice := slice_ptr(target, int(capacity - num))
src_slice := array_to_slice(other)
copy( dst_slice, src_slice )
num += other.num
return AllocatorError.None

View File

@ -14,6 +14,7 @@ and direct pointers are kept across the codebase instead of a key to the slot.
package grime
import "core:mem"
import "base:runtime"
HTable_Minimum_Capacity :: 4 * Kilobyte
@ -111,7 +112,11 @@ hmap_chained_lookup_id :: #force_inline proc( using self : HMapChained($Type), k
hmap_chained_get :: proc( using self : HMapChained($Type), key : u64) -> ^Type
{
// profile(#procedure)
surface_slot := lookup[hmap_chained_lookup_id(self, key)]
hash_index := hmap_chained_lookup_id(self, key)
// if hash_index == 565 {
// runtime.debug_trap()
// }
surface_slot := lookup[hash_index]
if surface_slot == nil {
return nil
@ -178,7 +183,7 @@ 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)
block, error = pool_grab(pool, true)
next := transmute( ^HMapChainedSlot(Type)) & block[0]
slot.next = next
next.prev = slot
@ -190,7 +195,7 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
}
if surface_slot == nil {
block, error := pool_grab(pool)
block, error := pool_grab(pool, true)
surface_slot := transmute( ^HMapChainedSlot(Type)) & block[0]
surface_slot.key = key
surface_slot.value = value
@ -201,7 +206,7 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
}
lookup[hash_index] = surface_slot
block, error = pool_grab(pool)
block, error = pool_grab(pool, true)
next := transmute( ^HMapChainedSlot(Type)) & block[0]
surface_slot.next = next
next.prev = surface_slot
@ -214,12 +219,12 @@ hmap_chained_set :: proc( self : HMapChained($Type), key : u64, value : Type ) -
return result, error
}
slot := surface_slot.next
slot : ^HMapChainedSlot(Type) = surface_slot.next
for ; slot != nil; slot = slot.next
{
if !slot.occupied
{
result, error := set_slot( self, surface_slot, key, value)
result, error := set_slot( self, slot, key, value)
return result, error
}
}

View File

@ -423,6 +423,8 @@ font_load :: proc(path_file : string,
def, set_error := hmap_chained_set(font_cache, key, FontDef{})
verify( set_error == AllocatorError.None, "Failed to add new font entry to cache" )
def.path_file = path_file
// TODO(Ed): Load even sizes from 8px to upper bound.
def.ve_id = ve.load_font( & provider_data.ve_font_cache, desired_id, font_data, 36.0 )

View File

@ -109,13 +109,14 @@ clone-gitrepo $path_sokol_tools $url_sokol_tools
$path_vendor = join-path $path_odin 'vendor'
$path_vendor_raylib = join-path $path_vendor 'raylib'
$path_freetype_dlls = join-path $path_freetype 'binaries/release'
$path_harfbuzz_dlls = join-path $path_harfbuzz 'lib/win64'
$path_raylib_dlls = join-path $path_vendor_raylib 'windows'
$path_sokol_dlls = join-path $path_thirdparty 'sokol'
if ( $binaries_dirty -or $true )
{
$third_party_dlls = Get-ChildItem -path $path_harfbuzz_dlls -Filter '*dll'
$third_party_dlls = Get-ChildItem -path $path_harfbuzz_dlls -Filter '*.dll'
foreach ($dll in $third_party_dlls) {
$destination = join-path $path_build $dll.Name
Copy-Item $dll.FullName -Destination $destination -Force

2
thirdparty/harfbuzz vendored

@ -1 +1 @@
Subproject commit 4c81e825e1b58632b9c4e5e4974172b8b6740cde
Subproject commit 1bc1416645610dcf133a70722ae0a78fd179274e

@ -1 +1 @@
Subproject commit 8bfc2a0af0eff7b573eb8cd33de1c15a051dddb6
Subproject commit b7a7ada7aef38214c599e8691072f95b33c91913