Jump to content
  • Advertisement
Sign in to follow this  

Weird results from using a D3D11_QUERY_EVENT Query

This topic is 2564 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to use the Query system in DirectX 11 to monitor when DX commands have completed. But I get weird results, basically when I wait on an event it appears the context will always wait until ALL the currently submitted commands have finished, even if the the commands in question were submitted AFTER the event I'm waiting on.

Basically I do something like this, where run a small number of DX commands, enqueue an event, then run a large number of DX commands, and then enqueue a second event . No matter how much more work I between the two events. It will always wait a long time for the first event, and almost no time at all for the second event. This which implies to me its waiting for ALL the commands to finish when I wait on the first command not just the ones that were submitted before the first event. Is that the expected behaviour, or am I doing something wrong ? Is there a way to make DX wait for just the commands that are submitted before the event in question ?

//Make sure all previous commands have finished
while( g_pImmediateContext->GetData( g_pEventQuery0, NULL, 0, 0 ) == S_FALSE ) {}

double time0 = GetTimeMilliSecs();

//Run a small number of DX commands


//Run a large number of DX commands


//Wait for first event
while( g_pImmediateContext->GetData( g_pEventQuery1, NULL, 0, 0 ) == S_FALSE ) {}
double time1 = GetTimeMilliSecs();

//Wait for second event
while( g_pImmediateContext->GetData( g_pEventQuery2, NULL, 0, 0 ) == S_FALSE ) {}
double time2 = GetTimeMilliSecs();

double t0= time1-time0;
double t1= time2-time1;

printf("%f %f\n",t0,t1);

In this example wait times for the two events are:
t0 0.69156749546527863
t1 0.00030016526579856873

I create my events like this:

D3D11_QUERY_DESC pQueryDesc;
pQueryDesc.Query = D3D11_QUERY_EVENT;
pQueryDesc.MiscFlags = 0;

g_pd3dDevice->CreateQuery( &pQueryDesc, &g_pEventQuery0);
g_pd3dDevice->CreateQuery( &pQueryDesc, &g_pEventQuery1);
g_pd3dDevice->CreateQuery( &pQueryDesc, &g_pEventQuery2);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!