Fixed timer query.

This commit is contained in:
Branimir Karadžić 2015-05-15 16:49:53 -07:00
parent 2a49e5a143
commit c957a3dd51
2 changed files with 35 additions and 29 deletions

View File

@ -3586,25 +3586,28 @@ BX_PRAGMA_DIAGNOSTIC_POP();
bool TimerQueryD3D11::get()
{
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
Frame& frame = m_frame[m_control.m_read];
uint64_t end;
HRESULT hr = deviceCtx->GetData(frame.m_end, &end, sizeof(end), 0);
if (S_OK == hr)
if (0 != m_control.available() )
{
m_control.consume(1);
ID3D11DeviceContext* deviceCtx = s_renderD3D11->m_deviceCtx;
Frame& frame = m_frame[m_control.m_read];
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint;
deviceCtx->GetData(frame.m_disjoint, &disjoint, sizeof(disjoint), 0);
uint64_t end;
HRESULT hr = deviceCtx->GetData(frame.m_end, &end, sizeof(end), 0);
if (S_OK == hr)
{
m_control.consume(1);
uint64_t start;
deviceCtx->GetData(frame.m_start, &start, sizeof(start), 0);
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjoint;
deviceCtx->GetData(frame.m_disjoint, &disjoint, sizeof(disjoint), 0);
m_frequency = disjoint.Frequency;
m_elapsed = end - start;
uint64_t start;
deviceCtx->GetData(frame.m_start, &start, sizeof(start), 0);
return true;
m_frequency = disjoint.Frequency;
m_elapsed = end - start;
return true;
}
}
return false;
@ -4417,7 +4420,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
elapsedGpuMs = m_gpuTimer.m_elapsed * toGpuMs;
maxGpuElapsed = elapsedGpuMs > maxGpuElapsed ? elapsedGpuMs : maxGpuElapsed;
}
maxGpuLatency = bx::uint32_max(maxGpuLatency, m_gpuTimer.m_control.available()-1);
maxGpuLatency = bx::uint32_imax(maxGpuLatency, m_gpuTimer.m_control.available()-1);
TextVideoMem& tvm = m_textVideoMem;

View File

@ -2953,24 +2953,27 @@ namespace bgfx { namespace d3d9
bool TimerQueryD3D9::get()
{
Frame& frame = m_frame[m_control.m_read];
uint64_t freq;
HRESULT hr = frame.m_freq->GetData(&freq, sizeof(freq), 0);
if (S_OK == hr)
if (0 != m_control.available() )
{
m_control.consume(1);
Frame& frame = m_frame[m_control.m_read];
uint64_t start;
DX_CHECK(frame.m_start->GetData(&start, sizeof(start), 0) );
uint64_t freq;
HRESULT hr = frame.m_freq->GetData(&freq, sizeof(freq), 0);
if (S_OK == hr)
{
m_control.consume(1);
uint64_t end;
DX_CHECK(frame.m_end->GetData(&end, sizeof(end), 0) );
uint64_t start;
DX_CHECK(frame.m_start->GetData(&start, sizeof(start), 0) );
m_frequency = freq;
m_elapsed = end - start;
uint64_t end;
DX_CHECK(frame.m_end->GetData(&end, sizeof(end), 0) );
return true;
m_frequency = freq;
m_elapsed = end - start;
return true;
}
}
return false;
@ -3560,7 +3563,7 @@ namespace bgfx { namespace d3d9
elapsedGpuMs = m_gpuTimer.m_elapsed * toGpuMs;
maxGpuElapsed = elapsedGpuMs > maxGpuElapsed ? elapsedGpuMs : maxGpuElapsed;
}
maxGpuLatency = bx::uint32_max(maxGpuLatency, m_gpuTimer.m_control.available()-1);
maxGpuLatency = bx::uint32_imax(maxGpuLatency, m_gpuTimer.m_control.available()-1);
TextVideoMem& tvm = m_textVideoMem;