X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_profiler.h;h=c8db76dab3c7ad8bfcf3322eeec37e2e0659e3a3;hb=3b3420de0251e489082814e60dcc45e5e8842224;hp=944a5bb2a02155e571b9e0b1781bf31e3bce7a7d;hpb=bc9d0792623d0839920fc09bbffe339e6dc104ee;p=vg.git diff --git a/vg_profiler.h b/vg_profiler.h index 944a5bb..c8db76d 100644 --- a/vg_profiler.h +++ b/vg_profiler.h @@ -13,8 +13,8 @@ struct vg_profile { const char *name; - u64 samples[ VG_PROFILE_SAMPLE_COUNT ]; - u32 buffer_count, buffer_current; + float samples[ VG_PROFILE_SAMPLE_COUNT ]; + u32 buffer_count, buffer_current; enum profile_mode { @@ -41,7 +41,7 @@ VG_STATIC void vg_profile_increment( struct vg_profile *profile ) if( profile->buffer_current >= VG_PROFILE_SAMPLE_COUNT ) profile->buffer_current = 0; - profile->samples[ profile->buffer_current ] = 0; + profile->samples[ profile->buffer_current ] = 0.0f; } VG_STATIC void vg_profile_end( struct vg_profile *profile ) @@ -51,7 +51,7 @@ VG_STATIC void vg_profile_end( struct vg_profile *profile ) if( profile->mode == k_profile_mode_frame ) { - profile->samples[ profile->buffer_current ] = delta; + profile->samples[ profile->buffer_current ] = (float)delta; vg_profile_increment( profile ); } else @@ -60,6 +60,12 @@ VG_STATIC void vg_profile_end( struct vg_profile *profile ) } } +VG_STATIC void vg_profile_graph_sample( struct vg_profile *profile, float s ) +{ + profile->samples[ profile->buffer_current ] = s; + vg_profile_increment( profile ); +} + VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count, float budget, ui_rect panel, u32 colour_offset ) { @@ -90,7 +96,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count, u32 colours[] = { 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffff00ff, 0xffffff00 }; - double rate_mul = 1000.0 / (double)SDL_GetPerformanceFrequency(); + float rate_mul = 1000.0f / (float)SDL_GetPerformanceFrequency(); for( int i=0; isamples[ptrs[j]] * rate_mul, + float sample = profiles[j]->samples[ptrs[j]] * rate_mul, px = (total / (budget)) * sw, wx = (sample / (budget)) * sw;