I meant all game logic as an example of stuff needing to modify the data. You know, changing the position based on the current velocity, destroying objects that have been hit by bullets. Adding to the score. Physical interactions between bodies. I thought it was obvious enough to not go into detail.
Changing the position based on the current velocity is a pretty damn trivial calculation. So is destroying objects. All you do is iterate over them once. The physics and collision detection are already parallel problems and handled in a previous phase. Adding to score? Are you
serious? score += points;
That wasn't so hard.
What? No. If you have discrete phases for each part of your game, and others are single-threaded and take 75% of each frame, then you are only using 4 cores for 25% of game time, and they are being underutilized the rest of the time.
The abovementioned tasks like destroying objects certainly do
not take 75% of the game loop. It's collision detection, pathfinding, AI and rendering that take the most time.
Not to mention [...]
Some things are difficult to parallelize, yes. But it doesn't matter. You don't
have to parallelize
everything, that's not what multithreading is about. The point is to just parallelize enough to make up for the overhead, and you're already profiting.
hahaha you don't make a thread for each unit that requires AI. how many threads do you think you're going to have here? you don't want to be creating threads constantly either.
try writing a thread pool to do some complex operation such as AI or pathfinding, then you'll realize how difficult multithreading is.
I never said I was creating a thread per unit, That would be idiotic. I said I'm creating a
job per unit, putting said jobs in a queue and letting the worker threads loose on them. Yes I'm using a thread pool, and it's
easy.