After a fresh install, X11 is probably not configured to take full advantage of your graphics card. Learn how to take advantage of proprietary drivers to configure your video card for top speed.
Modern graphics cards are actually quite powerful little computers in their own right. Squeezing maximum performance out of them requires them to be set up the right way.
Measure Performance
To see how well your system is currently performing and give yourself a baseline to compare against after making changes, you can use a game such as Unreal Tournament 2004 or Quake III to measure graphic-card performance, both of which have "timedemo" modes that run through a defined sequence of events as fast as possible and report the average framerate achieved. An alternative is to use the glxgears utility (run glxgears -printfps), which is included with the mesa-utils package, but it's such a simple application that it really doesn't stress any decent 3-D hardware, so the framerate figures it generates aren't much use as a benchmark. If you get anything less than about 2,000 fps in glxgears, your video card could probably do with a tune-upor replacement!
Identify Your Video Card
To get your video card running at maximum speed, you need to know what brand and model it is so you can select the best drivers. Video cards are generally installed as PCI, PCI-X, or AGP cards, or are provided directly on the motherboard. In reality, all of these card types are just variations on the basic PCI technology, and even onboard video cards are essentially just PCI devices that happen to be permanently installed on the motherboard. This makes it very easy to identify your card by scanning the PCI bus using lspci:
$ lspci -X
The -X flag tells lspci to report device identifiers in the format used by the X Windows configuration files rather than in native format.
You can also tell lspci to report in "verbose" mode:
$ lspci -v
Verbose mode provides you a bit more information about each device. Unfortunately, the -X and -v flags can't be combined, so you have to run them separately.
Look in the reported device list for an entry that says "VGA compatible controller." The device string will include the manufacturer and model. The most common brands of high-performance 3-D card are nVidia, ATI, and Matrox, although some embedded video cards use chipsets from Intel or other manufacturers.
Drivers
Drivers for video cards have been something of a sore point for open source developers over the last couple of years. Modern video cards are essentially very small, very high-performance computers with their own CPUs and memory, and the drivers are an essential part of what makes them work. The manufacturers tend to guard their driver technology greedily and release only precompiled drivers in binary format that may be used but not modified or reverse-engineered. This runs counter to the ideals of many open source developers who insist that all software, including drivers, should be available in source code format. Thus, many high-performance video cards have at least two sets of drivers available: binary drivers provided by the manufacturer and open source drivers developed by third parties who examine the cards and try to write drivers that will work with them.
Binary drivers have the advantage that they generally offer higher performance and make use of all the features of the card, but they cannot be modified or examined by other developers and can't be compiled to run on different hardware architectures not supported by the manufacturer.
Open source drivers have the advantage of running on more types of hardware because developers can modify them to suit their own requirements, but the disadvantage is that the developers don't have access to internal information about the video-card hardware and may not be able to achieve high performance or make use of all features of the card.
The Ubuntu commitment to ship only free software means binary drivers aren't available in the base distribution, but if you want maximum performance from your 3-D card, you will need to install the binary drivers from the universe and multiverse repositories, or directly from the card manufacturer's web site.
nVidia
The open source driver for nVidia cards is called nv and comes as part of the basic Xorg installation in Dapper, but for maximum performance, install the binary nvidia driver, which is part of the linux-restricted-modules package. The linux-restricted-modules package comes in several different versions to suit the different kernels, so check which kernel version you are running:
$ uname -r
2.6.15-17-686
Then install the matching linux-restricted-modules package:
$ sudo apt-get install linux-restricted-modules-2.6.15-17-686
You will also need either the nvidia-glx or the nvidia-glx-legacy package, depending on the specific card model. If your card is an older modelsuch as the TNT, TNT2, TNT Ultra, GeForce, or GeForce2install the nvidia-glx-legacy package. If it's a newer modelsuch as a 4-series, 6-series, nForce, Quadro, or FX-seriesinstall nvidia-glx:
$ sudo apt-get install nvidia-glx
Edit /etc/X11/xorg.conf and look for a line that says something like:
Driver "nv"
Edit it to specify the nvidia driver:
Driver "nvidia"
Exit from your GNOME session. Then, when you are back at the login prompt, press Ctrl-Alt-Backspace to kill off the X server and force it to restart. As X restarts, you will probably see a big nVidia logo flash on the screen, showing that it has loaded the binary nvidia driver rather than the default nv driver. Log back in to GNOME, start up glxgears, and see if your framerate has improved.
ATI
If you have an ATI card that was auto-configured by Ubuntu, it's probably running either the ati or radeon driver. For maximum performance with cards in the "Radeon" series, 9-series, X-series, or TV-Out-capable ATI cards, you can install the fglrx driver, and if your card is an 8500 or better, you can also install ATI's proprietary driver.
Installing the fglrx driver is very easy:
$ sudo apt-get install xorg-driver-fglrx
Then edit /etc/X11/xorg.conf, look for a line that lists either the ati or radeon driver:
Driver "ati"
and replace it with the fglrx driver:
Driver "fglrx"
Installing ATI's proprietary driver requires a few more steps but may produce better performance on the latest cards. Start by going to http://support.ati.com and navigating to the Linux drivers. Download the ATI Driver Installer, not the specific Xorg driverbecause that's packaged as an RPM, and you need to build a .deb instead. Once the (very large!) driver file has downloaded, install some supporting packages and configure the driver. It helps keep things neat if you do this in a subdirectory:
$ sudo apt-get install fakeroot gcc-3.4 module-assistant \\
build-essential debhelper
$ mkdir ATI
$ mv ati-driver-installer-8.22.5-i386.run ATI/; cd ATI
$ chmod +x ati-driver-installer-8.22.5-i386.run
$ fakeroot ./ati-driver-installer-8.22.5-i386.run
The installer will ask you a couple of questions: answer "Generate distribution specific packages," then "Ubuntu," and then "Dapper." Once the installer finishes, it will have created a nice little Debian package that you can install:
$ sudo dpkg -i *.deb
$ sudo module-assistant build,install fglrx-kernel
Edit /etc/X11/xorg.conf to use the fglrx driver, as described earlier, reboot, and you're done.
Matrox
Matrox also makes available a proprietary driver that you can build as a Linux kernel module. First, install the kernel headers to use when building the new module:
$ sudo apt-get install linux header \Quname -r\Q
Then download the latest driver installer from Matrox at http://www.matrox.com/mga/support/drivers/latest/.
Building the driver must be done with GCC 3.4, so install it, set an environment variable that specifies that it should be used in preference to other installed versions, and run the installer:
$ sudo apt-get install gcc-3.4 gcc-3.4-base
$ export CC=gcc-3.4
$ sudo sh mtxdriver-x86_32-1.4.3.3.run
Back up your existing libGL installation, since it won't work with the mtx driver:
$ sudo mkdir /usr/lib/libGL.back
$ sudo mv /usr/lib/libGL.so* /usr/lib/libGL.back/
Then edit /etc/X11/xorg.conf, find the Device section for your video card, and alter the Driver line to use the mtx driver:
Driver "mtx"
Finally, reboot your computer so the kernel can load the new module.