/[gentoo]/xml/htdocs/doc/en/dri-howto.xml
Gentoo

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download) (as text)
Wed Feb 11 22:29:57 2004 UTC (10 years, 10 months ago) by dertobi123
Branch: MAIN
Changes since 1.10: +3 -3 lines
File MIME type: application/xml
Fix Typo, #40584

1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/dri-howto.xml,v 1.10 2004/01/21 07:58:11 swift Exp $ -->
3 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
5 <guide link="/doc/en/dri-howto.xml">
6 <title>Hardware 3D Acceleration Guide</title>
7 <author title="Author">
8 <mail link="spyderous@gentoo.org">Donnie Berkholz</mail>
9 </author>
10 <author title="Editor">
11 <mail link="peesh@gentoo.org">Jorge Paulo</mail>
12 </author>
13
14 <license/>
15
16 <abstract>
17 This document is a guide to getting 3D acceleration working using XFree-DRM
18 with XFree86 in Gentoo Linux.
19 </abstract>
20
21 <version>1.0.2</version>
22 <date>December 20 2003</date>
23
24 <chapter>
25 <title>Introduction</title>
26 <section>
27 <title>What is hardware 3D acceleration and why do I want it?</title>
28 <body>
29
30 <p>
31 With hardware 3D acceleration, three-dimensional rendering uses the graphics
32 processor on your video card instead of taking up valuable CPU resources
33 drawing 3D images. It's also referred to as "hardware acceleration" instead of
34 "software acceleration" because without this 3D acceleration your CPU is forced
35 to draw everything itself using the Mesa software rendering libraries, which
36 takes up quite a bit of processing power. While XFree86 typically supports 2D
37 hardware acceleration, it often lacks hardware 3D acceleration.
38 Three-dimensional hardware acceleration is valuable in situations requiring
39 rendering of 3D objects such as games, 3D CAD and modeling.
40 </p>
41
42 </body>
43 </section>
44 <section>
45 <title>How do I get hardware 3D acceleration?</title>
46 <body>
47
48 <p>
49 In many cases, both binary and open-source drivers exist. Open-source drivers
50 are preferable since we're using Linux and open source is one of its underlying
51 principles. Sometimes, binary drivers are the only option, like with nVidia's
52 cards. Binary drivers include media-video/nvidia-kernel and
53 media-video/nvidia-glx for nVidia cards, media-video/mgavideo for Matrox cards
54 and media-video/ati-drivers for ATI cards. Other open-source drivers include
55 media-video/kyro-kernel for KyroII cards and media-video/ati-gatos for ATI
56 cards, which aim to support ATI's video capabilities more fully.
57 </p>
58
59 </body>
60 </section>
61 <section>
62 <title>What is DRI?</title>
63 <body>
64
65 <p>
66 The Direct Rendering Infrastructure (<uri
67 link="http://dri.sourceforge.net">dri.sourceforge.net</uri>), also known as the
68 DRI, is a framework for allowing direct access to graphics hardware in a safe
69 and efficient manner. It includes changes to the X server, to several client
70 libraries and to the kernel. The first major use for the DRI is to create fast
71 OpenGL implementations.
72 </p>
73
74 </body>
75 </section>
76 <section>
77 <title>What is XFree-DRM and how does it relate to regular XFree86?</title>
78 <body>
79
80 <p>
81 XFree-DRM is an <e>enhancement</e> to XFree86 that adds 3D acceleration for
82 cards by adding the kernel module necessary for direct rendering.
83 </p>
84
85 </body>
86 </section>
87 <section>
88 <title>Purpose</title>
89 <body>
90
91 <p>
92 This guide is for people who can't get direct rendering working with just
93 XFree. XFree-DRM works for 3dfx, gamma, i8x0, matrox, rage128, radeon, mach64
94 (as of xfree-drm-4.3.0-r7) and sis300 series drivers. Since the 2.4 kernels'
95 Direct Rendering Manager (DRM) doesn't support XFree 4.3, the xfree-drm package
96 is needed. If you're using a 2.6 kernel, its DRM supports XFree 4.3; Gentoo's
97 XFree-DRM package is not yet working on 2.6 kernels. See the <uri
98 link="http://dri.sourceforge.net">DRI homepage</uri> for more info and
99 documentation.
100 </p>
101
102 </body>
103 </section>
104 <section>
105 <title>Feedback</title>
106 <body>
107
108 <p>
109 With suggestions, questions, etc., e-mail <mail
110 link="spyderous@gentoo.org">Donnie Berkholz</mail>.
111 </p>
112
113 </body>
114 </section>
115 </chapter>
116
117 <chapter>
118 <title>Install XFree86 and configure your kernel</title>
119 <section>
120 <title>Install XFree86</title>
121 <body>
122
123 <pre caption="Installing XFree86">
124 # <i>emerge x11-base/xfree</i>
125 </pre>
126
127 </body>
128 </section>
129 <section>
130 <title>Configure your kernel</title>
131 <body>
132
133 <p>
134 Probe for your chipset and enable just that one.
135 </p>
136
137 <pre caption="Checking your AGP chipset">
138 # <i>emerge pciutils; lspci | grep AGP</i>
139 # <i>00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 03)</i>
140 <codenote>Your output may not match the above due to different hardware.</codenote>
141 </pre>
142
143 <p>
144 Most, if not all, kernels should have these options. This was configured using
145 gentoo-sources-2.4.20-r5.
146 </p>
147
148 <pre caption="Configuring the kernel">
149 # <i>ls -l /usr/src/linux </i>
150 lrwxrwxrwx 1 root root 22 May 29 18:20 /usr/src/linux -> linux-2.4.20-gentoo-r5
151 <codenote>Make sure <path>/usr/src/linux</path> links to your current kernel.</codenote>
152 # <i>cd /usr/src/linux</i>
153 # <i>make menuconfig</i>
154 </pre>
155
156 <pre caption="make menuconfig options">
157 Processor type and features ---&gt;
158 &lt;*&gt; MTRR (Memory Type Range Register) support
159 Character devices ---&gt;
160 &lt;M&gt; /dev/agpgart (AGP Support)
161 [*] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
162 <codenote>Enable your chipset instead of the above.</codenote>
163 [ ] Direct Rendering Manager (XFree86 DRI support)
164 </pre>
165
166 <p>
167 Make sure the Direct Rendering Manager (DRM) is <e>off</e>. The XFree-DRM
168 package will provide its own. The 2.4 kernel's version is for XFree 4.2.
169 </p>
170
171 </body>
172 </section>
173 <section>
174 <title>Compile and install your kernel</title>
175 <body>
176
177 <pre caption="Compiling and installing kernel">
178 # <i>make dep &amp;&amp; make clean bzImage modules modules_install</i>
179 # <i>mount /boot</i>
180 # <i>cp arch/i386/boot/bzImage /boot</i>
181 </pre>
182
183 <p>
184 If you want your kernel to be named something other than bzImage, be sure to
185 copy to /boot/yourname instead. Don't forget to set up grub.conf or lilo.conf
186 and run /sbin/lilo if you use LILO.
187 </p>
188
189 </body>
190 </section>
191 </chapter>
192
193 <chapter>
194 <title>Install XFree-DRM and configure direct rendering</title>
195 <section>
196 <title>Install XFree-DRM</title>
197 <body>
198
199 <pre caption="Installing XFree-DRM">
200 # <i>ACCEPT_KEYWORDS="~x86" emerge xfree-drm</i>
201 </pre>
202
203 </body>
204 </section>
205 <section>
206 <title>Configure XF86Config</title>
207 <body>
208
209 <p>
210 Open <path>/etc/X11/XF86Config</path> with your favorite text editor and edit
211 it to enable DRI and GLX.
212 </p>
213
214 <pre caption="XF86Config">
215 ...
216 Section "Module"
217 Load "dri"
218 Load "glx"
219 ...
220 EndSection
221 ...
222 Section "Device"
223 Driver "radeon"
224 ...
225 EndSection
226 ...
227 Section "dri"
228 Mode 0666
229 EndSection
230 </pre>
231
232 <p>
233 If you are using a different driver, replace "radeon" with yours.
234 </p>
235
236 </body>
237 </section>
238 </chapter>
239
240 <chapter>
241 <title>Test 3D acceleration</title>
242 <section>
243 <title>Reboot to the new kernel</title>
244 <body>
245
246 <p>
247 Reboot your computer to your new kernel. It's time to see if you have direct
248 rendering and how good it is.
249 </p>
250
251 <pre caption="Testing rendering">
252 # <i>startx</i>
253 <codenote>No need to load modules for your driver or agpgart, if you compiled agpgart as a module.</codenote>
254 <codenote>They will be loaded automatically.</codenote>
255 # <i>glxinfo | grep rendering</i>
256 direct rendering: Yes
257 <codenote>If it says "No," you don't have 3D acceleration.</codenote>
258 # <i>glxgears</i>
259 <codenote>Test your frames per second (FPS) at the default size. The number should be </codenote>
260 <codenote>significantly higher than before installing xfree-drm. Do this while the CPU is as idle as possible.</codenote>
261 </pre>
262
263 </body>
264 </section>
265 </chapter>
266
267 <chapter>
268 <title>Using the CVS sources</title>
269 <section>
270 <body>
271
272 <warn>
273 Don't do this if the package worked.
274 </warn>
275
276 <note>
277 By their nature, CVS sources are always changing. Your configuration may not
278 look exactly like the one below.
279 </note>
280
281 </body>
282 </section>
283 <section>
284 <title>Do you need the CVS?</title>
285 <body>
286
287 <p>
288 First you have to check whether the xfree-drm package works. If it doesn't and
289 you have checked your logs to verify it's not a configuration error, you might
290 want to consider the CVS sources. There are also daily driver snapshots
291 available if you do not wish to build the full CVS.
292 </p>
293
294 </body>
295 </section>
296 <section>
297 <title>Do the CVS sources support your card?</title>
298 <body>
299
300 <p>
301 Check the DRI <uri link="http://dri.sourceforge.net/dri_status.phtml">supported
302 cards list</uri> to see if the CVS supports your card. Even if it doesn't, but
303 it supports a similar card, try it.
304 </p>
305
306 <warn>
307 "Linux 2.4 doesn't support agp 8x, so I had to go find a backport. The backport
308 works .... it doesn't patch quite properly, and it requires 2.4.21 (I've only
309 gotten it to work with vanilla, straight from the tarball (not ebuild)). First
310 go get the 2.4.20-2.4.21 patch from kernel.org .... (then get the patch,) It
311 was on a mailing list somewhere. It doesn't patch cleanly -- one file fails,
312 the pci_ids.h file, but if you actually read the file and the reject list, it's
313 very easy to fix. But it does load, and it gives me 1600x1200 with video
314 (although a bit slow b/c of lack of dga) with xfree-drm." (SanityInAnarchy on
315 #gentoo)
316 </warn>
317
318 <impo>
319 The patch is a little tricky to work with but <uri
320 link="http://www.ussg.iu.edu/hypermail/linux/kernel/0302.2/att-1618/01-agp3.diff.bz2">here's
321 the link</uri>. If you can disable 8X AGP in your BIOS, change it to 4X and you
322 may not need the patch.
323 </impo>
324
325 </body>
326 </section>
327 <section>
328 <title>Install the CVS sources</title>
329 <body>
330
331 <p>
332 Follow this guide through "Compile and install your kernel." Then continue with
333 this guide, which tracks step 6 of the <uri
334 link="http://dri.sourceforge.net/doc/DRIcompile.html">DRI compilation
335 guide</uri> and follows it through step 8.3.
336 </p>
337
338 </body>
339 </section>
340 <section>
341 <title>Anonymous CVS download</title>
342 <body>
343
344 <p>
345 Create a directory to store the CVS files:
346 </p>
347
348 <pre caption="Create a directory for CVS">
349 # <i>cd ~</i>
350 # <i>mkdir DRI-CVS</i>
351 </pre>
352
353 <p>
354 Check out the CVS sources:
355 </p>
356
357 <pre caption="Check out CVS sources">
358 # <i>cd ~/DRI-CVS</i>
359 # <i>cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login</i>
360 <codenote>(hit ENTER when prompted for a password)</codenote>
361 # <i>cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc</i>
362 <codenote>The -z3 flag causes compression to be used to reduce the download time.</codenote>
363 </pre>
364
365 </body>
366 </section>
367 <section>
368 <title>Updating your CVS sources</title>
369 <body>
370
371 <p>
372 In the future you'll want to occasionally update your local copy of the DRI
373 source code to get the latest changes. This can be done with:
374 </p>
375
376 <pre caption="Update local copy">
377 # <i>cd ~/DRI-CVS</i>
378 # <i>cvs -z3 update -dA xc</i>
379 <codenote>The -d flag causes any new subdirectories to be created.</codenote>
380 <codenote>The -A flag causes most recent trunk sources to be fetched, not branch sources.</codenote>
381 </pre>
382
383 </body>
384 </section>
385 <section>
386 <title>Make a build tree</title>
387 <body>
388
389 <p>
390 Rather than placing object files and library files right in the source tree,
391 they're instead put into a parallel <e>build</e> tree. The build tree is made
392 with the <c>lndir</c> command:
393 </p>
394
395 <pre caption="Creating a parallel build tree">
396 # <i>cd ~/DRI-CVS</i>
397 # <i>ln -s xc XFree40</i>
398 # <i>mkdir build; cd build</i>
399 # <i>lndir -silent -ignorelinks ../XFree40</i>
400 </pre>
401
402 <p>
403 The build tree will be populated with symbolic links which point back into the
404 CVS source tree. Advanced users may have several build trees for compiling and
405 testing with different options.
406 </p>
407
408 </body>
409 </section>
410 <section>
411 <title>Edit the host.def file</title>
412 <body>
413
414 <p>
415 The <path>~/DRI-CVS/build/xc/config/cf/host.def</path> file is used to
416 configure the XFree86 build process. You can change it to customize your build
417 options or make adjustments for your particular system configuration. The
418 default host.def file will look something like this:
419 </p>
420
421 <pre caption="host.def">
422 #define DefaultCCOptions -Wall
423 <codenote>For i386:</codenote>
424 #define DefaultGcc2i386Opt -O2
425 <codenote>For Alpha:</codenote>
426 #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
427 <codenote>For all architectures</codenote>
428 #define LibraryCDebugFlags -O2
429 #define BuildServersOnly YES
430 #define XF86CardDrivers vga tdfx mga ati i810
431 #define LinuxDistribution LinuxRedHat
432 #define DefaultCCOptions -ansi GccWarningOptions -pipe
433 #define BuildXF86DRI YES
434 /* Optionally turn these on for debugging */
435 /* #define GlxBuiltInTdfx YES */
436 /* #define GlxBuiltInMga YES */
437 /* #define GlxBuiltInR128 YES */
438 /* #define GlxBuiltInRadeon YES */
439 /* #define DoLoadableServer NO */
440 #define SharedLibFont NO
441 </pre>
442
443 <pre caption="host.def continued">
444 <codenote>Note the XF86CardDrivers line to be sure your card's driver is listed.</codenote>
445 <codenote>If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you should add the following:</codenote>
446 #define MesaUse3DNow YES
447 <codenote>You don't have to be using an AMD processor to enable this option.</codenote>
448 <codenote>The DRI will look for 3DNow! support at runtime and only enable it if applicable.</codenote>
449 </pre>
450
451 <p>
452 If you want to enable SSE optimizations in Mesa and the DRI drivers, you must
453 upgrade to a Linux 2.4.x kernel. Mesa will verify that SSE is supported by both
454 your processor and your operating system, but to build Mesa inside the DRI you
455 need to have the Linux 2.4.x kernel headers in <path>/usr/src/linux</path>. If
456 you enable SSE optimizations with an earlier version of the Linux kernel in
457 <path>/usr/src/linux</path>, Mesa will not compile. You have been warned. If
458 you do have a 2.4.x kernel, you should add the following:
459 </p>
460
461 <pre caption="Update on host.def">
462 #define MesaUseKatmai YES
463 </pre>
464
465 </body>
466 </section>
467 <section>
468 <title>Compile the XFree86/DRI tree</title>
469 <body>
470
471 <p>
472 To compile the complete DRI tree:
473 </p>
474
475 <pre caption="Compile the DRI tree">
476 # <i>cd ~/DRI-CVS/build/xc/</i>
477 # <i>make World &gt;&amp; world.log</i>
478 </pre>
479
480 <p>
481 It may also be necessary to do the following, depending on what you placed in
482 host.def:
483 </p>
484
485 <pre caption="Further compiling steps">
486 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel</i>
487 # <i>make -f Makefile.linux radeon.o</i>
488 <codenote>Replace radeon with your driver.</codenote>
489 </pre>
490
491 <p>
492 With the default compilation flags it's normal to get a lot of warnings during
493 compilation. Building will take some time so you may want to go check your
494 email or visit slashdot.
495 </p>
496
497 <warn>
498 Do not use the -j option with make (i.e., do not use distcc). It's reported that
499 it does not work with XFree86/DRI.
500 </warn>
501
502 <p>
503 Using your text editor, examine world.log for errors by searching for the
504 pattern ***.
505 </p>
506
507 </body>
508 </section>
509 <section>
510 <title>Install the CVS</title>
511 <body>
512
513 <p>
514 Verify that the DRI kernel module(s) for your system were built:
515 </p>
516
517 <pre caption="Verification">
518 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel; ls</i>
519 </pre>
520
521 <p>
522 For the 3dfx Voodoo, you should see <path>tdfx.o</path>. For the Matrox
523 G200/G400, you should see <path>mga.o</path>. For the ATI Rage 128, you should
524 see <path>r128.o</path>. For the ATI Radeon, you should see
525 <path>radeon.o</path>. For the Intel i810, you should see <path>i810.o</path>.
526 If the DRI kernel module(s) failed to build, you should verify that you're
527 using the right version of the Linux kernel. The most recent kernels are not
528 always supported.
529 </p>
530
531 <p>
532 Install over your XFree86 installation. You may wish to back up xfree.
533 </p>
534
535 <pre caption="Backing up XFree">
536 # <i>quickpkg xfree</i>
537 <codenote>This backs up your XFree86 package.</codenote>
538 # <i>make install</i>
539 </pre>
540
541 <p>
542 Follow the "Configure XF86Config" section above.
543 </p>
544
545 <p>
546 To load the appropriate DRM module in your running kernel, copy the kernel
547 module to <path>/lib/modules/`uname -r`/kernel/drivers/char/drm/</path> then
548 run <c>modules-update</c> and restart your X server. If you're not running the
549 kernel you'll be using it in, instead of <c>`uname -r`,</c> use that kernel's
550 name.
551 </p>
552
553 <warn>
554 Make sure you first unload any older DRI kernel modules that might be already
555 loaded. Note that some DRM modules require that the agpgart module be loaded
556 first.
557 </warn>
558
559 </body>
560 </section>
561 </chapter>
562
563 <chapter>
564 <title>Tweak your performance</title>
565 <section>
566 <title>Get the most out of direct rendering</title>
567 <body>
568
569 <p>
570 A few options may increase performance by up to 30 percent (or more) over the
571 default. Set them in <path>/etc/X11/XF86Config</path>.
572 </p>
573
574 <pre caption="XF86Config">
575 Section "Device"
576 Option "AGPMode" "4"
577 <codenote>This increased FPS from 609 to 618.</codenote>
578 Option "AGPFastWrite" "True"
579 <codenote>This had no measurable effect, but it may increase instability of your computer.</codenote>
580 <codenote>You may also need to set it in your BIOS.</codenote>
581 Option "EnablePageFlip" "True"
582 <codenote>This improved FPS from 618 to 702. It also is "risky" but few people have reported problems.</codenote>
583 ...
584 EndSection
585 </pre>
586
587 <p>
588 If you want to set even more features, check out the <uri
589 link="http://dri.sourceforge.net/doc/dri_driver_features.phtml">features
590 listing</uri> on the DRI Web site.
591 </p>
592
593 </body>
594 </section>
595 </chapter>
596
597 <chapter>
598 <title>Troubleshooting</title>
599 <section>
600 <title>It doesn't work. I just recompiled my kernel or switched to a new one.</title>
601 <body>
602
603 <p>
604 Whenever you rebuild your kernel or switch to another kernel, you'll have to
605 rebuild the kernel module. Note that you don't need to remerge xfree, but you
606 will need to remerge xfree-drm.
607 </p>
608
609 </body>
610 </section>
611
612 <section>
613 <title>It doesn't work. I don't have rendering, and I can't tell why.</title>
614 <body>
615
616 <p>
617 Try <c>insmod radeon</c> before you start the X server. Also, try building
618 agpgart into the kernel instead of as a module.
619 </p>
620
621 </body>
622 </section>
623 <section>
624 <title>When I <c>startx</c>, I get this error: "[drm] failed to load kernel module agpgart"</title>
625 <body>
626
627 <p>
628 That's because you compiled agpgart into the kernel instead of as a module.
629 Ignore it unless you're having problems.
630 </p>
631
632 </body>
633 </section>
634 <section>
635 <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>
636 <body>
637
638 <p>
639 You aren't using the xfree-drm driver. Check if you compiled DRM and the driver
640 into the kernel; you shouldn't have.
641 </p>
642
643 </body>
644 </section>
645 <section>
646 <title>I have a Radeon, and I want TV-Out.</title>
647 <body>
648
649 <p>
650 Check out ati-gatos drivers. <c>emerge -s gatos</c>.
651 </p>
652
653 </body>
654 </section>
655 <section>
656 <title>It doesn't work. My card is so incredibly new and cool that it isn't supported at all.</title>
657 <body>
658
659 <p>
660 Try out the binary drivers. For ati-drivers, a listing is at
661 <uri>http://www.schneider-digital.de/html/download_ati.html</uri>. If those
662 don't support it, use fbdev. It's slow, but it works.
663 </p>
664
665 </body>
666 </section>
667 <section>
668 <title>I have a PCI card and it doesn't work. Help!</title>
669 <body>
670
671 <p>
672 In section "Device" enable ForcePCIMode.
673 </p>
674
675 <pre caption="Enabling ForcePCIMode">
676 Option "ForcePCIMode" "True"
677 </pre>
678
679 </body>
680 </section>
681 </chapter>
682
683 <chapter>
684 <title>Acknowledgments</title>
685 <section>
686 <body>
687
688 <ol>
689 <li>
690 Christopher Webber for suggesting a troubleshooting question about changing
691 or recompiling kernels
692 </li>
693 <li>
694 Steve, for suggesting consistency between the cases of dri and DRI in
695 XF86Config
696 </li>
697 </ol>
698
699 </body>
700 </section>
701 </chapter>
702
703 <chapter>
704 <title>References</title>
705 <section>
706 <body>
707
708 <ol>
709 <li>http://forums.gentoo.org/viewtopic.php?t=46681</li>
710 <li>http://forums.gentoo.org/viewtopic.php?t=29264</li>
711 <li>http://dri.sourceforge.net/</li>
712 <li>http://www.retinalburn.net/linux/dri_status.html</li>
713 </ol>
714
715 </body>
716 </section>
717 </chapter>
718 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20