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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.7 - (hide annotations) (download) (as text)
Sat Dec 20 19:55:17 2003 UTC (10 years, 4 months ago) by swift
Branch: MAIN
Changes since 1.6: +45 -37 lines
File MIME type: application/xml
Updates by Donnie - #36106

1 peesh 1.1 <?xml version="1.0" encoding="UTF-8"?>
2 swift 1.7 <!-- $Header: /home/cvsroot/gentoo/xml/htdocs/doc/en/dri-howto.xml,v 1.6 2003/11/15 00:35:18 neysx Exp $ -->
3 peesh 1.1 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
5     <guide link="/doc/en/dri-howto.xml">
6     <title>Hardware 3D Acceleration Guide</title>
7     <author title="Author">
8 swift 1.7 <mail link="spyderous@gentoo.org">Donnie Berkholz</mail>
9 peesh 1.1 </author>
10     <author title="Editor">
11     <mail link="peesh@gentoo.org">Jorge Paulo</mail>
12     </author>
14 swift 1.4 <license/>
16 peesh 1.1 <abstract>This document is a guide to getting 3D acceleration working using XFree-DRM with XFree86 in Gentoo Linux.</abstract>
18 swift 1.7 <version>1.0.1</version>
19     <date>December 19 2003</date>
20 peesh 1.1
21     <chapter>
22     <title>Introduction</title>
23     <section>
24     <title>What is hardware 3D acceleration and why do I want it?</title>
25     <body>
26     <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>
27     </body>
28     </section>
31     <section>
32     <title>How do I get hardware 3D acceleration?</title>
33     <body>
34 swift 1.7 <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. Binary drivers include media-video/nvidia-kernel and media-video/nvidia-glx for nVidia cards, media-video/mgavideo for Matrox cards 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>
35 peesh 1.1 </body>
36     </section>
39     <section>
40     <title>What is DRI?</title>
41     <body>
42     <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>
43     </body>
44     </section>
47     <section>
48     <title>What is XFree-DRM and how does it relate to regular XFree86?</title>
49     <body>
50 swift 1.7 <p>XFree-DRM is an <e>enhancement</e> to XFree86 that adds 3D acceleration for cards by adding the kernel module necessary for direct rendering.</p>
51 peesh 1.1 </body>
52     </section>
55     <section>
56     <title>Purpose</title>
57     <body>
58 swift 1.7 <p>This guide is for people who can't get direct rendering working with just XFree. XFree-DRM works for 3dfx, gamma, i8x0, matrox, rage128, radeon, mach64 (as of xfree-drm-4.3.0-r7) and sis300 series drivers. 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.6 kernel, its DRM supports XFree 4.3; Gentoo's XFree-DRM package is not yet working on 2.6 kernels. See the <uri link="http://dri.sourceforge.net">DRI homepage</uri> for more info and documentation. </p>
59 peesh 1.1 </body>
60     </section>
63     <section>
64     <title>Feedback</title>
65     <body>
66 swift 1.7 <p>With suggestions, questions, etc., e-mail <mail link="spyderous@gentoo.org">Donnie Berkholz</mail>.</p>
67 peesh 1.1 </body>
68     </section>
69     </chapter>
72     <chapter>
73     <title>Install XFree86 and configure your kernel</title>
74     <section>
75     <title>Install XFree86</title>
76     <body>
77     <pre>
78     # <i>emerge x11-base/xfree</i>
79     </pre>
80     </body>
81     </section>
84     <section>
85     <title>Configure your kernel</title>
86     <body>
87     <p>Probe for your chipset and enable just that one.</p>
88     <pre caption="Checking your AGP chipset">
89     # <i>emerge pciutils; lspci | grep AGP</i>
90     # <i>00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 03)</i>
91     <codenote>Your output may not match the above due to different hardware.</codenote>
92     </pre>
93     <p>Most, if not all, kernels should have these options. This was configured using gentoo-sources-2.4.20-r5.</p>
94     <pre>
95     # <i>ls -l /usr/src/linux </i>
96     lrwxrwxrwx 1 root root 22 May 29 18:20 /usr/src/linux -> linux-2.4.20-gentoo-r5
97     <codenote>Make sure <path>/usr/src/linux</path> links to your current kernel.</codenote>
98     # <i>cd /usr/src/linux</i>
99     # <i>make menuconfig</i>
100     </pre>
101     <p></p>
102     <pre caption="make menuconfig options">
103     Processor type and features ---&gt;
104     &lt;*&gt; MTRR (Memory Type Range Register) support
105     Character devices ---&gt;
106     &lt;*&gt; /dev/agpgart (AGP Support)
107 swift 1.7 [M] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
108 peesh 1.1 <codenote>Enable your chipset instead of the above.</codenote>
109     [ ] Direct Rendering Manager (XFree86 DRI support)
110     </pre>
111 swift 1.7 <p>Make sure the Direct Rendering Manager (DRM) is <e>off</e>. The XFree-DRM package will provide its own. The 2.4 kernel's version is for XFree 4.2.</p>
112 peesh 1.1 </body>
113     </section>
116     <section>
117     <title>Compile and install your kernel</title>
118     <body>
119     <pre caption="Compiling and installing kernel">
120     # <i>make dep &amp;&amp; make clean bzImage modules modules_install</i>
121     # <i>mount /boot</i>
122     # <i>cp arch/i386/boot/bzImage /boot</i>
123     </pre>
124     <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>
125     </body>
126     </section>
127     </chapter>
130     <chapter>
131     <title>Install XFree-DRM and configure direct rendering</title>
132     <section>
133     <title>Install XFree-DRM</title>
134     <body>
135     <pre>
136     # <i>ACCEPT_KEYWORDS="~x86" emerge xfree-drm</i>
137     </pre>
138     </body>
139     </section>
142     <section>
143     <title>Configure XF86Config</title>
144     <body>
145     <p>Open <path>/etc/X11/XF86Config</path> with your favorite text editor and edit it to enable DRI and GLX.</p>
146     <pre caption="XF86Config">
147     ...
148     Section "Module"
149     Load "dri"
150     Load "glx"
151     ...
152     EndSection
153     ...
154     Section "Device"
155     Driver "radeon"
156     ...
157     EndSection
158     ...
159 swift 1.7 Section "dri"
160 peesh 1.1 Mode 0666
161     EndSection
162     </pre>
163     <p>If you are using a different driver, replace "radeon" with yours.</p>
164     </body>
165     </section>
166     </chapter>
169     <chapter>
170     <title>Test 3D acceleration</title>
171     <section>
172     <title>Reboot to the new kernel</title>
173     <body>
174     <p>Reboot your computer to your new kernel. It's time to see if you have direct rendering and how good it is.</p>
175     <pre caption="Testing rendering">
176     # <i>startx</i>
177     <codenote>No need to load modules for your driver or agpgart, if you compiled agpgart as a module.</codenote>
178     <codenote>They will be loaded automatically.</codenote>
179     # <i>glxinfo | grep rendering</i>
180     direct rendering: Yes
181     <codenote>If it says "No," you don't have 3D acceleration.</codenote>
182     # <i>glxgears</i>
183 swift 1.7 <codenote>Test your frames per second (FPS) at the default size. The number should be significantly higher than before installing xfree-drm. Do this while the CPU is as idle as possible.</codenote>
184 peesh 1.1 </pre>
185     </body>
186     </section>
187     </chapter>
190     <chapter>
191     <title>Using the CVS sources</title>
192     <section>
193     <body>
194     <warn>Don't do this if the package worked.</warn>
195 peesh 1.2 <note>By their nature, CVS sources are always changing. Your configuration may not look exactly like the one below.</note>
196 peesh 1.1 </body>
197     </section>
198     <section>
199     <title>Do you need the CVS?</title>
200     <body>
201 swift 1.7 <p>First you have to check whether the xfree-drm package works. If it doesn't and you have checked your logs to verify it's not a configuration error, you might want to consider the CVS sources. There are also daily driver snapshots available if you do not wish to build the full CVS.</p>
202 peesh 1.1 </body>
203     </section>
204     <section>
205     <title>Do the CVS sources support your card?</title>
206     <body>
207     <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>
208     <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>
209     <p></p>
210     <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>
211     </body>
212     </section>
215     <section>
216     <title>Install the CVS sources</title>
217     <body>
218 swift 1.7 <p>Follow this guide through "Compile and install your kernel." Then continue with this guide, which tracks step 6 of the <uri link="http://dri.sourceforge.net/doc/DRIcompile.html">DRI compilation guide</uri> and follows it through step 8.3.</p>
219 peesh 1.1 </body>
220     </section>
223     <section>
224     <title>Anonymous CVS download</title>
225     <body>
226     <p>Create a directory to store the CVS files:</p>
227     <pre>
228     # <i>cd ~</i>
229     # <i>mkdir DRI-CVS</i>
230     </pre>
231     <p>Check out the CVS sources</p>
232     <pre>
233     # <i>cd ~/DRI-CVS</i>
234     # <i>cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login</i>
235     <codenote>(hit ENTER when prompted for a password)</codenote>
236     # <i>cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc</i>
237 swift 1.7 <codenote>The -z3 flag causes compression to be used to reduce the download time.</codenote>
238 peesh 1.1 </pre>
239     </body>
240     </section>
243     <section>
244     <title>Updating your CVS sources</title>
245     <body>
246     <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>
247     <pre>
248     # <i>cd ~/DRI-CVS</i>
249     # <i>cvs -z3 update -dA xc</i>
250     <codenote>The -d flag causes any new subdirectories to be created.</codenote>
251     <codenote>The -A flag causes most recent trunk sources to be fetched, not branch sources.</codenote>
252     </pre>
253     </body>
254     </section>
257     <section>
258     <title>Make a build tree</title>
259     <body>
260     <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>
261     <pre>
262     # <i>cd ~/DRI-CVS</i>
263     # <i>ln -s xc XFree40</i>
264     # <i>mkdir build; cd build</i>
265     # <i>lndir -silent -ignorelinks ../XFree40</i>
266     </pre>
267     <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>
268     </body>
269     </section>
272     <section>
273     <title>Edit the host.def file</title>
274     <body>
275     <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>
276     <pre>
277     #define DefaultCCOptions -Wall
278     <codenote>For i386:</codenote>
279     #define DefaultGcc2i386Opt -O2
280     <codenote>For Alpha:</codenote>
281     #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
282     <codenote>For all architectures</codenote>
283     #define LibraryCDebugFlags -O2
284     #define BuildServersOnly YES
285     #define XF86CardDrivers vga tdfx mga ati i810
286     #define LinuxDistribution LinuxRedHat
287     #define DefaultCCOptions -ansi GccWarningOptions -pipe
288     #define BuildXF86DRI YES
289     /* Optionally turn these on for debugging */
290     /* #define GlxBuiltInTdfx YES */
291     /* #define GlxBuiltInMga YES */
292     /* #define GlxBuiltInR128 YES */
293     /* #define GlxBuiltInRadeon YES */
294     /* #define DoLoadableServer NO */
295     #define SharedLibFont NO
296     </pre>
297     <pre>
298     <codenote>Note the XF86CardDrivers line to be sure your card's driver is listed.</codenote>
299     <codenote>If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you should add the following:</codenote>
300     #define MesaUse3DNow YES
301     <codenote>You don't have to be using an AMD processor to enable this option.</codenote>
302     <codenote>The DRI will look for 3DNow! support at runtime and only enable it if applicable.</codenote>
303     </pre>
304     <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>
305     <pre>
306     #define MesaUseKatmai YES
307     </pre>
308     </body>
309     </section>
312     <section>
313     <title>Compile the XFree86/DRI tree</title>
314     <body>
315     <p>To compile the complete DRI tree:</p>
316     <pre>
317     # <i>cd ~/DRI-CVS/build/xc/</i>
318     # <i>make World &gt;&amp; world.log</i>
319     </pre>
320 swift 1.7 <p>It may also be necessary to do the following, depending on what you placed in host.def:</p>
321 peesh 1.1 <pre>
322     # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel</i>
323     # <i>make -f Makefile.linux radeon.o</i>
324     <codenote>Replace radeon with your driver.</codenote>
325     </pre>
326     <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>
327     <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>
328     <p>Using your text editor, examine world.log for errors by searching for the pattern ***.</p>
329     </body>
330     </section>
333     <section>
334 swift 1.7 <title>Install the CVS</title>
335 peesh 1.1 <body>
336     <p>Verify that the DRI kernel module(s) for your system were built:</p>
337     <pre>
338     # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel; ls</i>
339     </pre>
340     <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>
341 swift 1.7 <p>Install over your XFree86 installation. You may wish to back up xfree.</p>
342 peesh 1.1 <pre>
343 swift 1.7 # <i>quickpkg xfree</i>
344     <codenote>This backs up your XFree86 package.</codenote>
345     # <i>make install</i>
346 peesh 1.1 </pre>
347     <p>Follow the "Configure XF86Config" section above.</p>
348     <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>
349     <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>
350     </body>
351     </section>
352     </chapter>
355     <chapter>
356     <title>Tweak your performance</title>
357     <section>
358     <title>Get the most out of direct rendering</title>
359     <body>
360     <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>
361     <pre caption="XF86Config">
362     Section "Device"
363     Option "AGPMode" "4"
364     <codenote>This increased FPS from 609 to 618.</codenote>
365     Option "AGPFastWrite" "True"
366     <codenote>This had no measurable effect, but it may increase instability of your computer.</codenote>
367     <codenote>You may also need to set it in your BIOS.</codenote>
368     Option "EnablePageFlip" "True"
369     <codenote>This improved FPS from 618 to 702. It also is "risky" but few people have reported problems.</codenote>
370     ...
371     EndSection
372     </pre>
373     <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>
374     </body>
375     </section>
376     </chapter>
378     <chapter>
379     <title>Troubleshooting</title>
380     <section>
381 swift 1.7 <title>It doesn't work. I just recompiled my kernel or switched to a new one.</title>
382     <body>
383     <p>Whenever you rebuild your kernel or switch to another kernel, you'll have to rebuild the kernel module. Note that you don't need to remerge xfree, but you will need to remerge xfree-drm.</p>
384     </body>
385     </section>
386     <section>
387 peesh 1.1 <title>It doesn't work. I don't have rendering, and I can't tell why.</title>
388     <body>
389 swift 1.7 <p>Try <c>insmod radeon</c> before you start the X server. Also, try building agpgart into the kernel instead of as a module.</p>
390 peesh 1.1 </body>
391     </section>
392     <section>
393     <title>When I <c>startx</c>, I get this error: "[drm] failed to load kernel module agpgart"</title>
394     <body>
395 swift 1.7 <p>That's because you compiled agpgart into the kernel instead of as a module. Ignore it unless you're having problems.</p>
396 peesh 1.1 </body>
397     </section>
398     <section>
399     <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>
400     <body>
401     <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>
402     </body>
403     </section>
404     <section>
405     <title>I have a Radeon, and I want TV-Out.</title>
406     <body>
407     <p>Check out ati-gatos drivers. <c>emerge -s gatos</c>.</p>
408     </body>
409     </section>
410     <section>
411     <title>It doesn't work. My card is so incredibly new and cool that it isn't supported at all.</title>
412     <body>
413 swift 1.7 <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 fbdev. It's slow, but it works.</p>
414 peesh 1.1 </body>
415     </section>
416     <section>
417     <title>I have a PCI card and it doesn't work. Help!</title>
418     <body>
419     <p>In section "Device" enable ForcePCIMode.
420     <pre>Option "ForcePCIMode" "True"</pre></p>
421     </body>
422     </section>
424     </chapter>
427     <chapter>
428 swift 1.7 <title>Acknowledgments</title>
429     <section>
430     <body>
431     <p>
432     <ol>
433     <li>Christopher Webber for suggesting a troubleshooting question about changing or recompiling kernels</li>
434     <li>Steve, for suggesting consistency between the cases of dri and DRI in XF86Config</li>
435     </ol>
436     </p>
437     </body>
438     </section>
439     </chapter>
442     <chapter>
443 peesh 1.1 <title>References</title>
444     <section>
445     <body>
446     <p>
447     <ol>
448     <li>http://forums.gentoo.org/viewtopic.php?t=46681</li>
449     <li>http://forums.gentoo.org/viewtopic.php?t=29264</li>
450     <li>http://dri.sourceforge.net/</li>
451     <li>http://www.retinalburn.net/linux/dri_status.html</li>
452     </ol>
453     </p>
454     </body>
455     </section>
456     </chapter>
457     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20