File:  [NetBSD Developer Wiki] / wikisrc / tutorials / x11 / compiz.mdwn
Revision 1.1: download - view: text, annotated - select for diffs
Fri Nov 27 10:14:07 2009 UTC (4 years, 4 months ago) by imil
Branches: MAIN
CVS tags: HEAD
Added DRI/Compiz tutorial

## Eye Candy for NetBSD 5.0

Since a couple of years, there are some Window Managers providing shiny 3D effects like a cube-mapped-desktop, wobbly windows and various other animations.

NetBSD is capable of dealing with those interfaces, but their installation is not yet straightforward. Here are the couple of steps you'll have to go through in order to impress your friends with a modern 3D NetBSD desktop.

### Enable DRM in the kernel

Depending on the graphic card you are using, add one of the following to your kernel configuration:

	i915drm*        at vga?         # Intel i915, i945 DRM driver
	mach64drm*      at vga?         # mach64 (3D Rage Pro, Rage) DRM driver
	mgadrm*         at vga?         # Matrox G[24]00, G[45]50 DRM driver
	r128drm*        at vga?         # ATI Rage 128 DRM driver
	radeondrm*      at vga?         # ATI Radeon DRM driver
	savagedrm*      at vga?         # S3 Savage DRM driver
	sisdrm*         at vga?         # SiS DRM driver
	tdfxdrm*        at vga?         # 3dfx (voodoo) DRM driver

For example, if your graphic card has an intel 945GM chip and your architecture is amd64-based:

	# cd /usr/src/sys/arch/amd64/conf
	# echo "i915drm*        at vga?" >> MYKERNEL

Then recompile and copy your kernel [as usual]( as usual).

### Modular Xorg

