diff --git a/src/pp/pp_vis/pp_vis_core.c b/src/pp/pp_vis/pp_vis_core.c index fef78855..07e10e6d 100644 --- a/src/pp/pp_vis/pp_vis_core.c +++ b/src/pp/pp_vis/pp_vis_core.c @@ -5401,22 +5401,11 @@ void V_TickForever(WaveLaneCtx *lane) zone_track->id = V.zone_tracks_count++; SllQueuePush(V.first_zone_track, V.last_zone_track, zone_track); - // Init sentinel skip list chunks - for (u64 row_idx = 0; row_idx < countof(zone_track->rows); ++row_idx) - { - V_ZoneRow *row = &zone_track->rows[row_idx]; - row->first_chunk = PushStruct(perm, V_ZoneChunk); - row->first_chunk->start_ns = I64Min; - row->first_chunk->end_ns = I64Min; - row->last_chunk = PushStruct(perm, V_ZoneChunk); - row->last_chunk->start_ns = I64Max; - row->last_chunk->end_ns = I64Max; - for (u64 level = 0; level < V_ZoneChunkLevelsCount; ++level) - { - row->first_chunk->nexts[level] = row->last_chunk; - row->last_chunk->prevs[level] = row->first_chunk; - } - } + // Push root zone + zone_track->root_zone = PushStruct(perm, V_Zone); + zone_track->root_zone->start_ns = I64Min; + zone_track->root_zone->end_ns = I64Max; + zone_track->open_zone = zone_track->root_zone; } } @@ -5441,78 +5430,62 @@ void V_TickForever(WaveLaneCtx *lane) b32 is_end_zone = !is_begin_zone; if (is_begin_zone) { - //- Start zone - if (zone_track->current_sample_depth < V_MaxZoneDepth) + //- Begin zone + V_Zone *parent = zone_track->open_zone; + u64 zone_id = V.total_zones_count++; + + //- Fetch chunk + V_ZoneChunk *chunk = parent->last_chunk; { - u64 zone_id = V.total_zones_count++; - V_ZoneRow *row = &zone_track->rows[zone_track->current_sample_depth]; - - //- Fetch chunk - V_ZoneChunk *chunk = row->last_chunk->prevs[0]; + u64 new_chunk_capacity = 1; + if (chunk && chunk->count >= chunk->capacity) { - b32 is_first_chunk = chunk->end_ns == I64Min; - if (chunk->zones_count >= V_MaxZonesPerChunk || is_first_chunk) - { - chunk = PushStruct(perm, V_ZoneChunk); - chunk->start_ns = sample_time_ns; - chunk->end_ns = I64Max; - for (u32 level = 0; level < V_ZoneChunkLevelsCount; ++level) - { - // Insert into skip list - V_ZoneChunk *prev_chunk = row->last_chunk->prevs[level]; - DllQueueInsertNP( - row->first_chunk, - row->last_chunk, - prev_chunk, - chunk, - nexts[level], - prevs[level] - ); - if (MixU64(zone_id) % 2) - { - // Exit skip list initialization - break; - } - } - } + new_chunk_capacity = chunk->capacity * 2; + chunk = 0; } - - //- Push zone - u64 chunk_zone_idx = chunk->zones_count++; - V_Zone *zone = &chunk->zones[chunk_zone_idx]; + if (!chunk) { - zone->id = zone_id; - zone->start_ns = sample_time_ns; - zone->end_ns = I64Max; - - // TODO: More efficient name processing - char *name_cstr = sample->name_cstr_lit; - String name = StringFromCstrNoLimit(name_cstr); - u64 color_seed = HashString(name); - - f32 h = (Norm16(color_seed >> 0) * 1) * 360; - f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1); - f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1); - zone->color = SrgbFromHsv(h, s, v); - zone->name = name; + chunk = PushStruct(perm, V_ZoneChunk); + chunk->capacity = new_chunk_capacity; + chunk->zones = PushStructsNoZero(perm, V_Zone, chunk->capacity); + SllQueuePush(parent->first_chunk, parent->last_chunk, chunk); } - - zone_track->rows_count = MaxU64(zone_track->rows_count, zone_track->current_sample_depth + 1); } - zone_track->current_sample_depth += 1; + + V_Zone *zone = &chunk->zones[chunk->count++]; + { + zone->id = zone_id; + zone->start_ns = sample_time_ns; + zone->end_ns = I64Max; + zone->parent = parent; + zone->depth = parent->depth + 1; + + // TODO: More efficient name processing + char *name_cstr = sample->name_cstr_lit; + zone->name = StringFromCstrNoLimit(name_cstr); + + u64 color_seed = HashString(zone->name); + f32 h = (Norm16(color_seed >> 0) * 1) * 360; + f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1); + f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1); + zone->color = SrgbFromHsv(h, s, v); + } + zone_track->open_zone = zone; + + // Update ancestor counts + for (V_Zone *ancestor = parent; ancestor; ancestor = ancestor->parent) + { + ancestor->total_descendents_count += 1; + } } else if (is_end_zone) { //- End zone - zone_track->current_sample_depth -= 1; - if (zone_track->current_sample_depth < V_MaxZoneDepth) + V_Zone *zone = zone_track->open_zone; { - V_ZoneRow *row = &zone_track->rows[zone_track->current_sample_depth]; - V_ZoneChunk *chunk = row->last_chunk->prevs[0]; - V_Zone *zone = &chunk->zones[chunk->zones_count - 1]; zone->end_ns = sample_time_ns; - chunk->end_ns = sample_time_ns; } + zone_track->open_zone = zone->parent; } } @@ -5587,6 +5560,7 @@ void V_TickForever(WaveLaneCtx *lane) UI_Size header_height = UI_Fnt(2, 1); UI_Size footer_height = UI_Fnt(2, 1); UI_Size window_padding = UI_Fnt(0.60, 1); + UI_Size minor_padding = UI_Fnt(0.15, 1); // UI_Size graph_height = UI_Grow(0.25, 0); UI_Size graph_height = UI_Fnt(2, 1); UI_Size main_height = UI_Grow(1, 0); @@ -5757,9 +5731,10 @@ void V_TickForever(WaveLaneCtx *lane) Vec4 color; f64 start_px; - f64 len_px; + f64 end_px; - i64 elapsed_ns; + i64 start_ns; + i64 end_ns; b32 is_collapsed; u64 collapsed_count; @@ -5778,140 +5753,136 @@ void V_TickForever(WaveLaneCtx *lane) VisTrack *first_vis_track = 0; VisTrack *last_vis_track = 0; + + + + + + + //- Compute visible zones + f32 zone_collapse_threshold_px = 10; + f32 min_zone_width_px = 1; ProfZoneDF("Compute visible zones") { for (V_ZoneTrack *zone_track = V.first_zone_track; zone_track; zone_track = zone_track->next) { // TODO: Ignore non-visible tracks + // TODO: Ignore non-visible depths + VisTrack *vis_track = PushStruct(frame->arena, VisTrack); SllQueuePush(first_vis_track, last_vis_track, vis_track); vis_track->id = zone_track->id; - // TODO: Ignore non-visible rows - for (u64 row_idx = 0; row_idx < zone_track->rows_count; ++row_idx) + Struct(BfsZone) { BfsZone *next; V_Zone *zone; }; + BfsZone *first_bfs_zone = 0; + BfsZone *last_bfs_zone = 0; + { - V_ZoneRow *zone_row = &zone_track->rows[row_idx]; + BfsZone *root_bfs = PushStruct(frame->arena, BfsZone); + root_bfs->zone = zone_track->root_zone; + SllQueuePush(first_bfs_zone, last_bfs_zone, root_bfs); + } + VisZone *collapsed_vis_zone = 0; + V_Zone *collapsed_zone_parent = 0; + for (BfsZone *bfs_zone = first_bfs_zone; bfs_zone; bfs_zone = first_bfs_zone) + { + SllQueuePop(first_bfs_zone, last_bfs_zone); + V_Zone *zone = bfs_zone->zone; - // Locate first chunk in view - V_ZoneChunk *closest_start = zone_row->last_chunk; + i64 zone_start_ns = zone->start_ns; + i64 zone_end_ns = MinI64(zone->end_ns, frame->time_ns); + i64 zone_elapsed_ns = zone_end_ns - zone_start_ns; + i64 visual_zone_start_ns = MaxI64(zone_start_ns, profiler->view_ns); + i64 visual_zone_end_ns = MinI64(zone_end_ns, profiler->view_ns + view_range_len_ns); + f64 visual_zone_start_px = visual_zone_start_ns / profiler->ns_per_px; + f64 visual_zone_end_px = MaxF64(visual_zone_end_ns / profiler->ns_per_px, visual_zone_start_px + min_zone_width_px); + + b32 is_root_zone = zone == zone_track->root_zone; + b32 should_collapse_zone = (zone_elapsed_ns / profiler->ns_per_px) <= zone_collapse_threshold_px && !is_root_zone; + + // Push children to bfs queue + if (!should_collapse_zone && visual_zone_end_ns >= view_start_ns && visual_zone_start_ns <= view_end_ns) { - for (i32 level = countof(closest_start->prevs) - 1; level >= 0; --level) + b32 reached_end_of_view = 0; + for (V_ZoneChunk *chunk = zone->first_chunk; chunk && !reached_end_of_view; chunk = chunk->next) { - while (closest_start->prevs[level] && closest_start->prevs[level]->end_ns >= view_start_ns) + i64 chunk_start_ns = chunk->zones[0].start_ns; + i64 chunk_end_ns = MinI64(chunk->zones[chunk->count - 1].end_ns, frame->time_ns); + + // i64 should_collapse_chunk = (chunk->end_ns - chunk->start_ns) / + + if (chunk_start_ns <= view_end_ns && chunk_end_ns >= view_start_ns) { - closest_start = closest_start->prevs[level]; + // TODO: Binary search to find start + for (u64 chunk_zone_idx = 0; chunk_zone_idx < chunk->count && !reached_end_of_view; ++chunk_zone_idx) + { + V_Zone *child = &chunk->zones[chunk_zone_idx]; + if (child->start_ns > view_end_ns) + { + reached_end_of_view = 1; + } + else + { + BfsZone *child_bfs = PushStruct(frame->arena, BfsZone); + child_bfs->zone = child; + SllQueuePush(first_bfs_zone, last_bfs_zone, child_bfs); + } + } } } } - - - i64 collapsed_zones_count = 0; - i64 collapsed_start_ns = 0; - i64 collapsed_end_ns = 0; - f32 zone_collapse_threshold_px = 10; - if (closest_start->end_ns >= view_start_ns && closest_start->start_ns <= view_end_ns) + // Push vis zone + if (!is_root_zone) { - for (V_ZoneChunk *chunk = closest_start; chunk && chunk->start_ns <= view_end_ns; chunk = chunk->nexts[0]) + String zone_name = zone->name; + u64 zone_id = zone->id; + Vec4 zone_color = zone->color; + + // b32 should_collapse_zone = visual_zone_len_px <= zone_collapse_threshold_px; + // b32 should_collapse_zone = 0; + + // if (visual_zone_start_ns > view_end_ns) + // { + // reached_end_of_view = 1; + // } + + if (visual_zone_end_ns >= view_start_ns && visual_zone_start_ns <= view_end_ns) { - i64 visual_chunk_start_ns = MaxI64(chunk->start_ns, profiler->view_ns); - i64 visual_chunk_end_ns = MinI64(chunk->end_ns, profiler->view_ns + view_range_len_ns); - f64 visual_chunk_len_px = (visual_chunk_end_ns - visual_chunk_start_ns) / profiler->ns_per_px; - - b32 should_collapse_chunk = visual_chunk_len_px <= zone_collapse_threshold_px; - - // TODO: Larger chunks w/ binary search to locate start & end zones - - - // FIXME: Enable this - // if (!should_collapse_chunk) - - - - + VisZone *vis_zone = 0; + if ( + should_collapse_zone && + collapsed_vis_zone && + collapsed_zone_parent == zone->parent && + ((zone_start_ns - collapsed_vis_zone->end_ns) / profiler->ns_per_px) < zone_collapse_threshold_px + ) { - b32 reached_end_of_view = 0; - for (u64 chunk_zone_idx = 0; chunk_zone_idx < chunk->zones_count && !reached_end_of_view; ++chunk_zone_idx) - { - V_Zone *zone = &chunk->zones[chunk_zone_idx]; + vis_zone = collapsed_vis_zone; + } + else + { + vis_zone = PushStruct(frame->arena, VisZone); + vis_zone->start_ns = zone_start_ns; + vis_zone->start_px = visual_zone_start_px; + vis_zone->name = zone_name; + vis_zone->id = zone_id; + } - i64 zone_start_ns = zone->start_ns; - i64 zone_end_ns = MinI64(zone->end_ns, frame->time_ns); - i64 zone_elapsed_ns = zone_end_ns - zone_start_ns; - i64 visual_zone_start_ns = MaxI64(zone_start_ns, profiler->view_ns); - i64 visual_zone_end_ns = MinI64(zone_end_ns, profiler->view_ns + view_range_len_ns); - f64 visual_zone_start_px = visual_zone_start_ns / profiler->ns_per_px; - f64 visual_zone_len_px = (visual_zone_end_ns - visual_zone_start_ns) / profiler->ns_per_px; + SllQueuePush(vis_track->first_zone, vis_track->last_zone, vis_zone); + vis_zone->end_px = visual_zone_end_px; + vis_zone->end_ns = zone_end_ns; + vis_zone->color = zone_color; + vis_zone->depth = zone->depth; + vis_track->rows_count = MaxU32(vis_track->rows_count, vis_zone->depth); - String zone_name = zone->name; - u64 zone_id = zone->id; - Vec4 zone_color = zone->color; - - b32 should_collapse_zone = visual_zone_len_px <= zone_collapse_threshold_px; - // b32 should_collapse_zone = 0; - - if (visual_zone_start_ns > view_end_ns) - { - reached_end_of_view = 1; - } - - if (should_collapse_zone) - { - if (collapsed_zones_count <= 0) - { - collapsed_start_ns = zone_start_ns; - } - collapsed_end_ns = zone_end_ns; - collapsed_zones_count += 1; - } - - // Draw collapsed zones - // FIXME: Draw final collapsed zones in chunk - if (collapsed_zones_count > 0 && (!should_collapse_zone || reached_end_of_view)) - { - i64 collapsed_zone_start_ns = collapsed_start_ns; - i64 collapsed_zone_end_ns = MinI64(collapsed_end_ns, frame->time_ns); - i64 collapsed_zone_elapsed_ns = collapsed_zone_end_ns - collapsed_zone_start_ns; - f64 collapsed_visual_zone_start_ns = MaxI64(collapsed_zone_start_ns, profiler->view_ns); - f64 collapsed_visual_zone_end_ns = MinI64(collapsed_zone_end_ns, profiler->view_ns + view_range_len_ns); - f64 collapsed_visual_zone_start_px = collapsed_visual_zone_start_ns / profiler->ns_per_px; - f64 collapsed_visual_zone_len_px = (collapsed_visual_zone_end_ns - collapsed_visual_zone_start_ns) / profiler->ns_per_px; - { - VisZone *vis_zone = PushStruct(frame->arena, VisZone); - SllQueuePush(vis_track->first_zone, vis_track->last_zone, vis_zone); - // vis_zone->name = StringF(frame->arena, "%F collapsed zones", FmtSint(collapsed_zones_count)); - vis_zone->name = Lit("Collapsed"); - vis_zone->id = MixU64s(zone->id, V_CollapsedZoneBasis); - vis_zone->color = VEC4(0.55, 0.15, 0.15, 1); - vis_zone->start_px = collapsed_visual_zone_start_px; - vis_zone->len_px = collapsed_visual_zone_len_px; - vis_zone->elapsed_ns = collapsed_zone_elapsed_ns; - vis_zone->depth = row_idx; - vis_zone->is_collapsed = 1; - vis_zone->collapsed_count = collapsed_zones_count; - vis_track->rows_count = MaxU32(vis_track->rows_count, vis_zone->depth + 1); - } - collapsed_zones_count = 0; - collapsed_start_ns = 0; - collapsed_end_ns = 0; - } - - if (!should_collapse_zone && visual_zone_end_ns >= view_start_ns && visual_zone_start_ns <= view_end_ns) - { - VisZone *vis_zone = PushStruct(frame->arena, VisZone); - SllQueuePush(vis_track->first_zone, vis_track->last_zone, vis_zone); - vis_zone->name = zone_name; - vis_zone->id = zone_id; - vis_zone->color = zone_color; - vis_zone->start_px = visual_zone_start_px; - vis_zone->len_px = visual_zone_len_px; - vis_zone->elapsed_ns = zone_elapsed_ns; - vis_zone->depth = row_idx; - vis_track->rows_count = MaxU32(vis_track->rows_count, vis_zone->depth + 1); - } - } + if (should_collapse_zone) + { + vis_zone->is_collapsed = 1; + vis_zone->collapsed_count += zone->total_descendents_count + 1; + collapsed_vis_zone = vis_zone; + collapsed_zone_parent = zone->parent; } } } @@ -5919,24 +5890,6 @@ void V_TickForever(WaveLaneCtx *lane) } } - - - - - - - - - - - - - - - - - // 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; f32 profiler_opacity = TweakFloat("Profiler opacity", 1, 0, 1); @@ -6066,7 +6019,7 @@ void V_TickForever(WaveLaneCtx *lane) //- Zones for (VisZone *zone = vis_track->first_zone; zone; zone = zone->next) { - UI_Key zone_row_box = zone_row_boxes[zone->depth]; + UI_Key zone_row_box = zone_row_boxes[zone->depth - 1]; UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id)); if (UI_HotAbsolute(zone_box)) @@ -6076,7 +6029,7 @@ void V_TickForever(WaveLaneCtx *lane) } f64 zone_offset_px = zone->start_px - view_start_px; - f64 zone_len_px = zone->len_px; + f64 zone_len_px = zone->end_px - zone->start_px; Vec2 zone_pos = VEC2(zone_offset_px, 0); UI_Size zone_width = UI_Px(zone_len_px, 1); @@ -6085,22 +6038,34 @@ void V_TickForever(WaveLaneCtx *lane) zone_color_bd = MulVec4(zone_color_bd, 0.65); zone_color_bd.a = 1; + zone_color_bd = LerpSrgb(zone_color_bd, Color_White, UI_Hot(zone_box)); Vec4 zone_text_color = UI_Top(TextColor); zone_text_color.a *= 0.75; + // b32 is_collapsed = zone->is_collapsed; + b32 is_collapsed = zone->collapsed_count > 1; + UI_Size collapsed_line_size = UI_Fnt(0.1, 1); + // Vec4 collapsed_text_color = theme.col.positive; + Vec4 collapsed_line_color = theme.col.negative; + // Vec4 collapsed_line_color = theme.col.hint; + Vec4 collapsed_text_color = theme.col.positive; + // Vec4 collapsed_line_color = collapsed_text_color; + collapsed_text_color = LerpSrgb(collapsed_text_color, Color_White, UI_Hot(zone_box)); + collapsed_line_color = LerpSrgb(collapsed_line_color, Color_White, UI_Hot(zone_box)); + String zone_text = zone->name; - if (zone->is_collapsed) + if (is_collapsed) { zone_text = StringF(frame->arena, "%F", FmtUint(zone->collapsed_count)); - zone_text_color = theme.col.positive; - // zone_color = VEC4(0, 0, 0, 0); - zone_color = VEC4(1, 0, 1, 1); + zone_text_color = collapsed_text_color; + zone_color = VEC4(0, 0, 0, 0); + // zone_color = VEC4(1, 0, 1, 1); + // zone_color = VEC4(0.15, 0.15, 0.15, 0.5); + // zone_color = VEC4(0.20, 0.20, 0.20, 0.5); zone_color_bd = VEC4(0, 0, 0, 0); } - zone_color_bd = LerpSrgb(zone_color_bd, Color_White, UI_Hot(zone_box)); - UI_SetNext(Width, zone_width); UI_SetNext(Height, UI_Grow(1, 0)); UI_SetNext(BackgroundColor, zone_color); @@ -6110,22 +6075,31 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(Flags, UI_BoxFlag_Floating | UI_BoxFlag_DontClampFloatingX | UI_BoxFlag_DontClampFloatingY | UI_BoxFlag_CaptureMouse | UI_BoxFlag_Scissor); UI_SetNext(Parent, zone_row_box); - UI_SetDF(OrFlags, UI_Top(OrFlags) | (UI_BoxFlag_DontTruncateText * !!(zone->is_collapsed))) + UI_SetDF(OrFlags, UI_Top(OrFlags) | (UI_BoxFlag_DontTruncateText * !!(is_collapsed))) + UI_SetDF(OmitFlags, UI_Top(OmitFlags) | (UI_BoxFlag_Scissor * !!(is_collapsed))) UI_SetDF(Parent, UI_BuildRowEx(zone_box)) { - // Collapsed line - if (zone->is_collapsed) + // Left collapsed lines + if (is_collapsed) { - UI_SetNext(Flags, UI_BoxFlag_Floating); - UI_SetDF(Opacity, 0.25) + // Vertical line + { + UI_SetDF(Opacity, 1.0 - UI_Hot(zone_box)) + UI_SetNext(BackgroundColor, collapsed_line_color); + UI_SetNext(Width, collapsed_line_size); + UI_SetNext(Height, UI_Grow(1, 0)); + UI_BuildBox(); + } + + // Horizontal line UI_SetDF(Parent, UI_BuildColumn()) { UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); UI_SetNext(Width, UI_Grow(1, 0)); - UI_SetNext(Height, UI_Fnt(0.1, 1)); - UI_SetNext(Anchor, UI_Region_Center); - UI_SetNext(BackgroundColor, theme.col.positive); + UI_SetNext(Height, collapsed_line_size); + // UI_SetNext(Anchor, UI_Region_Center); + UI_SetNext(BackgroundColor, collapsed_line_color); UI_BuildBox(); UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); @@ -6133,8 +6107,16 @@ void V_TickForever(WaveLaneCtx *lane) } // Zone name + if (zone_len_px > zone_collapse_threshold_px) { - UI_SetNext(Width, UI_Shrink(0, 0)); + if (is_collapsed) + { + UI_SetNext(Width, UI_Shrink(0, 1)); + } + else + { + UI_SetNext(Width, UI_Shrink(0, 0)); + } UI_SetNext(ChildAlignment, UI_Region_Center); UI_SetNext(FontSize, UI_Top(FontSize) * theme.h5); UI_SetNext(TextColor, zone_text_color); @@ -6142,6 +6124,34 @@ void V_TickForever(WaveLaneCtx *lane) UI_SetNext(Flags, UI_BoxFlag_DrawText); UI_BuildRow(); } + + // Right collapsed lines + if (is_collapsed) + { + // Horizontal line + // UI_SetNext(Flags, UI_BoxFlag_Floating); + // UI_SetDF(Opacity, 0.25) + UI_SetDF(Parent, UI_BuildColumn()) + { + UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); + + UI_SetNext(Width, UI_Grow(1, 0)); + UI_SetNext(Height, collapsed_line_size); + // UI_SetNext(Anchor, UI_Region_Center); + UI_SetNext(BackgroundColor, collapsed_line_color); + UI_BuildBox(); + + UI_BuildSpacer(UI_Grow(1, 0), Axis_Y); + } + + // Vertical line + { + UI_SetNext(BackgroundColor, collapsed_line_color); + UI_SetNext(Width, collapsed_line_size); + UI_SetNext(Height, UI_Grow(1, 0)); + UI_BuildBox(); + } + } } } } @@ -6168,7 +6178,8 @@ void V_TickForever(WaveLaneCtx *lane) Vec2 ruler_pos = VEC2(ruler_offset_px, 0); UI_Size ruler_width = UI_Px(ruler_len_px, 1); - Vec4 ruler_color = VEC4(0.25, 0.25, 0.25, 0.25); + // Vec4 ruler_color = VEC4(0.25, 0.25, 0.25, 0.25); + Vec4 ruler_color = VEC4(0.20, 0.20, 0.20, 0.25); // Ruler rect { @@ -6244,31 +6255,49 @@ void V_TickForever(WaveLaneCtx *lane) { // UI_SetNext(TextColor, theme.col.positive); // UI_SetNext(TextColor, theme.col.button_active); + + UI_SetNext(TextColor, theme.col.button_selected); UI_BuildLabelF("%F", FmtTimeNs(ruler_len_ns, .p = 2)); + + // UI_SetNext(TextColor, theme.col.button_selected); + // UI_BuildLabelF("Ruler"); + + if (show_hovered_zone) + { + UI_BuildSpacer(minor_padding, Axis_Y); + UI_BuildSpacer(minor_padding, Axis_Y); + UI_BuildDivider(UI_Px(1, 0), theme.col.divider, Axis_Y); + UI_BuildSpacer(minor_padding, Axis_Y); + } } if (show_hovered_zone) { VisZone *zone = hovered_zone; - // UI_BuildLabelF("Hi!!"); - - - - // UI_BuildLabelF("%Fms", FmtFloat(MsFromNs(zone_elapsed_ns), .p = 2)); UI_SetDF(Parent, UI_BuildRow()) { - UI_BuildLabelF("%F ", FmtTimeNs(zone->elapsed_ns, .p = 2)); - if (zone->is_collapsed) + i64 elapsed_ns = zone->end_ns - zone->start_ns; + UI_SetDF(Parent, UI_BuildColumn()) { - UI_SetNext(TextColor, theme.col.hint); - UI_BuildLabelF("Collapsed zones"); - UI_SetNext(TextColor, theme.col.positive); - UI_BuildLabelF(" (%F)", FmtUint(zone->collapsed_count)); - } - else - { - UI_SetNext(TextColor, theme.col.hint); - UI_BuildLabelF("%F", FmtString(zone->name)); + UI_BuildLabelF("%F ", FmtTimeNs(elapsed_ns, .p = 2)); + + if (zone->collapsed_count > 1) + { + UI_SetDF(Parent, UI_BuildRow()) + { + UI_SetNext(TextColor, theme.col.hint); + // UI_BuildLabelF("Collapsed zones"); + UI_BuildLabelF("Multiple zones"); + + UI_SetNext(TextColor, theme.col.positive); + UI_BuildLabelF(" (%F)", FmtUint(zone->collapsed_count)); + } + } + else + { + UI_SetNext(TextColor, theme.col.hint); + UI_BuildLabelF("%F", FmtString(zone->name)); + } } } } diff --git a/src/pp/pp_vis/pp_vis_core.h b/src/pp/pp_vis/pp_vis_core.h index 7288af5f..c2591a25 100644 --- a/src/pp/pp_vis/pp_vis_core.h +++ b/src/pp/pp_vis/pp_vis_core.h @@ -240,16 +240,22 @@ Struct(V_Palette) //////////////////////////////////////////////////////////// //~ Profiler types -#define V_MaxZonesPerChunk 1024 -#define V_MaxZoneDepth 128 -#define V_ZoneChunkLevelsCount 32 -#define V_CollapsedZoneBasis 0x4a06f782d21f18af +// #define V_CollapsedZoneBasis 0x4a06f782d21f18af +#define V_MinChunkCapacity 1 Struct(V_Zone) { + V_Zone *parent; + struct V_ZoneChunk *first_chunk; + struct V_ZoneChunk *last_chunk; + + u64 total_descendents_count; + String name; u64 id; + i64 depth; + Vec4 color; i64 start_ns; i64 end_ns; @@ -257,37 +263,24 @@ Struct(V_Zone) Struct(V_ZoneChunk) { - V_ZoneChunk *nexts[V_ZoneChunkLevelsCount]; - V_ZoneChunk *prevs[V_ZoneChunkLevelsCount]; + V_ZoneChunk *next; - i64 start_ns; - i64 end_ns; - - u64 zones_count; - V_Zone zones[V_MaxZonesPerChunk]; -}; - -Struct(V_ZoneRow) -{ - // Skip list sentinels - V_ZoneChunk *first_chunk; - V_ZoneChunk *last_chunk; + u64 count; + u64 capacity; + V_Zone *zones; }; Struct(V_ZoneTrack) { V_ZoneTrack *next; - V_ZoneTrack *prev; - // Zones + V_Zone *root_zone; u64 id; - u64 rows_count; - V_ZoneRow rows[V_MaxZoneDepth]; // Sample collection ProfTrack *prof_track; u64 next_collection_sample_seq; - u64 current_sample_depth; + V_Zone *open_zone; }; diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index 36bbdb63..42cfc5cc 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -1963,7 +1963,7 @@ void UI_EndFrame(UI_Frame *frame, i32 vsync) } break; } baseline = CeilVec2(baseline); - baseline.x = MaxF32(baseline.x, box->screen_rect.p0.x); + // baseline.x = MaxF32(baseline.x, box->screen_rect.p0.x); // Push text rects for (u64 rect_idx = 0; rect_idx < final_rects_count; ++rect_idx)