store chunk zone start time

This commit is contained in:
jacob 2026-04-01 02:45:30 -05:00
parent ef5b79e52f
commit 9ef91e48a0
3 changed files with 125 additions and 118 deletions

View File

@ -3862,7 +3862,7 @@ G_BackbufferHandle G_PrepareBackbuffer(G_SwapchainHandle swapchain_handle, G_For
// Wait for available backbuffer // Wait for available backbuffer
if (swapchain->waitable) if (swapchain->waitable)
{ {
ProfZoneDF("Wait on swapchain") ProfZoneDF("Wait for swapchain")
{ {
DWORD wait_result = WaitForSingleObject(swapchain->waitable, 500); DWORD wait_result = WaitForSingleObject(swapchain->waitable, 500);
if (wait_result == WAIT_TIMEOUT) if (wait_result == WAIT_TIMEOUT)

View File

@ -5454,6 +5454,7 @@ void V_TickForever(WaveLaneCtx *lane)
if (chunk->zones_count >= V_MaxZonesPerChunk || is_first_chunk) if (chunk->zones_count >= V_MaxZonesPerChunk || is_first_chunk)
{ {
chunk = PushStruct(perm, V_ZoneChunk); chunk = PushStruct(perm, V_ZoneChunk);
chunk->start_ns = sample_time_ns;
chunk->end_ns = I64Max; chunk->end_ns = I64Max;
for (u32 level = 0; level < V_ZoneChunkLevelsCount; ++level) for (u32 level = 0; level < V_ZoneChunkLevelsCount; ++level)
{ {
@ -5487,17 +5488,16 @@ void V_TickForever(WaveLaneCtx *lane)
// TODO: More efficient name processing // TODO: More efficient name processing
char *name_cstr = sample->name_cstr_lit; char *name_cstr = sample->name_cstr_lit;
String name = StringFromCstrNoLimit(name_cstr); String name = StringFromCstrNoLimit(name_cstr);
zone->name = name;
u64 color_seed = HashString(name); u64 color_seed = HashString(name);
f32 h = (Norm16(color_seed >> 0) * 1) * 360; f32 h = (Norm16(color_seed >> 0) * 1) * 360;
f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1); f32 s = TweakFloat("Profiler zone saturation", 0.50, 0, 1);
f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1); f32 v = TweakFloat("Profiler zone brightness", 1.00, 0, 1);
zone->color = SrgbFromHsv(h, s, v); zone->color = SrgbFromHsv(h, s, v);
zone->name = name;
} }
zone_track->rows_count = MaxU64(zone_track->rows_count, zone_track->current_sample_depth); zone_track->rows_count = MaxU64(zone_track->rows_count, zone_track->current_sample_depth + 1);
} }
zone_track->current_sample_depth += 1; zone_track->current_sample_depth += 1;
} }
@ -5537,7 +5537,8 @@ void V_TickForever(WaveLaneCtx *lane)
V_Profiler *profiler = &frame->profiler; V_Profiler *profiler = &frame->profiler;
f64 min_profiler_ns_per_px = 1; f64 min_profiler_ns_per_px = 1;
f64 max_profiler_ns_per_px = NsFromSeconds(100); // f64 max_profiler_ns_per_px = NsFromSeconds(100);
f64 max_profiler_ns_per_px = frame->time_ns / 10;
profiler->target_ns_per_px = ClampF64(profiler->target_ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); profiler->target_ns_per_px = ClampF64(profiler->target_ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px);
profiler->ns_per_px = ClampF64(profiler->ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px); profiler->ns_per_px = ClampF64(profiler->ns_per_px, min_profiler_ns_per_px, max_profiler_ns_per_px);
@ -5789,8 +5790,6 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
if (closest_start->end_ns >= view_start_ns && closest_start->start_ns <= view_end_ns) if (closest_start->end_ns >= view_start_ns && closest_start->start_ns <= view_end_ns)
{ {
VisRow *vis_row = PushStruct(perm, VisRow); VisRow *vis_row = PushStruct(perm, VisRow);
@ -5889,7 +5888,7 @@ void V_TickForever(WaveLaneCtx *lane)
//- Main area //- Main area
UI_SetNext(BackgroundColor, main_color_unsampled); UI_SetNext(BackgroundColor, main_color_unsampled);
UI_SetNext(Height, main_height); UI_SetNext(Height, main_height);
UI_SetNext(Rounding, UI_Rpx(10)); UI_SetNext(Rounding, UI_Rpx(5 * theme.rounding));
// UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren | UI_BoxFlag_Scissor); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren | UI_BoxFlag_Scissor);
UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren); UI_SetNext(Flags, UI_BoxFlag_CaptureMouse | UI_BoxFlag_CaptureThroughChildren);
// UI_SetNext(Flags, UI_BoxFlag_CaptureMouse); // UI_SetNext(Flags, UI_BoxFlag_CaptureMouse);
@ -5926,6 +5925,7 @@ void V_TickForever(WaveLaneCtx *lane)
//- Zone tracks //- Zone tracks
{ {
f32 zone_collapse_threshold_px = 5;
for (VisTrack *vis_track = first_vis_track; vis_track; vis_track = vis_track->next) for (VisTrack *vis_track = first_vis_track; vis_track; vis_track = vis_track->next)
{ {
V_ZoneTrack *zone_track = vis_track->zone_track; V_ZoneTrack *zone_track = vis_track->zone_track;
@ -5941,6 +5941,11 @@ void V_TickForever(WaveLaneCtx *lane)
UI_SetDF(Parent, UI_BuildRow()) UI_SetDF(Parent, UI_BuildRow())
{ {
for (V_ZoneChunk *chunk = row->closest_zone_chunk; chunk && chunk->start_ns <= view_end_ns; chunk = chunk->nexts[0]) for (V_ZoneChunk *chunk = row->closest_zone_chunk; chunk && chunk->start_ns <= view_end_ns; chunk = chunk->nexts[0])
{
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;
if (visual_chunk_len_px > zone_collapse_threshold_px)
{ {
b32 reached_end_of_visible_chunk = 0; b32 reached_end_of_visible_chunk = 0;
for (u64 chunk_zone_idx = 0; chunk_zone_idx < chunk->zones_count && !reached_end_of_visible_chunk; ++chunk_zone_idx) for (u64 chunk_zone_idx = 0; chunk_zone_idx < chunk->zones_count && !reached_end_of_visible_chunk; ++chunk_zone_idx)
@ -5955,7 +5960,7 @@ void V_TickForever(WaveLaneCtx *lane)
{ {
reached_end_of_visible_chunk = 1; reached_end_of_visible_chunk = 1;
} }
else if (visual_zone_end_ns >= view_start_ns && visual_zone_len_px > 5) else if (visual_zone_end_ns >= view_start_ns && visual_zone_len_px > zone_collapse_threshold_px)
{ {
UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id)); UI_Key zone_box = UI_KeyF("Zone %F", FmtUint(zone->id));
if (UI_HotAbsolute(zone_box)) if (UI_HotAbsolute(zone_box))
@ -6062,6 +6067,8 @@ void V_TickForever(WaveLaneCtx *lane)
} }
} }
} }
}
} }
} }
} }

View File

@ -240,9 +240,9 @@ Struct(V_Palette)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//~ Profiler types //~ Profiler types
#define V_MaxZonesPerChunk 256 #define V_MaxZonesPerChunk 1024
#define V_ZoneChunkLevelsCount 32
#define V_MaxZoneDepth 128 #define V_MaxZoneDepth 128
#define V_ZoneChunkLevelsCount 32
Struct(V_Zone) Struct(V_Zone)
{ {
@ -278,12 +278,12 @@ Struct(V_ZoneTrack)
V_ZoneTrack *next; V_ZoneTrack *next;
V_ZoneTrack *prev; V_ZoneTrack *prev;
// FIXME: Set this // Zones
u64 id; u64 id;
u64 rows_count; u64 rows_count;
V_ZoneRow rows[V_MaxZoneDepth]; V_ZoneRow rows[V_MaxZoneDepth];
// Sample collection
ProfTrack *prof_track; ProfTrack *prof_track;
u64 next_collection_sample_seq; u64 next_collection_sample_seq;
u64 current_sample_depth; u64 current_sample_depth;