Posted December 11, 2020
drmsux: Isn't there a way to write code so if AVX is present, it's used, and if it's not, it doesn't -fucking crash-? I'm pretty sure that's a thing...
Yes. Here's how it works on Linux (which I am more familiar with, but I would imagine Windows handles things similarly):
* If the CPU tries to execute an instruction it doesn't understand (like the AVX instructions on a CPU that doesn't support it), a trap is triggered on the CPU, which is then handled by the kernel.
* The kernel handles the trap by sending the process a SIGILL (Illegal Instruction) signal. If it is not caught by the application, it will crash with the message "Illegal Instruction". (Note that this is not the same as a Segmentation Fault (SIGSEGV), which Windows calls a "general protection fault"; those indicate memory errors, not invalid instructions.)
* It is possible for a program to set a signal handler to handle the SIGILL instruction. What it does now, of course, depends. One approach would be to emulate the instruction; the handler would change the processor's state to what it would be had the instruction been executed. (Note that the handler would have to keep track of what would be in the AVX registers.) Another would be to modify the code (or, more likely, change a function pointer that's called in the code) in order to point to an alternate version of the function, one that's compiled without AVX instructions.
* Alternatively, the game could execute a CPUID instruction on startup, check the result to see if the AVX bit is set, and use that to determine which version of the function that needs AVX instructions gets called. (If the CPU doesn't support CPUID, then it's so old that it doesn't come even close to supporting long mode, and therefore there's no way a 64-bit OS, which is clearly listed as a requirement for this game, would run on it without emulation.)
KU27PS: There is a mod on nexus mods that fixes this called avx check fix for cyberpunk. Pretty annoying CDPR couldn't such a basic thing. You don't need to replace anything just yeet it into you bin/x64 folder and open it from there
MJ2019: KU27PS – Thanks very much for your help you are a life saver. This is basic coding that CDPR should of included in the first place.
In my opinion this is not about CPU age or how powerful it is. It’s about good coding practice.
If the Mod community can come up with a solution so quickly then CDPR could of too.
Again MOD community comes to the rescue.
P.S. Mod actually called “AVX Fix”.
As for why the AVX Fix mod exists, someone with the technological knowledge to make the mod happened to have a non-AVX CPU, ran into this crash, and decided to look into it and see if they could fix it.
(One thing of note: Any update to the game is likely to break this mod, so you might want to disable auto-updating if you need to use it, and wait until the mod gets an update (or CDPR provides their fix) before you update the game.)
Post edited December 11, 2020 by dtgreene