diff --git a/GL/draw.c b/GL/draw.c index 628ca46..a16a7ea 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -1239,6 +1239,8 @@ static void submitVertices(GLenum mode, GLsizei first, GLsizei count, GLenum typ glBlendFunc(blendSrc, blendDst); (blendEnabled) ? glEnable(GL_BLEND) : glDisable(GL_BLEND); (depthEnabled) ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); + + PROFILER_POP(); } void APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) { diff --git a/GL/flush.c b/GL/flush.c index 835e62a..096c73e 100644 --- a/GL/flush.c +++ b/GL/flush.c @@ -121,7 +121,7 @@ void APIENTRY glKosInit() { void APIENTRY glKosSwapBuffers() { static int frame_count = 0; - + TRACE(); PROFILER_PUSH(__func__); @@ -152,7 +152,7 @@ void APIENTRY glKosSwapBuffers() { PROFILER_CHECKPOINT("scene"); PROFILER_POP(); - if(frame_count++ > 100) { + if(++frame_count > 49) { profiler_print_stats(); frame_count = 0; } diff --git a/GL/profiler.c b/GL/profiler.c index d922b83..49d353b 100644 --- a/GL/profiler.c +++ b/GL/profiler.c @@ -5,6 +5,7 @@ #include #include "profiler.h" +#include "private.h" #ifdef PROFILER_COMPILE #include "../containers/aligned_vector.h" @@ -132,15 +133,20 @@ void profiler_pop() { void profiler_print_stats() { if(!PROFILER_ENABLED) return; - fprintf(stderr, "%-60s%-20s%-20s%-20s\n", "Path", "Average", "Total", "Calls"); - + fprintf(stderr, "%-40s%-20s%-20s%-20s%-20s\n", "Path", "Time(ms)", "Average", "Total", "Calls"); + float total_ms = 0; + float fps = 0; uint16_t i = 0; for(; i < root->results.size; ++i) { ProfilerResult* result = aligned_vector_at(&root->results, i); float ms = ((float) result->total_time_us) / 1000.0f; float avg = ms / (float) result->total_calls; + total_ms += ms; fprintf(stderr, "%-60s%-20f%-20f%u\n", result->name, avg, ms, result->total_calls); } + total_ms/=((ProfilerResult*)aligned_vector_at(&root->results, i-1))->total_calls; + fps = 1000/total_ms; + fprintf(stderr, "%-10s%-10f%-10s%-10f\n", "Time(ms)", total_ms, "FPS", fps); } #endif diff --git a/GL/profiler.h b/GL/profiler.h index f7a6ec4..15216e8 100644 --- a/GL/profiler.h +++ b/GL/profiler.h @@ -3,7 +3,7 @@ #include #define PROFILER_COMPILE 1 -#ifdef PROFILER_COMPILE +#if PROFILER_COMPILE #define PROFILER_PUSH(S) profiler_push(S) #define PROFILER_CHECKPOINT(P) profiler_checkpoint(P) #define PROFILER_POP() profiler_pop()