{"id":1247,"date":"2010-05-01T01:21:51","date_gmt":"2010-04-30T14:21:51","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=1247"},"modified":"2010-05-01T01:23:50","modified_gmt":"2010-04-30T14:23:50","slug":"vectorstorm-engine-improvements","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2010\/05\/01\/vectorstorm-engine-improvements\/","title":{"rendered":"VectorStorm engine improvements"},"content":{"rendered":"
I’ve spent a day working on VectorStorm engine improvements, today. \u00a0Those who aren’t interested in technical details should probably skip the rest of this post; \u00a0sorry, guys!<\/p>\n
Here’s the list of improvements:<\/p>\n
2D Display lists now correctly calculate their bounding boxes, even if there are transforms applied within the display list. \u00a0(previously, transforms within a display list were ignored for the purposes of calculating their visible size. \u00a0This probably wouldn’t have affected anyone; \u00a0it’s pretty unusual for a transform to be explicitly placed inside a display list that cares about its bounding box.<\/p>\n
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. \u00a0As a result, font rendering commands now only take up about a third as much system memory as they used to. \u00a0(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.)<\/p>\n
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. \u00a0The vsBuffer will also transparently fall-back to OpenGL’s older “array” functionality, for folks whose 3D cards or drivers don’t support VBOs. \u00a0 Today, I have implemented interleaved VBOs within vsBuffer.<\/p>\n
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. \u00a0(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.) \u00a0That old code will all still work. \u00a0However, 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. \u00a0The vsBuffer places all these bits of data together into a single OpenGL VBO, interleaved for fast access. \u00a0You bind these interleaved buffers by giving a “BindBuffer” command to the display list. \u00a0When finished, you can either give an “UnbindBuffer”, or “ClearAllArrays” command.<\/p>\n
I’ve also converted the vsMesh utility class to automatically use its internal vsBuffers in interleaved mode, when it can. \u00a0So if you were already using the vsMesh or the vsMeshMaker (as I do in MMORPG Tycoon 2), you’ll automatically get this improvement.<\/p>\n
With that said, I only see a moderate performance improvement on my laptop, but every little bit helps. \u00a0And I’m reliably informed that on embedded systems (such as mobile phones) that having interleaved VBOs gives substantially improved performance. \u00a0And someday I might want to look into things like that, I suppose.<\/p>\n
Anyhow, as is often the case with these sorts of improvements, I’ve done this in my MMORPG Tycoon 2 development branch; \u00a0these changes haven’t yet been migrated back into the main publicly accessible VectorStorm trunk. \u00a0But I’ll get to that eventually. \u00a0:)<\/p>\n","protected":false},"excerpt":{"rendered":"
I’ve spent a day working on VectorStorm engine improvements, today. \u00a0Those who aren’t interested in technical details should probably skip the rest of this post; \u00a0sorry, 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. \u00a0(previously, transforms within a…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[4,3],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-k7","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1247"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=1247"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/1247\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=1247"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=1247"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=1247"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}