tweak ctrl entity building to be bucketed per 'entity store' - we can now have multiple 'entity stores', one on the frontend thread, one on the ctrl thread, and keep them in sync at specific points via event lists

This commit is contained in:
Ryan Fleury
2024-03-12 14:20:24 -07:00
parent 4a3cc9bb39
commit d1e88f781e
4 changed files with 282 additions and 191 deletions
+3 -1
View File
@@ -3656,7 +3656,7 @@ internal CTRL_Unwind
df_push_unwind_from_thread(Arena *arena, DF_Entity *thread)
{
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
CTRL_Unwind unwind = ctrl_unwind_from_thread(arena, thread->ctrl_machine_id, thread->ctrl_handle, 0);
CTRL_Unwind unwind = ctrl_unwind_from_thread(arena, df_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle, 0);
return unwind;
}
@@ -6398,6 +6398,7 @@ df_core_init(CmdLine *cmdln, DF_StateDeltaHistory *hist)
df_state->entities_base = push_array(df_state->entities_arena, DF_Entity, 0);
df_state->entities_count = 0;
df_state->ctrl_msg_arena = arena_alloc();
df_state->ctrl_entity_store = ctrl_entity_store_alloc();
df_state->ctrl_stop_arena = arena_alloc();
df_state->entities_root = df_entity_alloc(0, &df_g_nil_entity, DF_EntityKind_Root);
df_state->cmd_spec_table_size = 1024;
@@ -6549,6 +6550,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
//- rjf: consume & process events
CTRL_EventList events = ctrl_c2u_pop_events(scratch.arena);
ctrl_entity_store_apply_events(df_state->ctrl_entity_store, &events);
for(CTRL_EventNode *event_n = events.first; event_n != 0; event_n = event_n->next)
{
CTRL_Event *event = &event_n->v;
+1
View File
@@ -1179,6 +1179,7 @@ struct DF_State
B32 ctrl_solo_stepping_mode;
// rjf: control thread ctrl -> user reading state
CTRL_EntityStore *ctrl_entity_store;
Arena *ctrl_stop_arena;
CTRL_Event ctrl_last_stop_event;