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/not_a_novel_account cmake dev Jul 02 '26
I don't know what this means. All I was trying to say was "it's not a COFF limitation". Some compilers support automatic CPU dispatch on COFF or in general better than others, but there's no restriction inherent to the format.
Once you're through a dispatch boundary you only make calls to functions within the dispatch universe. The boundary is a generic call site,
transform. Once you're through that intotransform_sse4, you only call other*_sse4functions and you do so directly. Once you're intransform_avx2, you only call other*_avx2functions, etc.You pay for the dispatch when passing through generic code into a dispatch universe. One you're in a given universe you stay there until the final return back through the dispatch. There's nothing for the compiler to do for you.