Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.25 KB | None | 0 0
  1. diff --git a/microprofileui.h b/microprofileui.h
  2. index 3489350..7a70b21 100644
  3. --- a/microprofileui.h
  4. +++ b/microprofileui.h
  5. @@ -975,6 +975,32 @@ uint32_t MicroProfileWriteProcessHeader(uint32_t nY, uint32_t nProcessId)
  6. return nY;
  7. }
  8.  
  9. +void MicroProfileGetFrameRange(int64_t nTicksCpu, int64_t nTicksEndCpu, uint32_t nFrameIndex[2])
  10. +{
  11. + MicroProfile& S = *MicroProfileGet();
  12. +
  13. + uint32_t nBegin = S.nFrameCurrent;
  14. +
  15. + for(uint32_t i = 0; i < MICROPROFILE_MAX_FRAME_HISTORY - MICROPROFILE_GPU_FRAME_DELAY; ++i)
  16. + {
  17. + nBegin = (S.nFrameCurrent + MICROPROFILE_MAX_FRAME_HISTORY - i) % MICROPROFILE_MAX_FRAME_HISTORY;
  18. + if(S.Frames[nBegin].nFrameStartCpu <= nTicksCpu)
  19. + break;
  20. + }
  21. +
  22. + uint32_t nEnd = nBegin;
  23. +
  24. + while (nEnd != S.nFrameCurrent)
  25. + {
  26. + nEnd = (nEnd + 1) % MICROPROFILE_MAX_FRAME_HISTORY;
  27. + if(S.Frames[nEnd].nFrameStartCpu >= nTicksEndCpu)
  28. + break;
  29. + }
  30. +
  31. + nFrameIndex[0] = nBegin;
  32. + nFrameIndex[1] = nEnd;
  33. +}
  34. +
  35. void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, int nSelectedFrame)
  36. {
  37. MicroProfile& S = *MicroProfileGet();
  38. @@ -983,18 +1009,15 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
  39. int64_t nNumBoxes = 0;
  40. int64_t nNumLines = 0;
  41.  
  42. - uint32_t nFrameNext = (S.nFrameCurrent+1) % MICROPROFILE_MAX_FRAME_HISTORY;
  43. - MicroProfileFrameState* pFrameCurrent = &S.Frames[S.nFrameCurrent];
  44. - MicroProfileFrameState* pFrameNext = &S.Frames[nFrameNext];
  45. -
  46. UI.nRangeBegin = 0;
  47. UI.nRangeEnd = 0;
  48. UI.nRangeBeginGpu = 0;
  49. UI.nRangeEndGpu = 0;
  50. UI.nRangeBeginIndex = UI.nRangeEndIndex = 0;
  51. UI.pRangeLog = 0;
  52. - int64_t nFrameStartCpu = pFrameCurrent->nFrameStartCpu;
  53. - int64_t nFrameStartGpu = pFrameCurrent->nFrameStartGpu;
  54. +
  55. + int64_t nFrameStartCpu = S.Frames[S.nFrameCurrent].nFrameStartCpu;
  56. + int64_t nFrameStartGpu = S.Frames[S.nFrameCurrent].nFrameStartGpu;
  57. int64_t nTicksPerSecondCpu = MicroProfileTicksPerSecondCpu();
  58. int64_t nTicksPerSecondGpu = MicroProfileTicksPerSecondGpu();
  59. float fToMsCpu = MicroProfileTickToMsMultiplier(nTicksPerSecondCpu);
  60. @@ -1019,15 +1042,11 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
  61. int64_t nBaseTicksGpu = MicroProfileGetGpuTickSync(nBaseTicksCpu, nDetailedOffsetTicksGpu + nFrameStartGpu);
  62. int64_t nBaseTicksEndCpu = nBaseTicksCpu + MicroProfileMsToTick(fDetailedRange, MicroProfileTicksPerSecondCpu());
  63.  
  64. - MicroProfileFrameState* pFrameFirst = pFrameCurrent;
  65. + // MicroProfileFrameState* pFrameFirst = pFrameCurrent;
  66. int64_t nGapTime = MicroProfileTicksPerSecondCpu() * MICROPROFILE_GAP_TIME / 1000;
  67. - for(uint32_t i = 0; i < MICROPROFILE_MAX_FRAME_HISTORY - MICROPROFILE_GPU_FRAME_DELAY; ++i)
  68. - {
  69. - uint32_t nPrevIndex = (S.nFrameCurrent + MICROPROFILE_MAX_FRAME_HISTORY - i) % MICROPROFILE_MAX_FRAME_HISTORY;
  70. - pFrameFirst = &S.Frames[nPrevIndex];
  71. - if(pFrameFirst->nFrameStartCpu <= nBaseTicksCpu-nGapTime)
  72. - break;
  73. - }
  74. +
  75. + uint32_t nFrameIndex[2];
  76. + MicroProfileGetFrameRange(nBaseTicksCpu - nGapTime, nBaseTicksEndCpu, nFrameIndex);
  77.  
  78. float fMsBase = fToMsCpu * nDetailedOffsetTicksCpu;
  79. float fMs = fDetailedRange;
  80. @@ -1035,7 +1054,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
  81. float fWidth = (float)nWidth;
  82. float fMsToScreen = fWidth / fMs;
  83.  
  84. - for(uint32_t i = pFrameFirst - &S.Frames[0]; i != nFrameNext; i = (i+1) % MICROPROFILE_MAX_FRAME_HISTORY)
  85. + for(uint32_t i = nFrameIndex[0]; i != nFrameIndex[1]; i = (i+1) % MICROPROFILE_MAX_FRAME_HISTORY)
  86. {
  87. uint64_t nTickStart = S.Frames[i].nFrameStartCpu;
  88. float fMsStart = fToMsCpu * MicroProfileLogTickDifference(nBaseTicksCpu, nTickStart);
  89. @@ -1122,6 +1141,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
  90. if(!pLog)
  91. continue;
  92.  
  93. + /*
  94. uint32_t nPut = pFrameNext->nLogStart[i];
  95. ///note: this may display new samples as old data, but this will only happen when
  96. // unpaused, where the detailed view is hardly perceptible
  97. @@ -1161,6 +1181,10 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
  98. MP_ASSERT(nGet != (uint32_t)-1);
  99.  
  100. nPut = pFrameLogLast->nLogStart[i];
  101. + */
  102. +
  103. + uint32_t nGet = S.Frames[nFrameIndex[0]].nLogStart[i];
  104. + uint32_t nPut = S.Frames[nFrameIndex[1]].nLogStart[i];
  105.  
  106. uint32_t nRange[2][2] = { {0, 0}, {0, 0}, };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement