[Mesa-dev] FreeGLUT performance - pointless X server roundtrip

Keith Whitwell keithw at vmware.com
Tue Feb 22 02:50:58 PST 2011

I've always wondered why freeGLUT gives such poor numbers for gears and
similar high-framerate demos relative to the original.

It looks like one reason is the code added for Spaceball handling which
tries to initialize the Spaceball device every frame, even if it
previously failed.  The trouble being that this introduces an
unnecessary X server round-trip each frame:

#0  0x00007ffff68bf870 in _XReply () from /usr/lib/libX11.so.6
#1  0x00007ffff68a1c84 in XInternAtom () from /usr/lib/libX11.so.6
#2  0x00007ffff7bb4c1f in fgInitialiseSpaceball () from /usr/lib/libglut.so.3
#3  0x00007ffff7bb5015 in fgSpaceballSetWindow () from /usr/lib/libglut.so.3
#4  0x00007ffff7bbb5db in fgSetWindow () from /usr/lib/libglut.so.3
#5  0x00007ffff7bb5df1 in ?? () from /usr/lib/libglut.so.3
#6  0x00007ffff7bb99f9 in fgEnumWindows () from /usr/lib/libglut.so.3
#7  0x00007ffff7bb62d2 in glutMainLoopEvent () from /usr/lib/libglut.so.3
#8  0x00007ffff7bb6c67 in glutMainLoop () from /usr/lib/libglut.so.3
#9  0x00000000004032e2 in main (argc=1, argv=0x7fffffffe078)

Basically the spaceball code doesn't remember that it failed last time &
keeps trying to initialize itself.  This code went in at the end of

I have a patch, but can't seem to get freeglut to build to test it
(autogen.sh fails on demos/Error directory???) so hoping one of the glut
maintainers can look at this.

FWIW, I get:

nvidia, freeglut, gears:   2600fps
nvidia, origglut, gears:   5000fps
llvmpipe, freeglut, gears:  499fps
llvmpipe, origglut, gears: 1300fps

It also shows up in much less framerate-bound apps:

llvmpipe, freeglut, tunnel: 56fps
llvmpipe, origglut, tunnel: 68fps

Patch attached, but consider untested.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: spaceball.diff
Type: text/x-patch
Size: 2671 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110222/bf421ff0/attachment.bin>

More information about the mesa-dev mailing list