amonakov / primus

Low-overhead client-side GPU offloading
ISC License
218 stars 21 forks source link

primus

Primus is a shared library that provides OpenGL and GLX APIs and implements low-overhead local-only client-side OpenGL offloading via GLX forking, similar to VirtualGL. It intercepts GLX calls and redirects GL rendering to a secondary X display, presumably driven by a faster GPU. On swapping buffers, rendered contents are read back using a PBO and copied onto the drawable it was supposed to be rendered on in the first place. For more information, refer to [technotes.md] (https://github.com/amonakov/primus/blob/master/technotes.md).

To use, install or build from source and use primusrun wrapper script.

In distributions

Building for multilib (32-bit + 64-bit) systems

LIBDIR=lib make && CXX=g++\ -m32 LIBDIR=lib32 make

Adjust LIBDIR variables above as appropriate for your distribution (reflecting how /usr/lib* are named):

Issues under compositing WMs

Since compositing hurts performance, invoking primus when a compositing WM is active is not recommended. If you need to use primus with compositing and see flickering or bad performance, synchronizing primus' display thread with the application's rendering thread may help (can anyone investigate why?):

PRIMUS_SYNC=1 primusrun ...

This makes primus display the previously rendered frame. Alternatively, with PRIMUS_SYNC=2 primus will display the latest rendered frame, trading frame rate for reduced visual latency.

FAQ

Q: Performance does not exceed 60 fps, I was getting more with optirun/VirtualGL.
A: This is the effect of vblank synchronisation. For benchmarking, you can use vblank_mode=0 primusrun ..., but in practice this will probably only waste power, as your LCD panel does not display more than 60 frames per second anyway.