Wednesday, October 11, 2006

That was so fun - let's do it again!

One of the less fun aspects of X-Plane 8.50 was dealing with driver bugs. The basic problem is that PC hardware vendors have a relatively slow cycle for updating the software they bundle with their machines; while the companies that write drivers (ATI and nVidia) have a pretty high latency from when they first ship a card to when the driver support is to the level that X-Plane needs.

The clearest case of this I saw during 8.50 was in the case of PC users with "1.5"*-type ATI drivers. These drivers will cause the terrain textures to swim when hardware-accelerated runway lights are used. Upgrading to "2.0"-type ATI drivers fix the bug. A lot of users were just fine with the 1.5 drivers that came with their machines until X-Plane 8.50 came out, and have only now updated.

8.50 started using pixel shaders; hence the need for newer drivers with bug-free pixel-shader support. But in the future we're going to move from "DSP"-type shaders (that is, shaders written in a very low level language) to shaders writen in a GLSL, a high level abstract way to write shaders.

My fear is that this will induce a second round of "update your driver" for PC and Linux users. (Apple ships new drivers with system update, so users of the current Mac OS can usually just run the updater if it isn't set to update automatically.) But I think it's probably for the best that people use the latest drivers, as ATI and nVidia put software changes in the drivers that increase the throughput of the graphics card, through smarter use of the hardware.

The one group that is really stuck is Macintosh 10.3 users; Apple doesn't provide driver updates to older operating systems. So for example users with 10.3.9 and an ATI card with pixel shaders can't get hardware-accelerated texture lights without buying OS X 10.4. I would go as far as saying that in the future if you have a pixel-shader card it might be worth buying an OS upgrade to unlock the driver support needed to use these features.

Why move to GLSL (and require more driver updates)? In the long term it will provide superior framerate. The current shaders we have now are written in a very low level language, that roughly matches the technology of the first generation pixel-shader cards (Radeon 9700 and GeForce "FX" series). As cards gain new capabilities, Austin and I can't take advantage of the new capabilities using this old language.

GLSL however is a higher level language; when we write a shader in GLSL, the graphics driver translates our shader into code specific to the video card at hand when X-Plane starts. This means that if the video card has some new magic trick it can do, the driver can take advantage of that trick as it translates our shader, resulting in higher framerate. And everyone loves higher framerate. :-)

EDIT: who will be able to use GLSL? Basically any card that has hardware-based pixel shaders** from ATI or nVidia will support GLSL-based shaders if you have a modern enough driver. So if you are seeing hardware-accelerated runway lights in 850 then the GLSL changeover shouldn't cause any more fuss than a driver upgrade if you haven't done one rcently.

Also I should say that if I sound like I am dumping on ATI and nVidia for driver bugs, I shouldn't be; video cards are amazingly powerful, the drivers are very complex, and the technology jumps by huge amounts in a very short time period. I believe the level of driver bugginess we see is a function of fast technology rollout and not the competence of the driver teams, who I am sure are working as hard as they can.

So we, the developers who write programs that use these cards, and you, the users who enjoy these cards, have to ask whether we'd rather have faster framerate and more eye candy or less chaos from our drivers.

*ATI drivers are numbered by ATI to match ATI's internal versioning scheme. But X-Plane can't really see what the ATI driver version number is (e.g. the catalyst version number). So when I say 1.5 or 2.0 I am really talking about the OpenGL specification number that the driver implements. ATI implements newer specs in newer drivers, so we can tell that an ATI driver that supports the 2.0 spec is newer than an ATI driver that supports teh 1.5 spec.

So while I have no idea of either which versions of the ATI drivers had this bug or which version it was fixed in, but we can tell from an X-Plane Log.txt file whether the drivers are going to have this bug.

**Hardware-accelerated shaders? Well, previously I've described a graphics card as either having shaders or not, but this isn't totally accurate. Technically a shader can include a non-programmable shader. Furthermore the driver can present software emulation of a shader. For example, the Intel GMA950 has programmable pixel shaders in hardware. On a Mac the driver reports that it has vertex shaders, but the vertex shadings is actually done by the CPU. (This isn't unreasonable -- all vertex processing is done by the CPU on the GMA950.)

So really when we talk about "cards with shaders" we mean: any nVidia card with a number of 5000 or higher (plus some Quadros, sorry I don't know the numbres on those), and any ATI card with a number of 9500 or higher, and any ATI card with an "X" in it, e.g. X850. At this point we've had shaders in cards for 3 generations, so if you buy a new computer and it has an ATI or nVidia graphics card, it should have fully programmable hardware shaders.

Of course now not all shaders are equal; the newest cards have even more powerful shaders. But this isn't likely to matter a whole lot to X-Plane for a while. But generally I'd recommend buying the mid-range latest generation cards over high-end obsolete cards at this point.

No comments: