Sign in to follow this  
rtclawson

Profiling Directx for comparison

Recommended Posts

rtclawson    168
The following code is used in our tests of Directx 9 to profile the time it takes to complete a task. My question is, what would be the equivalent in Directx 11?
 
 
SlimDX, Directx 9
/// <summary>
/// Flushes the queue of rendering commands. This is implemented as a blocking call.
/// </summary>
public void Flush() {
// From DirectX SDK Documentation "Accurately Profiling direct3D API Calls (Direct3D 9)" 
// Create an Event query from the current device
using ( Query q = new Query( _device, QueryType.Event ) ) {
 
// Add an end marker to the command buffer queue.
q.Issue( Issue.End );
 
// Empty the command buffer and wait until the GPU is idle.
 
while ( q.GetData<bool>( true ) == false ) {
// CPU spinning
//NOTE: device could be lost while querying driver
}
}
}
 
 
Here is my attempt. I have tried different combinations of calls, but nothing seems to work. Specifically, I get the error "DXGI_ERROR_INVALID_CALL"  on the GetData call. If I uncomment the begin, flush, and end calls, then I get the error "D3D11 ERROR: ID3D11DeviceContext::Begin: Begin is not supported and cannot be invoked for the D3D11_QUERY"
SlimDX, Directx 11
public void Flush() {
QueryDescription qd = new QueryDescription() {
Flags = QueryFlags.None,
Type = QueryType.Event
};
 
using (Query q = new Query(_device, qd)) {
 
//_device.ImmediateContext.Begin(q);
//_device.ImmediateContext.Flush();
//_device.ImmediateContext.End(q);
 
 
while (_device.ImmediateContext.GetData<bool>(q,AsynchronousFlags.DoNotFlush) == false) {
// CPU spinning
//NOTE: device could be lost while querying driver
}
}
}
 
 
 
Any help?
 
 

Share this post


Link to post
Share on other sites
unbird    8335
This blog post of MJP explains how to time the D3D11 Pipeline. I couldn't use that approach for compute shaders though, I always got a disjoint, unfortunately.
 
Update: A little bit off topic (timing compute shaders). I do get sensible numbers (no disjoint) after the first dispatch. Looks like the device must be in "compute mode" already to make those queries work.

Scratch that, I was wrong. Anybody had success with timing compute shaders ?

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