| 1 | primus |
| 2 | ====== |
| 3 | |
| 4 | Primus is a shared library that provides OpenGL and GLX APIs and |
| 5 | implements low-overhead |
| 6 | local-only client-side OpenGL offloading via GLX forking, similar to |
| 7 | VirtualGL. It intercepts GLX calls and redirects GL rendering to a |
| 8 | secondary X display, presumably driven by a faster GPU. On swapping |
| 9 | buffers, rendered contents are read back using a PBO and copied onto |
| 10 | the drawable it was supposed to be rendered on in the first place. |
| 11 | For more information, refer to [technotes.md] |
| 12 | (https://github.com/amonakov/primus/blob/master/technotes.md). |
| 13 | |
| 14 | To use, install or build from source and use `primusrun` wrapper script. |
| 15 | |
| 16 | In distributions |
| 17 | ---------------- |
| 18 | |
| 19 | * Arch: [primus-git](https://aur.archlinux.org/packages.php?ID=63239) |
| 20 | and [lib32-primus-git](https://aur.archlinux.org/packages.php?ID=63240) |
| 21 | in AUR |
| 22 | * Gentoo: `primus-9999.ebuild` in the `bumblebee` overlay |
| 23 | * Ubuntu: in the [Bumblebee PPA](https://launchpad.net/~bumblebee/+archive/stable) |
| 24 | |
| 25 | Building for multilib (32-bit + 64-bit) systems |
| 26 | ----------------------------------------------- |
| 27 | |
| 28 | LIBDIR=lib make && CXX=g++\ -m32 LIBDIR=lib32 make |
| 29 | |
| 30 | Adjust `LIBDIR` variables above as appropriate for your distribution |
| 31 | (reflecting how `/usr/lib*` are named): |
| 32 | |
| 33 | * Arch needs `lib` and `lib32` as above |
| 34 | * Gentoo needs `lib64` and `lib32` |
| 35 | * RPM-based may need `lib64` and `lib` |
| 36 | * Debian (with multiarch) needs `lib/x86_64-linux-gnu` and `lib/i386-linux-gnu` |
| 37 | * Ubuntu (with multiarch) seems rather inconsistent. The dynamic linker |
| 38 | expands `$LIB` to `x86_64-linux-gnu`/`i386-linux-gnu` (without `lib/`), but |
| 39 | Nvidia drivers are installed into `/usr/lib{,32}/nvidia-current`. Something |
| 40 | like the following is needed: |
| 41 | |
| 42 | export PRIMUS_libGLd='/usr/lib/$$LIB/mesa/libGL.so.1' |
| 43 | LIBDIR=x86_64-linux-gnu make |
| 44 | LIBDIR=i386-linux-gnu CXX=g++\ -m32 make |
| 45 | unset PRIMUS_libGLd |
| 46 | |
| 47 | Starting from 13.04, Ubuntu needs the same `LIBDIR` paths as Debian (with |
| 48 | leading `lib/`); consequently, `lib/` in `PRIMUS_libGLd` should be omitted. |
| 49 | |
| 50 | Furthermore, `libnvidia-tls.so` is not present in default shared library |
| 51 | search directories. Uncomment the corresponding line in `primusrun`. |
| 52 | |
| 53 | Issues under compositing WMs |
| 54 | ---------------------------- |
| 55 | |
| 56 | Since compositing hurts performance, invoking primus when a compositing WM is |
| 57 | active is not recommended. If you need to use primus with compositing and see |
| 58 | flickering or bad performance, synchronizing primus' display thread with the |
| 59 | application's rendering thread may help (can anyone investigate why?): |
| 60 | |
| 61 | PRIMUS_SYNC=1 primusrun ... |
| 62 | |
| 63 | This makes primus display the previously rendered frame. Alternatively, |
| 64 | with `PRIMUS_SYNC=2` primus will display the latest rendered frame, trading |
| 65 | frame rate for reduced visual latency. |
| 66 | |
| 67 | FAQ |
| 68 | --- |
| 69 | |
| 70 | Q: Performance does not exceed 60 fps, I was getting more with optirun/VirtualGL. |
| 71 | A: This is the effect of vblank synchronisation. For benchmarking, you can use |
| 72 | `vblank_mode=0 primusrun ...`, but in practice this will probably only waste power, |
| 73 | as your LCD panel does not display more than 60 frames per second anyway. |