Installing and using PRIME (real Optimus solution) :::::::::::::::::::::::::::::::::::::::::::::::::: WARNING: installing PRIME at this stage is not for the light-hearted. PRIME-related and unrelated code (e.g. code in development) may break your X server. Keep a copy of your working X stack to avoid frustration, e.g. by installing to /opt. Dave Airlie's repos are located at http://cgit.freedesktop.org/~airlied. You need to install git to get these, and a compiler for being able to build everything. Some basic knowledge of building software is required, otherwise you may break your machine without even knowing why... these instructions are not meant for the novice. PRIME currently does not work with the proprietary nvidia blob although NVIDIA seems to be talking about it (pasted by Eric Appleman from #dri-devel, http://pastebin.com/saCEbugb). My trees from Dave are located at /src/airlied/. In that directory, I checked out repositories as mentioned in http://people.freedesktop.org/~airlied/prime-notes.txt: randr + client: git://people.freedesktop.org/~airlied/randrproto prime git://people.freedesktop.org/~airlied/libXrandr prime git://people.freedesktop.org/~airlied/xrandr prime dri2proto: git://people.freedesktop.org/~airlied/dri2proto prime libdrm: git://people.freedesktop.org/~airlied/drm prime mesa: git://people.freedesktop.org/~airlied/mesa prime (simple patch should probably just pick onto master) xserver: git://people.freedesktop.org/~airlied/xserver prime-101 drivers: git://people.freedesktop.org/~airlied/xf86-video-nouveau prime git://people.freedesktop.org/~airlied/xf86-video-intel prime When retrieving other repos, I install those in /src/. Anyway, it does not really matter, the commands in the .bashrc below can handle either. Adjust the below path for your distro and setup if necessary. cat >> ~/.bashrc <<'EOF' getsdir() { local d i;for i in airlied xorg; do d=/src/$i/$P; [ -f $d/configure -o -f $d/autogen.sh ]&&echo $d&&return 0;done;return 1;} md() { P=$1;[ -d ~/build/$P ]||mkdir ~/build/$P;cd ~/build/$P;} ag() { local d;P=$1;shift;md $P;if d=$(getsdir);then "$d/autogen.sh" --prefix=/opt/xorg "$@";fi;} : optional bash autocompletion _xsrc_dir() { [ $COMP_CWORD != 1 ]||COMPREPLY=( $(compgen -W "$(find /src/airlied /src/xorg -mindepth 1 -maxdepth 1 -type d -printf "%f ")" -- "${COMP_WORDS[1]}"));} complete -F _xsrc_dir md . /usr/share/bash-completion/completions/configure _xcd_autogen() { P=${COMP_WORDS[1]};local d;if [ $COMP_CWORD = 1 ];then _xsrc_dir "$@" elif d=$(getsdir);then shift 2;_configure $d/configure "$@";fi;} complete -F _xsrc_dir md . /usr/share/bash-completion/completions/configure _xcd_autogen() { P=${COMP_WORDS[1]};if [ $COMP_CWORD = 1 ];then _xsrc_dir "$@";else shift 2;_configure /src/airlied/$P/configure "$@";fi;} complete -F _xcd_autogen ag : update build instructions export ACLOCAL="aclocal -I /opt/xorg/share/aclocal" export PKG_CONFIG_PATH=/opt/xorg/lib/pkgconfig:/opt/xorg/share/pkgconfig:/opt/mesa/lib/pkgconfig:${PKG_CONFIG_PATH} export LD_LIBRARY_PATH=/opt/xorg/lib:${LD_LIBRARY_PATH} export LD_RUN_PATH=/opt/xorg/lib:${LD_RUN_PATH} EOF : if you have more machines, borrow their CPU power using distcc alias make='make -j$(distcc -j)' git clone git://anongit.freedesktop.org/git/xorg/util/macros cd macros ./autogen.sh --prefix=/opt/xorg # make install : from airlie ag randrproto # make install : for xext xextproto xrender renderproto # pacman -S libxrender libxext : from airlie ag libXrandr make # make install : from airlie ag xrandr make # make install : from airlie ag dri2proto # make install : from airlie wget -O no-pthread-stubs.patch \ https://projects.archlinux.org/svntogit/packages.git/plain/trunk/no-pthread-stubs.patch?h=packages/libdrm patch -d /src/airlied/drm -p1 < no-pthread-stubs.patch # pacman -S libpciaccess ag drm --disable-radeon make : Mesa # pacman -S imake glproto libxfixes libxdamage : Stupid MAPI script is a python script. # pacman -S python2 libxml2 git clone git://anongit.freedesktop.org/mesa/mesa : mesa-8.0.3 is broken for nouveau, let us try master wget -O prime-support-for-mesa.patch \ http://cgit.freedesktop.org/~airlied/mesa/patch/?id=444159aae6a0a9b9cc0514f34ba754469b0d2dc2 patch -d mesa -p1 < prime-support-for-mesa.patch : Mesa you suck, why cannot I make an out-of-tree build?! cd /src/mesa ./autogen.sh --prefix=/opt/mesa \ --with-dri-drivers=i965,nouveau,swrast \ --with-gallium-drivers=nouveau,swrast \ --enable-gallium-egl --enable-gallium-llvm \ --enable-gles1 --enable-gles2 --enable-texture-float make # make install : Xserver, from airlie : build fix: add @GL_CFLAGS@ to AM_CFLAGS in hw/xfree86/dixmods/Makefile.am # pacman -S xorg-font-util xtrans pixman # pacman -S xcmiscproto bigreqsproto inputproto fontsproto videoproto compositeproto recordproto scrnsaverproto resourceproto xineramaproto xf86driproto # pacman -S libxkbfile libxfont libxv ag xserver --enable-ipv6 \ --enable-dri \ --enable-dri2 \ --disable-dmx \ --enable-xvfb \ --enable-xnest \ --enable-composite \ --enable-xcsecurity \ --enable-xorg \ --enable-xephyr \ --enable-glx-tls \ --enable-kdrive \ --enable-kdrive-evdev \ --enable-kdrive-kbd \ --enable-kdrive-mouse \ --enable-install-setuid \ --enable-config-udev \ --disable-config-dbus \ --enable-record \ --disable-xfbdev \ --disable-xfake \ --disable-static \ --with-xkb-path=/usr/share/X11/xkb --with-xkb-output=/var/lib/xkb \ --with-fontrootdir=/usr/share/font : intel driver, from airlie ag xf86-video-intel make # make install : nouveau, from airlie ag xf86-video-nouveau make # make install : rebuild for new Xorg ABI, otherwise you cannot move your mouse nor type : something. Not even switch to a text console! git clone git://anongit.freedesktop.org/xorg/driver/xf86-input-evdev cd xf86-input-evdev;git checkout xf86-input-evdev-2.7.0 ag xf86-input-evdev make # make install # pacman -S mtdev git clone git://anongit.freedesktop.org/xorg/driver/xf86-input-synaptics cd xf86-input-synaptics;git checkout xf86-input-synaptics-1.6.0 ag xf86-input-synaptics : Post-installation: Make /opt/mesa/lib and /opt/xorg/lib available in your libraries path. For example, create a file in /etc/ld.so.conf.d/ and run ldconfig. This did not fully work for me, so I created a file in /etc/profile.d/ that exports LD_LIBRARY_PATH=/opt/mesa/lib:/opt/xorg/lib:$LD_LIBRARY_PATH and also PATH=/opt/xorg/bin:$PATH to ensure that the new X stack is loaded. Then, symlink /usr/bin/X to /opt/xorg/bin/xorg (necessary for KDM, possibly others). Backup /usr/bin/X if it is not a symlink as is the case with Ubuntu. Restart X and you should login. : Testing Before X loads, make sure the kernel modules i915 and nouveau are loaded. Start X, you should see intel and nouveau in the xorg logs. $ xrandr --listproviders ... Providers: number : 2 Provider 0: id: 106 cap: b nc: 2 no: 4 nap 0 name:Intel Provider 1: id: 68 cap: 5 nc: 2 no: 3 nap 0 name:nouveau The capabilities ("cap") are shown as a hexadecimal number. Each bit is a combination of capabilies: - bit 0 (1) Source output - bit 1 (2) Sink Output - bit 2 (4) Source offload - bit 3 (8) Sink offload - "Sink" means that something can go into it. - "Source" means that something comes from it. - "output" means the device that should show something on a display. - "offload" refers to the device that should do rendering. See also http://airlied.livejournal.com/75555.html for a more detailled expanation of these roles. In the previous xrandr output, the intel provider has bit 3 set which means that it is a sink offload. The nouveau provider has bit 2 set which means that it is a source offload. In revision 8 (since 5 July 2012), the way to change the provider roles changed. Case: show things on the display driven by the intel GPU while rendering stuff on the nvidia GPU (nouveau driver). Since nouveau (ID 68) is doing rendering, it is an offload source. We would like to allow to redirect the rendered things to intel (ID 106), making intel an offload sink. The command for turning a provider into an offload sink is: xrandr --setprovideroffloadsink In our case, the command becomes: xrandr --setprovideroffloadsink 68 106 Be sure that the library path points to the Mesa installation. If necessary set LD_LIBRARY_PATH to include it. With the above installation instructions, this would be: export LD_LIBRARY_PATH=/opt/mesa/lib Tests: glxinfo - should give Intel DRI_PRIME=1 glxinfo should give nvidia DRI_PRIME=1 openarena should maybe work If you get a black screen testing an OpenGL application (e.g. glxgears), check your kernel logs. On my NVC1 chip (a GT425M), my logs got spammed with PGRAPH errors. In cooperation with the #nouveau people, this could be fixed