Gentoo Logo

Hardware 3D Acceleration Guide

Content:

1.  Introduction

What is hardware 3D acceleration and why do I want it?

With hardware 3D acceleration, three-dimensional rendering uses the graphics processor on your video card instead of taking up valuable CPU resources drawing 3D images. It's also referred to as "hardware acceleration" instead of "software acceleration" because without this 3D acceleration your CPU is forced to draw everything itself using the Mesa software rendering libraries, which takes up quite a bit of processing power. While Xorg typically supports 2D hardware acceleration, it often lacks hardware 3D acceleration. Three-dimensional hardware acceleration is valuable in situations requiring rendering of 3D objects such as games, 3D CAD and modeling.

How do I get hardware 3D acceleration?

In many cases, both binary and open-source drivers exist. Open-source drivers are preferable since we're using Linux and open source is one of its underlying principles. Sometimes, binary drivers are the only option, like with nVidia's cards. Binary drivers include x11-drivers/nvidia-drivers for nVidia cards and x11-drivers/ati-drivers for ATI cards.

What is DRI?

The Direct Rendering Infrastructure, also known as the DRI, is a framework for allowing direct access to graphics hardware in a safe and efficient manner. It includes changes to the X server, to several client libraries and to the kernel. The first major use for the DRI is to create fast OpenGL implementations.

What is the DRM and how does it relate to regular Xorg?

The DRM (Direct Rendering Manager) is an enhancement to Xorg that adds 3D acceleration for cards by adding the kernel module necessary for direct rendering.

Purpose

This guide is for people who can't get direct rendering working with just Xorg. The DRM works for the following drivers:

  • 3dfx
  • i8x0
  • matrox
  • rage128
  • radeon
  • mach64
  • sis300
  • via

See the DRI homepage for more info and documentation.

Feedback

With suggestions, questions, etc., e-mail Donnie Berkholz.

2.  Install Xorg and configure your kernel

Install Xorg

Please read our Xorg Configuration Guide to get Xorg up and running.

Configure your kernel

Probe for your chipset and enable just that one.

Code Listing 2.1: Checking your AGP chipset

# emerge pciutils; lspci | grep AGP
# 00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 03)
(Your output may not match the above due to different hardware.)

If your chipset is not supported by the kernel you might have some succes by passing agp=try_unsupported as a kernel parameter. This will use Intel's generic routines for AGP support. To add this parameter, edit your bootloader configuration file!

Most, if not all, kernels should have these options. This was configured using a standard gentoo-sources kernel.

Code Listing 2.2: Configuring the kernel

# ls -l /usr/src/linux 
lrwxrwxrwx 1 root root 22 2007-02-14 20:12 /usr/src/linux -> linux-2.6.18-gentoo-r4
(Make sure /usr/src/linux links to your current kernel.)
# cd /usr/src/linux
# make menuconfig

Code Listing 2.3: make menuconfig options

Processor type and features --->
<*> MTRR (Memory Type Range Register) support
Device drivers --->
   Character devices --->
   <M> /dev/agpgart (AGP Support)
   (The agpgart option is not present on 64-bit kernels; just choose your chipset support.)
   <M> Intel 440LX/BX/GX, I8xx and E7x05 support
(Enable your chipset instead of the above.)
   <M> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)

Compile and install your kernel

Code Listing 2.4: Compiling and installing kernel

# make && make modules_install

Don't forget to set up grub.conf or lilo.conf and run /sbin/lilo if you use LILO.

3.  Configure direct rendering

Configure Xorg.conf

Open /etc/X11/xorg.conf with your favorite text editor and edit it to enable DRI and GLX.

Code Listing 3.1: xorg.conf

...
Section "Module"
  Load "dri"
  Load "glx"
  ...
EndSection
...
Section "Device"
  Driver "radeon"
  (Replace radeon with the name of your driver.)
  ...
EndSection
...
Section "dri"
  Mode 0666
EndSection

Changes to modules.autoload.d

You will need to add the module name that your card uses to /etc/modules.autoload.d/kernel-2.6 to ensure that the module is loaded automatically when the system starts up.

Code Listing 3.2: Editing /etc/modules.autoload.d/kernel-2.6

(Change module name as required.)
intel-agp

Note: If you compiled agpgart as a module, you will also need to add it to /etc/modules.autoload.d/kernel-2.6.

4.  Test 3D acceleration

Reboot to the new kernel

Reboot your computer to your new kernel and login as a normal user. It's time to see if you have direct rendering and how good it is. glxinfo and glxgears are part of the mesa-progs package, so make sure it is installed before you attempt to run these commands.

Code Listing 4.1: Testing rendering

