Fixed CPU timer.

This commit is contained in:
Branimir Karadžić
2017-09-21 21:34:02 -07:00
parent fc65c6a95e
commit 2abe7db80a
6 changed files with 67 additions and 100 deletions

View File

@@ -6524,7 +6524,7 @@ namespace bgfx { namespace gl
updateResolution(_render->m_resolution);
int64_t elapsed = -bx::getHPCounter();
int64_t timeBegin = bx::getHPCounter();
int64_t captureElapsed = 0;
uint32_t frameQueryIdx = UINT32_MAX;
@@ -7594,16 +7594,8 @@ namespace bgfx { namespace gl
}
m_glctx.makeCurrent(NULL);
int64_t now = bx::getHPCounter();
elapsed += now;
static int64_t last = now;
Stats& perfStats = _render->m_perfStats;
perfStats.cpuTimeBegin = last;
int64_t frameTime = now - last;
last = now;
int64_t timeEnd = bx::getHPCounter();
int64_t frameTime = timeEnd - timeBegin;
static int64_t min = frameTime;
static int64_t max = frameTime;
@@ -7628,7 +7620,9 @@ namespace bgfx { namespace gl
const int64_t timerFreq = bx::getHPFrequency();
perfStats.cpuTimeEnd = now;
Stats& perfStats = _render->m_perfStats;
perfStats.cpuTimeBegin = timeBegin;
perfStats.cpuTimeEnd = timeEnd;
perfStats.cpuTimerFreq = timerFreq;
const TimerQueryGL::Result& result = m_gpuTimer.m_result[BGFX_CONFIG_MAX_VIEWS];
perfStats.gpuTimeBegin = result.m_begin;
@@ -7643,11 +7637,11 @@ namespace bgfx { namespace gl
m_needPresent = true;
TextVideoMem& tvm = m_textVideoMem;
static int64_t next = now;
static int64_t next = timeEnd;
if (now >= next)
if (timeEnd >= next)
{
next = now + timerFreq;
next = timeEnd + timerFreq;
double freq = double(timerFreq);
double toMs = 1000.0/freq;
@@ -7685,7 +7679,7 @@ namespace bgfx { namespace gl
, !!(m_resolution.m_flags&BGFX_RESET_MAXANISOTROPY) ? '\xfe' : ' '
);
double elapsedCpuMs = double(elapsed)*toMs;
double elapsedCpuMs = double(timeBegin)*toMs;
tvm.printf(10, pos++, 0x8e, " Submitted: %5d (draw %5d, compute %4d) / CPU %7.4f [ms] %c GPU %7.4f [ms] (latency %d) "
, _render->m_num
, statsKeyType[0]