Contents of /xml/htdocs/doc/en/dri-howto.xml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.3 - (show annotations) (download) (as text)
Sat Jul 19 10:08:57 2003 UTC (15 years, 8 months ago) by swift
Branch: MAIN
Changes since 1.2: +9 -2 lines
File MIME type: application/xml
Removed nvidia tsg link until it is updated

1 <?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
4 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
6 <guide link="/doc/en/dri-howto.xml">
7 <title>Hardware 3D Acceleration Guide</title>
8 <author title="Author">
9 <mail link="donnie.berkholz@richmond.edu">Donnie Berkholz</mail>
10 </author>
11 <author title="Editor">
12 <mail link="peesh@gentoo.org">Jorge Paulo</mail>
13 </author>
15 <abstract>This document is a guide to getting 3D acceleration working using XFree-DRM with XFree86 in Gentoo Linux.</abstract>
17 <version>1.0.0</version>
18 <date>June 19 2003</date>
20 <chapter>
21 <title>Introduction</title>
22 <section>
23 <title>What is hardware 3D acceleration and why do I want it?</title>
24 <body>
25 <p>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 XFree86 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.</p>
26 </body>
27 </section>
30 <section>
31 <title>How do I get hardware 3D acceleration?</title>
32 <body>
33 <p>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.
34 <!--
35 Temporarily removed from the guide as nvidia tsg is not more
36 supported.
38 If you have an nVidia card, see the <uri link="nvidia_tsg.xml">nVidia troubleshooting guide</uri>. This guide describes how to use XFree-DRM's open-source drivers. Supported cards are listed later in the document.
39 -->
40 Binary drivers include media-video/mgavideo for Matrox and media-video/ati-drivers for ATI cards. Other open-source drivers include media-video/kyro-kernel for KyroII cards and media-video/ati-gatos for ATI cards, which aim to support ATI's video capabilities more fully.</p>
41 </body>
42 </section>
45 <section>
46 <title>What is DRI?</title>
47 <body>
48 <p>The Direct Rendering Infrastructure (<uri link="http://dri.sourceforge.net">dri.sourceforge.net</uri>), 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.</p>
49 </body>
50 </section>
53 <section>
54 <title>What is XFree-DRM and how does it relate to regular XFree86?</title>
55 <body>
56 <p>XFree-DRM is an <e>enhancement</e> to XFree86 that adds 3D acceleration for cards to which XFree86 doesn't provide acceleration.</p>
57 </body>
58 </section>
61 <section>
62 <title>Purpose</title>
63 <body>
64 <p>This guide is for people that can't get direct rendering working with just XFree. XFree-DRM works for 3dfx, gamma, i8x0, matrox, rage128, radeon and sis drivers. There's also some support for mach64 in the CVS sources -- check out <uri link="http://www.retinalburn.net/linux/dri_status.html">this site</uri> and the <uri link="http://www.retinalburn.net/linux/dri_HOWTO.html">howto</uri>. Since the 2.4 kernels' Direct Rendering Manager (DRM) doesn't support XFree 4.3, the xfree-drm package is needed. If you're using a 2.5 kernel, its DRM supports XFree 4.3; so unless your card is so new it doesn't get direct rendering, don't bother with this guide. See the <uri link="http://dri.sourceforge.net">DRI homepage</uri> for more info and documentation. </p>
65 </body>
66 </section>
69 <section>
70 <title>Feedback</title>
71 <body>
72 <p>For suggestions, questions, etc., e-mail <mail link="donnie.berkholz@richmond.edu">Donnie Berkholz</mail>.</p>
73 </body>
74 </section>
75 </chapter>
78 <chapter>
79 <title>Install XFree86 and configure your kernel</title>
80 <section>
81 <title>Install XFree86</title>
82 <body>
83 <pre>
84 # <i>emerge x11-base/xfree</i>
85 </pre>
86 </body>
87 </section>
90 <section>
91 <title>Configure your kernel</title>
92 <body>
93 <p>Probe for your chipset and enable just that one.</p>
94 <pre caption="Checking your AGP chipset">
95 # <i>emerge pciutils; lspci | grep AGP</i>
96 # <i>00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 03)</i>
97 <codenote>Your output may not match the above due to different hardware.</codenote>
98 </pre>
99 <p>Most, if not all, kernels should have these options. This was configured using gentoo-sources-2.4.20-r5.</p>
100 <pre>
101 # <i>ls -l /usr/src/linux </i>
102 lrwxrwxrwx 1 root root 22 May 29 18:20 /usr/src/linux -> linux-2.4.20-gentoo-r5
103 <codenote>Make sure <path>/usr/src/linux</path> links to your current kernel.</codenote>
104 # <i>cd /usr/src/linux</i>
105 # <i>make menuconfig</i>
106 </pre>
107 <p></p>
108 <pre caption="make menuconfig options">
109 Processor type and features ---&gt;
110 &lt;*&gt; MTRR (Memory Type Range Register) support
111 Character devices ---&gt;
112 &lt;*&gt; /dev/agpgart (AGP Support)
113 [*] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
114 <codenote>Enable your chipset instead of the above.</codenote>
115 [ ] Direct Rendering Manager (XFree86 DRI support)
116 </pre>
117 <p>Make sure the Direct Rendering Manager (DRM) is <e>off</e>. The XFree-DRM package will provide its own. The kernel's version is for XFree 4.2.</p>
118 </body>
119 </section>
122 <section>
123 <title>Compile and install your kernel</title>
124 <body>
125 <pre caption="Compiling and installing kernel">
126 # <i>make dep &amp;&amp; make clean bzImage modules modules_install</i>
127 # <i>mount /boot</i>
128 # <i>cp arch/i386/boot/bzImage /boot</i>
129 </pre>
130 <p>If you want your kernel to be named something other than bzImage, be sure to copy to /boot/yourname instead. Don't forget to set up grub.conf or lilo.conf and run /sbin/lilo if you use LILO.</p>
131 </body>
132 </section>
133 </chapter>
136 <chapter>
137 <title>Install XFree-DRM and configure direct rendering</title>
138 <section>
139 <title>Install XFree-DRM</title>
140 <body>
141 <pre>
142 # <i>ACCEPT_KEYWORDS="~x86" emerge xfree-drm</i>
143 </pre>
144 </body>
145 </section>
148 <section>
149 <title>Configure XF86Config</title>
150 <body>
151 <p>Open <path>/etc/X11/XF86Config</path> with your favorite text editor and edit it to enable DRI and GLX.</p>
152 <pre caption="XF86Config">
153 ...
154 Section "Module"
155 Load "dri"
156 Load "glx"
157 ...
158 EndSection
159 ...
160 Section "Device"
161 Driver "radeon"
162 ...
163 EndSection
164 ...
165 Section "DRI"
166 Mode 0666
167 EndSection
168 </pre>
169 <p>If you are using a different driver, replace "radeon" with yours.</p>
170 </body>
171 </section>
172 </chapter>
175 <chapter>
176 <title>Test 3D acceleration</title>
177 <section>
178 <title>Reboot to the new kernel</title>
179 <body>
180 <p>Reboot your computer to your new kernel. It's time to see if you have direct rendering and how good it is.</p>
181 <pre caption="Testing rendering">
182 # <i>startx</i>
183 <codenote>No need to load modules for your driver or agpgart, if you compiled agpgart as a module.</codenote>
184 <codenote>They will be loaded automatically.</codenote>
185 # <i>glxinfo | grep rendering</i>
186 direct rendering: Yes
187 <codenote>If it says "No," you don't have 3D acceleration.</codenote>
188 # <i>glxgears</i>
189 <codenote>Test your frames per second (FPS) at the default size. Do this while the CPU is as idle as possible.</codenote>
190 </pre>
191 </body>
192 </section>
193 </chapter>
196 <chapter>
197 <title>Using the CVS sources</title>
198 <section>
199 <body>
200 <warn>Don't do this if the package worked.</warn>
201 <note>By their nature, CVS sources are always changing. Your configuration may not look exactly like the one below.</note>
202 </body>
203 </section>
204 <section>
205 <title>Do you need the CVS?</title>
206 <body>
207 <p>First you have to check whether the xfree-drm package works. If it doesn't and you have a very new card, you might want to consider the CVS sources. The xfree-drm package currently supports at least the Radeon 9000.</p>
208 </body>
209 </section>
210 <section>
211 <title>Do the CVS sources support your card?</title>
212 <body>
213 <p>Check the DRI <uri link="http://dri.sourceforge.net/dri_status.phtml">supported cards list</uri> to see if the CVS supports your card. Even if it doesn't, but it supports a similar card, try it.</p>
214 <warn>"Linux 2.4 doesn't support agp 8x, so I had to go find a backport. The backport works .... it doesn't patch quite properly, and it requires 2.4.21 (I've only gotten it to work with vanilla, straight from the tarball (not ebuild)). First go get the 2.4.20-2.4.21 patch from kernel.org .... (then get the patch,) It was on a mailing list somewhere. It doesn't patch cleanly -- one file fails, the pci_ids.h file, but if you actually read the file and the reject list, it's very easy to fix. But it does load, and it gives me 1600x1200 with video (although a bit slow b/c of lack of dga) with xfree-drm." (SanityInAnarchy on #gentoo)</warn>
215 <p></p>
216 <impo>The patch is a little tricky to work with but <uri link="http://www.ussg.iu.edu/hypermail/linux/kernel/0302.2/att-1618/01-agp3.diff.bz2">here's the link</uri>. If you can disable 8X AGP in your BIOS, change it to 4X and you may not need the patch.</impo>
217 </body>
218 </section>
221 <section>
222 <title>Install the CVS sources</title>
223 <body>
224 <p>Follow this guide through "Compile and install your kernel." Then we'll move to step 6 of the <uri link="http://dri.sourceforge.net/doc/DRIcompile.html">DRI compilation guide</uri> and follow it through step 8.3.</p>
225 </body>
226 </section>
229 <section>
230 <title>Anonymous CVS download</title>
231 <body>
232 <p>Create a directory to store the CVS files:</p>
233 <pre>
234 # <i>cd ~</i>
235 # <i>mkdir DRI-CVS</i>
236 </pre>
237 <p>Check out the CVS sources</p>
238 <pre>
239 # <i>cd ~/DRI-CVS</i>
240 # <i>cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login</i>
241 <codenote>(hit ENTER when prompted for a password)</codenote>
242 # <i>cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc</i>
243 <codenote>The -z3 flag causes compression to be used in order to reduce the download time.</codenote>
244 </pre>
245 </body>
246 </section>
249 <section>
250 <title>Updating your CVS sources</title>
251 <body>
252 <p>In the future you'll want to occasionally update your local copy of the DRI source code to get the latest changes. This can be done with:</p>
253 <pre>
254 # <i>cd ~/DRI-CVS</i>
255 # <i>cvs -z3 update -dA xc</i>
256 <codenote>The -d flag causes any new subdirectories to be created.</codenote>
257 <codenote>The -A flag causes most recent trunk sources to be fetched, not branch sources.</codenote>
258 </pre>
259 </body>
260 </section>
263 <section>
264 <title>Make a build tree</title>
265 <body>
266 <p>Rather than placing object files and library files right in the source tree, they're instead put into a parallel <e>build</e> tree. The build tree is made with the <c>lndir</c> command:</p>
267 <pre>
268 # <i>cd ~/DRI-CVS</i>
269 # <i>ln -s xc XFree40</i>
270 # <i>mkdir build; cd build</i>
271 # <i>lndir -silent -ignorelinks ../XFree40</i>
272 </pre>
273 <p>The build tree will be populated with symbolic links which point back into the CVS source tree. Advanced users may have several build trees for compiling and testing with different options.</p>
274 </body>
275 </section>
278 <section>
279 <title>Edit the host.def file</title>
280 <body>
281 <p>The <path>~/DRI-CVS/build/xc/config/cf/host.def</path> file is used to configure the XFree86 build process. You can change it to customize your build options or make adjustments for your particular system configuration. The default host.def file will look something like this:</p>
282 <pre>
283 #define DefaultCCOptions -Wall
284 <codenote>For i386:</codenote>
285 #define DefaultGcc2i386Opt -O2
286 <codenote>For Alpha:</codenote>
287 #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
288 <codenote>For all architectures</codenote>
289 #define LibraryCDebugFlags -O2
290 #define BuildServersOnly YES
291 #define XF86CardDrivers vga tdfx mga ati i810
292 #define LinuxDistribution LinuxRedHat
293 #define DefaultCCOptions -ansi GccWarningOptions -pipe
294 #define BuildXF86DRI YES
295 /* Optionally turn these on for debugging */
296 /* #define GlxBuiltInTdfx YES */
297 /* #define GlxBuiltInMga YES */
298 /* #define GlxBuiltInR128 YES */
299 /* #define GlxBuiltInRadeon YES */
300 /* #define DoLoadableServer NO */
301 #define SharedLibFont NO
302 </pre>
303 <p>The ProjectRoot variable specifies where the XFree86 files will be installed. We recommend installing the DRI files over your existing XFree86 installation - it's generally safe to do and less error-prone. This policy is different from what we used to recommend.</p>
304 <p>If XFree86 4.x is not installed in <path>/usr/X11R6/</path> you'll have to add the following to the host.def file:</p>
305 <pre>
306 #define ProjectRoot pathToYourXFree86installation
307 <codenote>Note the XF86CardDrivers line to be sure your card's driver is listed.</codenote>
308 <codenote>If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you should add the following:</codenote>
309 #define MesaUse3DNow YES
310 <codenote>You don't have to be using an AMD processor to enable this option.</codenote>
311 <codenote>The DRI will look for 3DNow! support at runtime and only enable it if applicable.</codenote>
312 </pre>
313 <p>If you want to enable SSE optimizations in Mesa and the DRI drivers, you must upgrade to a Linux 2.4.x kernel. Mesa will verify that SSE is supported by both your processor and your operating system, but to build Mesa inside the DRI you need to have the Linux 2.4.x kernel headers in <path>/usr/src/linux</path>. If you enable SSE optimizations with an earlier version of the Linux kernel in <path>/usr/src/linux</path>, Mesa will not compile. You have been warned. If you do have a 2.4.x kernel, you should add the following:</p>
314 <pre>
315 #define MesaUseKatmai YES
316 </pre>
317 </body>
318 </section>
321 <section>
322 <title>Compile the XFree86/DRI tree</title>
323 <body>
324 <p>To compile the complete DRI tree:</p>
325 <pre>
326 # <i>cd ~/DRI-CVS/build/xc/</i>
327 # <i>make World &gt;&amp; world.log</i>
328 </pre>
329 <p>One user suggests it may also be necessary to do the following:</p>
330 <pre>
331 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel</i>
332 # <i>make -f Makefile.linux radeon.o</i>
333 <codenote>Replace radeon with your driver.</codenote>
334 </pre>
335 <p>With the default compilation flags it's normal to get a lot of warnings during compilation. Building will take some time so you may want to go check your email or visit slashdot. </p>
336 <warn>Do not use the -j option with make (i.e., do not use distcc). It's reported that it does not work with XFree86/DRI.</warn>
337 <p>Using your text editor, examine world.log for errors by searching for the pattern ***.</p>
338 </body>
339 </section>
342 <section>
343 <title>Install your driver</title>
344 <body>
345 <p>Verify that the DRI kernel module(s) for your system were built:</p>
346 <pre>
347 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel; ls</i>
348 </pre>
349 <p>For the 3dfx Voodoo, you should see <path>tdfx.o</path>. For the Matrox G200/G400, you should see <path>mga.o</path>. For the ATI Rage 128, you should see <path>r128.o</path>. For the ATI Radeon, you should see <path>radeon.o</path>. For the Intel i810, you should see <path>i810.o</path>. If the DRI kernel module(s) failed to build, you should verify that you're using the right version of the Linux kernel. The most recent kernels are not always supported.</p>
350 <p>Copy all of your driver files to your XFree86 installation. You may wish to back up replaced files. This is an example using a Radeon card. If you have another card, copy the appropriate files. If you don't know what they are, check the directory to which you're going to copy them to see what's there.</p>
351 <pre>
352 # <i>cd ~/DRI-CVS/build/xc/exports/lib/modules/</i>
353 # <i>cp dri/r200_dri.so /usr/X11R6/lib/modules/dri/</i>
354 # <i>cp drivers/atimisc_drv.o /usr/X11R6/lib/modules/drivers/</i>
355 # <i>cp drivers/radeon_drv.o /usr/X11R6/lib/modules/drivers/</i>
356 # <i>cp extensions/libdri.a /usr/X11R6/lib/modules/extensions/</i>
357 # <i>cp linux/libdrm.a /usr/X11R6/lib/modules/linux/</i>
358 </pre>
359 <p>Follow the "Configure XF86Config" section above.</p>
360 <p>To load the appropriate DRM module in your running kernel, copy the kernel module to <path>/lib/modules/`uname -r`/kernel/drivers/char/drm/</path> then run <c>modules-update</c> and restart your X server. If you're not running the kernel you'll be using it in, instead of <c>`uname -r`,</c> use that kernel's name.</p>
361 <warn>Make sure you first unload any older DRI kernel modules that might be already loaded. Note that some DRM modules require that the agpgart module be loaded first.</warn>
362 </body>
363 </section>
364 </chapter>
367 <chapter>
368 <title>Tweak your performance</title>
369 <section>
370 <title>Get the most out of direct rendering</title>
371 <body>
372 <p>A few options may increase performance by up to 30 percent (or more) over the default. Set them in <path>/etc/X11/XF86Config</path>.</p>
373 <pre caption="XF86Config">
374 Section "Device"
375 Option "AGPMode" "4"
376 <codenote>This increased FPS from 609 to 618.</codenote>
377 Option "AGPFastWrite" "True"
378 <codenote>This had no measurable effect, but it may increase instability of your computer.</codenote>
379 <codenote>You may also need to set it in your BIOS.</codenote>
380 Option "EnablePageFlip" "True"
381 <codenote>This improved FPS from 618 to 702. It also is "risky" but few people have reported problems.</codenote>
382 ...
383 EndSection
384 </pre>
385 <p>If you want to set even more features, check out the <uri link="http://dri.sourceforge.net/doc/dri_driver_features.phtml">features listing</uri> on the DRI Web site.</p>
386 </body>
387 </section>
388 </chapter>
390 <chapter>
391 <title>Troubleshooting</title>
392 <section>
393 <title>It doesn't work. I don't have rendering, and I can't tell why.</title>
394 <body>
395 <p>Try <c>insmod radeon</c> before you start the X server. Also, try building agpgart as a module instead of into the kernel.</p>
396 </body>
397 </section>
398 <section>
399 <title>When I <c>startx</c>, I get this error: "[drm] failed to load kernel module agpgart"</title>
400 <body>
401 <p>That's because you compiled agpgart into the kernel instead of as a module. Ignore it.</p>
402 </body>
403 </section>
404 <section>
405 <title>Direct rendering doesn't work, and in <path>/var/log/XFree86.0.log</path> I have an error about driver version too low.</title>
406 <body>
407 <p>You aren't using the xfree-drm driver. Check if you compiled DRM and the driver into the kernel; you shouldn't have.</p>
408 </body>
409 </section>
410 <section>
411 <title>I have a Radeon, and I want TV-Out.</title>
412 <body>
413 <p>Check out ati-gatos drivers. <c>emerge -s gatos</c>.</p>
414 </body>
415 </section>
416 <section>
417 <title>It doesn't work. My card is so incredibly new and cool that it isn't supported at all.</title>
418 <body>
419 <p>Try out the binary drivers. For ati-drivers, a listing is at <uri>http://www.schneider-digital.de/html/download_ati.html</uri>. If those don't support it, use VESA. It's slow, but it works. Check the drivers in the future because they will support your card soon.</p>
420 </body>
421 </section>
422 <section>
423 <title>I have a PCI card and it doesn't work. Help!</title>
424 <body>
425 <p>In section "Device" enable ForcePCIMode.
426 <pre>Option "ForcePCIMode" "True"</pre></p>
427 </body>
428 </section>
430 </chapter>
433 <chapter>
434 <title>References</title>
435 <section>
436 <body>
437 <p>
438 <ol>
439 <li>http://forums.gentoo.org/viewtopic.php?t=46681</li>
440 <li>http://forums.gentoo.org/viewtopic.php?t=29264</li>
441 <li>http://dri.sourceforge.net/</li>
442 <li>http://www.retinalburn.net/linux/dri_status.html</li>
443 </ol>
444 </p>
445 </body>
446 </section>
447 </chapter>
448 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20