Tuesday, July 25, 2006

Fixing DRI for the ATI Rage Mobility M3 on Ubuntu

I'm setting up a cheap PC for my Mom with Ubuntu (yeah, it's a Linux distro that even Mom can use) and I noticed it was waaaay snappier than on Ali's Dell Latitude C600 laptop. I thought at first, is it the power management messing up and slowing the CPU down? As I was looking up benchmark programs I had another idea - the difference was that the video was much faster on the tower PC. Now, it's no screamer - it's got an old S3 AGP 1x video card, probably a bargain even when it was new, so I knew something was up.

Searching on Ubuntu video benchmark, I came across the popular glxgears demo. Now I can hear the purists screaming already, it's not a real benchmark - but it's very useful for debugging video card problems. Probably these bunch of semantic whiners are the ones that removed the FPS from the default display in glxgears (at least in Ubuntu 6 "Dapper Drake") and lacking a man page I had to Google to discover glxgears -printfps brings it back. The old PC was doing about 350fps, crap by today's standards but it looked nice and smooth. The laptop was getting 70fps and it was choppy as hell. Uh oh!!

The first thing I found was that "direct render" aka DRI wasn't working; I got something like this:

% glxinfo | grep direct
Xlib: extension "XFree86-DRI" missing on display ":0.0".
direct rendering: No
OpenGL renderer string: Mesa GLX Indirect

According to the ThinkWiki the ATI Mobility Rage 3M is supposed to support DRI. Big problem because the poor old CPU in this laptop is having to do all the work instead of offloading video tasks to the graphics card, which makes Ubuntu almost as slow as Windows XP which was on it previously before it decided to eat it's own registry.

At first I thought I needed to install the fglrx driver package as per the Ubuntu Desktop Guide. I followed the instructions and.... kaboom, X would no longer start. Oops, I should have read things more carefully - the ati driver X was using before was the right one, since this is an R128 card. After running sudo dpkg-reconfigure xserver-xorg and changing back to the ati driver, X came back, but I was back to square one - no direct rendering.

Well I searched some more and finally found the Tao Security Blog which pointed me in the right direction - I use FreeBSD a lot for my server work so his OS of choice didn't throw me off. Indeed, the problem was the paltry 8MB of memory on this card would not support DRI with 24 bpp. Changing it to 16 bpp and voila: Direct rendering enabled in my /var/log/Xorg.0.log

However, all was not well - glxgears still reported the same crap 70 fps.

The next piece of the puzzle came soon though, from the DRI Wiki. Enabling verbose mode via export LIBGL_DEBUG=verbose showed this interesting factoid when running glxgears:

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

Well this drove me up the wall for a while. I dumped symbol tables, reinstalled all the libgl, mesa, etc packages in Synaptic, nothing helped. By the way, being able to search for files in Ubuntu packages helped a lot. Then I compared the size and dates of /usr/lib/libGL.so.1.2 and r128_dri.so between the laptop and the PC and lo, libGL.so.1.2 was different sizes and dates...

Some quick investigating told me I was still using the fglrx version of that file. Oops - how was I to know it would overwrite it with an incompatible version? Oh well - removing the xorg-driver-fglrx package finally fixed it.

Hooray! The Latitude is now pushing about 500 fps on glxgears, and the UI is much snappier. Playing anime video no longer stutters and chops if you do... anything else. The CPU is happier too, and Ali's lap should be kept a little cooler.

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?