3

Assume a d3d 11 device has been created, and then create a query:

ID3D11Query*    m_pQuery

...

HRESULT hr = S_OK;

D3D11_QUERY_DESC queryDesc;
queryDesc.Query = D3D11_QUERY_EVENT;
queryDesc.MiscFlags = 0;
//pd3dDevice has been created beforehand.
hr = pd3dDevice->CreateQuery(&queryDesc, &m_pQuery);

Now, define a function to wait GPU returns it's query result:

void GlobalAppState::WaitForGPU()
{
    DXUTGetD3D11DeviceContext()->Flush();
    DXUTGetD3D11DeviceContext()->End(m_pQuery);
    DXUTGetD3D11DeviceContext()->Flush();

    while (S_OK != DXUTGetD3D11DeviceContext()->GetData(m_pQuery, NULL, 0, 0));
}

My question is why flush is called twice before and after a query ends? The command buffer is cleared out after the 1st flush, so whether the 2nd "flush" makes sense or not?

Original code comes from VoxelHashing/DepthSensingCUDA/Source/GlobalAppState.cpp

Finley
  • 795
  • 1
  • 8
  • 26

0 Answers0