Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Regarding counters used in GPU performance tools

  1. #1
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81

    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!

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    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
    Last edited by Dark Photon; 04-26-2012 at 04:53 AM.

  3. #3
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81
    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!

  4. #4
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81
    .....bump.....

  5. #5
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    Quote Originally Posted by myk45 View Post
    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_t...Math_Libraries
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  6. #6
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    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

    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.

  7. #7
    Intern Contributor
    Join Date
    Jan 2012
    Posts
    81
    Thanks a lot V-man, Dark Photon!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •