{"id":2394,"date":"2012-03-08T21:50:05","date_gmt":"2012-03-08T11:50:05","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=2394"},"modified":"2012-03-08T21:50:05","modified_gmt":"2012-03-08T11:50:05","slug":"old-hardware","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2012\/03\/08\/old-hardware\/","title":{"rendered":"Old hardware"},"content":{"rendered":"

Over the past few years, it’s been becoming more and more rare for me to find myself using a laptop; \u00a0I seem to have settled back into desktop machines. \u00a0But every once in a while, I still find myself using my five-year-old laptop; \u00a0the one that I was using when I first started developing MMORPG Tycoon 2.<\/p>\n

For the last week or two, I’ve been using it almost exclusively, often while watching television (or to be precise, while being in the same room with the television, but not actually watching it). \u00a0And this has shown me just how badly I’ve mucked up MMORPG Tycoon 2’s performance over the past year of development, as I’ve been coding on an extremely fast desktop machine. \u00a0As of just a few days ago, MMORPG Tycoon 2 wasn’t hitting 60fps on that five year old laptop, even in an empty game world.<\/p>\n

So this week, I’ve been focused on performance. \u00a0And as a result, the average fps on that old laptop has risen from an average of about 40fps in an empty world to about 180fps in an empty world, without any changes to what’s actually being drawn. \u00a0This is making me feel an awful lot better!<\/p>\n

Core performance notes:<\/p>\n

    \n
  1. Previously, I was dividing the local part of the world into a grid of 15×15 terrain tiles (225 tiles in total), each of which was rendering about 1,000 vertices. \u00a0Now I’m drawing the same amount of terrain, but dividing it up as a 3×3 grid of terrain tiles (9 in total), each of which is rendering about 25,000 vertices. \u00a0Lots of small draw operations are slow — much better performance to have a small number of big draw operations! \u00a0I preferred to use lots of small tiles because that made it faster to recalculate them when the terrain was being resculpted. \u00a0But now that those recalculations are being performed in a background thread, there’s much less reason to worry about how big the tiles are. \u00a0There’s still some tuning to do here; \u00a03×3 is probably too few tiles to keep the world loaded nicely around where the player is. \u00a0Maybe I’ll try 5×5 and see how performance changes.<\/li>\n
  2. Drawing lines is ridiculously slow on some graphics hardware, including the GPU of my old laptop. \u00a0Anything I can do to limit the number of lines drawn will be worthwhile. \u00a0(must consider converting lines into rectangles manually, if I can work out a way to keep the apparent widths of 3D lines consistent on-screen, regardless of their distance from the camera)<\/li>\n
  3. Related to #2, I was drawing all the player’s action bars, even though normally only one or two of them are visible at any given time; \u00a0all the others were still being drawn, just slightly outside of the window frame. \u00a0Making offscreen action bars not draw themselves made a big difference to the frame rate.<\/li>\n
  4. Lots of UI code was still using the extremely old “compatibility” rendering architecture (which dates back to the earliest days of the VectorStorm library), and so it wasn’t taking \u00a0advantage of modern features like render buffers or the automatic material batching given by the relatively new\u00a0vsFragment<\/em> system. \u00a0I’ve now converted most currently-used UI code to use render buffers and fragments, instead of pushing explicit display lists and vertex arrays through the slower compatibility interface.<\/li>\n<\/ol>\n

    I think I’m now basically done with performance for the next little while. \u00a0So back to game features again! \u00a0I’ve been working on world editing a lot, but that’s not quite ready to be shown yet. \u00a0Maybe toward the end of this coming weekend. \u00a0We’ll see!<\/p>\n","protected":false},"excerpt":{"rendered":"

    Over the past few years, it’s been becoming more and more rare for me to find myself using a laptop; \u00a0I seem to have settled back into desktop machines. \u00a0But every once in a while, I still find myself using my five-year-old laptop; \u00a0the one that I was using when I first started developing MMORPG…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[24,25],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-CC","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2394"}],"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=2394"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/2394\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=2394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=2394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=2394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}