| 68 | #endif |
| 69 | |
| 70 | static void UpdateFramerate() |
| 71 | { |
| 72 | #ifdef DAEDALUS_FRAMERATE_ANALYSIS |
| 73 | gTotalFrames++; |
| 74 | #endif |
| 75 | gFlipCount++; |
| 76 | |
| 77 | u64 now {}; |
| 78 | NTiming::GetPreciseTime( &now ); |
| 79 | |
| 80 | if(gLastFramerateCalcTime == 0) |
| 81 | { |
| 82 | u64 freq {}; |
| 83 | gLastFramerateCalcTime = now; |
| 84 | |
| 85 | NTiming::GetPreciseFrequency( &freq ); |
| 86 | gTicksPerSecond = freq; |
| 87 | } |
| 88 | |
| 89 | #ifdef DAEDALUS_FRAMERATE_ANALYSIS |
| 90 | if( gFramerateFile == nullptr ) |
| 91 | { |
| 92 | gFirstFrameTime = now; |
| 93 | gFramerateFile = fopen( "framerate.csv", "w" ); |
| 94 | } |
| 95 | fprintf( gFramerateFile, "%d,%f\n", gTotalFrames, f32(now - gFirstFrameTime) / f32(gTicksPerSecond) ); |
| 96 | #endif |
| 97 | |
| 98 | // If 1 second has elapsed since last recalculation, do it now |
| 99 | u64 ticks_since_recalc( now - gLastFramerateCalcTime ); |
| 100 | if(ticks_since_recalc > gTicksPerSecond) |
| 101 | { |
| 102 | //gCurrentVblrate = float( gVblCount * gTicksPerSecond ) / float( ticks_since_recalc ); |
| 103 | gCurrentFramerate = float( gFlipCount * gTicksPerSecond ) / float( ticks_since_recalc ); |
| 104 | |
| 105 | //gVblCount = 0; |
| 106 | gFlipCount = 0; |
| 107 | gLastFramerateCalcTime = now; |
| 108 | |
| 109 | #ifdef DAEDALUS_FRAMERATE_ANALYSIS |
| 110 | if( gFramerateFile != nullptr ) |
| 111 | { |
| 112 | fflush( gFramerateFile ); |
| 113 | } |
| 114 | #endif |
| 115 | } |
| 116 | |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | class CGraphicsPluginImpl : public CGraphicsPlugin |
no test coverage detected