[osg-users] Using SSE within OSG

James Killian James_Killian at hotmail.com
Tue Jul 29 07:59:51 PDT 2008

Paul asked me the same question a few days ago, and I just realized that we
took that offline so I'll repost here:
One of the things I should add is the actual profile dump, since that shows
a more comprehensive picture.  The actual game demo is free to download and
play here:

The current installer of the game does not have my optimization in it yet,
but it should be noted even with the optimization the postmult is still at
the top.  The Invert4x4() however got pushed way down to the bottom (which
is great).  I'll post my profiles when I get home.

That is a good question, and I believe the answer is collision detection.  I
should disable it and run the numbers again to confirm.  All ships fire
machine guns at a fast rate, and each bullet that gets close enough to a
bounding box/sphere region has to go through the osg code to get the precise
point where it hit.  Rick would probably have a better explanation of this
and other factors since he coded the bulk of the collision detection (and
osg integration).  Most of my time development in the game has been spent on
the physics and flight dynamics (and now optimization).

It may turn out that we could find some caching technique to reduce the
collision stress (like the KBDtree), but in the mean time, matrix
optimizations can benefit the whole community if we do them right, and I
would like to make some contribution to the community.

----- Original Message ----- 
From: "Paul Melis" <paul at science.uva.nl>
To: <James_Killian at hotmail.com>
Sent: Monday, July 28, 2008 9:05 AM
Subject: [Fwd: Re: [osg-users] [osg-submissions] Matrixf multiply

> Hi James,
> I noted you posts on the osg-users list on the Matrix multiplication
> optimizations using SSE.
> You mention "Our game uses approximately 25% of all processing to these
> functions [...]". What on earth takes up so much matrix computing time
> in your game?
> Regards,
> Paul

----- Original Message ----- 
From: "Mathias Fröhlich" <M.Froehlich at science-computing.de>
To: "OpenSceneGraph Users" <osg-users at lists.openscenegraph.org>
Sent: Tuesday, July 29, 2008 9:31 AM
Subject: Re: [osg-users] Using SSE within OSG


On Tuesday 29 July 2008 15:18, James Killian wrote:
> I 100% agree with that as that is the first thing I did.  For the matrixf
> mult I got 50% improvement with aligned data and 35% with unaligned.  For
> the Invert4x4 I got 80% improvement with aligned and 70% aligned with
> unaligned.  I've submitted this code in as it was the most time spent in
> the profiles of our game.
I wonder what your scenegraph looks like.
Why do you have that much matrix operations?
Where are they called from?
Why do you need that many inverted matrices?

Also the invert method makes me wonder. As far as I can tell, you do not
inverted matrices to do cull and draw. At least not in a magnitude that
that method appear in profiles.

Do you compute intersection tests where you need that inverse?
And what kind of matrices are in your code that you really need the full 4x4
inverse? Almost alway the cheaper 3x4 variant can be used for usual

Well, I ask that because I get the impression that the real botteneck -
you can gain much performance - is somwhere different.



Dr. Mathias Fröhlich, science + computing ag, Software Solutions
Hagellocher Weg 71-75, D-72070 Tuebingen, Germany
Phone: +49 7071 9457-268, Fax: +49 7071 9457-511
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196

osg-users mailing list
osg-users at lists.openscenegraph.org

More information about the osg-users mailing list