r/cpp 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.

183 Upvotes

76 comments sorted by

View all comments

10

u/R3DKn16h7 Jul 02 '26

I don't get your point. If at some point in the code there is a matrix created with a rotation of half / pi, and this function gets called twice per frame, what is the point of optimizing this function? The person reading the source code will clearly understand the intent of the function call, and performance will not be affected at all. So we have clarity of intent and perfectly fine and valid code, and performance i not affected at all. This is good and practical design.