I’ve spent a day working on VectorStorm engine improvements, today. Those who aren’t interested in technical details should probably skip the rest of this post; sorry, guys!
Here’s the list of improvements:
2D Display lists now correctly calculate their bounding boxes, even if there are transforms applied within the display list. (previously, transforms within a display list were ignored for the purposes of calculating their visible size. This probably wouldn’t have affected anyone; it’s pretty unusual for a transform to be explicitly placed inside a display list that cares about its bounding box.
Bitmap font rendering now uses a vsBuffer to store each font glyph, so their data is stored on the GPU persistently, instead of needing to push explicit vertex positions and texture coordinates into the display list to draw text to the screen. As a result, font rendering commands now only take up about a third as much system memory as they used to. (My MMORPG Tycoon example was the string “Monster Type”, which dropped from requiring 1232 bytes of display list data to draw under the old system, to requiring only 352 bytes of display list data now that it’s using vsBuffers to store its vertex data.)
As a quick reminder, vsBuffer is my wrapper around OpenGL’s concept of VBOs (“Vertex Buffer Objects”), which are designed to store blobs of frequently-used data on the GPU. The vsBuffer will also transparently fall-back to OpenGL’s older “array” functionality, for folks whose 3D cards or drivers don’t support VBOs. Today, I have implemented interleaved VBOs within vsBuffer.
The old way of using vsBuffer was to give it an array of positions or colors or some other data type, and then put a command onto a display list telling the renderer what to do with the buffer. (For example, you might tell it to use one buffer as a vertex position buffer, and another one as a normal buffer, and yet another as a texture coordinate buffer, each storing one type of data about each vertex to be drawn.) That old code will all still work. However, you can now use the explicit vertex formats exposed by the vsBuffer, such as “PNT”, for vertices which specify a position, a normal, and a texture coordinate. The vsBuffer places all these bits of data together into a single OpenGL VBO, interleaved for fast access. You bind these interleaved buffers by giving a “BindBuffer” command to the display list. When finished, you can either give an “UnbindBuffer”, or “ClearAllArrays” command.
I’ve also converted the vsMesh utility class to automatically use its internal vsBuffers in interleaved mode, when it can. So if you were already using the vsMesh or the vsMeshMaker (as I do in MMORPG Tycoon 2), you’ll automatically get this improvement.
With that said, I only see a moderate performance improvement on my laptop, but every little bit helps. And I’m reliably informed that on embedded systems (such as mobile phones) that having interleaved VBOs gives substantially improved performance. And someday I might want to look into things like that, I suppose.
Anyhow, as is often the case with these sorts of improvements, I’ve done this in my MMORPG Tycoon 2 development branch; these changes haven’t yet been migrated back into the main publicly accessible VectorStorm trunk. But I’ll get to that eventually. :)