fix entries always out of date
This commit is contained in:
parent
fafbfbfa6a
commit
f7c994678d
14
src/sprite.c
14
src/sprite.c
@ -258,7 +258,6 @@ struct sprite_startup_receipt sprite_startup(struct renderer_startup_receipt *re
|
|||||||
|
|
||||||
G.evictor_mutex = sys_mutex_alloc();
|
G.evictor_mutex = sys_mutex_alloc();
|
||||||
G.evictor_cv = sys_condition_variable_alloc();
|
G.evictor_cv = sys_condition_variable_alloc();
|
||||||
atomic_i32_eval_exchange(&G.evictor_cycle, 1);
|
|
||||||
|
|
||||||
G.evictor_thread = sys_thread_alloc(sprite_evictor_thread_entry_point, NULL, LIT("[P2] Sprite evictor"));
|
G.evictor_thread = sys_thread_alloc(sprite_evictor_thread_entry_point, NULL, LIT("[P2] Sprite evictor"));
|
||||||
|
|
||||||
@ -400,7 +399,7 @@ INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag t
|
|||||||
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
||||||
{
|
{
|
||||||
for (struct cache_entry *old_entry = bin->first; old_entry; old_entry = old_entry->next_in_bin) {
|
for (struct cache_entry *old_entry = bin->first; old_entry; old_entry = old_entry->next_in_bin) {
|
||||||
if (old_entry->hash.v == e->hash.v) {
|
if (old_entry != e && old_entry->hash.v == e->hash.v) {
|
||||||
atomic_i32_eval_exchange(&old_entry->out_of_date, 1);
|
atomic_i32_eval_exchange(&old_entry->out_of_date, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -708,7 +707,7 @@ INTERNAL void cache_entry_load_sheet(struct cache_ref ref, struct sprite_tag tag
|
|||||||
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
||||||
{
|
{
|
||||||
for (struct cache_entry *old_entry = bin->first; old_entry; old_entry = old_entry->next_in_bin) {
|
for (struct cache_entry *old_entry = bin->first; old_entry; old_entry = old_entry->next_in_bin) {
|
||||||
if (old_entry->hash.v == e->hash.v) {
|
if (old_entry != e && old_entry->hash.v == e->hash.v) {
|
||||||
atomic_i32_eval_exchange(&old_entry->out_of_date, 1);
|
atomic_i32_eval_exchange(&old_entry->out_of_date, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1245,7 +1244,10 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
|
|||||||
struct evict_node *en = arena_push_zero(scratch.arena, struct evict_node);
|
struct evict_node *en = arena_push_zero(scratch.arena, struct evict_node);
|
||||||
en->cache_entry = n;
|
en->cache_entry = n;
|
||||||
en->cache_bin = bin;
|
en->cache_bin = bin;
|
||||||
en->last_ref_cycle = refcount.last_ref_cycle * !is_out_of_date; /* If out of date then set last cycle to 0 */
|
en->last_ref_cycle = refcount.last_ref_cycle;
|
||||||
|
if (is_out_of_date) {
|
||||||
|
en->last_ref_cycle = -1;
|
||||||
|
}
|
||||||
++evict_array_count;
|
++evict_array_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1280,9 +1282,9 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
|
|||||||
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
struct sys_lock bin_lock = sys_mutex_lock_e(&bin->mutex);
|
||||||
{
|
{
|
||||||
struct cache_refcount refcount = *(struct cache_refcount *)atomic_u64_raw(&entry->refcount_struct);
|
struct cache_refcount refcount = *(struct cache_refcount *)atomic_u64_raw(&entry->refcount_struct);
|
||||||
if (refcount.count > 0 || (last_ref_cycle > 0 && refcount.last_ref_cycle != en->last_ref_cycle)) {
|
if (refcount.count > 0 || (last_ref_cycle >= 0 && refcount.last_ref_cycle != en->last_ref_cycle)) {
|
||||||
/* Cache node has been referenced since scan, skip node. */
|
/* Cache node has been referenced since scan, skip node. */
|
||||||
} else if (cache_over_budget_target || last_ref_cycle == 0) {
|
} else if (cache_over_budget_target || last_ref_cycle < 0) {
|
||||||
/* Remove from cache bin */
|
/* Remove from cache bin */
|
||||||
struct cache_entry *prev = entry->prev_in_bin;
|
struct cache_entry *prev = entry->prev_in_bin;
|
||||||
struct cache_entry *next = entry->next_in_bin;
|
struct cache_entry *next = entry->next_in_bin;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user