Hardware 3D acceleration on an ATI Radeon 9600 mobile

by levien on vr 25 april 2008 // Posted in misc // under

UPDATE (2010-08-25): This article describes how to configure Ubuntu 8.04 LTS (Hardy Heron) for stable 3D-acceleration and desktop-effects with ATI R300 series (Radeon Mobility 9600 and similar) GPUs. On recent Ubuntu versions (such as 10.04 LTS) this should work out of the box, and making modifications to xorg.conf may actually introduce unwanted artefacts. Therefore if you upgrade from 8.04 LTS to 10.04 LTS you should remove your customised settings. See the description at the bottom of the article for more details...


One of the things that has really frustrated me over the last couple of years is the apparent inability of ATI to properly support their own hardware under Linux. My laptop has an ATI Radeon Mobility 9600 (RV350 M10) on board, which works fine under Windows with 3D acceleration and under Linux without 3D acceleration. However, as soon as I try to use ATI's own closed-source fgrlx driver, everything becomes unstable, and my laptop experiences random lockups, reboots, garbled screens and other nasty things.

NVIDIA seems to have learned their lesson some time ago, their linux drivers may also be closed-source, but at least they're fast, up-to-date, complete and stable. And they boast a wonderful configuration tool, nvidia-settings.

I had hoped that ATI would have fixed things for Ubuntu Hardy (8.04), so I could at least run Compiz and other OpenGL applications like Google Earth. Alas, although ATI did add AIGLX support to their latest fglrx driver, it basically sucks. It's slow, causes flickering with OpenGL apps and video playback and has managed to make my laptop even more unstable than before.

So I decided to give up on fglrx and try the open-source radeon driver from Xorg instead. Theoretically it should work out of the box, as the driver claims to support 3D direct rendering on R300 chips, including the RV350. Of course, in practice it doesn't.

To cut a long story short, I had to spend a full day googling and experimenting to get it to work. Here's what I found:

• The driver basically works. With the default settings it already enables direct-rendering and AIGLX. However, both the driver and glxinfo produce some misleading messages, that can keep you busy for a few hours... :-/ You can safely ignore these messages in /var/log/Xorg.0.log:

drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
...
(II) RADEON(0): Render acceleration unsupported on Radeon 9500/9700 and newer.
(II) RADEON(0): Render acceleration disabled
...
(--) RandR disabled
...
(WW) AIGLX: 3D driver claims to not support visual 0x23
(WW) AIGLX: 3D driver claims to not support visual 0x24
(WW) AIGLX: 3D driver claims to not support visual 0x25
(WW) AIGLX: 3D driver claims to not support visual 0x26
(WW) AIGLX: 3D driver claims to not support visual 0x27
(WW) AIGLX: 3D driver claims to not support visual 0x28
(WW) AIGLX: 3D driver claims to not support visual 0x29
(WW) AIGLX: 3D driver claims to not support visual 0x2a
(WW) AIGLX: 3D driver claims to not support visual 0x2b
(WW) AIGLX: 3D driver claims to not support visual 0x2c
(WW) AIGLX: 3D driver claims to not support visual 0x2d
(WW) AIGLX: 3D driver claims to not support visual 0x2e
(WW) AIGLX: 3D driver claims to not support visual 0x2f
(WW) AIGLX: 3D driver claims to not support visual 0x30
(WW) AIGLX: 3D driver claims to not support visual 0x31
(WW) AIGLX: 3D driver claims to not support visual 0x32

As long as you have these:

(II) RADEON(0): [dri] Found DRI library version 1.3.0 and kernel module version 1.28.0
...
(II) RADEON(0): Direct rendering enabled
...
(II) RADEON(0): RandR 1.2 enabled, ignore the following RandR disabled message.
...
(II) AIGLX: Loaded and initialized /usr/lib/dri/r300_dri.so
(II) GLX: Initialized DRI GL provider for screen 0

As for glxinfo, its output is somewhat broken. Only pay attention to the line that says:

direct rendering: Yes

If it says No, run LIBGL_DEBUG=verbose glxinfo and check for error messages. If it produces the following error, chances are that you still have the fglrx driver installed:

libGL: OpenDriver: trying /usr/lib/dri/r300_dri.so
libGL error: dlopen /usr/lib/dri/r300_dri.so failed
(/usr/lib/dri/r300_dri.so: undefined symbol: _glapi_get_dispatch)

The presence of fglrx interferes with the open-source driver, even if you're not using it. Uninstall the package xorg-driver-fglrx using Synaptic, and try again.

• Google Earth (which you can install from the Medibuntu repository) will fall back to software rendering, even if hardware rendering is working. This is caused by the fact that the Xorg radeon driver does not yet implement all OpenGL features. If an application tries to use such an unimplemented feature, it switches back to painfully slow software rendering. If you start googleearth from a terminal, you get this message:

