mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-11-17 21:36:12 +00:00
Added begin/end CPU/GPU timer stats instead of elapsed.
This commit is contained in:
+15
-9
@@ -3318,7 +3318,7 @@ namespace bgfx { namespace d3d9
|
||||
{
|
||||
Frame& frame = m_frame[ii];
|
||||
DX_CHECK(device->CreateQuery(D3DQUERYTYPE_TIMESTAMPDISJOINT, &frame.m_disjoint) );
|
||||
DX_CHECK(device->CreateQuery(D3DQUERYTYPE_TIMESTAMP, &frame.m_start) );
|
||||
DX_CHECK(device->CreateQuery(D3DQUERYTYPE_TIMESTAMP, &frame.m_begin) );
|
||||
DX_CHECK(device->CreateQuery(D3DQUERYTYPE_TIMESTAMP, &frame.m_end) );
|
||||
DX_CHECK(device->CreateQuery(D3DQUERYTYPE_TIMESTAMPFREQ, &frame.m_freq) );
|
||||
}
|
||||
@@ -3334,7 +3334,7 @@ namespace bgfx { namespace d3d9
|
||||
{
|
||||
Frame& frame = m_frame[ii];
|
||||
DX_RELEASE(frame.m_disjoint, 0);
|
||||
DX_RELEASE(frame.m_start, 0);
|
||||
DX_RELEASE(frame.m_begin, 0);
|
||||
DX_RELEASE(frame.m_end, 0);
|
||||
DX_RELEASE(frame.m_freq, 0);
|
||||
}
|
||||
@@ -3349,7 +3349,7 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
Frame& frame = m_frame[m_control.m_current];
|
||||
frame.m_disjoint->Issue(D3DISSUE_BEGIN);
|
||||
frame.m_start->Issue(D3DISSUE_END);
|
||||
frame.m_begin->Issue(D3DISSUE_END);
|
||||
}
|
||||
|
||||
void TimerQueryD3D9::end()
|
||||
@@ -3373,14 +3373,16 @@ namespace bgfx { namespace d3d9
|
||||
{
|
||||
m_control.consume(1);
|
||||
|
||||
uint64_t timeStart;
|
||||
DX_CHECK(frame.m_start->GetData(&timeStart, sizeof(timeStart), 0) );
|
||||
uint64_t timeBegin;
|
||||
DX_CHECK(frame.m_begin->GetData(&timeBegin, sizeof(timeBegin), 0) );
|
||||
|
||||
uint64_t freq;
|
||||
DX_CHECK(frame.m_freq->GetData(&freq, sizeof(freq), 0) );
|
||||
|
||||
m_frequency = freq;
|
||||
m_elapsed = timeEnd - timeStart;
|
||||
m_begin = timeBegin;
|
||||
m_end = timeEnd;
|
||||
m_elapsed = timeEnd - timeBegin;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -4084,6 +4086,10 @@ namespace bgfx { namespace d3d9
|
||||
elapsed += now;
|
||||
|
||||
static int64_t last = now;
|
||||
|
||||
Stats& perfStats = _render->m_perfStats;
|
||||
perfStats.cpuTimeBegin = last;
|
||||
|
||||
int64_t frameTime = now - last;
|
||||
last = now;
|
||||
|
||||
@@ -4111,10 +4117,10 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
const int64_t timerFreq = bx::getHPFrequency();
|
||||
|
||||
Stats& perfStats = _render->m_perfStats;
|
||||
perfStats.cpuTime = frameTime;
|
||||
perfStats.cpuTimeEnd = now;
|
||||
perfStats.cpuTimerFreq = timerFreq;
|
||||
perfStats.gpuTime = m_gpuTimer.m_elapsed;
|
||||
perfStats.gpuTimeBegin = m_gpuTimer.m_begin;
|
||||
perfStats.gpuTimeEnd = m_gpuTimer.m_end;
|
||||
perfStats.gpuTimerFreq = m_gpuTimer.m_frequency;
|
||||
|
||||
if (_render->m_debug & (BGFX_DEBUG_IFH|BGFX_DEBUG_STATS) )
|
||||
|
||||
Reference in New Issue
Block a user