The next step involves the Xorg server. Xorg 1.4.2 which is the version bundled with NetBSD 5.0 has no real [AiGLX]( support. While Xorg.0.log will pretend AiGLX is enabled, it does not load the X dri driver related to your GPU. In order to have full AiGLX support, you will have to use pkgsrc's modular Xorg.
Refer to [this article]( see how to achieve this simple -but long- task.

Once modular Xorg is installed, you'll have to tell *gdm* not to start the base Xorg server, but the new one installed by *pkgsrc*. Edit */usr/pkg/etc/gdm/custom.conf* and add the following lines:

	name=Standard server
	command=/usr/pkg/bin/X vt05 -audit 0

Those using *startx* instead should create a *${HOME}/.xserverrc* with the following content:

	exec /usr/pkg/bin/X vt05 -audit 0

Update your *${PATH}* variable so */usr/pkg/bin* comes before */usr/X11R{6,7}/bin*, i.e.:

	export PATH

### Xorg configuration

Exit from any X Window environment you might be using and run:

	# Xorg -configure

This should produce a valid *xorg.conf* file in your *${HOME}* directory, just copy it to */etc/X11/xorg.conf*. Here is a typical *xorg.conf* file with necessary bits for DRI, AiGLX and Composite extensions to be loaded and operationals:

	Section "ServerLayout"
	        Identifier     " Configured"
	        Screen      0  "Screen0" 0 0
	        InputDevice    "Mouse0" "CorePointer"
	        InputDevice    "Keyboard0" "CoreKeyboard"
	Section "Files"
	        ModulePath   "/usr/pkg/lib/xorg/modules"
	        FontPath     "/usr/pkg/lib/X11/fonts/misc/"
	        FontPath     "/usr/pkg/lib/X11/fonts/TTF/"
	        FontPath     "/usr/pkg/lib/X11/fonts/OTF"
	        FontPath     "/usr/pkg/lib/X11/fonts/Type1/"
	        FontPath     "/usr/pkg/lib/X11/fonts/100dpi/"
	        FontPath     "/usr/pkg/lib/X11/fonts/75dpi/"
	Section "Module"
	        Load  "dbe"
	        Load  "dri"
	        Load  "dri2"
	        Load  "extmod"
	        Load  "glx"
	Section "InputDevice"
	        Identifier  "Keyboard0"
	        Driver      "kbd"
	        Option      "XkbRules"   "xorg"
	        Option      "XkbModel"   "pc105"
	        Option      "XkbLayout"  "us"
	        Option      "XkbOptions" "compose:ralt"
	Section "InputDevice"
	        Identifier  "Mouse0"
	        Driver      "mouse"
	        Option      "Protocol" "wsmouse"
	        Option      "Device" "/dev/wsmouse"
	        Option      "ZAxisMapping" "4 5 6 7"
	Section "Monitor"
	        #DisplaySize      330   210     # mm
	        Identifier   "Monitor0"
	        VendorName   "LPL"
	        ModelName    "2900"
	Section "Device"
	        Option      "DRI" "true"
	        Option      "AccelMethod" "XAA" # needed for 945GM GPUs
	        Option      "XAANoOffscreenPixmaps" "true"
	        Option      "AllowGLXWithComposite" "true"
	        Identifier  "Card0"
	        Driver      "intel"
	        VendorName  "Intel Corporation"
	        BoardName   "Mobile 945GM/GMS, 943/940GML Express Integrated Graphics Controller"
	        BusID       "PCI:0:2:0"
	Section "Screen"
	        Identifier "Screen0"
	        Device     "Card0"
	        Monitor    "Monitor0"
	        SubSection "Display"
	                Viewport   0 0
	                Depth     1
	        SubSection "Display"
	                Viewport   0 0
	                Depth     4
	        SubSection "Display"
	                Viewport   0 0
	                Depth     8
	        SubSection "Display"
	                Viewport   0 0
	                Depth     15
	        SubSection "Display"
	                Viewport   0 0
	                Depth     16
	        SubSection "Display"
	                Viewport   0 0
	                Depth     24
	Section "ServerFlags"
	        Option "AIGLX" "true"
	Section "DRI"
	        Mode 0666
	Section "Extensions"
	        Option "Composite" "Enable"

### Checklist

Now reboot your NetBSD computer with the previously compiled kernel. When Xorg starts, you should see the following kernel messages using dmesg:

	error: [drm:pid389:i915_getparam] *ERROR* i915_getparam called with no initialization
	i915drm0: interrupting at ioapic0 pin 16
	error: [drm:pid389:i915_getparam] *ERROR* Unknown parameter 5

Error messages can safely be ignored, they mean you're not running a GNU/Linux kernel >= 2.6.28.
Xorg.0.log now should contain the following messages:

	(**) AIGLX enabled
	(II) Loading extension GLX
	(II) LoadModule: "intel"
	(II) Loading /usr/pkg/lib/xorg/modules/drivers//
	drmOpenDevice: node name is /dev/dri/card0
	drmOpenDevice: open result is 8, (OK)
	drmOpenDevice: node name is /dev/dri/card0
	drmOpenDevice: open result is 8, (OK)
	drmOpenByBusid: Searching for BusID pci:0000:00:02.0
	drmOpenDevice: node name is /dev/dri/card0
	drmOpenDevice: open result is 8, (OK)
	drmOpenByBusid: drmOpenMinor returns 8
	drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
	(II) [drm] DRM interface version 1.2
	(II) [drm] DRM open master succeeded.
	(II) intel(0): [DRI] installation complete
	(II) AIGLX: enabled GLX_SGI_make_current_read
	(II) AIGLX: enabled GLX_MESA_copy_sub_buffer
	(II) AIGLX: enabled GLX_SGI_swap_control and GLX_MESA_swap_control
	(II) AIGLX: enabled GLX_texture_from_pixmap with driver support
	(II) AIGLX: Loaded and initialized /usr/pkg/lib/dri/
	(II) GLX: Initialized DRI GL provider for screen 0

Meaning your X11 environment can now play well with 3D gadgets.

### Running compiz

In order to test your new X Window powers, install the following packages using your favourite method (pkgsrc, pkg_add, pkgin...):


As of 26/11/2009, *pkgsrc-2009Q3* binary version of those packages is 0.6.0. If you'd like to use the latest compiz version (0.8.4), you'll have to install it using current version of *pkgsrc*.

Once done, if you use the GNOME desktop, start compiz with this little script:

	# compiz 0.6's --replace does not kill properly metacity
	pkill metacity
	# for intel cards, add INTEL_BATCH=1 to the following command
	LIBGL_ALWAYS_INDIRECT=1 /usr/pkg/bin/compiz --replace --indirect-rendering ccp &

If your windows don't have decorations, launch the ccsm utility and under the "Effect" section, check "Window Decoration".

0.6 version of compiz is old and suffers a known bug, instead of using metacity's themes, it draws white translucent borders. A [patch]( is available for the gtk-window-decorator program that fixes it, but if you don't feel like patching / compiling, revert to compiz's default windows decorator:

	$ gconftool-2 --set /apps/gwd/use_metacity_theme false --type bool

It's now up to you to play along with ccsm and try all those shiny effects you'll soon be unable to miss :)

Mandatory screenshot:
[Shiny Disco Balls !](

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb