X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_profiler.h;h=c8db76dab3c7ad8bfcf3322eeec37e2e0659e3a3;hb=3b3420de0251e489082814e60dcc45e5e8842224;hp=7be848aa3ee6937d930dc3f16fb7abd190594017;hpb=a7938c00a8c486ad0e2a765c3092017487ba761e;p=vg.git diff --git a/vg_profiler.h b/vg_profiler.h index 7be848a..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; @@ -136,10 +142,10 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count, VG_STATIC void vg_profiler_init(void) { - vg_convar_push( (struct vg_convar){ + vg_var_push( (struct vg_var){ .name = "vg_profiler", .data = &vg_profiler, - .data_type = k_convar_dtype_i32, + .data_type = k_var_dtype_i32, .opt_i32 = { .min=0, .max=1, .clamp=1 }, .persistent = 1 });