/[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.2 - (show annotations) (download) (as text)
Mon Jun 23 00:07:26 2003 UTC (11 years, 2 months ago) by peesh
Branch: MAIN
Changes since 1.1: +1 -0 lines
File MIME type: application/xml
Added note to cvs section -- thanks to Donnie Berkholz

1 <?xml version="1.0" encoding="UTF-8"?>
2 <?xml-stylesheet href="/xsl/guide.xsl" type="text/xsl"?>
3
4 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
5
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>
14
15 <abstract>This document is a guide to getting 3D acceleration working using XFree-DRM with XFree86 in Gentoo Linux.</abstract>
16
17 <version>1.0.0</version>
18 <date>June 14 2003</date>
19
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>
28
29
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. 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. 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>
34 </body>
35 </section>
36
37
38 <section>
39 <title>What is DRI?</title>
40 <body>
41 <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>
42 </body>
43 </section>
44
45
46 <section>
47 <title>What is XFree-DRM and how does it relate to regular XFree86?</title>
48 <body>
49 <p>XFree-DRM is an <e>enhancement</e> to XFree86 that adds 3D acceleration for cards to which XFree86 doesn't provide acceleration.</p>
50 </body>
51 </section>
52
53
54 <section>
55 <title>Purpose</title>
56 <body>
57 <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>
58 </body>
59 </section>
60
61
62 <section>
63 <title>Feedback</title>
64 <body>
65 <p>For suggestions, questions, etc., e-mail <mail link="donnie.berkholz@richmond.edu">Donnie Berkholz</mail>.</p>
66 </body>
67 </section>
68 </chapter>
69
70
71 <chapter>
72 <title>Install XFree86 and configure your kernel</title>
73 <section>
74 <title>Install XFree86</title>
75 <body>
76 <pre>
77 # <i>emerge x11-base/xfree</i>
78 </pre>
79 </body>
80 </section>
81
82
83 <section>
84 <title>Configure your kernel</title>
85 <body>
86 <p>Probe for your chipset and enable just that one.</p>
87 <pre caption="Checking your AGP chipset">
88 # <i>emerge pciutils; lspci | grep AGP</i>
89 # <i>00:01.0 PCI bridge: Intel Corp. 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 03)</i>
90 <codenote>Your output may not match the above due to different hardware.</codenote>
91 </pre>
92 <p>Most, if not all, kernels should have these options. This was configured using gentoo-sources-2.4.20-r5.</p>
93 <pre>
94 # <i>ls -l /usr/src/linux </i>
95 lrwxrwxrwx 1 root root 22 May 29 18:20 /usr/src/linux -> linux-2.4.20-gentoo-r5
96 <codenote>Make sure <path>/usr/src/linux</path> links to your current kernel.</codenote>
97 # <i>cd /usr/src/linux</i>
98 # <i>make menuconfig</i>
99 </pre>
100 <p></p>
101 <pre caption="make menuconfig options">
102 Processor type and features ---&gt;
103 &lt;*&gt; MTRR (Memory Type Range Register) support
104 Character devices ---&gt;
105 &lt;*&gt; /dev/agpgart (AGP Support)
106 [*] Intel 440LX/BX/GX and I815/I820/I830M/I830MP/I840/I845/I850/I860 support
107 <codenote>Enable your chipset instead of the above.</codenote>
108 [ ] Direct Rendering Manager (XFree86 DRI support)
109 </pre>
110 <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>
111 </body>
112 </section>
113
114
115 <section>
116 <title>Compile and install your kernel</title>
117 <body>
118 <pre caption="Compiling and installing kernel">
119 # <i>make dep &amp;&amp; make clean bzImage modules modules_install</i>
120 # <i>mount /boot</i>
121 # <i>cp arch/i386/boot/bzImage /boot</i>
122 </pre>
123 <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>
124 </body>
125 </section>
126 </chapter>
127
128
129 <chapter>
130 <title>Install XFree-DRM and configure direct rendering</title>
131 <section>
132 <title>Install XFree-DRM</title>
133 <body>
134 <pre>
135 # <i>ACCEPT_KEYWORDS="~x86" emerge xfree-drm</i>
136 </pre>
137 </body>
138 </section>
139
140
141 <section>
142 <title>Configure XF86Config</title>
143 <body>
144 <p>Open <path>/etc/X11/XF86Config</path> with your favorite text editor and edit it to enable DRI and GLX.</p>
145 <pre caption="XF86Config">
146 ...
147 Section "Module"
148 Load "dri"
149 Load "glx"
150 ...
151 EndSection
152 ...
153 Section "Device"
154 Driver "radeon"
155 ...
156 EndSection
157 ...
158 Section "DRI"
159 Mode 0666
160 EndSection
161 </pre>
162 <p>If you are using a different driver, replace "radeon" with yours.</p>
163 </body>
164 </section>
165 </chapter>
166
167
168 <chapter>
169 <title>Test 3D acceleration</title>
170 <section>
171 <title>Reboot to the new kernel</title>
172 <body>
173 <p>Reboot your computer to your new kernel. It's time to see if you have direct rendering and how good it is.</p>
174 <pre caption="Testing rendering">
175 # <i>startx</i>
176 <codenote>No need to load modules for your driver or agpgart, if you compiled agpgart as a module.</codenote>
177 <codenote>They will be loaded automatically.</codenote>
178 # <i>glxinfo | grep rendering</i>
179 direct rendering: Yes
180 <codenote>If it says "No," you don't have 3D acceleration.</codenote>
181 # <i>glxgears</i>
182 <codenote>Test your frames per second (FPS) at the default size. Do this while the CPU is as idle as possible.</codenote>
183 </pre>
184 </body>
185 </section>
186 </chapter>
187
188
189 <chapter>
190 <title>Using the CVS sources</title>
191 <section>
192 <body>
193 <warn>Don't do this if the package worked.</warn>
194 <note>By their nature, CVS sources are always changing. Your configuration may not look exactly like the one below.</note>
195 </body>
196 </section>
197 <section>
198 <title>Do you need the CVS?</title>
199 <body>
200 <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>
201 </body>
202 </section>
203 <section>
204 <title>Do the CVS sources support your card?</title>
205 <body>
206 <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>
207 <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>
208 <p></p>
209 <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>
210 </body>
211 </section>
212
213
214 <section>
215 <title>Install the CVS sources</title>
216 <body>
217 <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>
218 </body>
219 </section>
220
221
222 <section>
223 <title>Anonymous CVS download</title>
224 <body>
225 <p>Create a directory to store the CVS files:</p>
226 <pre>
227 # <i>cd ~</i>
228 # <i>mkdir DRI-CVS</i>
229 </pre>
230 <p>Check out the CVS sources</p>
231 <pre>
232 # <i>cd ~/DRI-CVS</i>
233 # <i>cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login</i>
234 <codenote>(hit ENTER when prompted for a password)</codenote>
235 # <i>cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc</i>
236 <codenote>The -z3 flag causes compression to be used in order to reduce the download time.</codenote>
237 </pre>
238 </body>
239 </section>
240
241
242 <section>
243 <title>Updating your CVS sources</title>
244 <body>
245 <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>
246 <pre>
247 # <i>cd ~/DRI-CVS</i>
248 # <i>cvs -z3 update -dA xc</i>
249 <codenote>The -d flag causes any new subdirectories to be created.</codenote>
250 <codenote>The -A flag causes most recent trunk sources to be fetched, not branch sources.</codenote>
251 </pre>
252 </body>
253 </section>
254
255
256 <section>
257 <title>Make a build tree</title>
258 <body>
259 <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>
260 <pre>
261 # <i>cd ~/DRI-CVS</i>
262 # <i>ln -s xc XFree40</i>
263 # <i>mkdir build; cd build</i>
264 # <i>lndir -silent -ignorelinks ../XFree40</i>
265 </pre>
266 <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>
267 </body>
268 </section>
269
270
271 <section>
272 <title>Edit the host.def file</title>
273 <body>
274 <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>
275 <pre>
276 #define DefaultCCOptions -Wall
277 <codenote>For i386:</codenote>
278 #define DefaultGcc2i386Opt -O2
279 <codenote>For Alpha:</codenote>
280 #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
281 <codenote>For all architectures</codenote>
282 #define LibraryCDebugFlags -O2
283 #define BuildServersOnly YES
284 #define XF86CardDrivers vga tdfx mga ati i810
285 #define LinuxDistribution LinuxRedHat
286 #define DefaultCCOptions -ansi GccWarningOptions -pipe
287 #define BuildXF86DRI YES
288 /* Optionally turn these on for debugging */
289 /* #define GlxBuiltInTdfx YES */
290 /* #define GlxBuiltInMga YES */
291 /* #define GlxBuiltInR128 YES */
292 /* #define GlxBuiltInRadeon YES */
293 /* #define DoLoadableServer NO */
294 #define SharedLibFont NO
295 </pre>
296 <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>
297 <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>
298 <pre>
299 #define ProjectRoot pathToYourXFree86installation
300 <codenote>Note the XF86CardDrivers line to be sure your card's driver is listed.</codenote>
301 <codenote>If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you should add the following:</codenote>
302 #define MesaUse3DNow YES
303 <codenote>You don't have to be using an AMD processor to enable this option.</codenote>
304 <codenote>The DRI will look for 3DNow! support at runtime and only enable it if applicable.</codenote>
305 </pre>
306 <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>
307 <pre>
308 #define MesaUseKatmai YES
309 </pre>
310 </body>
311 </section>
312
313
314 <section>
315 <title>Compile the XFree86/DRI tree</title>
316 <body>
317 <p>To compile the complete DRI tree:</p>
318 <pre>
319 # <i>cd ~/DRI-CVS/build/xc/</i>
320 # <i>make World &gt;&amp; world.log</i>
321 </pre>
322 <p>One user suggests it may also be necessary to do the following:</p>
323 <pre>
324 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel</i>
325 # <i>make -f Makefile.linux radeon.o</i>
326 <codenote>Replace radeon with your driver.</codenote>
327 </pre>
328 <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>
329 <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>
330 <p>Using your text editor, examine world.log for errors by searching for the pattern ***.</p>
331 </body>
332 </section>
333
334
335 <section>
336 <title>Install your driver</title>
337 <body>
338 <p>Verify that the DRI kernel module(s) for your system were built:</p>
339 <pre>
340 # <i>cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel; ls</i>
341 </pre>
342 <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>
343 <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>
344 <pre>
345 # <i>cd ~/DRI-CVS/build/xc/exports/lib/modules/</i>
346 # <i>cp dri/r200_dri.so /usr/X11R6/lib/modules/dri/</i>
347 # <i>cp drivers/atimisc_drv.o /usr/X11R6/lib/modules/drivers/</i>
348 # <i>cp drivers/radeon_drv.o /usr/X11R6/lib/modules/drivers/</i>
349 # <i>cp extensions/libdri.a /usr/X11R6/lib/modules/extensions/</i>
350 # <i>cp linux/libdrm.a /usr/X11R6/lib/modules/linux/</i>
351 </pre>
352 <p>Follow the "Configure XF86Config" section above.</p>
353 <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>
354 <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>
355 </body>
356 </section>
357 </chapter>
358
359
360 <chapter>
361 <title>Tweak your performance</title>
362 <section>
363 <title>Get the most out of direct rendering</title>
364 <body>
365 <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>
366 <pre caption="XF86Config">
367 Section "Device"
368 Option "AGPMode" "4"
369 <codenote>This increased FPS from 609 to 618.</codenote>
370 Option "AGPFastWrite" "True"
371 <codenote>This had no measurable effect, but it may increase instability of your computer.</codenote>
372 <codenote>You may also need to set it in your BIOS.</codenote>
373 Option "EnablePageFlip" "True"
374 <codenote>This improved FPS from 618 to 702. It also is "risky" but few people have reported problems.</codenote>
375 ...
376 EndSection
377 </pre>
378 <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>
379 </body>
380 </section>
381 </chapter>
382
383 <chapter>
384 <title>Troubleshooting</title>
385 <section>
386 <title>It doesn't work. I don't have rendering, and I can't tell why.</title>
387 <body>
388 <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>
389 </body>
390 </section>
391 <section>
392 <title>When I <c>startx</c>, I get this error: "[drm] failed to load kernel module agpgart"</title>
393 <body>
394 <p>That's because you compiled agpgart into the kernel instead of as a module. Ignore it.</p>
395 </body>
396 </section>
397 <section>
398 <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>
399 <body>
400 <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>
401 </body>
402 </section>
403 <section>
404 <title>I have a Radeon, and I want TV-Out.</title>
405 <body>
406 <p>Check out ati-gatos drivers. <c>emerge -s gatos</c>.</p>
407 </body>
408 </section>
409 <section>
410 <title>It doesn't work. My card is so incredibly new and cool that it isn't supported at all.</title>
411 <body>
412 <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>
413 </body>
414 </section>
415 <section>
416 <title>I have a PCI card and it doesn't work. Help!</title>
417 <body>
418 <p>In section "Device" enable ForcePCIMode.
419 <pre>Option "ForcePCIMode" "True"</pre></p>
420 </body>
421 </section>
422
423 </chapter>
424
425
426 <chapter>
427 <title>References</title>
428 <section>
429 <body>
430 <p>
431 <ol>
432 <li>http://forums.gentoo.org/viewtopic.php?t=46681</li>
433 <li>http://forums.gentoo.org/viewtopic.php?t=29264</li>
434 <li>http://dri.sourceforge.net/</li>
435 <li>http://www.retinalburn.net/linux/dri_status.html</li>
436 </ol>
437 </p>
438 </body>
439 </section>
440 </chapter>
441 </guide>

  ViewVC Help
Powered by ViewVC 1.1.20