From 2ceff4293f4dc294071a8d1e18a1a6a7cb49357f Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 30 Aug 2024 12:24:47 -0700 Subject: [PATCH] begin eliminating begin/end frame concept in debug engine, and moving to single debug engine tick --- src/dbg_engine/dbg_engine_core.c | 98 ++++++++++++++++---------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index dac37e07..a0798bf2 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -6787,6 +6787,48 @@ d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt) scratch_end(scratch); } + //- rjf: eliminate entities that are marked for deletion + ProfScope("eliminate deleted entities") + { + for(D_Entity *entity = d_entity_root(), *next = 0; !d_entity_is_nil(entity); entity = next) + { + next = d_entity_rec_depth_first_pre(entity, &d_nil_entity).next; + if(entity->flags & D_EntityFlag_MarkedForDeletion) + { + B32 undoable = (d_entity_kind_flags_table[entity->kind] & D_EntityKindFlag_UserDefinedLifetime); + + // rjf: fixup next entity to iterate to + next = d_entity_rec_depth_first(entity, &d_nil_entity, OffsetOf(D_Entity, next), OffsetOf(D_Entity, next)).next; + + // rjf: eliminate root entity if we're freeing it + if(entity == d_state->entities_root) + { + d_state->entities_root = &d_nil_entity; + } + + // rjf: unhook & release this entity tree + d_entity_change_parent(entity, entity->parent, &d_nil_entity, &d_nil_entity); + d_entity_release(entity); + } + } + } + + //- rjf: garbage collect eliminated thread unwinds + for(U64 slot_idx = 0; slot_idx < d_state->unwind_cache.slots_count; slot_idx += 1) + { + D_UnwindCacheSlot *slot = &d_state->unwind_cache.slots[slot_idx]; + for(D_UnwindCacheNode *n = slot->first, *next = 0; n != 0; n = next) + { + next = n->next; + if(d_entity_is_nil(d_entity_from_handle(n->thread))) + { + DLLRemove(slot->first, slot->last, n); + arena_release(n->arena); + SLLStackPush(d_state->unwind_cache.free_node, n); + } + } + } + //- rjf: sync with di parsers ProfScope("sync with di parsers") { @@ -8605,14 +8647,6 @@ d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt) } e_select_interpret_ctx(interpret_ctx); - ProfEnd(); -} - -internal void -d_end_frame(void) -{ - ProfBeginFunction(); - //- rjf: compute state parameterization hash for ctrl runs, if ctrl is running - // if the hash doesn't match the one for the last run, we need to soft-halt and // re-send down the parameterization state @@ -8635,47 +8669,13 @@ d_end_frame(void) } } - //- rjf: eliminate entities that are marked for deletion - ProfScope("eliminate deleted entities") - { - for(D_Entity *entity = d_entity_root(), *next = 0; !d_entity_is_nil(entity); entity = next) - { - next = d_entity_rec_depth_first_pre(entity, &d_nil_entity).next; - if(entity->flags & D_EntityFlag_MarkedForDeletion) - { - B32 undoable = (d_entity_kind_flags_table[entity->kind] & D_EntityKindFlag_UserDefinedLifetime); - - // rjf: fixup next entity to iterate to - next = d_entity_rec_depth_first(entity, &d_nil_entity, OffsetOf(D_Entity, next), OffsetOf(D_Entity, next)).next; - - // rjf: eliminate root entity if we're freeing it - if(entity == d_state->entities_root) - { - d_state->entities_root = &d_nil_entity; - } - - // rjf: unhook & release this entity tree - d_entity_change_parent(entity, entity->parent, &d_nil_entity, &d_nil_entity); - d_entity_release(entity); - } - } - } - - //- rjf: garbage collect eliminated thread unwinds - for(U64 slot_idx = 0; slot_idx < d_state->unwind_cache.slots_count; slot_idx += 1) - { - D_UnwindCacheSlot *slot = &d_state->unwind_cache.slots[slot_idx]; - for(D_UnwindCacheNode *n = slot->first, *next = 0; n != 0; n = next) - { - next = n->next; - if(d_entity_is_nil(d_entity_from_handle(n->thread))) - { - DLLRemove(slot->first, slot->last, n); - arena_release(n->arena); - SLLStackPush(d_state->unwind_cache.free_node, n); - } - } - } + ProfEnd(); +} + +internal void +d_end_frame(void) +{ + ProfBeginFunction(); //- rjf: write config changes ProfScope("write config changes")