void CRenderer::beginTimeQuery()
{
#ifdef RENDERER_D3D9
eventQuery->Issue(D3DISSUE_END);
while (eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE);
QueryPerformanceCounter(&beginTime);
#elif RENDERER_D3D10
timestampDisjointQuery->Begin();
beginTimestampQuery->End();
#endif
}
double CRenderer::endTimeQuery()
{
#ifdef RENDERER_D3D9
eventQuery->Issue(D3DISSUE_END);
while (eventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE);
QueryPerformanceCounter(&endTime);
return (double)(endTime.QuadPart - beginTime.QuadPart) / (double)timeFrequency.QuadPart;
#elif RENDERER_D3D10
endTimestampQuery->End();
timestampDisjointQuery->End();
uint64 beginTime, endTime;
D3D10_QUERY_DATA_TIMESTAMP_DISJOINT disjoint;
while (beginTimestampQuery->GetData(&beginTime, sizeof(uint64), 0) != S_OK);
while (endTimestampQuery->GetData(&endTime, sizeof(uint64), 0) != S_OK);
while (timestampDisjointQuery->GetData(&disjoint, sizeof(D3D10_QUERY_DATA_TIMESTAMP_DISJOINT), 0) != S_OK);
if (!disjoint.Disjoint)
return (double)(endTime - beginTime) / (double)disjoint.Frequency;
else
return -1.0;
#endif
}
Now, I render 2500 cubes, what gives me 230 FPS with both renderers. The problem is that the timings returned by endTimeQuery differ. For D3D9 it returns 0.003 and for D3D10 returns 0.0013. The rendering code does not do anything else and I wrapped the whole rendering loop inside the begin/end time block. So, where does this discrepancy could come from?