--- a/engine/vprof_engine.cpp +++ b/engine/vprof_engine.cpp @@ -246,11 +246,15 @@ g_VProfCurrentProfile.ResetCounters( COUNTER_GROUP_DEFAULT ); g_VProfCurrentProfile.ResetCounters( COUNTER_GROUP_TEXTURE_PER_FRAME ); +#ifdef VPROF_ENABLED + // Record the frame that just completed. Must run before + // VProfExport_SnapshotVProfHistory(), which consumes and clears the + // previous-frame data that Record_Snapshot() now reads. + VProfRecord_Snapshot(); +#endif + // This MUST come before GetVProfPanel()->UpdateProfile(), because UpdateProfile uses the data we snapshot here. VProfExport_SnapshotVProfHistory(); -#ifdef VPROF_ENABLED - VProfRecord_Snapshot(); -#endif #ifndef SWDS // Update the vgui panel --- a/engine/vprof_record.cpp +++ b/engine/vprof_record.cpp @@ -211,7 +211,7 @@ void Record_WriteTimings_R( const CVProfNode *pIn ) { - unsigned short curCalls = min( pIn->m_nCurFrameCalls, (unsigned)0xFFFF ); + unsigned short curCalls = min( pIn->m_nPrevFrameCalls, (unsigned)0xFFFF ); if ( curCalls >= 255 ) { unsigned char token = 255; @@ -226,7 +226,7 @@ } // This allows us to write 2 bytes unless it's > 256 milliseconds (unlikely). - unsigned long nMicroseconds = pIn->m_CurFrameTime.GetMicroseconds() / 4; + uint32 nMicroseconds = (uint32)( pIn->m_PrevFrameTime.GetMicroseconds() / 4 ); if ( nMicroseconds >= 0xFFFF ) { unsigned short token = 0xFFFF; @@ -481,11 +481,11 @@ if ( microsecondsToken == 0xFFFF ) { - unsigned long nMicroseconds; + uint32 nMicroseconds; if ( g_pFileSystem->Read( &nMicroseconds, sizeof( nMicroseconds ), m_hFile ) != sizeof( nMicroseconds ) ) return false; - pNode->m_CurFrameTime.SetMicroseconds( nMicroseconds * 4 ); + pNode->m_CurFrameTime.SetMicroseconds( (unsigned long)nMicroseconds * 4 ); } else {