fix-vprof-timings.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --- a/engine/vprof_engine.cpp
  2. +++ b/engine/vprof_engine.cpp
  3. @@ -246,11 +246,15 @@
  4. g_VProfCurrentProfile.ResetCounters( COUNTER_GROUP_DEFAULT );
  5. g_VProfCurrentProfile.ResetCounters( COUNTER_GROUP_TEXTURE_PER_FRAME );
  6. +#ifdef VPROF_ENABLED
  7. + // Record the frame that just completed. Must run before
  8. + // VProfExport_SnapshotVProfHistory(), which consumes and clears the
  9. + // previous-frame data that Record_Snapshot() now reads.
  10. + VProfRecord_Snapshot();
  11. +#endif
  12. +
  13. // This MUST come before GetVProfPanel()->UpdateProfile(), because UpdateProfile uses the data we snapshot here.
  14. VProfExport_SnapshotVProfHistory();
  15. -#ifdef VPROF_ENABLED
  16. - VProfRecord_Snapshot();
  17. -#endif
  18. #ifndef SWDS
  19. // Update the vgui panel
  20. --- a/engine/vprof_record.cpp
  21. +++ b/engine/vprof_record.cpp
  22. @@ -211,7 +211,7 @@
  23. void Record_WriteTimings_R( const CVProfNode *pIn )
  24. {
  25. - unsigned short curCalls = min( pIn->m_nCurFrameCalls, (unsigned)0xFFFF );
  26. + unsigned short curCalls = min( pIn->m_nPrevFrameCalls, (unsigned)0xFFFF );
  27. if ( curCalls >= 255 )
  28. {
  29. unsigned char token = 255;
  30. @@ -226,7 +226,7 @@
  31. }
  32. // This allows us to write 2 bytes unless it's > 256 milliseconds (unlikely).
  33. - unsigned long nMicroseconds = pIn->m_CurFrameTime.GetMicroseconds() / 4;
  34. + uint32 nMicroseconds = (uint32)( pIn->m_PrevFrameTime.GetMicroseconds() / 4 );
  35. if ( nMicroseconds >= 0xFFFF )
  36. {
  37. unsigned short token = 0xFFFF;
  38. @@ -481,11 +481,11 @@
  39. if ( microsecondsToken == 0xFFFF )
  40. {
  41. - unsigned long nMicroseconds;
  42. + uint32 nMicroseconds;
  43. if ( g_pFileSystem->Read( &nMicroseconds, sizeof( nMicroseconds ), m_hFile ) != sizeof( nMicroseconds ) )
  44. return false;
  45. - pNode->m_CurFrameTime.SetMicroseconds( nMicroseconds * 4 );
  46. + pNode->m_CurFrameTime.SetMicroseconds( (unsigned long)nMicroseconds * 4 );
  47. }
  48. else
  49. {