Sign in to follow this  
griffin77

Weird results from using a D3D11_QUERY_EVENT Query

Recommended Posts

griffin77    125
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 ?

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

double time0 = GetTimeMilliSecs();

//Run a small number of DX commands
doSmallStuff();

g_pImmediateContext->End(g_pEventQuery1);

//Run a large number of DX commands
doBigStuff();

g_pImmediateContext->End(g_pEventQuery2);


//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);

[/code]

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

I create my events like this:
[code]
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);
[/code]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this