r/cpp • u/zer0_1rp • Jul 02 '26
Redundancy seen in AAA game engines
https://zero-irp.github.io/Redundancy-seen-in-AAA-game-engines/I don't like people treating the compiler like a magic box that optimizes like Bjarne Stroustrup himself is checking every line of C++ to assembly. Clean C++ code does not always mean clean compiled code.
I've been reversing game engines to study how they constructed their fundamental Transformation matrices and handled temporal jitter logic when I spotted a lot of avoidable overhead and "over-engineering" across multiple engines, honestly I wasn't even looking for inefficiencies, but it stood out a lot... That said expect no performance gain this is simply for fun that I wrote this blog!
I’ll theorize how the original C++ code was written, show the unoptimized reality of what the compiler spat out, and then showcase how it could have been better optimized.
View all comments
Show parent comment
3
u/ParsingError Jul 02 '26
Clang-CL/MSABI uptake took a while for various reasons (mostly "letting things settle" and IIRC it had some problems with PDB support for a while) so probably not going to see it used by older games.
Problem with "simply writing a resolver" is having to manually propagate the dispatch architecture into child calls instead of the compiler selecting them automatically which is pretty annoying if I'm trying to use stuff like Matrix44/Vec4 wrapper types. It solves a lot of problems if you can just say "this function AND all of its child calls can use the AVX version."
Even with that though, if the math is mostly 4x32-bit float then that fits in an SSE register and the benefit isn't really as clear. The most obviously-useful addition in a while was the DPPS instruction in SSE4.1. It's been harder to find obvious wins from AVX except for like physics simulation.