2006-05-16

FreeBSD DRI

DRI (Direct Rendering Infrastructure) is an opensource project aimed at more fully utilizing video hardware capabilities under X11. It offers an alternative to using the nVidia drivers and a GeForce card for applications requiring OpenGL.

Note that performance on the DRI compatible cards I had available for testing was disappointing compared to the GeForce card with nVidia driver. Both DRI tests were run on a Pentium 866MHz system. I have not had a chance to test other video chipsets with DRI. It is probable that more modern video cards will show significantly better performance under DRI. I'd recommend 7 or 8 displays per second as a minimum for usability.

Card + Driver SUMA Speed Test (F12)
Matrox G400 + DRI 1.6 Displays/sec
ATI Rage 128 Pro Ultra TF + DRI 1.9 Displays/sec
GeForce + nVidia driver 10 - 20 Displays/sec

Enabling DRI on FreeBSD is relatively simple, although I have not found any official or organized documentation on it.

The steps below are for FreeBSD 5.4, but should be the same or at least similar on any recent FreeBSD. There are a number of resources on the WEB to help with troubleshooting. If you run into any problems, I suggest entering "FreeBSD direct rendering" on Google web and Google groups.

  1. Make sure the nVidia driver is NOT installed. It will interfere with the normal glx libraries needed to use dri.
  2. Install a 3D video card supported by the DRI project.
  3. Install the dri package: pkg_add -r dri This adds the DRI client modules to your X server in /usr/X11R6/lib/modules/dri. This is a necessary step I had a hard time finding out about. Without this package installed, the system logs will all erroneously indicate that DRI is working, but glxinfo will tell you it's not.
  4. Add driver_load="YES" to /boot/loader.conf, where driver is the appropriate dri driver from /boot/kernel. For example, for a Matrox card, use mga_load="YES". See /usr/X11R6/lib/modules/dri for a list of dri drivers.
  5. Make sure "dri" and "glx" are both being loaded in your xorg.conf. Also add a DRI section to allow non-root users to access the DRM device.

    Section "Module"
    Load "dri"
    Load "glx"
    ...
    EndSection

    Section "DRI"
    Mode 0666
    EndSection

  6. Restart your X server.
  7. Quick test: Run glxinfo:

    name of display: localhost:11.0
    display: localhost:11 screen: 0
    direct rendering: Yes
    ...
  8. If it says "direct rendering: No", check your logs to make sure the direct rendering module is loaded. It should look something like the text below:

    FreeBSD clone bacon ~ 206: dmesg | grep -i drm

    drm0: mem 0xfe000000-0xfe7fffff,0xfe9fc000-0xfe9fffff,0xf2000000-0xf3ffffff irq 11 at device 0.0 on pci1
    info: [drm] AGP at 0xf8000000 64MB
    info: [drm] Initialized mga 3.1.0 20021029 on minor 0

    FreeBSD clone bacon ~ 206: grep -i drm /var/log/Xorg.0.log

    (II) Loading sub module "drm"
    (II) LoadModule: "drm"
    (II) Loading /usr/X11R6/lib/modules/freebsd/libdrm.a
    (II) Module drm: vendor="X.Org Foundation"
    (II) MGA(0): [drm] bpp: 32 depth: 24
    (II) MGA(0): [drm] Sarea 2200+664: 2864
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: Searching for BusID pci:0000:01:00.0
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: drmOpenMinor returns 6
    drmOpenByBusid: drmGetBusid reports pci:0000:01:00.0
    (II) MGA(0): [drm] DRM interface version 1.2
    (II) MGA(0): [drm] created "mga" driver at busid "pci:0000:01:00.0"
    (II) MGA(0): [drm] added 8192 byte SAREA at 0xc2743000
    (II) MGA(0): [drm] mapped SAREA 0xc2743000 to 0x28371000
    (II) MGA(0): [drm] framebuffer handle = 0xf2000000
    (II) MGA(0): [drm] added 1 reserved context for kernel
    (II) MGA(0): [drm] Added 128 65536 byte DMA buffers
    (II) MGA(0): [drm] Registers handle = 0xfe9fc000
    (II) MGA(0): [drm] Status handle = 0xc2955000
    (II) MGA(0): [drm] installed DRM signal handler
    (II) MGA(0): [drm] Mapped 128 DMA buffers
    (II) MGA(0): [drm] dma control initialized, using IRQ 11
    (II) MGA(0): [drm] removed 1 reserved context for kernel
    (II) MGA(0): [drm] unmapping 8192 bytes of SAREA 0xc2743000 at 0x28371000
    (II) MGA(0): [drm] bpp: 32 depth: 24
    (II) MGA(0): [drm] Sarea 2200+664: 2864
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: Searching for BusID pci:0000:01:00.0
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: drmOpenMinor returns 6
    drmOpenByBusid: drmGetBusid reports pci:0000:01:00.0
    (II) MGA(0): [drm] DRM interface version 1.2
    (II) MGA(0): [drm] created "mga" driver at busid "pci:0000:01:00.0"
    (II) MGA(0): [drm] added 8192 byte SAREA at 0xc2651000
    (II) MGA(0): [drm] mapped SAREA 0xc2651000 to 0x28371000
    (II) MGA(0): [drm] framebuffer handle = 0xf2000000
    (II) MGA(0): [drm] added 1 reserved context for kernel
    (II) MGA(0): [drm] Added 128 65536 byte DMA buffers
    (II) MGA(0): [drm] Registers handle = 0xfe9fc000
    (II) MGA(0): [drm] Status handle = 0xc294f000
    (II) MGA(0): [drm] installed DRM signal handler
    (II) MGA(0): [drm] Mapped 128 DMA buffers
    (II) MGA(0): [drm] dma control initialized, using IRQ 11
    (II) MGA(0): [drm] removed 1 reserved context for kernel
    (II) MGA(0): [drm] unmapping 8192 bytes of SAREA 0xc2651000 at 0x28371000
    (II) MGA(0): [drm] bpp: 32 depth: 24
    (II) MGA(0): [drm] Sarea 2200+664: 2864
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: Searching for BusID pci:0000:01:00.0
    drmOpenDevice: node name is /dev/dri/card0
    drmOpenDevice: open result is 6, (OK)
    drmOpenByBusid: drmOpenMinor returns 6
    drmOpenByBusid: drmGetBusid reports pci:0000:01:00.0
    (II) MGA(0): [drm] DRM interface version 1.2
    (II) MGA(0): [drm] created "mga" driver at busid "pci:0000:01:00.0"
    (II) MGA(0): [drm] added 8192 byte SAREA at 0xc2651000
    (II) MGA(0): [drm] mapped SAREA 0xc2651000 to 0x2836d000
    (II) MGA(0): [drm] framebuffer handle = 0xf2000000
    (II) MGA(0): [drm] added 1 reserved context for kernel
    (II) MGA(0): [drm] Added 128 65536 byte DMA buffers
    (II) MGA(0): [drm] Registers handle = 0xfe9fc000
    (II) MGA(0): [drm] Status handle = 0xc2929000
    (II) MGA(0): [drm] installed DRM signal handler
    (II) MGA(0): [drm] Mapped 128 DMA buffers
    (II) MGA(0): [drm] dma control initialized, using IRQ 11

  9. One problem I ran into with the Matrox card was low memory. If this happens, you'll see a message like DRI static buffer allocation failed in your Xorg.0.log, and you'll need to reduce the resolution or color depth of your display.
  10. If you still have problems, check out this troubleshooting guide.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.