smooth profiler zooming
This commit is contained in:
parent
30271866f3
commit
b6adeb8861
@ -5385,7 +5385,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
|
|
||||||
V_Profiler *profiler = &frame->profiler;
|
V_Profiler *profiler = &frame->profiler;
|
||||||
profiler->ns_per_px = MaxI64(profiler->ns_per_px, 1);
|
profiler->target_ns_per_px = MaxF64(profiler->target_ns_per_px, 1);
|
||||||
|
profiler->ns_per_px = MaxF64(profiler->ns_per_px, 1);
|
||||||
UI_Key profiler_graph_box = UI_KeyF("graph");
|
UI_Key profiler_graph_box = UI_KeyF("graph");
|
||||||
UI_PushDF(OmitFlags, UI_BoxFlag_CaptureMouse * !!(frame->is_looking))
|
UI_PushDF(OmitFlags, UI_BoxFlag_CaptureMouse * !!(frame->is_looking))
|
||||||
if (TweakBool("Show profiler", 1))
|
if (TweakBool("Show profiler", 1))
|
||||||
@ -5406,7 +5407,8 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
if (frame->tick == 1)
|
if (frame->tick == 1)
|
||||||
{
|
{
|
||||||
profiler->ns_per_px = NsFromSeconds(0.0001);
|
// profiler->ns_per_px = NsFromSeconds(0.0001);
|
||||||
|
profiler->target_ns_per_px = NsFromSeconds(0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
profiler->graph_dims = DimsFromRng2(UI_Rect(profiler_graph_box));
|
profiler->graph_dims = DimsFromRng2(UI_Rect(profiler_graph_box));
|
||||||
@ -5477,8 +5479,9 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
// UI_Size graph_height = UI_GROW(0.25, 0);
|
// UI_Size graph_height = UI_GROW(0.25, 0);
|
||||||
UI_Size graph_height = UI_FNT(2, 1);
|
UI_Size graph_height = UI_FNT(2, 1);
|
||||||
UI_Size main_height = UI_GROW(1, 0);
|
UI_Size main_height = UI_GROW(1, 0);
|
||||||
UI_Size zone_height = UI_FNT(1, 0);
|
UI_Size zone_height = UI_FNT(1.25, 0);
|
||||||
UI_Size track_height = UI_FNT(25, 0);
|
UI_Size track_height = UI_FNT(25, 0);
|
||||||
|
f32 zone_text_padding_px = UI_Top(FontSize) * 0.2;
|
||||||
|
|
||||||
// Vec2 old_main_dims = DimsFromRng2(UI_Rect(main_box));
|
// Vec2 old_main_dims = DimsFromRng2(UI_Rect(main_box));
|
||||||
// old_main_dims.x = MaxF32(old_main_dims.x, 1);
|
// old_main_dims.x = MaxF32(old_main_dims.x, 1);
|
||||||
@ -5505,11 +5508,6 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns;
|
profiler->cursor_ns = (cursor_px * profiler->ns_per_px) + profiler->view_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
f32 view_offset_px = profiler->view_ns / profiler->ns_per_px;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -5518,16 +5516,20 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
|
|
||||||
// FIXME: Remove this
|
// FIXME: Remove this
|
||||||
f32 prof_zoom_rate = 1.5;
|
f32 prof_zoom_rate = 1.5;
|
||||||
|
f64 prof_lerp_rate = SaturateF64(frame->dt * 25);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i32 zooms = UI_Presses(main_box, Button_WheelDown) - UI_Presses(main_box, Button_WheelUp);
|
i32 zooms = UI_Presses(main_box, Button_WheelDown) - UI_Presses(main_box, Button_WheelUp);
|
||||||
f32 zoom_factor = PowF32(prof_zoom_rate, zooms);
|
f32 zoom_factor = PowF32(prof_zoom_rate, zooms);
|
||||||
|
|
||||||
profiler->ns_per_px *= zoom_factor;
|
profiler->target_ns_per_px *= zoom_factor;
|
||||||
|
|
||||||
// profiler->view_ns -= (profiler->cursor_ns - profiler->view_ns) / zoom_factor;
|
// profiler->view_ns = profiler->cursor_ns - (profiler->cursor_ns - profiler->view_ns) * zoom_factor;
|
||||||
profiler->view_ns = profiler->cursor_ns - (profiler->cursor_ns - profiler->view_ns) * zoom_factor;
|
profiler->target_view_ns = profiler->cursor_ns - (profiler->cursor_ns - profiler->target_view_ns) * zoom_factor;
|
||||||
|
|
||||||
|
profiler->ns_per_px = LerpF64(profiler->ns_per_px, profiler->target_ns_per_px, prof_lerp_rate);
|
||||||
|
profiler->view_ns = LerpF64(profiler->view_ns, profiler->target_view_ns, prof_lerp_rate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -5577,6 +5579,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
if (UI_Held(main_box, Button_M2) || UI_Held(main_box, Button_M3))
|
if (UI_Held(main_box, Button_M2) || UI_Held(main_box, Button_M3))
|
||||||
{
|
{
|
||||||
profiler->view_ns = profiler->drag_view_ns - ((cursor_px - profiler->drag_cursor_px) * profiler->ns_per_px);
|
profiler->view_ns = profiler->drag_view_ns - ((cursor_px - profiler->drag_cursor_px) * profiler->ns_per_px);
|
||||||
|
profiler->target_view_ns = profiler->view_ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5600,7 +5603,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
// f64 ns_per_px = MaxF64((profiler->view_end_ns - profiler->view_start_ns) / old_main_dims.x, 1);
|
// f64 ns_per_px = MaxF64((profiler->view_end_ns - profiler->view_start_ns) / old_main_dims.x, 1);
|
||||||
|
|
||||||
Vec4 profiler_color = theme.col.window_bg;
|
Vec4 profiler_color = theme.col.window_bg;
|
||||||
f32 profiler_opacity = 1;
|
f32 profiler_opacity = TweakFloat("Profiler opacity", 1, 0, 1);
|
||||||
|
|
||||||
Vec4 main_color = profiler_color;
|
Vec4 main_color = profiler_color;
|
||||||
main_color.r *= 0.75;
|
main_color.r *= 0.75;
|
||||||
@ -5817,6 +5820,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
depth -= 1;
|
depth -= 1;
|
||||||
V_ZoneDesc *zone = last_zone;
|
V_ZoneDesc *zone = last_zone;
|
||||||
|
// FIXME: OOB
|
||||||
for (; zone->depth > depth;)
|
for (; zone->depth > depth;)
|
||||||
{
|
{
|
||||||
zone = zone->prev;
|
zone = zone->prev;
|
||||||
@ -5833,6 +5837,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
char *name_cstr = sample->name_cstr_lit;
|
char *name_cstr = sample->name_cstr_lit;
|
||||||
String name = StringFromCstrNoLimit(name_cstr);
|
String name = StringFromCstrNoLimit(name_cstr);
|
||||||
|
|
||||||
|
// TODO: Also factor in sample source code location
|
||||||
u64 seed = HashString(name);
|
u64 seed = HashString(name);
|
||||||
// u64 seed = MixU64((u64)name_cstr);
|
// u64 seed = MixU64((u64)name_cstr);
|
||||||
|
|
||||||
@ -5958,17 +5963,26 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
{
|
{
|
||||||
UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->start_sample_seq));
|
UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->start_sample_seq));
|
||||||
|
|
||||||
|
// TODO: Dim in HSV space
|
||||||
|
Vec4 zone_color_dim = VEC4(0.15, 0.15, 0.15, 0);
|
||||||
|
|
||||||
Vec4 zone_color = zone->color;
|
Vec4 zone_color = zone->color;
|
||||||
|
// Vec4 zone_color_bd = Zi;
|
||||||
Vec4 zone_color_bd = zone_color;
|
Vec4 zone_color_bd = zone_color;
|
||||||
// zone_color = LerpSrgb(zone_color, Color_Cyan, UI_Hot(zone_box));
|
zone_color_bd.r -= zone_color_dim.r;
|
||||||
|
zone_color_bd.g -= zone_color_dim.g;
|
||||||
|
zone_color_bd.b -= zone_color_dim.b;
|
||||||
|
|
||||||
|
Vec4 zone_text_color = UI_Top(TextColor);
|
||||||
|
zone_text_color.a *= 0.75;
|
||||||
|
|
||||||
|
|
||||||
// zone_color_bd = LerpSrgb(zone_color_bd, theme.col.button_selected, UI_Hot(zone_box));
|
// zone_color_bd = LerpSrgb(zone_color_bd, theme.col.button_selected, UI_Hot(zone_box));
|
||||||
// zone_color_bd = LerpSrgb(zone_color_bd, theme.col.button_active, UI_Hot(zone_box));
|
// zone_color_bd = LerpSrgb(zone_color_bd, theme.col.button_active, UI_Hot(zone_box));
|
||||||
zone_color_bd = LerpSrgb(zone_color_bd, Color_White, UI_Hot(zone_box));
|
zone_color_bd = LerpSrgb(zone_color_bd, Color_White, UI_Hot(zone_box));
|
||||||
|
|
||||||
i64 zone_len_ns = zone->end_ns - zone->start_ns;
|
f64 zone_len_ns = zone->end_ns - zone->start_ns;
|
||||||
f32 zone_len_px = zone_len_ns / profiler->ns_per_px;
|
f64 zone_len_px = zone_len_ns / profiler->ns_per_px;
|
||||||
// i6
|
|
||||||
|
|
||||||
f32 zone_offset_px = (zone->start_ns - profiler->view_ns) / profiler->ns_per_px;
|
f32 zone_offset_px = (zone->start_ns - profiler->view_ns) / profiler->ns_per_px;
|
||||||
Vec2 zone_pos = VEC2(zone_offset_px, 0);
|
Vec2 zone_pos = VEC2(zone_offset_px, 0);
|
||||||
@ -5994,12 +6008,18 @@ void V_TickForever(WaveLaneCtx *lane)
|
|||||||
// UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingX | UI_BoxFlag_DontClampFloatingY);
|
// UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingX | UI_BoxFlag_DontClampFloatingY);
|
||||||
UI_PushDF(Parent, UI_BuildRowEx(zone_box))
|
UI_PushDF(Parent, UI_BuildRowEx(zone_box))
|
||||||
{
|
{
|
||||||
UI_SetNext(ChildAlignment, UI_Region_Center);
|
UI_BuildSpacer(UI_PIX(zone_text_padding_px, 0.25), Axis_X);
|
||||||
UI_SetNext(FontSize, UI_Top(FontSize) * 0.75);
|
|
||||||
|
UI_SetNext(Width, UI_SHRINK(1, 0));
|
||||||
|
UI_SetNext(ChildAlignment, UI_Region_Left);
|
||||||
|
UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5);
|
||||||
|
UI_SetNext(TextColor, zone_text_color);
|
||||||
UI_SetNext(Text, zone->name);
|
UI_SetNext(Text, zone->name);
|
||||||
// UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_DontTruncateText);
|
UI_SetNext(Flags, UI_BoxFlag_DrawText | UI_BoxFlag_DontTruncateText);
|
||||||
UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
// UI_SetNext(Flags, UI_BoxFlag_DrawText);
|
||||||
UI_BuildRow();
|
UI_BuildRow();
|
||||||
|
|
||||||
|
UI_BuildSpacer(UI_PIX(zone_text_padding_px, 1), Axis_X);
|
||||||
}
|
}
|
||||||
zone_idx += 1;
|
zone_idx += 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -245,12 +245,15 @@ Struct(V_Profiler)
|
|||||||
|
|
||||||
// TODO: Per track data
|
// TODO: Per track data
|
||||||
|
|
||||||
f32 drag_view_ns;
|
f64 drag_view_ns;
|
||||||
f32 drag_cursor_px;
|
f64 drag_cursor_px;
|
||||||
|
|
||||||
i64 cursor_ns;
|
f64 target_ns_per_px;
|
||||||
i64 ns_per_px;
|
f64 target_view_ns;
|
||||||
i64 view_ns;
|
|
||||||
|
f64 cursor_ns;
|
||||||
|
f64 ns_per_px;
|
||||||
|
f64 view_ns;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -1809,6 +1809,7 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
|
|||||||
//- Build render data
|
//- Build render data
|
||||||
|
|
||||||
// Build GPU rect data
|
// Build GPU rect data
|
||||||
|
ProfZoneDF("Build UI GPU rects")
|
||||||
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index)
|
for (u64 pre_index = 0; pre_index < boxes_count; ++pre_index)
|
||||||
{
|
{
|
||||||
UI_Box *box = boxes_pre[pre_index];
|
UI_Box *box = boxes_pre[pre_index];
|
||||||
@ -1877,7 +1878,7 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_upload_text)
|
if (should_upload_text || AnyBit(frame->frame_flags, UI_FrameFlag_Debug))
|
||||||
{
|
{
|
||||||
f32 max_baseline_length = CeilF32(DimsFromRng2(box->screen_rect).x);
|
f32 max_baseline_length = CeilF32(DimsFromRng2(box->screen_rect).x);
|
||||||
b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline_length && !AnyBit(box->desc.flags, UI_BoxFlag_DontTruncateText);
|
b32 should_truncate = FloorF32(raw_run.baseline_length) > max_baseline_length && !AnyBit(box->desc.flags, UI_BoxFlag_DontTruncateText);
|
||||||
@ -1999,7 +2000,8 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- Upload data to GPU
|
//- Upload data to GPU
|
||||||
|
|
||||||
G_ProfZoneDF(UI.cl, "UI upload")
|
ProfZoneDF("UI GPU upload")
|
||||||
|
G_ProfZoneDF(UI.cl, "UI GPU upload")
|
||||||
{
|
{
|
||||||
// Target
|
// Target
|
||||||
gpu_frame.target_size = draw_size;
|
gpu_frame.target_size = draw_size;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user