4.7. Nvidia GLX & DRI

NoteNote
 

Here you will learn how to configure your system for parallel use of Nvidia's GLX and XFree's DRI. If you do not have Nvidia cards, or you have only Nvidia cards, you do not need to read this section. In the first case you do not need the Nvidia GLX at all, and in the second, you can use the standard procedure for installing GLX.

Why Nvidia? Why closed source drivers?

A bit of a mixed up answer:

  1. With the open source driver it's almost impossible to bring up a secondary card, so we should use the closed source driver.

  2. Why the Nvidia card? Currently these are the only available, affordable PCI video cards with some acceleration.

  3. I tried to use DRI on 2 parallel X servers, but it didn't work. I posted emails to XFree, DRI and lkml list, but I only got a single answer with no valuable information on my problem. I tried to run DRI on a Matrox G550 DH AGP & SiS63xx PCI, but when enabled for both cards, I got AGP errors. When enabled only for one of the cards, I got DRI up and running. Please, someone confirm or prove me wrong!

I'll explain several ways to get configuration working for both Nvidia GLX and XFree86 DRI. There are probably a lot of other possibilities, and maybe these are not the simplest, but they are the ones I know to work.

The reasons why this is needed:

  1. Nvidia should use a different module path for xf86: the glx extension module from Nvidia is incompatible with the one from XFree86.

  2. Nvidia should use a different XF86Config file: because DRI should be disabled for Nvidia and enabled for others.

If you find a simpler way, please email it me and I'll include it.

CautionCaution
 

This can not be used as-is on SuSE Linux. In order to make it easy for the user to switch between Mesa, XFree and Nvidia GL libraries, SuSE uses a very complicated setup for the GL libraries. To use this setup you have to switch your configuration to XFree86's GL libraries.

4.7.1. Example 1

This is the configuration that I use on my system (ATI AIW Radeon 7500 AGP and Nvidia TNT2 M64 PCI) XFree configuration files:

  1. Create a directory /usr/X11R6/libNV:

    mkdir /usr/X11R6/libNV

  2. Create links to the original /usr/X11R6/lib:

    cd /usr/X11R6/libNV

    lndir -silent -ignorelinks ../lib

  3. Install the Nvidia driver and libraries in /usr/X11R6/libNV.

  4. Install Nvidia's libGLcore.so.1.0 [driver version], or better, libGLcore.so.1, in /usr/lib. Make a symbolic link from /usr/X11R6/libNV/libGLcore.so.1 to /usr/lib/libGLcore.so.1 (this will allow you to easily update your Nvidia drivers):

    cd /usr/lib

    ln -s ../X11R6/libNV/libGLcore.so.1 ./

    Note: the Nvidia libGL.so is installed /usr/X11R6/libNV, so it's invisible to the system unless you tell the system about the existence of /usr/X11R6/libNV. For this setup, you must not do this, as it will break the standard X server start-up. But you can use the XFree GL libraries with the Nvidia graphic card and Nvidia closed source drivers, with a non-Nvidia graphic card, using XFree's DRI, which the GL library from Nvidia cannot do.

  5. Add a line in the XFree configuration file for the Nvidia card to point the X server to the right location of the library and module path:
    
Section "Files"
    
    ..........
    ModulePath  "/usr/X11R6/libNV/modules"
    ..........
    
    EndSection
                

  6. Install the Nvidia kernel driver.

Now everything should be fine and you should be able to use DRI and Nvidia GLX at the same time. You will have a bit smaller performance in comparison to a setup which uses Nvidia's libGL & libGLcore, but the difference is not that big on my PC.

4.7.2. Example 2

This example will give you the full performance of both the Nvidia card(s), and the non-Nvidia card, since XFree's libGL is used for the non Nvidia card, and Nvidia's libGL is used for Nvidia cards. But this will require one more X server to be precise; a simple wrapper to add the path to the Nvidia libraries, and symbolic links to it for additional Nvidia cards.

It is almost the same as the previous scenario, with the difference that the X servers for the Nvidia cards should start with an environment where Nvidia's libGL is known, while the X servers for non Nvidia cards shouldn't know anything about the Nvidia libGL. This requires a wrapper to be used for starting the X servers driving Nvidia cards.

Install the Nvidia libraries and kernel driver like in the previous example. You may skip step 4. as libGLcore.so.1 is installed in /usr/X11R6/libNV, and we'll inform the X servers driving Nvidia cards about the proper path to the Nvidia libraries.

The missing part - the wrapper :

#!/bin/bash
export LD_LIBRARY_PATH=/usr/X11R6/libNV
exec /usr/X11R6/bin/X0 $*
          

Copy these lines into your favourite editor and save the file as XNV. Make it executable:

chmod +x XNV

Copy the file to /usr/X11R6/bin and make symbolic links to it for additional Nvidia cards (for additional cards just add more links):


cp XNV /usr/X11R6/bin
cd /usr/X11R6/bin
ln -s XNV Xnv0
ln -s XNV Xnv1
ln -s XNV Xnv2
        

Remember to use /usr/X11R6/bin/Xnv0, /usr/X11R6/bin/Xnv1 ..., instead of /usr/X11R6/bin/X0, /usr/X11R6/bin/X1 ... for your Nvidia cards while configuring the display managers in the next chapter, or when starting X on Nvidia card(s) from console.

4.7.3. Installing the Nvidia libraries easily

Using the new Nvidia installer (note, this is a work in progress, do not use if you don't understand what happens here. To-do: write a script to perform steps 1-4. Please provide some feedback on the script in Appendix->Scripts):

Manually:

  1. Make a backup of your XFree GL libraries:

    
cd  [XFree prefix]
                  

    On my Mandrake system I can use:

    
cd $OPENWINHOME
    find lib -name "libGL.*" -o -name "libGLcore*" -o -name "libglx.*" | xargs tar  rpfv   libGL-backup.tar
                  
  2. Then run the Nvidia installer:

    
./NVIDIA-Linux-x86-1.0-4349.run --no-opengl-headers --xfree86-prefix=/usr/X11R6NV --opengl-prefix=/usr/X11R6NV
                  
  3. Copy the installed files to /usr/X11R6/libNV:

    
cd /usr/X11R6NV/lib &&  tar cv * | tar xvC /usr/X11R6/libNV/
                  
  4. Restore the backed-up GL libraries:

    
cd [XFree prefix]
    tar xvfp libGL-backup.tar && ldconfig
                  

mirror server hosted at Truenetwork, Russian Federation.