mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
pipe through left-over OS events to subsequent frames; do not drop them
This commit is contained in:
+1
-2
@@ -10894,7 +10894,6 @@ df_gfx_init(OS_WindowRepaintFunctionType *window_repaint_entry_point, DF_StateDe
|
||||
Arena *arena = arena_alloc();
|
||||
df_gfx_state = push_array(arena, DF_GfxState, 1);
|
||||
df_gfx_state->arena = arena;
|
||||
df_gfx_state->frame_arena = arena_alloc();
|
||||
df_gfx_state->num_frames_requested = 2;
|
||||
df_gfx_state->hist = hist;
|
||||
df_gfx_state->key_map_arena = arena_alloc();
|
||||
@@ -10941,7 +10940,6 @@ internal void
|
||||
df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
arena_clear(df_gfx_state->frame_arena);
|
||||
df_gfx_state->hover_line_set_this_frame = 0;
|
||||
|
||||
//- rjf: animate confirmation
|
||||
@@ -11087,6 +11085,7 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds)
|
||||
arena_release(ws->hover_eval_arena);
|
||||
arena_release(ws->arena);
|
||||
SLLStackPush(df_gfx_state->free_window, ws);
|
||||
ws->gen += 1;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -662,7 +662,6 @@ struct DF_GfxState
|
||||
{
|
||||
// rjf: arenas
|
||||
Arena *arena;
|
||||
Arena *frame_arena;
|
||||
|
||||
// rjf: frame request state
|
||||
U64 num_frames_requested;
|
||||
|
||||
@@ -189,3 +189,35 @@ os_text(OS_EventList *events, OS_Handle window, U32 character)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal OS_EventList
|
||||
os_event_list_copy(Arena *arena, OS_EventList *src)
|
||||
{
|
||||
OS_EventList dst = {0};
|
||||
for(OS_Event *s = src->first; s != 0; s = s->next)
|
||||
{
|
||||
OS_Event *d = push_array(arena, OS_Event, 1);
|
||||
MemoryCopyStruct(d, s);
|
||||
d->strings = str8_list_copy(arena, &s->strings);
|
||||
DLLPushBack(dst.first, dst.last, d);
|
||||
dst.count += 1;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
internal void
|
||||
os_event_list_concat_in_place(OS_EventList *dst, OS_EventList *to_push)
|
||||
{
|
||||
if(dst->last && to_push->first)
|
||||
{
|
||||
dst->last->next = to_push->first;
|
||||
to_push->first->prev = dst->last;
|
||||
dst->last = to_push->last;
|
||||
dst->count += to_push->count;
|
||||
}
|
||||
else if(!dst->last && to_push->first)
|
||||
{
|
||||
MemoryCopyStruct(dst, to_push);
|
||||
}
|
||||
MemoryZeroStruct(to_push);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,8 @@ internal void os_eat_event(OS_EventList *events, OS_Event *event);
|
||||
internal B32 os_key_press(OS_EventList *events, OS_Handle window, OS_EventFlags flags, OS_Key key);
|
||||
internal B32 os_key_release(OS_EventList *events, OS_Handle window, OS_EventFlags flags, OS_Key key);
|
||||
internal B32 os_text(OS_EventList *events, OS_Handle window, U32 character);
|
||||
internal OS_EventList os_event_list_copy(Arena *arena, OS_EventList *src);
|
||||
internal void os_event_list_concat_in_place(OS_EventList *dst, OS_EventList *to_push);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: @os_hooks Main Initialization API (Implemented Per-OS)
|
||||
|
||||
@@ -114,6 +114,7 @@ w32_push_event(OS_EventKind kind, W32_Window *window)
|
||||
result->kind = kind;
|
||||
result->window = os_window_from_w32_window(window);
|
||||
result->flags = os_get_event_flags();
|
||||
w32_event_list.count += 1;
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
||||
+14
-1
@@ -65,7 +65,10 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
|
||||
OS_EventList events = {0};
|
||||
if(os_handle_match(repaint_window_handle, os_handle_zero()))
|
||||
{
|
||||
events = os_get_events(scratch.arena, df_gfx_state->num_frames_requested == 0);
|
||||
OS_EventList leftover_events_copy = os_event_list_copy(scratch.arena, &leftover_events);
|
||||
OS_EventList new_events = os_get_events(scratch.arena, df_gfx_state->num_frames_requested == 0);
|
||||
os_event_list_concat_in_place(&events, &leftover_events_copy);
|
||||
os_event_list_concat_in_place(&events, &new_events);
|
||||
}
|
||||
|
||||
//- rjf: enable txti change detection
|
||||
@@ -296,6 +299,13 @@ update_and_render(OS_Handle repaint_window_handle, void *user_data)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: gather leftover events for subsequent frame
|
||||
if(events.count != 0)
|
||||
{
|
||||
arena_clear(leftover_events_arena);
|
||||
leftover_events = os_event_list_copy(leftover_events_arena, &events);
|
||||
}
|
||||
|
||||
//- rjf: determine frame time, record into history
|
||||
U64 end_time_us = os_now_microseconds();
|
||||
U64 frame_time_us = end_time_us-begin_time_us;
|
||||
@@ -404,6 +414,9 @@ entry_point(int argc, char **argv)
|
||||
IPCInfo *ipc_info = (IPCInfo *)ipc_shared_memory_base;
|
||||
ipc_info->msg_size = 0;
|
||||
|
||||
//- rjf: set up leftover event arena
|
||||
leftover_events_arena = arena_alloc();
|
||||
|
||||
//- rjf: initialize stuff we depend on
|
||||
{
|
||||
hs_init();
|
||||
|
||||
@@ -482,6 +482,8 @@ read_only global String8 ipc_shared_memory_name = str8_lit_comp("_raddbg_ipc_sha
|
||||
read_only global String8 ipc_semaphore_name = str8_lit_comp("_raddbg_ipc_semaphore_");
|
||||
global U64 frame_time_us_history[64] = {0};
|
||||
global U64 frame_time_us_history_idx = 0;
|
||||
global Arena *leftover_events_arena = 0;
|
||||
global OS_EventList leftover_events = {0};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Frontend Entry Points
|
||||
|
||||
Reference in New Issue
Block a user