Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: When should you not use OpenGL's Matrices?

  1. #1
    Member Contributor
    Join Date
    Apr 2003
    Posts
    60

    When should you not use OpenGL's Matrices?

    I was just reading a bit about optimizing matrix commands for SSE, SIMD, MMX.. But I have no idea for what operations you would implement it for.

    If it's faster and better to use these instructions instead of opengl commands, shouldn't we just ignore opengl's matrix operations altogether?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: When should you not use OpenGL's Matrices?

    The matrices are an integral part of OpenGL and are needed for rendering one way or another. You could in theory perform all transformations in your program and then pass the final vertices through identity GL matrices, but this would nix any hardware acceleration gains.

    I think where exploiting special instruction sets comes in is where you calculate custom transformation matrices. Whether you then LoadMatrixd or MultMatrixd or do something else is up to you.

  3. #3
    Member Contributor
    Join Date
    Apr 2003
    Posts
    60

    Re: When should you not use OpenGL's Matrices?

    "You could in theory perform all transformations in your program and then pass the final vertices through identity GL matrices, but this would nix any hardware acceleration gains."

    OK. I thought it might have improved performance with using those instruction sets to calculate matrices, not reduce it. So I take it that OpenGL has already optimized it's matrix routines for different processors? How is it that openGL's matrix math is faster?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: When should you not use OpenGL's Matrices?

    If you have hardware acceleration then the transformation probably isn't even performed by the CPU. Your OpenGL driver calls upon your video driver to call upon the built in features of your video card to do all the work. That's why hardware acceleration works so fast--the CPU doesn't have to do all the video work too; the onboard controller of the video card takes that load off its back.

    If you do NOT have hardware acceleration, then how the transformations are optimized CPUwise depends on the provider of your OpenGL driver. If you'd like to skip it altogether, then you can write your own per-CPU optimized code with those special instruction sets and see how that goes.

  5. #5
    Member Newbie
    Join Date
    Aug 2003
    Location
    asda
    Posts
    47

    Re: When should you not use OpenGL's Matrices?

    Originally posted by Omaha:
    If you have hardware acceleration then the transformation probably isn't even performed by the CPU.
    As far as I know is this only true for matrix-vectors operations. The hardware is there to transform a lot of points. Building the matrices themself is done on the CPU with the possible support of SSE, 3DNow and other extensions depending on the actual implementation. In reality do I think that both NVidia and ATi is using them to speed up glMultMatrix and similar operations.

    This setup does not take a lot of time so the reason to use your own matrix functions is not speed but that you have to in some cases. The most common reason has to do with "Gimbal lock".
    asd

  6. #6
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    Eastern USA
    Posts
    218

    Re: When should you not use OpenGL's Matrices?

    Actually, I was referring to the transformation of an input vertex by the modelview and then projection matrices and so forth to ultimately become a vertex in the window.

    When we are now seeing even vertex arrays being stored on the server, it seems counter-intuitive to send vertex data from main memory to the video card and then back to the CPU and then back to the video card.

  7. #7
    Member Contributor
    Join Date
    Apr 2003
    Posts
    60

    Re: When should you not use OpenGL's Matrices?

    Thanks everyone, so I guess I'd be basically wasting my time writing processor specific code, except if I'm doing software rendering which Mesa probably does that for me already..

  8. #8
    Guest

    Re: When should you not use OpenGL's Matrices?

    With a gfx card using with a hardware T&L engine, the transformations will be done on the gfx card, rather than the CPU.

  9. #9
    Member Contributor
    Join Date
    Apr 2003
    Posts
    60

    Re: When should you not use OpenGL's Matrices?

    But if things are done "in software" isn't that all on the CPU, like say with Mesa?

  10. #10
    Senior Member Regular Contributor
    Join Date
    Jun 2003
    Posts
    121

    Re: When should you not use OpenGL's Matrices?

    Hi!

    As previous posters said, its better to allow OpenGL to do the matrix transformations for you. Most cards these days support hardware accelerated transform and lighting (all GeForces and Radeons), so they can do the transformations much faster than you can do in the CPU.

    Also, most games tend to be limited by the CPU than the GPU, and you'll find that Nvidia and ATI are constantly encouraging developers to move as many computations as possible onto the GPU.

    There are a few cases where you might want to perform your transformations on the CPU and in those cases, the special optimizations you mentioned are essential. For example, suppose you are doing skeletal bones animation with vertex weighting and you want to do high precision triangle-vs-triangle collision detection. Or if you need to calculate silhoutes for stenciled shadowed volumes, you might want to store a transformed copy of the vertices in main memory.

Page 1 of 2 12 LastLast

Similar Threads

  1. Problem with OpenGL matrices
    By bstow01 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-01-2005, 05:38 AM
  2. QT & OpenGL transformation matrices
    By Alezhi in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-07-2003, 01:28 AM
  3. Using OpenGL with your own Matrices
    By DennisMV in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-17-2002, 04:26 AM
  4. OpenGL Matrices .....
    By crain in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 03-17-2002, 05:52 PM
  5. OpenGL Matrices
    By LTJ in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-05-2002, 08:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean