14 Aug 2008 fzort   » (Journeyer)

OpenGL Optimization Notes - 1

The particles in my game are rendered as texture-mapped, transparent quads [1]. When I had lots (>1000) of particles on the screen at the same time, there was noticeable performance degradation with my GeForce FX. Now, to render the quads, I'm filling a big vertex array with the coordinates/color/texture coordinates for the vertices of all particles in the scene, and calling glDrawArray once. Initially, I assumed that the problem was caused by limited CPU->GPU bandwidth, so I tried different things: changed the data type for glColorArray from GL_FLOAT to GL_UNSIGNED_BYTE, did a similar thing for the texture coordinate array, and tried to use the vertex buffer object extension [2]. None of these improved things. Then I changed the texture size from 128x128 to 16x16 (the particles are quite small, so visually the change wasn't noticeable), and suddenly everything got quite fast!

In fact, since the texture is quite simple (just a linear function of distance from a point the center of the texture), perhaps I don't even need the texture - I can compute the intensity inside a fragment shader (nVidia says that their GPUs can compute square roots essentially for nothing). I'll try that some day.

[1] I can't use the point sprite extension since I want the particles to be rotated. Also, Intel graphics hardware doesn't support that extension (the initial motivation for the game was Intel's Game Demo Contest).

[2] There wasn't noticeable performance improvement on the GeForce, and - worse - despite being advertised as available by the Intel OpenGL drivers, the program exploded on *ndows, and didn't display anything on Linux (it worked fine with both nVidia and Mesa).

Latest blog entries     Older blog entries

New Advogato Features

FOAF updates: Trust rankings are now exported, making the data available to other users and websites. An external FOAF URI has been added, allowing users to link to an additional FOAF file.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!