In regards to gaming, what is “optimization”?


If consoles are just glorified PCs now, how is it that a game designed for PS5 or X-Box Series X alone better than one that is designed to be cross platform?

In: 19

It is a process used to make sure the software (game) will run in its environment (hardware/operating system/etc.) in an optimal fashion.

Consoles aren’t just glorified PCs. There are substantial differences between PCs and consoles, and between the different consoles. The user will get the best performance from games optimized for a particular system.

They aren’t just glorified PCs. They are very similar to PCs in some ways, but each console has different hardware and graphics chips that have unique features.

One that is designed to be cross platform only uses the features that are either common to all platforms, or ones that the compiler (the software that turns their text based code into a program to run) can automatically figure out how to use effectively.

If the game is optimized with a particular piece of hardware in mind it can use it to its full potential (if the programmers are good). But the downside is porting it to another platform becomes a lot more work.

Multiple ways:

* Every time you draw a different object with different “settings,” (reflectivity amount, textures, etc.) you have to do something called a “draw call.” The more draw calls, the slower things run, so 3D artists will merge multiple objects into one, and programmers will figure out ways to “batch,” things together so you can draw a scene using fewer draw calls. This usually makes things messy (especially on the 3D art side) so it’s done as late as possible in development.
* In the middle of development things are very fluid, so you often don’t know what objects are going to be seen from what angles, and the player’s intended path through a level might change on a whim. As the game starts to solidify towards the end however, developers can go in and remove unseen detail, as well as put loading and level transitions in certain areas where you won’t notice them which helps cut down on memory since smaller chunks are loaded at once.
* There’s also the basic programming stuff, such as processing data once and then caching it (once again, easier later in development once you know exactly when and where data will be needed) and trying to balance memory VS. performance based on what you need more of in that moment. Like 3D art, this can sometime mean making the code messier and less modifiable for the sake of saving a few operations here and there.

In short though, optimization is basically just “whatever needs to be done,” and can be be millions of different things.

Games need to do a few things very quickly:

* Determine where the player is
* Fetch the world state from the network, if required
* Determine if any physics objects or other objects have been impacted
* Determine if any AI behaviors or game code needs to run
* Load and play sounds
* Load and draw textures and models

Years ago you had the game running all of this in a simple loop. In the age of multi core processors, you write individual small programs, called threads, and have each core run one thread at a time. This requires precise timing, because if something doesn’t finish when it’s time to draw the next frame (in 16 milliseconds for 60 fps) you get stuttering.

When developers are optimizing their games, they use a tool known as a profiler to analyze how long code takes to run and what, if anything, is causing it to run slowly.

It’s much easier to do this on a console where the hardware is always exactly the same and there’s nothing running in the background taking up precious time. There are also a few optimizations – for example the PS5 has decompression hardware built into the storage. PCs don’t have that hardware, which is why The Last of Us’s PC port had poor performance and was maxing out CPUs, they can’t decompress as quickly or efficiently as dedicated hardware.

Here’s a great talk on Spider-Man and how tight some of that timing is:

More efficient hardware calls and software blocks to reduce latency, more modular coding and resource priority to reduce ram, etc