Counting Pollys in Game

I would like to display the total number of poly's currently in the viewport and I would like to display the total number of poly's in the scene. I've been looking through the docs and cannot find any obvious way to do this. Can anyone point me in the right direction?

Thanks.

[293 byte] By [jadams] at [2007-12-26]
# 1

There is no obvious way. You need to maintain your own count. Everywhere you render something add the # triangles to a counter. Clear it every frame.

in 3d this means getting ModelMeshPart.PrimitiveCount - or if you are using vertex buffers count them yourself.

in 2d assume each sprite.Draw is 2 triangles

TheZMan at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 2
If you install the full DirectX SDK, you can also use the PIX for Windows tool to capture this kind of information.

Point it at your compiled executable, select the "Statistics for each

frame" option, click the "HUD" checkbox, then run your game. This will

overlay draw call statistics on the game screen. You can press F12 to

toggle which data is displayed. This mode doesn't actually seem to show

the total triangle count, but it will tell you how many draw calls and

renderstate changes are happening, which is usually actually more

important for affecting the overall performance.

If you select "A single frame capture of Direct3D whenever F12 is

pressed", then you can run your game to the point you are interested in

measuring, press F12, then when you quit the game, you'll get a really

detailed view of exactly what calls it issued during the frame you

captured. Again I can't see any really easy way of extracting the total

triangle count, but you could export all this data to a

comma-separated-value format using the File menu (making sure you

include Function Call data), then write a little program to scan this

file and add up the triangle count information.

ShawnHargreaves-MSFT at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 3

Thanks for the tip Shawn, great tool. The hud is nice too. Help is non-existant for this tool. Where can I find info on what these call abbreviations stand for?

jadams at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 4
@ The ZMan - Thanks for the info. I was hoping you wouldn't say that :) I did stumble on PrimitiveCount late sunday night. The trick I guess will be getting the count in the view.
jadams at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...
# 5
if by call abbreviations you mean d3dDevice->DrawIndexedPrimitive and that kind of thing, the dx help will have what you're looking for. Is that what you're asking?

edit: never mind, I should have read more carefully

EliTayrien-MSFT at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Framework...