stats panel

This commit is contained in:
jacob 2026-04-06 05:46:14 -05:00
parent 3998e5b713
commit 3af5d804fb
2 changed files with 484 additions and 243 deletions

View File

@ -913,12 +913,13 @@ void V_TickForever(WaveLaneCtx *lane)
{
shutdown = Atomic32Fetch(&V.shutdown);
P_tl.debug_draw_enabled = TweakBool("Vis debug draw", 0);
i64 begin_time_ns = TimeNs();
i64 frame_begin_ns = TimeNs();
//////////////////////////////
//- Begin frame
i64 prev_frame_ack = ack;
G_Stats gpu_stats = G_QueryStats();
V.cur_frame_tick += 1;
V_Frame *prev_frame = V_PrevFrame();
@ -4210,6 +4211,197 @@ void V_TickForever(WaveLaneCtx *lane)
UI_PushDF(Tag, panel->contents_box.v)
UI_PushDF(Parent, panel->contents_box)
{
//////////////////////////////
//- Build stats panel
if (panel->flags & V_PanelFlag_Stats)
{
UI_SetNext(Width, UI_Grow(1, 0));
UI_PushDF(FontSize, UI_Top(FontSize) * 1.25)
UI_PushDF(Parent, UI_BuildRow())
{
Struct(Stat) { String name; String value; b32 is_separator; };
Stat stats[] = {
{ .is_separator = 1, .name = Lit("Cpu") },
{ Lit("Arenas allocated"), StringF(frame->arena, "%F", FmtSint(GetGstat(NumArenas))) },
{ Lit("Arena memory committed"), StringF(frame->arena, "%F MiB", FmtFloat((f64)GetGstat(ArenaMemoryCommitted) / 1024 / 1024, .p = 3)) },
{ Lit("Arena memory reserved"), StringF(frame->arena, "%F TiB", FmtFloat((f64)GetGstat(ArenaMemoryReserved) / 1024 / 1024 / 1024 / 1024, .p = 3)) },
{ .is_separator = 1, .name = Lit("Gpu") },
{ Lit("Arenas allocated"), StringF(frame->arena, "%F", FmtUint(gpu_stats.arenas_count)) },
{ Lit("Device memory usage"), StringF(frame->arena, "%F MiB", FmtFloat((f64)gpu_stats.device_committed / 1024 / 1024, .p = 3)) },
{ Lit("Host memory usage"), StringF(frame->arena, "%F MiB", FmtFloat((f64)gpu_stats.host_committed / 1024 / 1024, .p = 3)) },
{ Lit("Non reuse tally"), StringF(frame->arena, "%F", FmtUint(gpu_stats.cumulative_nonreuse_count)) },
{ .is_separator = 1, .name = Lit("Network") },
{ Lit("RTT"), StringF(frame->arena, "%F ms", FmtFloat(smoothed_rtt * 1000, .p = 3)) },
{ Lit("Client send"), StringF(frame->arena, "%F MiB", FmtFloat(CeilF64((f64)vis_pipe_stats.total_bytes_sent / 1024) / 1024, .p = 3)) },
{ Lit("Client recv"), StringF(frame->arena, "%F MiB", FmtFloat(CeilF64((f64)vis_pipe_stats.total_bytes_received / 1024) / 1024, .p = 3)) },
{ Lit("Server send"), StringF(frame->arena, "%F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_sent / 1024) / 1024, .p = 3)) },
{ Lit("Server recv"), StringF(frame->arena, "%F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_received / 1024) / 1024, .p = 3)) },
{ .is_separator = 1, .name = Lit("Game") },
{ Lit("Frame rate"), StringF(frame->arena, "%F fps", FmtFloat(1.0 / V.smooth_frame_time_seconds)) },
{ Lit("Frame time"), StringF(frame->arena, "%F ms", FmtFloat(V.smooth_frame_time_seconds * 1000)) },
{ Lit("Particles spawned"), StringF(frame->arena, "%F", FmtUint(V.particle_seq)) },
};
UI_Size padding = UI_Px(10, 1);
// Vec4 divider_color = Color_White;
Vec4 divider_color = theme.col.divider;
// Vec4 divider_color = VEC4(0.7, 0.6, 0.3, 1);
UI_Size divider_size = UI_Px(2, 1);
UI_Size row_height = UI_Fnt(2, 1);
// panel->bd = divider_color;
// panel->bd = Color_Transparent;
UI_Size child_padding = UI_Fnt(2, 0);
Vec4 bg_colors[] = {
VEC4(0.12, 0.12, 0.12, 1),
VEC4(0.10, 0.10, 0.10, 1)
};
for (u32 column_idx = 0; column_idx < 2; ++column_idx)
{
if (column_idx > 0)
{
UI_BuildDivider(divider_size, divider_color, Axis_X);
}
b32 is_name = column_idx == 0;
if (column_idx == 0)
{
UI_SetNext(Width, UI_Grow(0.6, 0));
}
else
{
UI_SetNext(Width, UI_Grow(0.4, 0));
}
UI_PushDF(Parent, UI_BuildColumn())
{
u64 stats_count = countof(stats);
for (u64 stat_idx = 0; stat_idx < stats_count; ++stat_idx)
{
Stat stat = stats[stat_idx];
// UI_BuildSpacer(padding, Axis_Y);
String text = stat.value;
// Vec4 text_color = Color_White;
Vec4 text_color = VEC4(0.7, 0.7, 0.7, 1);
if (is_name)
{
text = stat.name;
// text_color = theme.col.hint;
}
// UI_SetNext(Width
UI_SetNext(Width, UI_Grow(1, 0));
UI_SetNext(Height, row_height);
UI_SetNext(BackgroundColor, bg_colors[stat_idx % countof(bg_colors)]);
// if (stat.is_separator && column_idx > 0)
if (stat.is_separator)
{
UI_SetNext(BackgroundColor, Color_Transparent);
}
UI_SetNext(BorderSize, 2);
UI_PushDF(Parent, UI_BuildRow())
{
UI_BuildSpacer(padding, Axis_X);
if (!stat.is_separator && column_idx == 0)
{
UI_BuildSpacer(child_padding, Axis_X);
}
UI_SetNext(Width, UI_Shrink(0, 0));
UI_SetNext(ChildAlignment, UI_Region_Left);
if (is_name)
{
// UI_SetNext(ChildAlignment, UI_Region_Left);
}
else
{
// UI_BuildSpacer(UI_Grow(1, 0), Axis_X);
}
UI_SetNext(ChildAlignment, UI_Region_Left);
UI_SetNext(TextColor, text_color);
UI_SetNext(Height, UI_Grow(1, 0));
UI_SetNext(Text, text);
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_Scissor | UI_BoxFlag_DontTruncateText);
UI_BuildBox();
// UI_SetNext(Width, UI_Shrink(0, 1));
// UI_SetNext(Height, UI_Shrink(0, 1));
// UI_SetNext(Text, stat.value);
// UI_SetNext(Flags, UI_BoxFlag_DrawText);
// UI_BuildBox();
UI_BuildSpacer(padding, Axis_X);
}
// UI_BuildDivider(divider_size, divider_color, Axis_Y);
}
}
}
}
}
// if (panel->flags & V_PanelFlag_Stats)
// {
// UI_SetNext(Width, UI_Grow(1, 0));
// UI_PushDF(FontSize, UI_Top(FontSize) * 1.5)
// UI_PushDF(Parent, UI_BuildColumn())
// {
// Struct(Stat) { String name; String value; };
// Stat stats[] = {
// { Lit("Particle sequence"), StringF(frame->arena, "%F", FmtUint(V.particle_seq)) }
// };
// UI_Size padding = UI_Px(10, 1);
// u64 stats_count = countof(stats);
// for (u64 stat_idx = 0; stat_idx < stats_count; ++stat_idx)
// {
// UI_BuildSpacer(padding, Axis_Y);
// Stat stat = stats[stat_idx];
// // UI_SetNext(Width
// UI_SetNext(Width, UI_Grow(1, 0));
// UI_SetNext(Height, UI_Shrink(0, 1));
// UI_SetNext(BorderSize, 1)
// UI_PushDF(Parent, UI_BuildRow())
// {
// UI_BuildSpacer(padding, Axis_X);
// UI_SetNext(TextColor, theme.col.hint);
// UI_SetNext(Width, UI_Grow(1, 0));
// UI_SetNext(Height, UI_Shrink(0, 1));
// UI_SetNext(Text, stat.name);
// UI_SetNext(Flags, UI_BoxFlag_DrawText);
// UI_BuildBox();
// UI_SetNext(Width, UI_Shrink(0, 1));
// UI_SetNext(Height, UI_Shrink(0, 1));
// UI_SetNext(Text, stat.value);
// UI_SetNext(Flags, UI_BoxFlag_DrawText);
// UI_BuildBox();
// UI_BuildSpacer(padding, Axis_X);
// }
// };
// }
// }
//////////////////////////////
//- Build console panel
@ -4349,7 +4541,7 @@ void V_TickForever(WaveLaneCtx *lane)
{
for (P_TileKind tile_kind = 0; tile_kind < P_TileKind_COUNT; ++tile_kind)
{
UI_BuildDivider(UI_Px(1, 0), divider_color, Axis_Y);
UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y);
String tile_name = P_NameFromTileKind(tile_kind);
UI_Key tile_box = UI_KeyF("Tile %F", FmtString(tile_name));
@ -4377,13 +4569,13 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderColor, border_color);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_Grow(1, 0));
UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0));
UI_SetNext(Height, UI_Shrink(UI_Top(FontSize) * 0.25, 1));
UI_SetNext(Misc, is_selected);
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(ChildAlignment, UI_Region_Left);
UI_PushDF(Parent, UI_BuildRowEx(tile_box))
{
UI_BuildSpacer(UI_Fnt(0.25, 0), Axis_X);
UI_BuildSpacer(UI_Fnt(0.25, 1), Axis_X);
// Tile sprite
{
@ -4393,12 +4585,12 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(ChildAlignment, UI_Region_Center);
UI_SetNext(Width, UI_Fnt(2.5, 0));
UI_SetNext(Height, UI_Fnt(2.5, 0));
UI_SetNext(Height, UI_Fnt(2.5, 1));
UI_SetNext(SpriteSheet, sheet);
UI_BuildRow();
}
UI_BuildSpacer(UI_Fnt(0.5, 0), Axis_X);
UI_BuildSpacer(UI_Fnt(0.5, 1), Axis_X);
// Tile name
{
@ -4406,7 +4598,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Text, tile_name);
UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_SetNext(Width, UI_Shrink(4, 0));
UI_SetNext(Height, UI_Shrink(2, 0));
UI_SetNext(Height, UI_Shrink(2, 1));
UI_BuildRow();
}
}
@ -4422,7 +4614,7 @@ void V_TickForever(WaveLaneCtx *lane)
P_PrefabFlag prefab_flags = P_FlagsFromPrefabKind(prefab_kind);
if (!AnyBit(prefab_flags, P_PrefabFlag_HideFromEditor))
{
UI_BuildDivider(UI_Px(1, 0), divider_color, Axis_Y);
UI_BuildDivider(UI_Px(1, 1), divider_color, Axis_Y);
UI_Key prefab_box = UI_KeyF("Prefab %F", FmtString(prefab_name));
@ -4449,7 +4641,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(BorderColor, border_color);
UI_SetNext(BorderSize, 1);
UI_SetNext(Width, UI_Grow(1, 0));
UI_SetNext(Height, UI_Shrink(UI_Fnt(0.25, 0).v, 0));
UI_SetNext(Height, UI_Shrink(UI_Top(FontSize) * 0.25, 1));
UI_SetNext(Misc, is_selected);
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
UI_SetNext(ChildAlignment, UI_Region_Left);
@ -4478,7 +4670,7 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetNext(Text, prefab_name);
UI_SetNext(Flags, UI_BoxFlag_DrawText);
UI_SetNext(Width, UI_Shrink(4, 0));
UI_SetNext(Height, UI_Shrink(2, 0));
UI_SetNext(Height, UI_Shrink(2, 1));
UI_BuildRow();
}
}
@ -5733,111 +5925,124 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Init panel layout
// //////////////////////////////
// //- Init panel layout
// TODO: Allow for custom layouts stored in config files
// TODO: Don't use rand keys for panels
// // TODO: Allow for custom layouts stored in config files
// // TODO: Don't use rand keys for panels
if (!V.root_panel)
{
V.root_panel = PushStruct(perm, V_Panel);
V_Panel *left_panel = PushStruct(perm, V_Panel);
V_Panel *right_panel = PushStruct(perm, V_Panel);
// if (!V.root_panel)
// {
// V.root_panel = PushStruct(perm, V_Panel);
// V_Panel *left_panel = PushStruct(perm, V_Panel);
// V_Panel *right_panel = PushStruct(perm, V_Panel);
//- Root panel
{
{
V_Panel *panel = V.root_panel;
panel->box = UI_KeyF("test root panel");
panel->contents_box = vis_panels_box;
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 1;
panel->is_organizational = 1;
panel->axis = Axis_X;
V.root_panel = panel;
}
// //- Root panel
// {
// {
// V_Panel *panel = V.root_panel;
// panel->box = UI_KeyF("test root panel");
// panel->contents_box = vis_panels_box;
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->pct = 1;
// panel->is_organizational = 1;
// panel->axis = Axis_X;
// V.root_panel = panel;
// }
//- Left panel
{
V_Panel *panel = left_panel;
panel->parent = V.root_panel;
panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 0.10;
panel->is_organizational = 1;
}
// //- Left panel
// {
// V_Panel *panel = left_panel;
// panel->parent = V.root_panel;
// panel->axis = Axis_Y;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->pct = 0.10;
// panel->is_organizational = 1;
// }
//- Right panel
{
V_Panel *panel = right_panel;
panel->parent = V.root_panel;
panel->axis = Axis_Y;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 0.90;
panel->is_organizational = 1;
}
}
// //- Right panel
// {
// V_Panel *panel = right_panel;
// panel->parent = V.root_panel;
// panel->axis = Axis_Y;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->pct = 0.90;
// panel->is_organizational = 1;
// }
// }
//- Test spawn panel
{
V_Panel *panel = PushStruct(perm, V_Panel);
panel->parent = left_panel;
panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Spawn;
panel->pct = 0.25;
}
// //- Test stats panel
// {
// V_Panel *parent = left_panel;
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->axis = Axis_X;
// DllQueuePush(parent->first, parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_stats;
// panel->pct = 0.25;
// }
// //- Test profiler panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = right_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Profiler;
// panel->pct = 0.5;
// }
// //- Test spawn panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = left_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Spawn;
// panel->pct = 0.25;
// }
//- Vis screen panel
{
V_Panel *panel = PushStruct(perm, V_Panel);
panel->parent = right_panel;
panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = vis_screen_panel_box;
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Screen;
panel->pct = 1;
}
// // //- Test profiler panel
// // {
// // V_Panel *panel = PushStruct(perm, V_Panel);
// // panel->parent = right_panel;
// // panel->axis = Axis_X;
// // DllQueuePush(panel->parent->first, panel->parent->last, panel);
// // panel->box = UI_RandKey();
// // panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// // panel->flags |= V_PanelFlag_Profiler;
// // panel->pct = 0.5;
// // }
// //- Test console panel
// {
// V_Panel *parent = right_panel;
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->axis = Axis_X;
// DllQueuePush(parent->first, parent->last, panel);
// panel->box = UI_KeyF("test raah console panel");
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Console;
// // panel->flags |= V_PanelFlag_Spawn;
// panel->pct = 0.25;
// }
}
// //- Vis screen panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = right_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = vis_screen_panel_box;
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Screen;
// panel->pct = 1;
// }
// // //- Test console panel
// // {
// // V_Panel *parent = right_panel;
// // V_Panel *panel = PushStruct(perm, V_Panel);
// // panel->axis = Axis_X;
// // DllQueuePush(parent->first, parent->last, panel);
// // panel->box = UI_RandKey();
// // panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// // panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// // panel->flags |= V_PanelFlag_Console;
// // // panel->flags |= V_PanelFlag_Spawn;
// // panel->pct = 0.25;
// // }
// }
@ -5980,7 +6185,7 @@ void V_TickForever(WaveLaneCtx *lane)
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->axis = Axis_X;
// DllQueuePush(parent->first, parent->last, panel);
// panel->box = UI_KeyF("test raah console panel");
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Console;
@ -5999,6 +6204,155 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//-
//- STATS DEMO panel layout
//-
// TODO: Allow for custom layouts stored in config files
// TODO: Don't use rand keys for panels
if (!V.root_panel)
{
V.root_panel = PushStruct(perm, V_Panel);
V_Panel *left_panel = PushStruct(perm, V_Panel);
V_Panel *right_panel = PushStruct(perm, V_Panel);
//- Root panel
{
{
V_Panel *panel = V.root_panel;
panel->box = UI_KeyF("test root panel");
panel->contents_box = vis_panels_box;
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 1;
panel->is_organizational = 1;
panel->axis = Axis_X;
V.root_panel = panel;
}
//- Left panel
{
V_Panel *panel = left_panel;
panel->parent = V.root_panel;
panel->axis = Axis_Y;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 0.4;
panel->is_organizational = 1;
}
//- Right panel
{
V_Panel *panel = right_panel;
panel->parent = V.root_panel;
panel->axis = Axis_Y;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->pct = 0.90;
panel->is_organizational = 1;
}
}
//- Test stats panel
{
V_Panel *parent = left_panel;
V_Panel *panel = PushStruct(perm, V_Panel);
panel->axis = Axis_X;
DllQueuePush(parent->first, parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Stats;
panel->pct = 0.5;
}
//- Test spawn panel
{
V_Panel *panel = PushStruct(perm, V_Panel);
panel->parent = left_panel;
panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Spawn;
panel->pct = 0.25;
}
// //- Test profiler panel
// {
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->parent = right_panel;
// panel->axis = Axis_X;
// DllQueuePush(panel->parent->first, panel->parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Profiler;
// panel->pct = 0.5;
// }
//- Vis screen panel
{
V_Panel *panel = PushStruct(perm, V_Panel);
panel->parent = right_panel;
panel->axis = Axis_X;
DllQueuePush(panel->parent->first, panel->parent->last, panel);
panel->box = UI_RandKey();
panel->contents_box = vis_screen_panel_box;
panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
panel->flags |= V_PanelFlag_Screen;
panel->pct = 1;
}
// //- Test console panel
// {
// V_Panel *parent = right_panel;
// V_Panel *panel = PushStruct(perm, V_Panel);
// panel->axis = Axis_X;
// DllQueuePush(parent->first, parent->last, panel);
// panel->box = UI_RandKey();
// panel->contents_box = UI_KeyF("panel contents box %F", FmtUint(panel->box.v));
// panel->resizer_box = UI_KeyF("panel resizer box %F", FmtUint(panel->box.v));
// panel->flags |= V_PanelFlag_Console;
// // panel->flags |= V_PanelFlag_Spawn;
// panel->pct = 0.25;
// }
}
//////////////////////////////
//- Build vis panel contents
@ -7595,131 +7949,6 @@ void V_TickForever(WaveLaneCtx *lane)
//////////////////////////////
//- Build debug info UI
G_Stats gpu_stats = G_QueryStats();
if (0)
{
UI_Key dbg_box = UI_KeyF("Debug box");
Vec2 dbg_dims = DimsFromRng2(UI_Rect(dbg_box));
f32 padding = 20;
f32 rounding = 15 * theme.rounding;
Vec4 color = VEC4(0, 0, 0, 0.75);
UI_SetNext(Flags, UI_BoxFlag_Floating);
UI_SetNext(FloatingPos, VEC2(0, frame->screen_dims.y - dbg_dims.y));
UI_SetNext(Width, UI_Shrink(0, 1));
UI_SetNext(Height, UI_Shrink(0, 1));
UI_SetNext(BackgroundColor, color);
UI_SetNext(Rounding, UI_Rpx(rounding));
UI_PushCp(UI_BuildColumn());
{
// UI_BuildSpacer(UI_Px(10, 1), Axis_X);
// UI_Push(ChildAlignment, UI_Region_Center);
// UI_SetNext(Width, UI_Shrink(0, 1));
// UI_SetNext(Height, UI_Shrink(0, 1));
UI_SetNext(Width, UI_Shrink(0, 1));
UI_SetNext(Height, UI_Shrink(0, 1));
UI_PushCp(UI_BuildRow());
{
UI_BuildSpacer(UI_Px(padding, 1), Axis_X);
UI_SetNext(Width, UI_Shrink(0, 1));
UI_SetNext(Height, UI_Shrink(0, 1));
UI_PushCp(UI_BuildColumn());
{
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
UI_BuildLabelF("Local server world tick: %F", FmtSint(sim_stats.tick));
UI_BuildLabelF("Local server world entities: %F", FmtSint(sim_stats.ents_count));
UI_BuildLabelF("Local server world constraints: %F", FmtSint(sim_stats.constraints_count));
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
UI_BuildLabelF("Sim world seed: 0x%F", FmtHex(sim_world->seed));
UI_BuildLabelF("Sim world tick: %F", FmtSint(sim_world->last_frame->tick));
UI_BuildLabelF("Sim world entities: %F", FmtSint(sim_world->last_frame->ents_count));
UI_BuildLabelF("Sim world constraints: %F", FmtSint(sim_world->last_frame->constraints_count));
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
UI_BuildLabelF("Predicted world seed: 0x%F", FmtHex(predict_world->seed));
UI_BuildLabelF("Predicted world tick: %F", FmtSint(predict_world->last_frame->tick));
UI_BuildLabelF("Predicted world entities: %F", FmtSint(predict_world->last_frame->ents_count));
UI_BuildLabelF("Predicted world constraints: %F", FmtSint(predict_world->last_frame->constraints_count));
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
UI_BuildLabelF("Local world seed: 0x%F", FmtHex(frame->local_world->seed));
UI_BuildLabelF("Local world tick: %F", FmtSint(frame->local_world->last_frame->tick));
UI_BuildLabelF("Local world entities: %F", FmtSint(frame->local_world->last_frame->ents_count));
UI_BuildLabelF("Local world constraints: %F", FmtSint(frame->local_world->last_frame->constraints_count));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
Vec2 tile_pos = MulAffineVec2(frame->af.world_to_tile, frame->world_cursor);
Vec2 cell_pos = MulAffineVec2(frame->af.world_to_cell, frame->world_cursor);
i32 tile_idx = P_TileIdxFromTilePos(tile_pos);
UI_BuildLabelF("Camera pos: %F", FmtFloat2(frame->camera_pos));
UI_BuildLabelF("Camera zoom: %F", FmtFloat(frame->camera_zoom));
UI_BuildLabelF("Cursor pos: %F", FmtFloat2(frame->screen_cursor));
UI_BuildLabelF("Cursor world pos: %F", FmtFloat2(frame->world_cursor));
UI_BuildLabelF("Cursor tile pos: %F", FmtFloat2(tile_pos));
UI_BuildLabelF("Cursor tile idx: %F", FmtSint(tile_idx));
UI_BuildLabelF("Cursor cell pos: %F", FmtFloat2(cell_pos));
UI_BuildLabelF("Hovered ent: %F", P_FmtKey(hovered_ent->key));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
UI_BuildLabelF("Screen dims: %F", FmtFloat2(frame->screen_dims));
UI_BuildLabelF("Shade dims: %F", FmtFloat2(frame->shade_dims));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
UI_BuildLabelF("Particle seq: %F", FmtFloat(V.particle_seq));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
UI_BuildLabelF("RTT: %Fms", FmtFloat(smoothed_rtt * 1000, .p = 3));
UI_BuildLabelF("Client send: %F MiB", FmtFloat(CeilF64((f64)vis_pipe_stats.total_bytes_sent / 1024) / 1024, .p = 3));
UI_BuildLabelF("Client recv: %F MiB", FmtFloat(CeilF64((f64)vis_pipe_stats.total_bytes_received / 1024) / 1024, .p = 3));
UI_BuildLabelF("Server send: %F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_sent / 1024) / 1024, .p = 3));
UI_BuildLabelF("Server recv: %F MiB", FmtFloat(CeilF64((f64)sim_stats.pipe.total_bytes_received / 1024) / 1024, .p = 3));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
{
UI_Push(FontSize, UI_Top(FontSize) * theme.h2);
UI_BuildLabelF("Cpu:");
UI_Pop(FontSize);
}
UI_BuildLabelF(" Arenas: %F", FmtSint(GetGstat(NumArenas)));
if (PROFILING_ENABLED)
{
UI_BuildLabelF(" Arena memory committed: %F MiB (Collecting profiler samples, so perpetual growth is expected)", FmtFloat((f64)GetGstat(ArenaMemoryCommitted) / 1024 / 1024, .p = 3));
}
else
{
UI_BuildLabelF(" Arena memory committed: %F MiB", FmtFloat((f64)GetGstat(ArenaMemoryCommitted) / 1024 / 1024, .p = 3));
}
UI_BuildLabelF(" Arena memory reserved: %F TiB", FmtFloat((f64)GetGstat(ArenaMemoryReserved) / 1024 / 1024 / 1024 / 1024, .p = 3));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
{
{
UI_Push(FontSize, UI_Top(FontSize) * theme.h2);
UI_BuildLabelF("Gpu:");
UI_Pop(FontSize);
}
UI_BuildLabelF(" Arenas: %F", FmtUint(gpu_stats.arenas_count));
UI_BuildLabelF(" Device memory usage: %F MiB", FmtFloat((f64)gpu_stats.device_committed / 1024 / 1024, .p = 3));
UI_BuildLabelF(" Host memory usage: %F MiB", FmtFloat((f64)gpu_stats.host_committed / 1024 / 1024, .p = 3));
UI_BuildLabelF(" Non-reuse tally: %F", FmtUint(gpu_stats.cumulative_nonreuse_count));
}
UI_BuildSpacer(UI_Px(padding, 1), Axis_Y);
}
UI_PopCp(UI_TopCp());
UI_BuildSpacer(UI_Px(padding, 1), Axis_X);
}
UI_PopCp(UI_TopCp());
}
UI_PopCp(UI_TopCp());
}
//////////////////////////////
@ -8295,6 +8524,7 @@ void V_TickForever(WaveLaneCtx *lane)
if (V_CountVisCmds(V_CmdKind_clear_particles))
{
frame->should_clear_particles = 1;
V_PushNotif(Lit("Particles cleared"));
}
if (V_CountVisCmds(V_CmdKind_clear_bullets))
@ -8782,13 +9012,20 @@ void V_TickForever(WaveLaneCtx *lane)
LogInfoF("Time to first frame: %Fs", FmtFloat(SecondsFromNs(TimeNs()), .p = 3));
}
frame->elapsed_ns = TimeNs() - frame_begin_ns;
V.smooth_frame_time_seconds = LerpF64(V.smooth_frame_time_seconds, SecondsFromNs(frame->elapsed_ns), SaturateF64(5 * frame->dt));
if (frame->tick < 100)
{
V.smooth_frame_time_seconds = SecondsFromNs(frame->elapsed_ns);
}
//////////////////////////////
//- Sleep
if (!shutdown && FPS_LIMIT > 0)
{
i64 step_dt_ns = FPS_LIMIT > 0 ? NsFromSeconds(1) / FPS_LIMIT : 0;
PLT_SleepFrame(begin_time_ns, step_dt_ns);
PLT_SleepFrame(frame_begin_ns, step_dt_ns);
}
}

