Jump to content
  • Advertisement
Sign in to follow this  
smally

Calc how many Verts on screen

This topic is 3879 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, I'm just wondering since I am starting to create a more informative Stats class (so it shows more than just the fps). I am wanting to include it so my stats can show how many triangles and vertices there currently in the viewing area. Is there an easy method that D3D9 provides to work this out? If not i can just make it so my stats class calculates how many vertices/traingles there are in the scene.

Share this post


Link to post
Share on other sites
Advertisement
Only way I know would be to construct a frustum from your camera data and then do a frustum intersection test on each vertex in the scene, which would be very slow indeed.

Share this post


Link to post
Share on other sites
Just count the number of vertices you pass to Draw[Indexed]Primitive[UP](). Most games use some form of scene graph, so they render everything in one go - which makes this a bit easier to keep track of. At the very least, you could just keep track of a global int, set it to zero at the start of each frame, and increase it on each DIP() call.

There's no function that D3D provides to tell you how many vertices were processed during the last frame though.

Share this post


Link to post
Share on other sites
What I am currently implementing is when an object is created, BuildVertexBuffer() and BuildIndexBuffer() functions also use the stats functions g_stats->AddVertices(DWORD num) and g_stats->AddTriangles(DWORD num), however this only shows how many are currently loaded.

If D3D doesn't provide a way of saying how many vertices and triangles are currently on the screen, I shall not bother with working it out, unless I've got a lot of time to spare.

Share this post


Link to post
Share on other sites
Quote:
Original post by smally
If D3D doesn't provide a way of saying how many vertices and triangles are currently on the screen, I shall not bother with working it out, unless I've got a lot of time to spare.
It doesn't take that long really, although it gets more complicated if you use D3DX objects that manage their own rendering (E.g. ID3DXMesh, ID3DXSprite and ID3DXFont).

You could create a subclassed IDirect3DDevice9 - A class derived from IDirect3DDevice9 that implements every member function, and has a real IDirect3DDevice9* as a member variable, then just call the real function for each of the implemented member functions. That would let you pass your own class to every D3DX function, and you could count the number of triangles and vertices passed around to the various DrawPrimitive calls, and reset the counters on BeginScene().
Although there's a lot of functions to implement even stubs for...

Share this post


Link to post
Share on other sites
Why would anyone care how many vertices are on screen? That doesn't have any effect on performance or anything else.

What you might want to track is how many vertices were processed by the GPU. Whether they then end up outside the screen or not is irrelevant. What matters is that they took up GPU processing time.

It's also easy to measure. Just keep track of how many vertices you send to the GPU with each draw call.

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!