Jump to content
  • Advertisement
Sign in to follow this  
simco50

Get the amount of draw calls in runtime

This topic is 772 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

Hello everyone,

 

I was wondering how to get the amount of draw calls each frame during run time?

Is there maybe a DirectX method for that?

 

Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement

There actually is a thing for this, called "queries"

 

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476515%28v=vs.85%29.aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476191%28v=vs.85%29.aspx

 

You need to look at the different types of queries to see if there actually is one for draw calls though (or someone tells you that knows this for sure).

 

Your other options include:

 

- using a 3rd-party application like nsight, perfstudio, or the build-in visual studio graphics debugger, which all can show you those metrics.

- if its about an application that you write yourself, just make a wrapper for draw-calls. Instead of calling ID3D11DeviceContext::DrawXXX() in your code, you wrap this inside a custom function that also increased a counter, which is reset before each frame. This gives you the metrics you want on your side of the application.

Share this post


Link to post
Share on other sites

some example code:

 

 

// render queue

// each call to render the render queue adds Znumdrawrecs to drawlist_meshes_drawn for later display by the debugging HUD
add2meshtex_index(Znumdrawrecs);
Znumdrawrecs++;
 
 
// alpha blended clouds
Zdrawimmediate2(&ABa);
num_clouds_drawn++;
 
 
// terrain chunks
Zd3d_device_ptr->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,Znum_verts,0,Znum_primitives);
chunk_meshes_drawn++;
 
 
// debugging HUD. the +1 is for the sun / moon mesh.
Ss("total meshes drawn: ");
Sai(chunk_meshes_drawn + num_clouds_drawn + drawlist_meshes_drawn + 1);
tx(0,775,S);
 
note that drawing is only done in 3 places in the game: render queue, clouds, and terrain chunks. 4 actually - i don't count the calls to drawsubset for skinned meshes. I recently switched from rigid body to skinned meshes, and haven't needed to monitor scene complexity (measured in number of draw calls) since then.  a skinned mesh is just a single drawSubset call in the game.
 
 
Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Why would the runtime be burden with counting the same items you are directly submitting....meaning why would it count draw calls, when you are calling draw yourself? Hint: see Hodgman post.

Share this post


Link to post
Share on other sites

Amount of draw calls isn't necessarily useful information anyway.  A draw call can range from quite cheap to very expensive, depending on how much state is changed before it's made, how many vertices, whether it's indexed or not, vertex order and index order, does it involve much or little overdraw, etc.

 

I guess it's one of those metrics that it's nice to see, and maybe it's helpful to confirm that you're not doing unnecessary work, but otherwise you really should be aware that there's a whole load of other factors at play, some of them quite deep in the pipeline and not all of them easily surfaced through application counters.

Share this post


Link to post
Share on other sites

The truth of that statement is a bit variable depending on the version of D3D being used, right?  I mean, obviously for full perf coverage you always need to be tracking a lot more than just draw calls, but if you're in pre-10 this is still a fairly useful metric.  There were very real bottlenecks around number of draw calls, regardless of anything else, in and before 9.

 

10+, I absolutely agree with it mostly being nice to see, moreso then being a useful data point for actual perf.

Share this post


Link to post
Share on other sites

The truth of that statement is a bit variable depending on the version of D3D being used, right?  I mean, obviously for full perf coverage you always need to be tracking a lot more than just draw calls, but if you're in pre-10 this is still a fairly useful metric.  There were very real bottlenecks around number of draw calls, regardless of anything else, in and before 9.

 

10+, I absolutely agree with it mostly being nice to see, moreso then being a useful data point for actual perf.

 

9 on a WDDM driver has similar perf characteristics to 10+, so yeah, the cutoff would be 9 on XP or worse.  Despite that, the core of what I wrote above remains true (i.e that there are other factors which it's still important to consider), just that the fixed overhead of each individual draw call is higher.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!