Sunday, December 06, 2009

Why Isn't SLI/CrossFire A No-Brainer?

To get this out: I have no idea if/whether/how much SLI or Crossfire improve or hinder X-Plane's framerate. None of my development systems have such hardware, and I spend no time either optimizing for SLI/CrossFire or testing. If you have done tests with SLI enabled and disabled, I would like to know the results!

I have read the white papers on how to optimize an application for SLI/CrossFire, and while X-Plane isn't quite a laundry of SLI/CrossFire sins, we're definitely an application that has the potential for optimization.

Now normally more hardware = faster framerate. In particular, the limiting factor of filling in a big display with high shader options and full screen anti-aliasing can be the time it takes to fill in pixels, and more shaders mean more pixels filled in at once.* Why doesn't having an entire second GPU to fill in pixels allow us to go twice as fast?

The answer is: coordination. Normally the process of drawing an X-Plane frame goes a little bit like this:
  1. Draw a little bit more of the cloud shadows into the cloud shadow texture. (This is a gradual process.)
  2. Draw the panel into the panel texture.
  3. Draw the world (as seen from below the water) into the water reflection texture.
  4. Draw the airplane shadow into the airplane shadow texture.
  5. Draw the entire world using the above four textures.
Notice a trend? Those four textures are dynamic textures, meaning they are created by the viedo card drawing into its own texture, once per frame. Dynamic textures are generally a good thing, because they let us create texture content much more rapidly than we could with the CPU. (There is no way we could prepare the panel texture once per frame if we had to do it on the CPU.)

In fact, the total dynamic textures can be more so - if you use panel regions, there are 2 panel textures per region, and if you use volumetric fog, there are two more textures with interim renderings of the world, used to create fog effects.

Okay, so we have a lot of textures we drew. What does that have to do with multiple video cards?

Well, one reason why dynamic textures are normally fast is because, when a dynamic texture is finished, it lives exactly where we want it to live: on the video card!

But...what if there are two video cards? Uh oh. Now maybe one video card drew the water, and another drew the clouds. We have to copy those textures to every video card that will help draw the final frame.

There is a sequence to draw the right textures on the right card at the right time to make X-Plane run faster with two video cards...but the video drivers that manage SLI or CrossFire may have no way to know what that sequence is. The driver has to make some guesses, and if it puts the wrong textures in the wrong places, framerate may be slower, due to the overhead of shuffling textures around.

So SLI and CrossFire are not simple, no-brainer ways to get more framerate, the way having a faster GPU might be.

* If you have a huge number of objects, your framerate is suffering due to the CPU being overloaded, and this is all entirely moot!


Anonymous said...

Hi Ben,

Well remember a few months ago when you said X-plane shouldn't work in SLi mode because of the way the texturing works. You were spot on. I was having issues maintaining the minimum 19FPS and was getting those dang warnings. Disabled SLi in the Nvidia control panel and I was screaming at 70FPS. :)

So as it stands the current engine cannot be run in SLi mode at all. Now my understanding was that Nvidia goes around tweaking apps to get SLi support out of older products like FSX. Well it does achieve this and it's about less than 10% improvement, which leads me to think the only improvement here is the final rasterization.

As far as X-plane working with SLi in the future, well that's your problem now isn't it. But If I were you, I'd explore other avenues first.

Benjamin Supnik said...

"That's your problem now isn't it."

Lucky me. :-)

Seriously, I do not know if SLI is even architecturally useful for X-Plane...our use of render-to-texture causes serious issues, ones that may not be addressable using current APIs.

I also question how cost effective SLI is - it would be a way for me to spend finite optimization time only improving the framerate for the subset of users who have AT LEAST one good graphics card already.

Anonymous said...

I think the biggest problem is the fact that most of the PC games today are simply just ports limited by the console hardware restrictions. I could put two Nvidia 295 in a machine but what is that going to get me when the object and texture assets are limited to something less than an 8000 series at best. SLi might be a great idea on paper but with Nvidia these days you really have to question their motives. Are they doing this for gamers or the High Performance Computing market?

As I mentioned I'd rather see improvements elsewhere that'll help destroy that FSX beast for good. :) And when I do upgrade to the Fermi chances are I'll only be getting one card, and will focus on the fastest core and plenty of VRAM.

Chris said...

Hey Ben,

I just ran several test runs on one of my rigs with SLI. After reading some of your posts, it got me wondering if it was even worth the extra wattage, so... The system is a dual-boot with XP SP3 and Vista Ultimate 32-bit, 4GB SLI-ready RAM, and twin GeForce 9800 GTX+ in SLI config. CPU is a Core 2 Duo, OC to 2.98GHz.

What I found: no matter what settings used, SLI made no difference in either OS. In fact, I squeezed about 4 FPS more with SLI disabled as I flew over a small city with objects at "megatons." Framerate was only about 5 more in XP than Vista. Being a dual-boot system, all hardware is precisely the same, though drivers of course may be slightly different, but this is still a good test.

Overall, I now totally agree with you that SLI is pretty much a waste of money in this context.