Get the amount of draw calls in runtime

Started by
6 comments, last by 21st Century Moose 7 years, 10 months ago

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

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.

Increment an integer every time you call Draw :P

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.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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.

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

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.

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement