Monday, November 16, 2009

The Legacy of the R300

You know it as the Radeon 9700 (and its later cheaper 9600XT, as well as the X300, X500 and X600). The R300 was a definite victory for ATI - when it came out it was vastly superior to the NVidia GeForce FX series, and for a video card it held up pretty well.

From my perspective as an application's developer, however, the R300 has some fine print that makes it difficult to deal with:
  • It features only 24-bit floating point precision (as opposed to 32-bit precision in all other shader-enabled hardware from ATI or NV). This is why the reflective water looks square and pixelated up close on these cards.
  • It has a 96 instruction limit per shader (as opposed to the 1024 instruction or larger limit in all other shader-enabled hardware from ATI or NV.) X-Plane 9's current water shader is right on the bleeding edge of exceeding this limit. In fact, the water pattern is simplified for this set of GPUs to stay within the 96 instruction limit.
  • Since the cards were really quite decent for their time, they are still in field and in use.
(This is a different problem from the Geforce FX/5 series...those GPUs were fully capable of running advanced shaders, they just couldn't do it quickly. In practice this is better for an application's developer, because users are more likely to replace a slow GeForce FX than a capable but internally limited 9700.)

This shows up in X-Plane as a pile of special cases...X-Plane 9 productizes 2.5 renderers:
  • A no shader renderer for old GPUs and buggy drivers.
  • A shader-based renderer for modern hardware.
  • A special-case on the shader based GPU to meet the limits of the R300.
I'm not sure what we will do about this in the future. But as I go through the shader code, this special casing sticks out. We don't usually special case X-Plane for a particular set of hardware, but in the case of the R300, it was for a while so widespread that it made sense to special-case for its limitations.


Wayne Conrad said...

The worst special cases ever are for configurations you can't test yourself.

// do funky stuff that I can't refactor
// without huge risk because I sure
// can't test it.

Bold & Courageous said...

Since the R420 is can be seen as two 300's back-to-back, do these limitations apply to the 420 as well?

Benjamin Supnik said...

I am pretty sure that the R420 doesn't have the instruction limit, and I think it's also full 32-bit float inside, but I can't confirm that - I don't have one myself.

Bold & Courageous said...

I only ask because my water looks "looks square and pixelated up close" and I have an X800 XT.

Anonymous said...

I looked around a bit on the web and found a little evidence for R420 using 24-bit still, none for 32-bit.

But I have to say, even 32-bit isn't that much at the scale of X-Plane's coordinate system. When you don't happen to be near the origin there's only about a centimeter of precision (not counting cumulative rounding). That jitter is getting on my nerves. I don't mean the reflections in particular (couldn't care less about that), but the plane in external views and anything nearby from any view, really, like runways.

Benjamin Supnik said...

Yep - 32 bits isn't much. Jittering effects are not from the card usually though - usually it's from the sim not being very, very careful with how we manage those 32 bits.

Anonymous said...

I know X-Plane is to blame. ;-)