Brendan wrote:For games (especially poorly designed games) often there's an incredibly silly "game loop" that would (e.g.) get keyboard/mouse/network input, update stuff, generate the next frame of graphics, then busy wait for vertical sync and do a buffer flip; where the entire game and all timing is dependent on waiting for vertical sync. Also don't forget that for all graphically intensive video games there's a bizarre "if this game isn't using the CPU/s then nothing is using the CPU/s" assumption (multi-tasking is a feature that's almost always ignored by game developers). These things combined mean that often "busy wait for vertical sync" is what game developers wanted, and if there was a vertical sync IRQ then it'd be mostly only be used for "busy wait until IRQ occurs".
Part of the reason for this is that often there's "global state" (e.g. where each entity is) that is modified by multiple pieces (by player controls, by enemy AI, by physics, etc) and also read by graphics; where doing everything serially avoids synchronisation difficulties (e.g. no need to worry about something modifying the data when graphics is trying to read it to generate the next frame).
Of course do I think this is extremely bad/wasteful; but even now a lot of games are still written like this.
While I certainly agree with you on this, I should point out that this wasn't just ignorance - game developers
deliberately do this sort of thing, or did until recently anyway, mostly for reasons which were sort of sound in the past (mainly the belief that players would want all of the power of their system to be focused on the game they are currently playing, and the assumption that the game would need all of it anyway) but have been irrelevant for years if not decades.
When I took a course on game design in 2008 (it filled a major requirement, and I did learn a few things, but it was barely worth it - mostly, we focused on coaxing
Torque3D into moving a few assets made by the professor in patterns dictated by the assignments), we were told flat out that trying to multithread a game was a Bad Thing, and that a game loop was the only way to go. A lot of online tutorials repeat this 'advice' even to this day, and until recently a newbie game dev who asked about using threads on most game dev fora would get the same ridicule that a newbie OS dev would get here if they asked about writing a kernel in VBScript.
This is why, until about four years ago, system building 'gurus' such as Paul Heimlich and Linus Sebastian usually dismissed multicore performance as irrelevant for games and focusing on CPU clock speed and GPU performance over everything else when discussing gaming rigs.
Things have changed among the major commercial game designers, who have been slowly warming up to the idea of using more than one thread in one process (though many commercial games still don't), but indie devs often ignore - or are ignorant of - the issue, relying on the often poorly optimized out-of-box performance of the game engine they are using to be sufficient, which is why - among other things -
Player Unknown's Battlegrounds (which, for those too sensible to care about the topic, was the runaway hit indie game of the past year) has such notoriously poor performance even on massively overpowered game rigs.
This is exacerbated by the fact that (according to what I have read), fitting multiple threads into most game engines works about as well as fitting afterburners onto most lawnmower engines.
It is getting better, slowly, but it is still a major problem.
While some indie devs do tune their games, most don't, and it shows. Even some AAA houses do only minimal tuning initially, counting on being able to patch any issues later if they get a lot of complaints (or even leaving it to modders to do their work for them, as seen in such infamous dumpster fires as
Aliens: Colonial Marines,
Mass Effect Andromeda, or the PC version of
Arkham Knight). This becomes all the more evident when a truly well-tuned game such as the 2016
Doom reboot comes along and shows just what a piss-poor job everyone else is doing with it.
But this is getting away from the thread topic. Sorry for the digression. And yes, I know that the Sky Cutter isn't actually made from a lawnmower, it was just made to look like one, but saying that earlier would have killed the joke.