Bugfixing the runtime (rendering not working yet)
This commit is contained in:
		| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 ) | ||||
|  | ||||
|   | ||||
| @@ -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) | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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 | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
| @@ -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 ) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user