Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/microprofileui.h b/microprofileui.h
- index 3489350..7a70b21 100644
- --- a/microprofileui.h
- +++ b/microprofileui.h
- @@ -975,6 +975,32 @@ uint32_t MicroProfileWriteProcessHeader(uint32_t nY, uint32_t nProcessId)
- return nY;
- }
- +void MicroProfileGetFrameRange(int64_t nTicksCpu, int64_t nTicksEndCpu, uint32_t nFrameIndex[2])
- +{
- + MicroProfile& S = *MicroProfileGet();
- +
- + uint32_t nBegin = S.nFrameCurrent;
- +
- + for(uint32_t i = 0; i < MICROPROFILE_MAX_FRAME_HISTORY - MICROPROFILE_GPU_FRAME_DELAY; ++i)
- + {
- + nBegin = (S.nFrameCurrent + MICROPROFILE_MAX_FRAME_HISTORY - i) % MICROPROFILE_MAX_FRAME_HISTORY;
- + if(S.Frames[nBegin].nFrameStartCpu <= nTicksCpu)
- + break;
- + }
- +
- + uint32_t nEnd = nBegin;
- +
- + while (nEnd != S.nFrameCurrent)
- + {
- + nEnd = (nEnd + 1) % MICROPROFILE_MAX_FRAME_HISTORY;
- + if(S.Frames[nEnd].nFrameStartCpu >= nTicksEndCpu)
- + break;
- + }
- +
- + nFrameIndex[0] = nBegin;
- + nFrameIndex[1] = nEnd;
- +}
- +
- void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, int nSelectedFrame)
- {
- MicroProfile& S = *MicroProfileGet();
- @@ -983,18 +1009,15 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
- int64_t nNumBoxes = 0;
- int64_t nNumLines = 0;
- - uint32_t nFrameNext = (S.nFrameCurrent+1) % MICROPROFILE_MAX_FRAME_HISTORY;
- - MicroProfileFrameState* pFrameCurrent = &S.Frames[S.nFrameCurrent];
- - MicroProfileFrameState* pFrameNext = &S.Frames[nFrameNext];
- -
- UI.nRangeBegin = 0;
- UI.nRangeEnd = 0;
- UI.nRangeBeginGpu = 0;
- UI.nRangeEndGpu = 0;
- UI.nRangeBeginIndex = UI.nRangeEndIndex = 0;
- UI.pRangeLog = 0;
- - int64_t nFrameStartCpu = pFrameCurrent->nFrameStartCpu;
- - int64_t nFrameStartGpu = pFrameCurrent->nFrameStartGpu;
- +
- + int64_t nFrameStartCpu = S.Frames[S.nFrameCurrent].nFrameStartCpu;
- + int64_t nFrameStartGpu = S.Frames[S.nFrameCurrent].nFrameStartGpu;
- int64_t nTicksPerSecondCpu = MicroProfileTicksPerSecondCpu();
- int64_t nTicksPerSecondGpu = MicroProfileTicksPerSecondGpu();
- float fToMsCpu = MicroProfileTickToMsMultiplier(nTicksPerSecondCpu);
- @@ -1019,15 +1042,11 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
- int64_t nBaseTicksGpu = MicroProfileGetGpuTickSync(nBaseTicksCpu, nDetailedOffsetTicksGpu + nFrameStartGpu);
- int64_t nBaseTicksEndCpu = nBaseTicksCpu + MicroProfileMsToTick(fDetailedRange, MicroProfileTicksPerSecondCpu());
- - MicroProfileFrameState* pFrameFirst = pFrameCurrent;
- + // MicroProfileFrameState* pFrameFirst = pFrameCurrent;
- int64_t nGapTime = MicroProfileTicksPerSecondCpu() * MICROPROFILE_GAP_TIME / 1000;
- - for(uint32_t i = 0; i < MICROPROFILE_MAX_FRAME_HISTORY - MICROPROFILE_GPU_FRAME_DELAY; ++i)
- - {
- - uint32_t nPrevIndex = (S.nFrameCurrent + MICROPROFILE_MAX_FRAME_HISTORY - i) % MICROPROFILE_MAX_FRAME_HISTORY;
- - pFrameFirst = &S.Frames[nPrevIndex];
- - if(pFrameFirst->nFrameStartCpu <= nBaseTicksCpu-nGapTime)
- - break;
- - }
- +
- + uint32_t nFrameIndex[2];
- + MicroProfileGetFrameRange(nBaseTicksCpu - nGapTime, nBaseTicksEndCpu, nFrameIndex);
- float fMsBase = fToMsCpu * nDetailedOffsetTicksCpu;
- float fMs = fDetailedRange;
- @@ -1035,7 +1054,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
- float fWidth = (float)nWidth;
- float fMsToScreen = fWidth / fMs;
- - for(uint32_t i = pFrameFirst - &S.Frames[0]; i != nFrameNext; i = (i+1) % MICROPROFILE_MAX_FRAME_HISTORY)
- + for(uint32_t i = nFrameIndex[0]; i != nFrameIndex[1]; i = (i+1) % MICROPROFILE_MAX_FRAME_HISTORY)
- {
- uint64_t nTickStart = S.Frames[i].nFrameStartCpu;
- float fMsStart = fToMsCpu * MicroProfileLogTickDifference(nBaseTicksCpu, nTickStart);
- @@ -1122,6 +1141,7 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
- if(!pLog)
- continue;
- + /*
- uint32_t nPut = pFrameNext->nLogStart[i];
- ///note: this may display new samples as old data, but this will only happen when
- // unpaused, where the detailed view is hardly perceptible
- @@ -1161,6 +1181,10 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY,
- MP_ASSERT(nGet != (uint32_t)-1);
- nPut = pFrameLogLast->nLogStart[i];
- + */
- +
- + uint32_t nGet = S.Frames[nFrameIndex[0]].nLogStart[i];
- + uint32_t nPut = S.Frames[nFrameIndex[1]].nLogStart[i];
- uint32_t nRange[2][2] = { {0, 0}, {0, 0}, };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement