Question Why are MFDs so resource intensive?

TCR_500

Developer of Solar Lander
Joined
Mar 3, 2009
Messages
595
Reaction score
14
Points
18
Website
www.tchapman500.com
A while ago, on the OF discord, after having some serious framerate issues, I was told to reduce the MFD update time to something like 1.0 to 0.25 seconds. That did improve the framerate significantly (particularly with a 1.0 update time). But I would like to know why the MFDs need such a long delay to maintain a smooth in-game framerate? Is it drawing every pixel using the CPU or something? Also, why is it that other instruments (eg: all of the non-MFD instruments of the Delta Glider) can be updated quickly enough to give smooth motion without any noticeable framerate loss?
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
9,802
Reaction score
644
Points
203
Location
between the planets
There's two major reasons, and they can depend heavily on the MFD you're using. These are:

Drawing time: The MFDs use a vector drawing implementation that depends on the graphic client. Depending on the complexity of what is drawn and the drawing implementation, drawing an MFD can consume almost as much time as drawing the rest of the simulation window (non-buffered true-type fonts are very expensive, for example). I might be wrong about this, but I think the default graphics client implementation of sketchpad doesn't even use the GPU to draw, while the D3D9 implementation does.

Calculation time: All's fun and horses as long as an MFD only displays data retrieved from the simulation. But quite often, they do calculations of their own. Usually these calculations are done all over for every update cycle, because the data the calculations are based on may have changed in the meantime. Depending on how many calculations an MFD does, how complex they are, and how well the developer of the MFD optimised them, this can be quite a tough load.

By reducing the update cycle, MFDs are redrawn less frequently and run their calculations less often, so changing the update cycle from for example 0.01 seconds to 1 second is likely to literally reduce the computational overhead of the MFD a hundred fold.

Also, why is it that other instruments (eg: all of the non-MFD instruments of the Delta Glider) can be updated quickly enough to give smooth motion without any noticeable framerate loss?
This too depends on how the panel is implemented, of course. But if you look at the reference implementation of the DGs instrument panel, you will see that it is using a buffered font, meaning it doesn't "draw" on the screen, it merely copies bitmaps around in memory for each letter/digit. Which is a loooooot more performant and mostly relies on the GPU to handle the heavy lifting.
Also, most of the data displayed already exists in the simulation and only needs to be queried, rather than calculated from scratch each time.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
7,923
Reaction score
999
Points
188
Location
Toulouse
I use a 0.1 sec refresh rate, and I'm happy with it. Means 10 updates per second.

Now using the D3D9 client tends to drastically improve things. Also, you can use @asbjos improved Map MFD, which drawns the maps in a more efficient way (in terms of calculations). The default D3D7 methods used back in the 2000's are quite obsolete now, and modern hardware can have issues with them (because backwards compatibility is often limited). So an older computer might perform better than a newer one.

But if you use @jarmonik 's D3D9 client, and as much as possible updated release of the MFDs, you should be fine.
 

4throck

Enthusiast !
Joined
Jun 19, 2008
Messages
3,304
Reaction score
571
Points
153
Location
Lisbon
Website
orbiterspaceport.blogspot.com
On MFDs things like number to text conversion can be slow, as the code needs to handle rounding and formatting.
You need multiple operations for that.

On a VC things can be much faster. Matching an animation state to your fuel amount only takes a single operation.
 

TCR_500

Developer of Solar Lander
Joined
Mar 3, 2009
Messages
595
Reaction score
14
Points
18
Website
www.tchapman500.com
Interesting. I am going to have to do an experiment of the GC vs nonGC versions of Orbiter.
 
Top