View Full Version : Regarding counters used in GPU performance tools

myk45

04-24-2012, 11:51 PM

Hello All!

I am using PVRTune to analyze the SGX GPU performance. It has a counter called:

frustrum passes per second and it is described as:

This is the number of intersections between triangles and frustrum (guard band and

front/rear) clip planes.

Can anyone please tell me how these calculations are done? There are many such counters.

I was wondering how these calculations are done.

Thanks!

Dark Photon

04-26-2012, 04:50 AM

Are you talking about how you'd do triangle-frustum clipping so that you can generate these statistics yourself?

If so google homogenous clipping. If you need some pointers, let me know and I can dig some up. Clipping happens in "clip space" (intuitively), so you might read up on that:

* http://www.songho.ca/opengl/gl_transform.html

myk45

04-27-2012, 12:00 PM

Thanks for the reply Dark Photon.

> Are you talking about how you'd do triangle-frustum clipping so that you can generate these statistics yourself?

Yes, i was talking about the same.

> If you need some pointers, let me know and I can dig some up.

Oh, please, that would be great! What i basically wanted to know is, once you pass all your vertex data to shaders, how do these tools obtain these information? Now we can find if a single point lies within the clip space. How can i find if a triangle is within the clip space? The primitive assembly would be done after this stage right?

Thanks!

myk45

04-30-2012, 04:27 AM

.....bump.....

V-man

04-30-2012, 06:24 AM

Thanks for the reply Dark Photon.

> Are you talking about how you'd do triangle-frustum clipping so that you can generate these statistics yourself?

Yes, i was talking about the same.

> If you need some pointers, let me know and I can dig some up.

Oh, please, that would be great! What i basically wanted to know is, once you pass all your vertex data to shaders, how do these tools obtain these information? Now we can find if a single point lies within the clip space. How can i find if a triangle is within the clip space? The primitive assembly would be done after this stage right?

Thanks!

I imagine that the GPU stores information in its registers and the tool simply communicates with the driver and the driver gets the values from the GPU. Pretty much any GPU should have that kind of ability.

If you want the coordinates in clipspace, then you transform your vertex by the modelview matrix. Then you transform by the projection matrix.

Reference = http://www.opengl.org/wiki/Vertex_Transformation

If you are looking for a math library that can do such calculation

http://www.opengl.org/wiki/Related_toolkits_and_APIs#Math_Libraries

Dark Photon

04-30-2012, 06:29 AM

There's probably a bunch of ways to do it, but check this out:

* http://www.cs.fit.edu/~wds/classes/graphics/Clip/clip/clip.html (http://www.cs.fit.edu/%7Ewds/classes/graphics/Clip/clip/clip.html)

Main thing is you want to clip in 4D homogenous coordinates (i.e. before the perspective divide) so you don't have nasty issues with divide by zero singularities and such. Jim Blinn's got some good stuff on this.

For instance, clip to 3D planes defined in 4D. Using Blinn's convention of upper-case letters for 3D affine coords and lower-case letters for homogeneous coordinates), we start with the basic 3D plane equation:

A*X + B*Y + C*Z + D = 0

Now we plug in homogenous coordinates:

A*(x/w) + B*(y/w) + C*(z/w) + D = 0

aka A*x + B*y + C*z + D*w = 0

So if we take the std 3D plane equation coefficients and multiply (dot product) by a homogenous 4D point, we've actually evaluated the plane equation just as we did in 3D by plugging in for X,Y,Z.

Then you'll probably want an "intersect line against plane" function that operates in 4D too to intersect against these 4D planes. Calls to this function are driven by the polygon clipping algorithm you choose to implement. At the time I used Sutherland-Hodgman (for just doing this all in software; Foley and van Daam has a decent writeup on this), but there's nothing holy about that. You can choose another.

myk45

05-01-2012, 06:10 AM

Thanks a lot V-man, Dark Photon!

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.