this is a guide for everyone using an Intel i915 graphics chipset on their system and just having updated their X stack to xorg-server-1.5 plus mesa-7.1.
The problem:
mesa's i915 driver is dead slow when not backed up by a memory manager like TTM or GEM (the one that replaced TTM). mesa-7.1 only supports the TTM API, since the GEM code was not merged before the release.
In more detail: The mesa-7.1 release was done from the 7.2-branch of the mesa/mesa repository hosted on FDO. Take a look at it:
http://gitweb.freedesktop.org/?p=mesa/m ... 7_2_branch
The GEM part was already merged, but for the 7.2-branch it was reverted, leaving mesa-7.1 only with TTM support. Furthermore this is deactivated inside the standard ebuild that is currently found in portage.
Without TTM the Intel i915 is especially slow when it comes to OpenGL's glDrawPixels and glReadPixels calls, these are for example use by wine for some emulation features for old DX versions. Moreover these calls are pretty performance critical.
Also some extensions like PBO (pixel buffer objects) and FBO (frame buffer objects) are not exported by the driver when no memory manager is found. Again wine suffers when these extensions are lacking. Trying to play any kind of (old) windows games through wine on a Intel i915 is not an option because it results in a slide show.
So it's time to change this and get some performance out of the chip.
The setup:
My current setup looks like this:
- xorg-server-1.5.0
- mesa-7.1
- xf86-video-i810-2.4.2-r1
- libdrm-2.3.1
- gentoo-sources-2.6.26-r1
Searching for TTM:
The big problem is that the latest git master snapshot of mesa/drm already has TTM ripped out and replaced by GEM. We can't use GEM with the mesa version we have installed. In my case I didn't want to update mesa to git as well. The worst thing I wanted to do at this point was patching the mesa ebuild, nothing more. No upgrading all the X stack to git, THIS was not an option for me.
So I had to find a snapshot of mesa/drm with TTM still intact. Looking at the commit history indicated that this snap should do it:
http://gitweb.freedesktop.org/?p=mesa/d ... e611f4e95d
The commit after this one merges the GEM branch and a commit or two later the TTM API is ripped out. So we want this specific version:
Code: Select all
git clone git://anongit.freedesktop.org/git/mesa/drm drm-ttm
cd drm-ttm
git checkout -b ttm 46e9274e8538e5b0517f611dca99dde611f4e95d
Patching the kernel:
We also need to patch the gentoo-sources-2.6.26-r1 tree, otherwise we'll get three unknown symbol errors when compiling.
You need two patches I uploaded here:
http://www.math.uni-bielefeld.de/~tjakobi/drm-ttm/
One additional thing you have to patch manually (I didn't find a patch and didn't bother to create one myself) is the file:
arch/x86/kernel/init_task.c
There you replace "EXPORT_UNUSED_SYMBOL(init_mm);" with "EXPORT_SYMBOL(init_mm);"
This should do it, don't forget to recompile your kernel though (and reboot before modprobbing the module later on).
Packaging libdrm:
I was going to name my ebuild libdrm-2.4.0-r1 and put it into my local overlay.
Code: Select all
cp -R drm-ttm libdrm-2.4.0
cd libdrm-2.4.0
rm -rf bsd-core ; rm -rf linux-core
Code: Select all
libdrm/Makefile.am:
libdrm_la_LDFLAGS = -version-number 2:3:0 -no-undefined
Code: Select all
./autogen.sh
make
make clean && make distclean
rm -rf autom4te.cache
Code: Select all
cd ..
tar cvjf libdrm-2.4.0.tar.bz2 libdrm-2.4.0/
Now copy the libdrm-2.3.1.ebuild over to your overlay (x11-libs/libdrm), renaming it to libdrm-2.4.0-r1.ebuild (don't forgot to add keywords to your package.keywords file). You have to change the "SRC_URI" line in the ebuild as well. Just change the extension of the archive from gz to bz2.
Code: Select all
ebuild libdrm-2.4.0-r1.ebuild digest
Please note: This can also possibly be done by grabbing a GIT (9999) ebuild and forcing it to checkout a specific version (the commit ID I mentioned above). I didn't try that myself and did it the more "manual" way.
Patching mesa ebuild
The current mesa ebuild in portage always has TTM disabled, we want to change that. Copy the mesa-7.1.ebuild over to your overlay (media-libs/mesa), renaming to to something like mesa-7.1-r1.ebuild (think about your package.keywords). Now look for this line:
Code: Select all
myconf="${myconf} --disable-ttm-api"
The DRM kernel module:
I did not create a x11-drm ebuild for that one. One reason is that the important part of the ebuild is the kernel module itself. I'm not sure if it is that important to have this managed by portage.
So I'm just building this directly from my drm-ttm directory. However there is one include missing in linux-core, so we add it here:
Code: Select all
cd drm-ttm/linux-core
wget "http://www.math.uni-bielefeld.de/~tjakobi/drm-ttm/i915_gem.h"
Code: Select all
#include "drmP.h"
#include "drm.h"
#include "i915_drm.h"
#include "i915_drv.h"
#include "i915_gem.h"
Code: Select all
cd drm-ttm
./autogen.sh
CFLAGS="..." LDFLAGS="..." ./configure
cd linux-core
make DRM_MODULES="i915"
Code: Select all
depmod -a
modprobe i915
Testing TTM:
Restart your X and check with glxinfo for GL_ARB_pixel_buffer_object and GL_EXT_framebuffer_object. If it's there your mesa i915 driver should now be powered by TTM.
At least it's now for me.
Appendix:
I should note that this is only temporary solution to the 3D acceleration problem on Intel i915 hardware.
We already have a 2.6.27-rc kernel branch patched with the latest DRM-GEM code (Eric Anholt's linux-2.6 tree on FDO) and can expect that GEM gets merged upstream in the 2.6.28 kernel.
Meanwhile a new xf86-video-i810/intel driver should be out, with the GEM branch merged and fully utilizing the power of the new memory manager. As soon as the 2.6.28 kernel (with GEM) and the corresponding intel (2D) driver is out, I'm going to upgrade again - this time also to mesa git master.
Please note that TTM was never actually "released" and it's not supported in any way. So if your system crashes, lockups, whatever you won't get any kind of support. Not from me, not from the mesa, X or kernel guys. That's different with GEM because Intel is currently pushing it by a great deal.
So only use this (hackish) approach as long as you have to.
Greets,
Tobias


