zerodef tile cache stuff for now

This commit is contained in:
jacob 2025-04-24 17:18:37 -05:00
parent fc3c67b445
commit 58b31f9192
3 changed files with 13 additions and 17 deletions

View File

@ -211,14 +211,14 @@ void app_entry_point(struct string args_str)
struct temp_arena scratch = scratch_begin_no_conflict(); struct temp_arena scratch = scratch_begin_no_conflict();
struct app_arg_list args = parse_args(scratch.arena, args_str); 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 settings_file_name = LIT("settings.txt");
struct string connect_address = ZI; struct string connect_address = ZI;
for (struct app_arg *arg = args.first; arg; arg = arg->next) { for (struct app_arg *arg = args.first; arg; arg = arg->next) {
struct string key = arg->key; struct string key = arg->key;
struct string value = arg->value; struct string value = arg->value;
if (string_eq(key, LIT("log"))) { if (string_eq(key, LIT("log"))) {
log_file_name = value; logfile_name = value;
} else if (string_eq(key, LIT("settings"))) { } else if (string_eq(key, LIT("settings"))) {
settings_file_name = value; settings_file_name = value;
} else if (string_eq(key, LIT("connect"))) { } 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 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); struct log_startup_receipt log_sr = log_startup(logfile_path);
(UNUSED)log_sr; (UNUSED)log_sr;

View File

@ -1101,20 +1101,13 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
} }
#endif #endif
#if RESOURCE_RELOADING
/* Check usage time */ /* 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; u32 last_used_cycle = refcount.last_modified_cycle;
f64 time_since_use = (f64)(cur_cycle - last_used_cycle) * EVICTOR_CYCLE_INTERVAL; f64 time_since_use = (f64)(cur_cycle - last_used_cycle) * EVICTOR_CYCLE_INTERVAL;
if (time_since_use > EVICTOR_GRACE_PERIOD) { if (time_since_use > EVICTOR_GRACE_PERIOD) {
/* Cache is over budget and node hasn't been referenced in a while */ /* Cache is over budget and node hasn't been referenced in a while */
consider_for_eviction = true; 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); 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)) { 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. */ /* 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 */ /* Remove from cache bin */
if (n->prev_hash) { if (n->prev_hash) {
n->prev_hash->next_hash = n->next_hash; n->prev_hash->next_hash = n->next_hash;

View File

@ -646,7 +646,6 @@ INTERNAL void user_update(void)
* Find local entities * 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_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_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); 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); draw_grid(G.world_cmd_buffer, RECT_FROM_V2(pos, size), color, thickness, spacing, offset);
} }
#if 0
/* ========================== * /* ========================== *
* Alloc / release tile cache entries * Alloc / release tile cache entries
* ========================== */ * ========================== */
@ -979,6 +979,7 @@ INTERNAL void user_update(void)
} }
} }
} }
#endif
#endif #endif
/* ========================== * /* ========================== *