Wednesday, July 26, 2006

X-Plane Framerate and VRAM

When it comes to discussing graphics cards, VRAM always comes up. How much do you need? Is more really better? And why does X-Plane say it is using 300 MB of VRAM at current settings when you only have 64 MB of VRAM on your graphics card? How is this possible?

Well, the short answer is that X-Plane's measure of VRAM is actually mislabeled. But there's more to it than that. (See the bottom for tips for managing VRAM and framerate.)

X-Plane creates two kinds of graphics data for your graphics card: geometry data (the shape of mountains and valleys, buildings, runways and airplanes) and texture data (the raw images that are "painted" onto that geometry, such as grass, water, and airplane liveries).

The amount of texture data X-Plane loads is a function of your texture resolution settings - lower resolution means less texture data. Turning on texure compression also lowers this amount, and adding custom scenery may raise it.

The amount of geometry data X-Plane loads is a function of the number of cars and objects, add-on scenery, and which base meshes you use (new DSFs have more than old ENVs). Turning down the 3-d detail can reduce the amount of geometry data X-Plane has to load.

There are three two places that geometry and texture data can be stored: system memory (the RAM in your computer, on the motherboard) and video memory (VRAM, the memory on your graphics card). VRAM is usually faster than system memory, especially when the graphics card uses it, but there is usually less of it. For example, my Mac has 2048 MB of RAM but only 256 MB of VRAM.

We need one more concept to understand how VRAM and frame-rate relate to each other: the "working set". X-Plane loads a lot of textures when it starts up. But when it draws a frame, it may not need them all. For example, we may load the grass runways texture, but we may not need it if there are no grass runways nearby. The "working set" is all of the geometry and texture data that X-Plane needs to draw the current frame. And since you cannot look at the whole world at once, the working set is usually a lot less than the total data loaded. (For example, as soon as you stop looking at that aircraft carrier because you're flying away from it, the geometry and texture data for the aircraft data are no longer in the working set.)

So putting it all together we can realize that:
  • In the rendering settings dialog box X-Plane is reporting the total texture data.
  • The rendering settings number is possibly low because it doesn't account for geometry data.
  • The rendering settings number is possibly high because not all loaded data is in the working set.
  • X-Plane has two sources of memory to work from (VRAM and system RAM), so even if the memory reported by X-Plane was right and bigger than VRAM, system memory would allow us to still run.
So in summary the display in the rendering settings dialog box is not very informative - you cannot look at that number and your card's VRAM and use that data alone to predict frame-rate troubles.

So...how much VRAM do you need? Well, X-Plane uses VRAM and system RAM. Anything that is stored in system RAM has to be transfered over your graphics bus (this is your AGP slot or PCIe slot, faster is better, meaning AGP 8x is better than AGP 4x).

This is about to get geeky...skip down a few paragraphs for the practical part.

Basically you need enough VRAM and bus bandwidth (capacity to shovel data from system memory to your graphics card) to handle the entire working set (the stuff X-Plane needs) once per frame.

If I haven't already lost everyone, you could say:

max framerate = bus bandwidth / (working set - VRAM )

So faster bus = faster framerate, and more VRAM = faster framerate. (Math sticklers might ask - if VRAM = working set, is framerate infinite? No...but this equation tells us that if the entire working set fits in VRAM and thus you are not limited by the card fetching data. Other limits on the card will limit your framerate. But this doesn't happen so often as X-Plane's working set on a high-end card with nice settings can be hundreds of MB.)

So you either need more VRAM or a faster bus. In practice, both are good! If you're looking at a new computer, do not settle for anything less than a PCIe16x slot - that's the fastest bus you can get now...less will limit the usefulness of your computer when you try to upgrade.

Generally when you've got more data than VRAM your framerate will be slow - but if you have extra unused VRAM, your framerate will not increase. So what I recommend is: turn down texture resolution (and restart) and check framerate. Once you do this and the framerate does not improve, go back up one notch. This is the highest texture resolution you can run without losing framerate. If you want to go higher, go for it...but you'll pay for it in framerate a bit. Also, turn off FSAA for this test, as it can slow down framerates and make the role of VRAM hard to detect.

(A historical note: in the old days graphics busses were a lot slower than they are now. Remember that everything the card needs that doesn't fit in VRAM has to go over the graphics bus. So...on the old cards if you ran out of VRAM, the sim's framerate really tanked - it could fall down to 2 or 3 fps. But modern machines have much faster graphics busses, so as you run out of VRAM, the framerate get slower but is not totally unusable, becaues the graphics bus can keep up.)

Tips for best framerate:
  • Always use texture compression.
  • Turn down tex res until framerate doesn't increase, then go up one notch.
  • Be sure to buy a card with PCIe 16X!
  • If the VRAM listed in the rendering settings is larger then your card's VRAM - don't panic!

1 comment:

Anonymous said...

Hi Ben

Thanks a lot for this great expanations!
A few things are know a lot more clearer for me...

Fran├žois