Got a quick question on PC games and code compilation

McHuj

Veteran
Supporter
For anyone who has done game development on a PC, does a PC binary contain code for different architectures or just the min spec one?

For example, Nehalem introduced SSE4.2, Sandy Briddge introduced 256-bit AVX, Haswell will introduce AVX2. Obviously the compiler would have to generate code for those instructions and at runtime, the program would have to choose the proper code path to take depending on the CPU to execute it.

Is this the kind of thing that's done, or are games pretty much compile for min spec CPU only and you get improved performance not by new ISA features, just by executing old code faster?
 
I still use conditional compilation quiet often (especially for reference C code and assembly routines), however, I usually don't have to worry about my code running on different architectures like PC game would.

My question was more about whether PC dev's (in general) do spend time doing this for PC games. I'm guessing it's not worth the effort to do it manually since CPU performance hasn't been an issue lately.
 
I don't think you really have to make a big deal of dispatching individual chunks of the code, you can just have entire separate program binaries for different compilation targets. Yeah this could get pretty out of hand if you support a lot of combinations but in practice only a few really make any kind of sense. Various OSes are already doing this with fat binaries. It's pretty befuddling why MS didn't choose to take this direction with Windows 8 and RT.

You can still do the dispatching at runtime (maybe have some stub program that picks the right program to run) but for anything with any kind of real installation procedure it'd may as well be done at install time and never bother putting the unneeded on the user's system. This is what happens on Android. Supporting safe dispatching of ISA extensions via compilation flags and conditional compilation is trivial there, but of course Android has to officially establish the dispatch type first.
 
Back
Top