Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jan 2001 04:54:30 +1000
From:      Andrew Kenneth Milton <akm@mail.theinternet.com.au>
To:        current@freebsd.org
Subject:   Voodoo3 + XFree4 + DRM - simple_lock ? :-)
Message-ID:  <20010131045430.R11513@zeus.theinternet.com.au>

next in thread | raw e-mail | index | archive | help
I've made a roadmap to getting hardware accel 3d support using a Voodoo3
under XFree-4. I've attached it in case anyone is interested.

However, recently simple_lock and friends seem to have disappeared, and the
kernel modules make some use of them (although there is still reference
to it in machine/smptests.h)

It looked like I could replace them with calls to mtx_* stuff
Removing the calls to simple_lock etc sure made it run a lot faster though,
but, I think I'd rather have the safety.

What are the 'new' corresponding structures and calls for simple_lock ?

------------------------------------------------------------------------
This is a roadmap for getting a native 3d Accelerated XFree 4 under FreeBSD.
The XFree4 port changes fairly regularly so patches might have proven
difficult (and I don't want to maintain a patchset for every revision). 
The instructions here can be followed with any tree even if stuff moves.

These won't work for a -current after the beginning of January
2001, since the simple_lock stuff has gone away in anticipation
of SMPng I assume.

I've only done this using a PCI Voodoo 3 2000 Card, but, I'd assume if your
card is working correctly then this will probably also work for you with
some minor modifications.

If you're using a 3dfx card, you'll need to grab the Glide SDK and install
the headers. And you'll need to grab the source for Glide 3 and install the
libraries. It compiled ok here, so I don't anticipate too many problems.

------------------------------------------------------------------------
Glide Libraries:

Glide3x_devel-2.2-2.i386.rpm
to install;
rpm2cpio Glide3x_devel-2.2-2.i386.rpm | cpio -i -d
cp -r usr/include/glide3 /usr/include

Glide_V3-DRI-3.10-6.src.rpm
to install;
rpm2cpio Glide_V3-DRI-3.10-6.src.rpm | cpio -i
You'll get a Glide3.10.tar.gz
unpack that in a new directory;
mkdir glide3
cd glide3
tar zxvf ../Glide3.10.tar.gz
make -f makefile.linux
look in the lib directory
some of the symlinks are hosed, and will need to be fixed
cp the glide3 libraries to /usr/lib

------------------------------------------------------------------------

This is for XFree-4.0.1 port revision 9 through to (so far)
            XFree-4.0.2 port revision 5

cd /usr/ports/x11/XFree-4
make extract
make patch
make configure (answer the questions).

edit work/xc/config/cf/FreeBSD.cf

and add;

#define BuildXF86DRM YES
#define BuildXF86DRI YES
#define HasGlide3    YES

At the bottom before the 

#include <bsdLib.rules>

cd work/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel

Someone fell asleep at the wheel here over at VA-Linux, I assume it
was a CVS snapshot that was half finished... but, other than this
thing, good work :-)

Basically you want to change all references to SYSCTL_HANDLER_ARGS
to (SYSCTL_HANDLER_ARGS) in; 
drmP.h
drm/memory.c
drm/sysctl.c

edit tdfx/tdfx_drv.c and change
callout_init(&dev->timer) to
callout_init(&dev->timer,0)

go back to the top of your XFree-4 tree and do;
make
make install (if you already have XFree 4 installed you can probably
skip this and continue on from here to get the kernel modules you need).

Now you have to wander back down to  
work/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel

copy drm.ko to /usr/local/modules (or somewhere else convenient).
and copy tdfx/tdfx.ko to /usr/local/modules/tdfx_drm.ko (this clashes
with an existing native tdfx module for 'older' hardware). If this
wasn't built automatically just type make in the tdfx directory and it
should be built for you.

kldload drm.ko
this requires the agp module to load, even if you don't have an agp card.

kldload tdfx_drm.ko

You should see similar to this;
drm0: <3Dfx Voodoo 3 graphics accelerator> port 0xdc00-0xdcff mem 0xe8000000-0xe9ffffff,0xee000000-0xefffffff irq 0 at device 14.0 on pci0
info: [drm] Initialized tdfx 1.0.0 19991009 on minor 0

If all goes well make an entry in /usr/local/etc/rc.d that loads your
local modules on boot (or edit your /boot/ files if you're really game).

I have this in /usr/local/etc/rc.d/3dfx.sh
------------------------------------------------------------------------
#!/bin/sh

case $1 in
start)
	[ -d /usr/local/modules ] && (
	[ -x /usr/local/modules/drm.ko ] && (
		kldload /usr/local/modules/drm.ko
	)
	[ -x /usr/local/modules/tdfx_drm.ko ] && (
		kldload /usr/local/modules/tdfx_drm.ko
	)
	echo -n ' XF86-DRI'
	)
	;;
stop)
	kldunload tdfx_drm.ko
	kldunload drm.ko
	;;
*)
	echo "usage: `basename $0` {start|stop}" >&2
	exit 64
	;;
esac

------------------------------------------------------------------------


In your /etc/X11/XF86Config you need to also have

Load "glx"
Load "dri"

If you have an existing libGL.so.14 in /usr/X11R6/lib
mv it to libGL.so.14.old and symlink libGL.so.14 to libGL.so.1 
(ports requiring Mesa check for libGL.so.14, and will link to the hardware 
accelerated version).

3D acceleration only works in 16bpp mode, so make sure you're running
with your depth set to 16 when you start your XFree 4.

You should see drm entries in /var/log/XFree86.0.log;

(0): [drm] created "tdfx" driver at busid "PCI:0:14:0"
(0): [drm] added 4096 byte SAREA at 0xce95e000
(0): [drm] mapped SAREA 0xce95e000 to 0x1826d000
(0): [drm] framebuffer handle = 0xe8000000
(0): [drm] added 1 reserved context for kernel

and later...
(0): [DRI] installation complete
(II) TDFX(0): direct rendering enabled

(0) is the card number, if you have more than one you should get the same
comments with (1) (2) etc.

You'll probably also want to fix GiveConsole in your xdm config
to give permissions to /dev/dri/card*

Finally when running a GL program that dumps the GL stuff, if you see
this;

GL_VENDOR: Precision Insight, Inc.
GL_RENDERER: Mesa DRI Voodoo3 20000616
GL_VERSION: 1.2 Mesa 3.3 beta

or in this format with glxinfo

OpenGL vendor string: VA Linux Systems, Inc.
OpenGL renderer string: Mesa DRI Voodoo3 20001101
OpenGL version string: 1.2 Mesa 3.4

Then it's hardware accelerated, otherwise its linked to an older software
library.

Strange things:
glplanet only gives a white globe, no texture map (from xscreensaver)
Having stuff like nuq-glx (latest standalone quake) running and then going 
to a fullscreen GL app (ala screen saver kicks in) and then back does weird 
things with the modes (so don't leave windowed gl applications running :-)
Quitting the GL application generally gets you back to normal (that's if
you can actually quit the application).

-- 
Totally Holistic Enterprises Internet|  P:+61 7 3870 0066   | Andrew Milton
The Internet (Aust) Pty Ltd          |  F:+61 7 3870 4477   | 
ACN: 082 081 472 ABN: 83 082 081 472 |  M:+61 416 022 411   | Carpe Daemon
PO Box 837 Indooroopilly QLD 4068    |akm@theinternet.com.au| 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010131045430.R11513>