$ startx
(No need to load modules for your driver or agpgart, even if you compiled them as a module.)
(They will be loaded automatically.)
$ glxinfo | grep rendering
direct rendering: Yes
(If it says "No", you don't have 3D acceleration.)
$ glxgears
(Test your frames per second (FPS) at the default size. The number should be 
significantly higher than before configuring DRM. Do this while the CPU is as idle as 
possible.)

Note: FPS may be limited by your screen's refresh rate, so keep this in mind if glxgears reports only about 70-100 FPS. games-fps/ut2004-demo is a better benchmarking tool, as it can give you real-world performance results.

5.  Tweak your performance

Get the most out of direct rendering

A few options may increase performance by up to 30 percent (or more) over the default. Set them in /etc/X11/xorg.conf. However, you will first need to check that your motherboard and video card support these options.

First, let's see if your video card can support fast writes. We'll do this by closely inspecting the output from lspci. Specifically, we are looking at the "VGA compatible controller" information.

Code Listing 5.1: Video card check

# lspci -vv
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility M6 LY (prog-if 00 [VGA])
. . .
Capabilities: [58] AGP version 2.0
    Status: RQ=48 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW+ AGP3- Rate=x1,x2,x4

While quite a lot of information is produced, we are looking for FW in the "Status" subsection of the AGP "Capabilities" section. If FW+ is present in the "Status" line, it means the card supports fast writes. We can now check if the motherboard supports fast writes.

Important: If you do not see FW+, but instead see FW-, you cannot enable fast writes in xorg.conf. Your card does not support fast writes.

Now let's make sure the motherboard supports fast writes as well. This time, look at the "Host bridge" section of your lspci output.

Code Listing 5.2: Motherboard check

# lspci -vv
00:00.0 Host bridge: Intel Corporation 82830 830 Chipset Host Bridge (rev 02)
. . .
Capabilities: [a0] AGP version 2.0
    Status: RQ=32 Iso- ArqSz=0 Cal=0 SBA+ ITACoh- GART64- HTrans- 64bit- FW+ AGP3- Rate=x1,x2,x4

Again, examine the "Status" subsection of your AGP "Capabilities" section. Look for FW. If you see FW+, your motherboard supports fast writes.

Important: Remember, both your video card information and your motherboard information must show the same FW capability. If either device shows FW- in "Status", you cannot enable fast writes in xorg.conf.

Assuming that all has gone well and both your motherboard and video card support fast writes, let's enable this option in /etc/X11/xorg.conf and get the best performance out of your hardware.

Code Listing 5.3: xorg.conf

Section "Device"
  Option     "AGPMode" "4"
  (This increased FPS from 609 to 618.)
  Option     "AGPFastWrite" "True"
  (This had no measurable effect, but it may increase instability of your computer.)
  (You may also need to set it in your BIOS.)
  Option     "EnablePageFlip" "True"
  (This improved FPS from 618 to 702. It also is "risky" but few people have reported problems.)
  ...
EndSection

Warning: Enabling AGPFastWrite on a VIA chipset will very likely cause your machine to lock up. VIA chipsets do not play nicely with fast writes, so use this setting at your own risk.

Note: Remember, if you want fast writes to work properly, you will have to first enable the appropriate option in your BIOS.

If you want to set even more features, check out the feature matrix on the DRI web site or the features listing on Sourceforge.

6.  Troubleshooting

It doesn't work. I don't have rendering, and I can't tell why.

Try modprobe radeon before you start the X server (replace radeon with the name of your driver). Also, try building agpgart into the kernel instead of as a module.

When I startx, I get this error: "[drm] failed to load kernel module agpgart"

That's because you compiled agpgart into the kernel instead of as a module. Ignore it unless you're having problems.

I have a Radeon, and I want TV-Out.

The drivers originally developed by the GATOS project have been merged into Xorg's codebase. You don't need anything special for TV-Out; x11-drivers/xf86-video-ati will work just fine.

It doesn't work. My card is so incredibly new and cool that it isn't supported at all.

Try out the binary drivers. For ati-drivers, a listing is at http://ati.amd.com/support/drivers/linux/linux-radeon.html (for x86) and at http://ati.amd.com/support/drivers/linux64/linux64-radeon.html (for amd64). If those don't support it, use fbdev. It's slow, but it works.

I have a PCI card and it doesn't work. Help!

Edit /etc/X11/xorg.conf. In section "Device" enable ForcePCIMode.

Code Listing 6.1: Enabling ForcePCIMode

Option "ForcePCIMode" "True"

7.  Acknowledgments

  1. Christopher Webber for suggesting a troubleshooting question about changing or recompiling kernels
  2. Steve, for suggesting consistency between the cases of dri and DRI in XF86Config

8.  References

  1. http://forums.gentoo.org/viewtopic.php?t=46681
  2. http://forums.gentoo.org/viewtopic.php?t=29264
  3. http://dri.freedesktop.org/
  4. http://www.retinalburn.net/linux/dri_status.html


Print

Updated August 23, 2007

Summary: This document is a guide to getting 3D acceleration working using the DRM with Xorg in Gentoo Linux.

Donnie Berkholz
Author

Jorge Paulo
Editor

Joshua Saddler
Editor

Donate to support our development efforts.

Support OSL

Support OSL

Gentoo Centric Hosting: vr.org

VR Hosted

Tek Alchemy

Tek Alchemy

SevenL.net

SevenL.net

Global Netoptex Inc.

Global Netoptex Inc.

Linux World Expo

Linux World Expo

Copyright 2001-2008 Gentoo Foundation, Inc. Questions, Comments? Contact us.