begin flattening d/df tick paths

This commit is contained in:
Ryan Fleury
2024-08-30 14:10:12 -07:00
parent 2ceff4293f
commit 533fd0041f
5 changed files with 59 additions and 112 deletions
+3 -7
View File
@@ -6364,12 +6364,11 @@ d_gather_root_cmds(Arena *arena)
}
internal void
d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt)
d_tick(Arena *arena, DI_Scope *di_scope, D_CmdList *cmds, F32 dt)
{
ProfBeginFunction();
d_state->frame_index += 1;
arena_clear(d_frame_arena());
d_state->frame_di_scope = di_scope_open();
d_state->frame_eval_memread_endt_us = os_now_microseconds() + 5000;
d_state->dt = dt;
d_state->time_in_seconds += dt;
@@ -8486,7 +8485,7 @@ d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt)
D_Entity *m = n->entity;
DI_Key dbgi_key = d_dbgi_key_from_module(m);
eval_modules[eval_module_idx].arch = d_arch_from_entity(m);
eval_modules[eval_module_idx].rdi = di_rdi_from_key(d_state->frame_di_scope, &dbgi_key, 0);
eval_modules[eval_module_idx].rdi = di_rdi_from_key(di_scope, &dbgi_key, 0);
eval_modules[eval_module_idx].vaddr_range = m->vaddr_rng;
eval_modules[eval_module_idx].space = d_eval_space_from_entity(d_entity_ancestor_from_kind(m, D_EntityKind_Process));
if(module == m)
@@ -8505,7 +8504,7 @@ d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt)
for(D_EntityNode *n = all_modules.first; n != 0; n = n->next, idx += 1)
{
DI_Key dbgi_key = d_dbgi_key_from_module(n->entity);
rdis[idx] = di_rdi_from_key(d_state->frame_di_scope, &dbgi_key, 0);
rdis[idx] = di_rdi_from_key(di_scope, &dbgi_key, 0);
rdis_vaddr_ranges[idx] = n->entity->vaddr_rng;
if(n->entity == module)
{
@@ -8693,8 +8692,5 @@ d_end_frame(void)
}
}
//- rjf: end scopes
di_scope_close(d_state->frame_di_scope);
ProfEnd();
}
+1 -2
View File
@@ -952,7 +952,6 @@ struct D_State
// rjf: frame info
Arena *frame_arenas[2];
DI_Scope *frame_di_scope;
// rjf: interaction registers
D_RegsNode base_regs;
@@ -1535,7 +1534,7 @@ __VA_ARGS__ \
internal void d_init(CmdLine *cmdln, D_StateDeltaHistory *hist);
internal D_CmdList d_gather_root_cmds(Arena *arena);
internal void d_begin_frame(Arena *arena, D_CmdList *cmds, F32 dt);
internal void d_tick(Arena *arena, DI_Scope *di_scope, D_CmdList *cmds, F32 dt);
internal void d_end_frame(void);
#endif // DBG_ENGINE_CORE_H
+46
View File
@@ -10599,3 +10599,49 @@ df_end_frame(void)
ProfEnd();
}
internal void
df_frame(Arena *arena, D_CmdList *cmds)
{
df_begin_frame(arena, cmds);
{
B32 queue_drag_drop = 0;
if(queue_drag_drop)
{
df_queue_drag_drop();
}
dr_begin_frame();
for(DF_Window *w = df_state->first_window; w != 0; w = w->next)
{
B32 window_is_focused = os_window_is_focused(w->os);
if(window_is_focused)
{
last_focused_window = df_handle_from_window(w);
}
d_push_regs();
d_regs()->window = df_handle_from_window(w);
df_window_update_and_render(arena, w, cmds);
D_Regs *window_regs = d_pop_regs();
if(df_window_from_handle(last_focused_window) == w)
{
MemoryCopyStruct(d_regs(), window_regs);
}
}
}
df_end_frame();
d_end_frame();
//////////////////////////////
//- rjf: submit rendering to all windows
//
{
r_begin_frame();
for(DF_Window *w = df_state->first_window; w != 0; w = w->next)
{
r_window_begin_frame(w->os, w->r);
dr_submit_bucket(w->os, w->r, w->draw_bucket);
r_window_end_frame(w->os, w->r);
}
r_end_frame();
}
}
+1
View File
@@ -925,5 +925,6 @@ internal void df_request_frame(void);
internal void df_init(OS_WindowRepaintFunctionType *window_repaint_entry_point, D_StateDeltaHistory *hist);
internal void df_begin_frame(Arena *arena, D_CmdList *cmds);
internal void df_end_frame(void);
internal void df_frame(Arena *arena, D_CmdList *cmds);
#endif // DBG_FRONTEND_CORE_H
+8 -103
View File
@@ -7,9 +7,9 @@
internal void
update_and_render(OS_Handle repaint_window_handle, void *user_data)
{
ProfTick(0);
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
DI_Scope *di_scope = di_scope_open();
//////////////////////////////
//- rjf: begin logging
@@ -27,8 +27,9 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
log_scope_begin();
//////////////////////////////
//- rjf: tick cache layers
//- rjf: mark user-facing tick
//
ProfTick(0);
txt_user_clock_tick();
dasm_user_clock_tick();
geo_user_clock_tick();
@@ -143,7 +144,6 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
//////////////////////////////
//- rjf: consume events
//
B32 queue_drag_drop = 0;
{
for(OS_Event *event = events.first, *next = 0;
event != 0;
@@ -153,14 +153,6 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
DF_Window *window = df_window_from_os_handle(event->window);
D_CmdParams params = window ? df_cmd_params_from_window(window) : df_cmd_params_from_gfx();
B32 take = 0;
B32 skip = 0;
//- rjf: try drag-drop
if(df_drag_is_active() && event->kind == OS_EventKind_Release && event->key == OS_Key_LeftMouseButton)
{
skip = 1;
queue_drag_drop = 1;
}
//- rjf: try window close
if(!take && event->kind == OS_EventKind_WindowClose && window != 0)
@@ -259,7 +251,7 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
}
//- rjf: take
if(take && !skip)
if(take)
{
os_eat_event(&events, event);
}
@@ -272,98 +264,10 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
D_CmdList cmds = d_gather_root_cmds(scratch.arena);
//////////////////////////////
//- rjf: begin frame
//- rjf: tick debug engine; do frontend frame
//
{
d_begin_frame(scratch.arena, &cmds, dt);
df_begin_frame(scratch.arena, &cmds);
}
//////////////////////////////
//- rjf: queue drop for drag/drop
//
if(queue_drag_drop)
{
df_queue_drag_drop();
}
//////////////////////////////
//- rjf: auto-focus moused-over windows while dragging
//
if(df_drag_is_active())
{
B32 over_focused_window = 0;
{
for(DF_Window *window = df_state->first_window; window != 0; window = window->next)
{
Vec2F32 mouse = os_mouse_from_window(window->os);
Rng2F32 rect = os_client_rect_from_window(window->os);
if(os_window_is_focused(window->os) && contains_2f32(rect, mouse))
{
over_focused_window = 1;
break;
}
}
}
if(!over_focused_window)
{
for(DF_Window *window = df_state->first_window; window != 0; window = window->next)
{
Vec2F32 mouse = os_mouse_from_window(window->os);
Rng2F32 rect = os_client_rect_from_window(window->os);
if(!os_window_is_focused(window->os) && contains_2f32(rect, mouse))
{
os_window_focus(window->os);
break;
}
}
}
}
//////////////////////////////
//- rjf: update & render
//
{
dr_begin_frame();
for(DF_Window *w = df_state->first_window; w != 0; w = w->next)
{
B32 window_is_focused = os_window_is_focused(w->os);
if(window_is_focused)
{
last_focused_window = df_handle_from_window(w);
}
d_push_regs();
d_regs()->window = df_handle_from_window(w);
df_window_update_and_render(scratch.arena, w, &cmds);
D_Regs *window_regs = d_pop_regs();
if(df_window_from_handle(last_focused_window) == w)
{
MemoryCopyStruct(d_regs(), window_regs);
}
}
}
//////////////////////////////
//- rjf: end frontend frame, send signals, etc.
//
{
df_end_frame();
d_end_frame();
}
//////////////////////////////
//- rjf: submit rendering to all windows
//
{
r_begin_frame();
for(DF_Window *w = df_state->first_window; w != 0; w = w->next)
{
r_window_begin_frame(w->os, w->r);
dr_submit_bucket(w->os, w->r, w->draw_bucket);
r_window_end_frame(w->os, w->r);
}
r_end_frame();
}
d_tick(scratch.arena, di_scope, &cmds, dt);
df_frame(scratch.arena, &cmds);
//////////////////////////////
//- rjf: show windows after first frame
@@ -405,6 +309,7 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
}
}
di_scope_close(di_scope);
scratch_end(scratch);
ProfEnd();
}