3 ms·
Game coding makes you have to think about thinks that a lot of web devs don't have to (or merely don't bother to) consider. Optimization is paramount. To main
by Sohcahtoa82 1y ago
Game coding makes you have to think about thinks that a lot of web devs don't have to (or merely don't bother to) consider.
Optimization is paramount. To maintain 60 fps, you need to calculate your game state and render graphics in under 1/60th of a second. That's only 16.6[..] milliseconds. If you want to appeal to the high-end players with 240 hz monitors, you get less than 5 ms. When you're operating at that level of latency, every microsecond counts.
You start having to care about how your data is laid out in memory so that you can optimize cache usage. You start caring about branch mispredictions. Multithreading becomes an absolute must, but locks are landmines. If you're using a garbage collecting language, per-frame allocations are kryptonite and you re-use buffers to avoid unpredictable pauses.
Your profiler becomes your best friend. You're not just looking for good performance, but consistent performance. If there's a 3 ms spike in CPU time every 10 frames, your players will absolutely notice it and it will destroy the feel of your game. That 3 ms becomes a critical bug.
- badsectoracula 1y agoI think this is some mythical game programmer you have in mind because, having worked in a few AAA/AA games myself, i can clearly tell you that the overwhelming majority of programmers - including engine programmers - rarely think about any of that. Sure, someone might occasionally pull out a profiler, but only if things start becoming visibly bad. But this is an exceptional situation, not the norm. On the other hand, game engines are constantly engineered with features that go against performance: interpreted scripting languages, ad-hoc garbage collectors (for assets, not only for scripts), visual material editors[0], deep object oriented hierarchies with FAT objects (hello Unreal Engine), etc. [0] Shader compilation stutter is something a lot of gamers notice and dislike and a common explanation for its existence is the number and complexity of shaders current games use. But one thing very few seem to notice is this is only the case in engines that allow designers/artists to create materials with visual editors that generate shaders without understanding the implications. In engines that do not allow that (such as current id Tech) and artist have to create their materials using a low number of predefined shaders you rarely hear about this issue.
- bentt 1y agoYou must have been working on a genre that wasnt perf sensitive.
- badsectoracula 1y agoI've been working on FPSs and ARPGs, which AFAIK are among the more perf sensitive genres, at least as far as mainstream genres go.
- bentt 1y agoHuh I am surprised perf wasnt more of a focus. Maybe the art style was intentionally keeping things hardware friendly?
- badsectoracula 1y agoThe art style was your regular 'realistic' one that most AA/AAA games use, though even if it wasn't it wouldn't make much of a difference - some art styled enable you to make more out of the hardware, but they do not provide better performance automatically (if anything, if done naively a non-photorealistic art style can actually be worse).
- Rohansi 1y agoMore performance sensitive but also more constrained. Balances out as long as you're not doing anything silly.
- lifeformed 1y agoIt just depends on if you're doing coding on the lower levels or scripting gameplay features. One is a lot more focused on optimization then the other.
- qingcharles 1y agoYikes. I lived inside the profiler when I was a gamedev, but that was many, many years ago. Probably spent more time trying to eke out performance than I did writing new features, sadly.