Monday, December 06, 2004

Enabling DRI on FreeBSD

Last February I wrote of my adventures enabling DRI on my laptop.

I already had a few tweaks to my /boot/loader.conf to get sound and AGP working:

snd_csa_load="YES"
r128_load="YES"

Using kldstat, I could see what kernel modules were loaded:

orr:/home/richard$ kldstat
Id Refs Address Size Name
1 12 0xc0400000 5cdb30 kernel
2 2 0xc09ce000 7464 snd_csa.ko
3 3 0xc09d6000 1d4fc sound.ko
4 1 0xc09f4000 1520c r128.ko
5 14 0xc0a0a000 537f0 acpi.ko
6 1 0xc1a97000 17000 linux.ko

When I installed FreeBSD 5.3 RELEASE I was not able to get DRI working when I simply uncommented it in my xorg.conf file:

# This loads the GLX module
Load "glx"
# This loads the DRI module
# Load "dri"

When I did uncomment the dri module, I saw a green bar appear at the top of my X display, and the system locked. Without DRI, a test with glxgears showed poor performance:

orr:/home/richard$ glxgears -info
GL_RENDERER = Mesa GLX Indirect
GL_VERSION = 1.2 (1.4 Mesa 5.0.2)
GL_VENDOR = Mesa project: www.mesa3d.org
...edited...
444 frames in 5.0 seconds = 88.800 FPS
440 frames in 5.0 seconds = 88.000 FPS

My /var/log/Xorg.0.log file showed no mention of DRI or DRM.

Inspired by this freebsd-stable thread, I installed graphics/dri via package:

# pkg_add -vr dri
...edited...
requesting ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/
packages-5.3-release/Latest/dri.tbz
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/
packages-5.3-release/Latest/dri.tbz...x +CONTENTS
x +COMMENT
x +DESC
x +MTREE_DIRS
x lib/modules/dri/gamma_dri.so
x lib/modules/dri/i810_dri.so
x lib/modules/dri/i830_dri.so
x lib/modules/dri/mga_dri.so
x lib/modules/dri/r128_dri.so
x lib/modules/dri/r200_dri.so
x lib/modules/dri/radeon_dri.so
x lib/modules/dri/sis_dri.so
x lib/modules/dri/tdfx_dri.so
tar command returns 0 status
Done.
...truncated...

I was pleased to see the r128_dri.so, since that is what my graphics card uses.

I uncommented the 'dri' entry from my xorg.conf file and restarted X. My /var/log/Xorg.0.log file now mentioned DRI and DRM:

(II) Loading extension XFree86-DRI
(II) LoadModule: "r128"
(II) Loading /usr/X11R6/lib/modules/drivers/r128_drv.o
(II) Module r128: vendor="X.Org Foundation"
compiled for 6.7.0, module version = 4.0.1
Module class: X.Org Video Driver
ABI class: X.Org Video Driver, version 0.7
...edited...
(II) R128(0): [drm] installed DRM signal handler
(II) R128(0): [DRI] installation complete
(II) R128(0): [drm] Added 128 16384 byte vertex/indirect buffers
(II) R128(0): [drm] Mapped 128 vertex/indirect buffers
(II) R128(0): [drm] dma control initialized, using IRQ 11
(II) R128(0): Direct rendering enabled

I found much better performance with glxgears:

orr:/home/richard$ glxgears -info
GL_RENDERER = Mesa DRI Rage 128 Mobility 20030328 AGP 1x x86/MMX/SSE
GL_VERSION = 1.2 Mesa 5.0.2
GL_VENDOR = VA Linux Systems, Inc.
...edited...
4737 frames in 5.0 seconds = 947.400 FPS
7280 frames in 5.0 seconds = 1456.000 FPS
7338 frames in 5.0 seconds = 1467.600 FPS
7207 frames in 5.0 seconds = 1441.400 FPS

I am glad this worked.

Update: I spoke too soon. I suspend my laptop using 'acpiconf -s 3'. When I return from sleeping, the X display is garbled. I've gone back to disabling DRI. I don't intend to work on this any further until X11R6.8.1 is released for FreeBSD. If the problem persists, I'll pursue troubleshooting it. I see others have problems too.

No comments: