Game Vs Application

The core of any application is a loop; few lines of code that keeps repeated while this application is alive! In applications most likely we do not notice this fact very much, because in applications we rely on Events. If a user pressed a button do this, if this happened call that method and so on. However, in games the concept is different. The game loop has to process every single frame displayed on the screen, going through: (the game logic, physics, AI, Scene management & bunch of other things) every time. For a smooth game, we need 30 – 60 FPS (Frame Per Second)! So imagine the processing load!


A nice comparison from MVPs.org:

Application Philosophy :
·        Don’t get in the way
·        Only take use of CPU when we are told to
·        Spend most of our time sleeping till someone wakes us
·        Be friendly to other applications and step aside

·        Things will get done when they need too, no hurry

 

Game Philosophy :
·        Take all that you can get
·        We control all that you see and hear….
·        Don’t let up for a moment
·        We’re on a deadline here – move it!
·        Only let others have control as it benefits us

 

So much processing -> CPU VS GPU

You want to build a game then, 95% you are a gamer! Therefore, you know that games needs good graphic cards. Why so? Because GPU is faster than CPU and CPU is slower with graphics. We all know that! Still the question is why? To answer this, we need to take a closer look at CPU & GPU Architecture.

 

  • CPU has few cores while GPU has 1000’s cores.
  • Single core in CPU is faster than GPU.
  • Single Core in CPU has longer Pipeline.

 

 

From nvidia (article link at the bottom)

When it comes to sequential computing CPU wins. However, when it comes to parallel computing GPU massively wins!
Games & graphic applications is all about transforming billions of vertices and applying special effects to them every time that 3D model is redrawn.
In simpler words, lets take a look at this picture:

 

1st Line shows walking animation & 2nd Line shows running animation.

Now for the player to see this character walking or running smoothly it has to be at least 30 FPS. Every time the vertices in the frame will change. In addition to that, to fully animate the walking scene, we have to translate all the vertices a little to the right every frame.
Then, the light source will come, which has different effect on the character while he is walking away from it for example.
We can see it is a huge amount of computing operations and has to be done on the fly. CPU can do these computations but it will take ages!

The following video is by nvidia (GPU Vs CPU).

For further reading, check these articles:

 

Leave a Reply

Your email address will not be published. Required fields are marked *