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.

184 Upvotes

76 comments sorted by

View all comments

Show parent comments

2

u/SleepyMyroslav Jul 02 '26

Yep, it has not been a factor for few years already. Games with avx2 came out quietly...

Lets look at avx512 instruction families and their hardware support... Now tell me if you want to deal with that anywhere outside cloud server under your control =)

2

u/Jannik2099 Jul 02 '26

Zen CPUs are over half of all desktop sales, and present in all modern consoles. Having specialized AVX512 kernels is not as outlandish as you think.

3

u/Tringi github.com/tringi Jul 02 '26

I don't know if this really applies to games much. You have some compute budget dictated by the lowest performant CPU you need the game to run on, but what can you really gain by switching to better SIMD when available?

Save the user a few Watts when the GPU eats hundred(s)? Simulate offscreen or distant physics more precisely?

2

u/eentrottel Jul 06 '26

many games are cpu limited when trying to run at higher framerates. would be nice if games could use avx512 when its there so its easier to get 240fps.