View File

@ -4,28 +4,28 @@
#define V_CmdsTableXList(X) \
X(nop, NOP, V_CmdDescFlag_HideFromPalette, V_HOTKEY( 0 ), ) \
X(exit_program, Exit Program, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_Escape ) ) \
X(toggle_palette, Toggle Command Palette, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_E, .ctrl = 1 ), V_HOTKEY( Button_P, .ctrl = 1, .shift = 1 ), ) \
X(toggle_palette, Toggle Command Palette, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_E, .alt = 1 ), V_HOTKEY( Button_P, .ctrl = 1, .shift = 1 ), ) \
X(zoom_in, Zoom In, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_WheelUp ), ) \
X(zoom_out, Zoom Out, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_WheelDown ), ) \
X(toggle_editor, Toggle Editor, V_CmdDescFlag_None, V_HOTKEY( Button_F1 ), ) \
X(save_level, Save level, V_CmdDescFlag_None, V_HOTKEY( Button_S, .ctrl = 1 ), ) \
X(save_level, Save level, V_CmdDescFlag_None, V_HOTKEY( Button_S, .alt = 1 ), ) \
X(toggle_ui_debug, Toggle UI Debug, V_CmdDescFlag_None, V_HOTKEY( Button_F5 ), ) \
X(toggle_console, Toggle Developer Console, V_CmdDescFlag_None, V_HOTKEY( Button_GraveAccent ), ) \
X(toggle_timeline, Toggle Debug Timeline, V_CmdDescFlag_None, V_HOTKEY( Button_GraveAccent, .alt = 1, .ctrl = 1 ), ) \
X(toggle_profiler, Toggle Profiler, V_CmdDescFlag_None, V_HOTKEY( 0 ), ) \
X(pause_timeline, Pause Debug Timeline, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_E ), ) \
X(lock_timeline, Lock Debug Timeline, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_R ), ) \
X(pause_timeline, Pause Debug Timeline, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_E, .alt = 1 ), ) \
X(lock_timeline, Lock Debug Timeline, V_CmdDescFlag_HideFromPalette, V_HOTKEY( Button_R, .alt = 1 ), ) \
X(toggle_fullscreen, Toggle Fullscreen Mode, V_CmdDescFlag_None, V_HOTKEY( Button_Enter, .alt = 1 ) ) \
X(toggle_window_topmost, Toggle Window Topmost, V_CmdDescFlag_None, V_HOTKEY( Button_F4 ), ) \
X(tp_player, Teleport Player, V_CmdDescFlag_None, V_HOTKEY( Button_Q ), ) \
X(spawn_tp_bot, Spawn/Teleport Bot, V_CmdDescFlag_None, V_HOTKEY( Button_T ), ) \
X(spawn_bot, Spawn Bot, V_CmdDescFlag_None, V_HOTKEY( Button_T, .ctrl = 1 ), ) \
X(tp_player, Teleport Player, V_CmdDescFlag_None, V_HOTKEY( Button_Q, .alt = 1 ), ) \
X(spawn_tp_bot, Spawn/Teleport Bot, V_CmdDescFlag_None, V_HOTKEY( Button_T, .alt = 1 ), ) \
X(spawn_bot, Spawn Bot, V_CmdDescFlag_None, V_HOTKEY( Button_T, .alt = 1, .shift = 1 ), ) \
X(delete, Delete entity at cursor, V_CmdDescFlag_None, V_HOTKEY( Button_M2 ), ) \
X(reset_world, Reset world, V_CmdDescFlag_None, V_HOTKEY( Button_R, .ctrl = 1, .alt = 1 ), ) \
X(clear_particles, Clear particles, V_CmdDescFlag_None, V_HOTKEY( Button_C ), ) \
X(clear_particles, Clear particles, V_CmdDescFlag_None, V_HOTKEY( Button_C, .alt = 1, ), ) \
X(clear_bullets, Clear bullets, V_CmdDescFlag_None, V_HOTKEY( Button_C, .shift = 1 ), ) \
X(test, Test, V_CmdDescFlag_None, V_HOTKEY( Button_Y ), ) \
/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
X(test, Test, V_CmdDescFlag_None, V_HOTKEY( Button_Y, .alt = 1 ), ) \
/* --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
////////////////////////////////////////////////////////////
//~ Theme types
@ -330,6 +330,7 @@ Enum(V_PanelFlag)
V_PanelFlag_Spawn = (1 << 1),
V_PanelFlag_Profiler = (1 << 2),
V_PanelFlag_Console = (1 << 3),
V_PanelFlag_Stats = (1 << 4),
};
Struct(V_Panel)
@ -440,6 +441,7 @@ Struct(V_Frame)
V_Palette palette;
UI_Key text_input_focus;
i64 elapsed_ns;
String window_restore;
@ -505,6 +507,8 @@ Struct(V_Ctx)
u64 profiler_frame_seq;
V_ProfilerFrame *profiler_frames;
f64 smooth_frame_time_seconds;
i64 cur_frame_tick;
V_Frame frames[2];
};