Let's pretend you have 8 assembly lines running side by side. Each of them is doing completely different things. Let's call them:
Sound AI Graphics (CPU) Post Processing Physics (Environment) Physics (Player+NPC) System OS Game Engine (Master)
----> Output
Every single one of those is reading from memory, processing data, writing to memory, sending data to devices or other threads, as well as keeping track of information locally.
Every single one needs to be in lockstep. If one slows down (due to lack of resources or too much workload) the entire game slows down (perceived as microstutter, FPS drop, or lag).
Leaving aside preventing bugs (Race Conditions, Memory Synchronization, Locking, etc.) and the performance issues from those alone, how do you balance these so nothing can slow down?
Slowdowns: Sound: Too many things happening generating sound events (See: EVE Online) AI: Too many AI entities onscreen, or too many objects that the AI needs to be aware of present in scene) (See: Basically every game ever that lags) Graphics (CPU): Too many draw calls (This is what Mantle/DX12 is for). This is a function of higher level draw calls so when a game is CPU bound, this is the issue. Post Processing: Transparency + screen effects such as bloom/HDR can really screw things up (see: Any game that lags like crazy when something happens with lighting effects or a sudden blur effect, I actually think GoldSrc (HL1) had issues with this) Physics (Environment): Something gets stuck or too many objects interacting with others (Havoc and Source Engine had severe performance issues)
"Tune it!" you say? Well great, it works indoors with 5 enemies. Walk outside and there's 50 enemies, your AI thread just took your FPS down to 1/10th what it was (more if they're aware of each other).
It is NOT as simple as you think it is.
The workload is not "multiple things that have next to nothing to do with each other and can be divided into parallel processes".
Now what about single threaded? None of this applies. If your AI thread needs more power, it simply preempts more cycles on the processor from the other threads and you get a modest FPS drop (you may have seen this on older games).
|