Howto:Activate multi core and multi GPU support
FlightGear supports a number of different threading modes to make use of multiple CPUs or GPUs, this applies mostly to high-end multi-core or multi-GPU, multi-screen (or multi-window) setups and may improve performance (see Howto: Configure camera view windows).
|Note In its current form, this section/article is largely based on quotes collected from various related discussions/channels (devel list, forum etc) using the Instant-Cquotes script. Wiki users and other contributors are encouraged to help rewrite/edit contents accordingly to help get rid of unnecessary quoting (i.e. while the wiki is not intended to be a collection of quotes, quotes are sometimes the best/easiest way to bootstrap new articles, while also providing a good way to link back to related discussions in the archives).
While rewriting usually only entails changing first person speech to 3rd person. However, please try to retain references/links to the original discussion whenever possible.
Proposals & RFCs
Selecting threading modes
|Note Beginning with FlightGear 3.0, you should be careful when changing the default OSG threading settings, as enabling multi-threading seems to be an increasingly reliable way to trigger race conditions/segfaults (crashes). Also see ticket #1393 and 
There is a property supported named /sim/rendering/multithreading-mode this can be set either in the preferences.xml file located in the flightgear data folder (base package: $FG_ROOT) or by using the --prop:/sim/rendering/multithreading-mode=... parameter from the console (or fgrun) this affects directly the osgviewer threading mode, supported values are:
* AutomaticSelection * CullDrawThreadPerContext * DrawThreadPerContext * CullThreadPerCameraDrawThreadPerContext
Further information on threading modes can be found here: http://firstname.lastname@example.org/msg09620.html and here: http://email@example.com/msg09611.html
To set this in a separate XML file, just include it from preferences.xml (toplevel PropertyList node):
<?xml version="1.0"?> <PropertyList> <sim> <rendering> <multithreading-mode>AutomaticSelection</multithreading-mode> </rendering> </sim> </PropertyList>
This property must be set during initialization, modifying it at runtime has no effect.
Multithreading modes allocate two instances of OpenGL resources to speed up rendering . Default implicit buffer attachment policy adds depth buffer to FBOs if only color buffer was attached.
if you have a single graphics card, having a thread per camera (each one with a graphics context) doesn't necessarily improve the performance, what is more, it can degrade it. The reason is that each thread will be competing for the graphics card, which is an exclusive resource, and the driver is forced to perform many context switchs. If you are using multiple graphics contexts then by default the OSG/OpenGL will be creating OpenGL objects (like textures) on a per context basis. So one osg::Texture in the scene graph even if it's rendered on two contexts you'll have two separate TextureObjects/OpenGL texture objects.