Regarding counters used in GPU performance tools

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!

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:

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!

…bump…

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 = Vertex Transformation - OpenGL Wiki

If you are looking for a math library that can do such calculation
http://www.opengl.org/wiki/Related_toolkits_and_APIs#Math_Libraries

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

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:

AX + BY + C*Z + D = 0

Now we plug in homogenous coordinates:

A*(x/w) + B*(y/w) + C*(z/w) + D = 0
aka Ax + By + Cz + Dw = 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.

Thanks a lot V-man, Dark Photon!