Graphics Update, v1.1

Discussion in 'Planetary Annihilation General Discussion' started by varrak, February 20, 2014.

  1. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    Back in December, I posted a long, waffling post about some changes I made to the low-level graphics engine. Some people seemed to like it, so I thought I'd do another update.

    My primary focus has still been on performance, with the occasional bug fix thrown in here and there for good measure. One of our big performance pain-points has been the effects system - that is, the part of the code that renders effects like explosions, rocket trails, the planet smash, weapon fire, and all that good stuff. This is also alternately known as "the particle system", or "argh argh argh" when I was feeling particularly annoyed.

    Anyway, this system was originally written to be entirely simulated on the CPU, which allows us to do a lot of cool stuff without requiring the end user having the latest and greatest graphics hardware, and is also a lot quicker to implement. Unfortunately, as the game scaled up, the effects system did not, and it became an issue. For the terminally curious out there, it used to work by building up all the geometry for particles on the CPU, and then render them all out as if they were just a mesh. The upshot was the CPU had to do a TON of work when there was a lot going on, and there was also a lot of data being thrown around.

    I spent the best part of the last month revisiting the system, and optimizing it. We still do the effect simulation on the CPU - but now particles are actually rendered as instanced quads (except the planet smash debris, which is instanced meshes), and all the of calculations required to set up their appearance are performed on the GPU. We also send a lot less data across the bus, as individual particle effects now understand the minimum set of data required by the GPU for rendering. Because of this we reduce the memory transfer per frame by a factor of 4 or more (actually, more like a full order of magnitude, so 10x or more).

    A lot of this work was built on top of some of the low-level engine re-architecture changes I made back in December. It made putting all the bits together a lot easier than it would have been.

    The net result is quite a decent speedup in late-game scenarios. This is not the definitive optimization by any means - we still have more to do, but it's made a difference. To give an example, typically in late-game scenarios I would see the CPU particle system take up 10ms or more (even upwards of 30ms when I sent 1000 bots on a rampage). This time is now in the order of between 1 and 3ms. It also speeds up other parts of the rendering (at least on NVidia GPUs), since the driver is better able to optimize around what we're doing (yes, I've been talking to the NVidia guys a lot lately - and for what it's worth, they've been amazing! :) ).

    You should see this going live shortly (it wasn't quite done for the last build release). We're still in the process of testing it. But once it's out there - stuff should start getting a bit quicker.

    Oh, in case anyone's curious about how I tested the performance as I was iterating... I set up the "ping" command to perform the planet-smash effect, after Metabolical did the same thing to test the original ping functionality (and posted a video about it, too). Then I'd do a bunch of them. So with around 10 planet-smash explosions going on, I was still seeing a solid 60fps. Which I'm quite happy with ... :)
  2. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    I (hopefully) would like to be the first to pat you on the back for a job well done. Everyone discusses right off the bat how much faster the game runs this update. It is the first thing everyone notices.
    drz1 likes this.
  3. lapsedpacifist

    lapsedpacifist Post Master General

    Messages:
    1,068
    Likes Received:
    877
    The real benchmark test is whether I'll be able to take my graphics from low, with everything turned off, to medium, with everything turned on.

    Sounds like great work, I think having better performance will do a lot to keep people playing.
  4. Hexadecibel

    Hexadecibel New Member

    Messages:
    10
    Likes Received:
    6
    No love for AMD?... :(
    drz1 and varrak like this.
  5. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    It's not in the latest update (we did a bunch of *other* optimizations on that update). So expect to see even more speed in the next one (at least, in later game).
    drz1, aevs and brianpurkiss like this.
  6. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    Of course I love AMD! And the improvements will apply on everything (since it's just more efficient all around). I wanted to call out NVidia especially because their developer relations guys were nothing short of amazing.
    Bastilean, EdWood, LavaSnake and 3 others like this.
  7. jeffwadsworth

    jeffwadsworth Member

    Messages:
    39
    Likes Received:
    32
    I really enjoy reading these tech write ups. Please keep it up.
  8. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    And that is fair. You can only love something that lets you love it.

    If Nvidia is being very cooperative and supportive, and AMD has no foreseeable solutions in parallel, then AMD is acting like that girl you like but she considers you awful and insults you when talking to others and shoos you away.

    Just like a woman who doesn't love you, you can only love something that lets you love it. AMD will get love in all the areas that are accessible for optimization.
    Bastilean and varrak like this.
  9. tollman

    tollman Member

    Messages:
    93
    Likes Received:
    26
    Thanks for the write-up! Really enjoy reading these. I am on a nvidia 765m (a laptop card) and the game is already running very well on a full HD screen (to my relief :) ) so many congrats to you and the team.
    varrak likes this.
  10. spicyquesidilla

    spicyquesidilla Active Member

    Messages:
    113
    Likes Received:
    72
    give this man a medal.
  11. brianpurkiss

    brianpurkiss Post Master General

    Messages:
    7,879
    Likes Received:
    7,438
    I... need to go change my pants.
    LavaSnake, cdrkf, Raevn and 1 other person like this.
  12. varrak

    varrak Official PA

    Messages:
    169
    Likes Received:
    1,237
    Let's not be premature... wait until you've played with these changes first... :p
  13. felipec

    felipec Active Member

    Messages:
    465
    Likes Received:
    190
    Nice reading! Keep up the great work! =)
  14. carlorizzante

    carlorizzante Post Master General

    Messages:
    1,371
    Likes Received:
    995
    You lost me at "Back in December...", but I think it's awesome that you guys keep us updated with even those technical details and challenges you are encountering.

    Thanks! It's really great seeing this game evolving, step by step.

    ps. Today I encountered a funny bug. On a strategical view (icons), bots instead of staying in formation, had their icons literally jumping around, like flickering, but switching location on the map pretty far away, and frenetically. It lasted for a little, around a dozen of seconds. And then all came back to normality.
    fr2ed likes this.
  15. paulusss

    paulusss Active Member

    Messages:
    271
    Likes Received:
    144
    Well done Varrak! the result are really noticeble, and i praise you endless for this achievement and more that is to come from your hands ^^
  16. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    He said we haven't even seen the results of this work yet. :eek:

    Just imagine how smooth this game will be when that work is done. When the sim and networking code catch up, we're going to have some fantastic 40 player games.
    varrak likes this.
  17. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
  18. garat

    garat Cat Herder Uber Alumni

    Messages:
    3,344
    Likes Received:
    5,376
    If you saw Metabolical's stream with the PIP on it, then you saw your first hint of it. PIP had dependencies on much of the work Varrak did.
    drz1 and varrak like this.
  19. Dementiurge

    Dementiurge Post Master General

    Messages:
    1,094
    Likes Received:
    693
    As performance goes up, features that suck performance (PIP) get implemented. It's the cycle of life. :D

    Nvidia just has more money to do it with. I've heard that Nvidia has over a thousand people working on driver development (and probably developer relations) while AMD's team is only in the double digits.

    It's probably no wonder AMD relies so heavily on Microsoft and open standards. They'd never be able to get anything done if they had to do the work themselves.
  20. websterx01

    websterx01 Post Master General

    Messages:
    1,682
    Likes Received:
    1,063
    So excited! Can't wait for the update that includes this!

Share This Page