[HOpenGL] GlxGears

Sven Panne Sven.Panne at aedion.de
Sat Mar 20 01:01:00 EST 2004


I wrote:
> Shawn P. Garbett wrote:
>> [...]
>> Haskell Version on my laptop, FPS = 103
>> C Version on my laptop, FPS = 192
>> [...]
> 
> I just gave your example a quick try on my PC, the results do not differ
> that much for my setup (SuSE x86 Linux 8.2, 3GHz P4, NVIDIA FX 5900):
> 
>    Haskell version: 6000 FPS
>    C version: 7165 FPS
> [...]

I've just overhauled your example and it's now in the GLUT examples:

    http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/GLUT/examples/Misc/Gears.hs

(Well, it's visible there when the mysterious cron job has done its job to
update the anonymous CVS repository...  :-P)   The good news: It runs with
7162 FPS now, which is only 0.03% slower than the C version! :-)  The problem
with your version was that due to some minor buglets it rendered a slightly
different scene, backface culling was not enabled, and some normals were
missing. Using ltrace to compare the libGL/libglut library calls of the C
version with the ones of the Haskell version was very helpful here. Furthermore,
there was a small transient space leak (the frame counter). Note that I haven't
even incorporated SimonM's hint of using strict unboxed constructor fields yet,
but I'll do that probably soon, anyway. It might not only help performance, but
also avoids some potential space leaks.

Playing around with various window sizes, it becomes clear that in this example
rasterization and framebuffer access dominates: The product of the number of
window pixels and the FPS is nearly constant for my platform, but your mileage
may vary here. For a nice introduction to performance tuning OpenGL apps see:

    http://developer.nvidia.com/docs/IO/8230/GDC2003_OGL_Performance.pdf

Perhaps I should cross-post to the "Haskell performance" thread... :-))

Cheers,
    S.



More information about the HOpenGL mailing list