*********************************WARN_ONCE*********************************
File r300_render.c function r300Fallback line 471
Software fallback:ctx->Line.SmoothFlag
***************************************************************************

Luckily you can change this fallback behaviour on a per-application-basis by installing the package driconf and setting disable low-impact fallback for the application googleearth-bin. See this Ubuntu forum-post by dinxter for more details.

If you're using Google Earth 4.3 and things are really slow even with hardware rendering, try switching off sky rendering in the view menu.

• Even when you've managed to get hardware accelerated OpenGL rendering to work, Ubuntu's desktop effects still refuse to be enabled. For some reason Compiz Fusion (the window-manager that does all the fancy effects) complains about XGL being unavailable and just gives up. Or more precisely, the compiz wrapper script gives up. If I ran compiz --replace from a terminal, I got this message:

Checking for Xgl: not present. 
Found laptop using radeon driver. 
aborting and using fallback: /usr/bin/metacity 

I could however make it work by bypassing the wrapper script and running compiz.real directly: LIBGL_ALWAYS_INDIRECT=1 compiz.real --replace --sm-disable ccp &

Luckily there is also a more elegant way. You can tell the compiz script to ignore any errors by adding the line SKIP_CHECKS=yes to the configuration file ~/.config/compiz/compiz-manager:

mkdir -p ~/.config/compiz; echo SKIP_CHECKS=yes >> ~/.config/compiz/compiz-manager

After doing that you should be able to enable the desktop effects the usual way, using the somewhat hidden "Visual Effects" tab in the System->Preferences->Appearance configuration dialog.

• The Xorg R300 driver seems to set the AGP GART size to 8 Mb by default. This is fine for Compiz on its own, but if you try to start Google Earth or another heavy 3D application, it runs out of AGP memory and crashes:

*********************************WARN_ONCE*********************************
File r300_mem.c function r300_mem_alloc line 225
Ran out of GART memory (for 1048576)!
Please consider adjusting GARTSize option.
***************************************************************************

The solution is to increase the GART memory size to 32 or 64 Mb, by adding Option "GARTSize" "64" to the Device section of your /etc/X11/xorg.conf file.

It may also help to decrease the bit-depth of your display from 24 to 16 bpp. This has the added advantage of speeding up Compiz and screen updates in general, at the cost of some minor colour quantisation artefacts. Just edit /etc/X11/xorg.conf, add a 16-bit display to the "Screen" section, and change the Defaultdepth to 16. Something like this:

Defaultdepth    16
        SubSection "Display"
                Depth           16
                Virtual         1024 768
                Modes           "1024x768"
        EndSubSection

On the other hand, a 16 bpp display sometimes breaks Xv video playback, due to bug #13924 in the radeon driver. If Xv gives you troubles, VLC and Mplayer allow OpenGL playback. Or you might simply want to keep a 24 bpp display in that case. :-)

• Using Google Earth together with Compiz Fusion will currently cause some flickering and other minor rendering artefacts. It's not as bad as with the fglrx driver, but if you want to get rid of it try installing Compiz-Switch. This will allow you to easily disable Compiz when running heavy OpenGL applications such as Google Earth.

• Since Ubuntu Gutsy (7.10), the ati Xorg driver has XRandR enabled. If this gives you trouble with dual monitor setups, try starting with a clean xorg.conf file. I had lots of problems with incorrect detection of external monitors and beamers on my laptop after the upgrade to Gutsy, which I eventually solved by commenting out a few lines in my original Xorg configuration. Apparently, less is more in this case. For a very useful guide on XRandR, see http://www.thinkwiki.org/wiki/Xorg_RandR_1.2

So all's well that ends well. I'm now happily running my laptop with the open-source radeon drivers and full hardware 3D acceleration. It's completely stable, a lot faster than it ever used to be under metacity, and of course has visual effects that beat the crap out of Vista with half the minimum hardware specifications. ;-)

UPDATE (2010-08-25):

After upgrading my laptop from Hardy 8.04 LTS to Lucid 10.04 LTS, I experienced some screen corruption problems when fading (e.g. with notifications and gksu password entry dialogs) and in QT4 apps (only with "-graphicssystem raster", which I need to speed up Kile). If this happens, first try running Xorg with default settings by moving your xorg.conf out of the way: sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.hardysettings

Then log out of your X-session and log back in to restart Xorg with default settings. The radeon driver in Lucid Lynx has been much improved since Hardy times, so chances are that it will work best with "out of the box" settings... However, if you still experience corruption issues after removing the xorg.conf, you could try switching to the cutting edge Xorg drivers by adding this PPA: https://launchpad.net/~xorg-edgers/+archive/ppa Note however that this is at your own risk. And if you do use this PPA, don't forget to install the ppa-purge package and run sudo ppa-purge ppa:xorg-edgers/ppa before attempting to do a distribution upgrade, or you'll risk breaking your system!

References