From 58b31f91920c9ddd919dcda74d02858fd7c21247 Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 24 Apr 2025 17:18:37 -0500 Subject: [PATCH] zerodef tile cache stuff for now --- src/app.c | 8 +++++--- src/sprite.c | 19 ++++++------------- src/user.c | 3 ++- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/app.c b/src/app.c index c1bcd4ec..30055f5c 100644 --- a/src/app.c +++ b/src/app.c @@ -211,14 +211,14 @@ void app_entry_point(struct string args_str) struct temp_arena scratch = scratch_begin_no_conflict(); struct app_arg_list args = parse_args(scratch.arena, args_str); - struct string log_file_name = LIT("log.txt"); + struct string logfile_name = LIT("log.log"); struct string settings_file_name = LIT("settings.txt"); struct string connect_address = ZI; for (struct app_arg *arg = args.first; arg; arg = arg->next) { struct string key = arg->key; struct string value = arg->value; if (string_eq(key, LIT("log"))) { - log_file_name = value; + logfile_name = value; } else if (string_eq(key, LIT("settings"))) { settings_file_name = value; } else if (string_eq(key, LIT("connect"))) { @@ -264,7 +264,9 @@ void app_entry_point(struct string args_str) { struct temp_arena temp = arena_temp_begin(scratch.arena); - struct string logfile_path = logfile_path = app_write_path_cat(temp.arena, log_file_name); + struct string logfile_dir = string_cat(temp.arena, G.write_path, LIT("logs/")); + struct string logfile_path = string_cat(temp.arena, logfile_dir, logfile_name); + sys_mkdir(logfile_dir); struct log_startup_receipt log_sr = log_startup(logfile_path); (UNUSED)log_sr; diff --git a/src/sprite.c b/src/sprite.c index 994525af..2673ddc7 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1101,19 +1101,12 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg) } #endif -#if RESOURCE_RELOADING /* Check usage time */ - /* Only check conditional if RESOURCE_RELOADING is enabled, - * since over-budget is assumed to be true otherwise */ - if (cache_over_budget) -#endif - { - u32 last_used_cycle = refcount.last_modified_cycle; - f64 time_since_use = (f64)(cur_cycle - last_used_cycle) * EVICTOR_CYCLE_INTERVAL; - if (time_since_use > EVICTOR_GRACE_PERIOD) { - /* Cache is over budget and node hasn't been referenced in a while */ - consider_for_eviction = true; - } + u32 last_used_cycle = refcount.last_modified_cycle; + f64 time_since_use = (f64)(cur_cycle - last_used_cycle) * EVICTOR_CYCLE_INTERVAL; + if (time_since_use > EVICTOR_GRACE_PERIOD) { + /* Cache is over budget and node hasn't been referenced in a while */ + consider_for_eviction = true; } } @@ -1169,7 +1162,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg) struct cache_node_refcount refcount = *(struct cache_node_refcount *)atomic_u64_raw(&n->refcount_struct); if (refcount.count > 0 || ((refcount.last_modified_cycle != en->refcount.last_modified_cycle) && !en->force_evict)) { /* Cache node has been referenced since scan, skip eviction. */ - } else if (en->force_evict || atomic_u64_eval(&G.cache.memory_usage) > CACHE_MEMORY_BUDGET) { + } else if (atomic_u64_eval(&G.cache.memory_usage) > CACHE_MEMORY_BUDGET || en->force_evict) { /* Remove from cache bin */ if (n->prev_hash) { n->prev_hash->next_hash = n->next_hash; diff --git a/src/user.c b/src/user.c index 49e00ea0..d5cca23d 100644 --- a/src/user.c +++ b/src/user.c @@ -646,7 +646,6 @@ INTERNAL void user_update(void) * Find local entities * ========================== */ - struct sim_ent *master_player = sim_ent_find_first_match_one(G.ss_blended, SIM_ENT_PROP_PLAYER_IS_MASTER); struct sim_ent *local_player = sim_ent_from_id(G.ss_blended, G.ss_blended->local_player); struct sim_ent *local_control = sim_ent_from_id(G.ss_blended, local_player->player_control_ent); struct sim_ent *local_camera = sim_ent_from_id(G.ss_blended, local_player->player_camera_ent); @@ -887,6 +886,7 @@ INTERNAL void user_update(void) draw_grid(G.world_cmd_buffer, RECT_FROM_V2(pos, size), color, thickness, spacing, offset); } +#if 0 /* ========================== * * Alloc / release tile cache entries * ========================== */ @@ -979,6 +979,7 @@ INTERNAL void user_update(void) } } } +#endif #endif /* ========================== *