Hi,

On Sunday, February 05, 2012 22:29:18 Heiko Schulz wrote:
> Because no one, not Tim Moore, not me, not anyone, did say this!
> The wiki article is btw by Tim Moore.
> 
> But they said, that the bottleneck of GPU's is not the vertice count, but
> other things. That never meant that you have to use many vertices as you
> want.
> 
> "... As many vertices as needed- not more or less!"
ACK.

Currently OpenGL wise we are basically geometry setup bound - at least for the 
models. This really means that vertices are not an issue.
That still means that for setting up that one draw with 3 triangles is about 
as heavy as setting up say 500 triangles, but the conclusion of this is *not* 
that you should schedule as many triangles ass possible.
The right conclusion is to collapse as many triangles as *sensible* for 
culling into a single draw.

A simple help is to switch on the onscreen stats in the viewer or flightgear 
and see if the yellow bar is longer than the orange one. A yellow bar longer 
than the orange one means that the cpu is not able to saturate the gpu.
Again, beware this does in no way mean that you should write complicated 
shaders to saturate the gpu! This rather means that the geometry setup/state 
change time - the yellow one - must decrease!

How to achieve that is a very long chain of right decisions. Starting with the 
modeler:
Avoid having leaf geometry with very small parts. Collapse as much triangles 
as sensible for culling into the same leaf geometry. Sure if geometry needs a 
different texture or anything that requires a different OpenGL state you cannot 
collapse this into the same leaf. May be it makes sense then to collapse the 
textures into a common one. Then you might be able to collapse more geometry.

Avoid animations that are not really required. If you need a transform node in 
between some geometry, the geometry below the transform needs to be drawn 
seperate which takes time on the cpu. Everything that needs geometry to be 
drawn seperately should be avoided to that level where it stops to make sense 
because of culling.

May be introduce some level of detail. Not just avoid the whole model in some 
distance, but also provide a static model without animations, simple geometry 
for the mid range. May be provide some more culling friendly and detaild with 
the animations you need for the short range.

Keep in mind that culling a model that you are close to should make you split 
the model into more parts that could possibly be culled away. But for culling 
a far away model is probably very sufficient to cull it either as a whole or 
not.

Avoid state changes. Use as much common state as possible. Osg does a good job 
in sorting together draws using the same state, but if the overall scene 
contains plenty of different state osg cannot change that.
A new texture is a new state for example. A new shader is a new state. ....

Once your orange bar is longer than the yellow one, you can start to care for 
the shaders and their execution.
When thinking about shaders, keep in mind that different GPU's perform very 
different on the same shader.

Appart from OpenGL we spend a lot of time in scenegraph traversal. This is 
mostly due to plenty of structural and often needless nodes in the scenegraph. 
The reason or this is that historically the xml files did some implicit 
grouping for *every* animation in the xml file. To make that reilably work I 
had to introduce a huge amount of group nodes in the xml file loader. These 
really hurt today as they introduce a whole lot of group nodes that just have 
a single child which need to be traversed for update and for cull. Profiling 
shows that Group::traverse is the most used function in flightgear.
The lowest hanging fruit could be to optimize away the redundant nodes from 
the top level model that gets loaded by a database pager request. We cannot do 
that recursively once a model part is loaded since the mentioned grouping 
nodes might be referenced in any level in the model hierarchy above the 
currently loaded model. So only the top level model could do this without 
braking tons of models.

And regarding all that, even if your box already is gpu bound this does not 
mean that other driver/hardware combinations are gpu bound too.

Always: As much as needed and as few as possible.

Ok, there are plenty of other aspects of performance tuning a scene graph, but 
these are the ones I think are most important for flightgear as of today.

Mathias

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to