In this short guide we show to make your YYC executables prefer the discrete NVIDIA/AMD GPU on Windows systems with two graphics chips in them, rather the allowing the OS to control this and it likely preferring the integrated graphics chip in the Intel/AMD CPU.
Be aware this is deliberately not enabled by default, as whilst this is suitable for some more intensive games and acceptable to players who are willing to allow their PC to run hot in favour of performance, there are just as many who would not be willing to allow this and who prefer lower energy drain/better battery life/lower heat and noise. Some games also just do not require this setting and run perfectly well on the integrated chip, so it's a waste of energy if it were forcibly-enabled.
For the above reasons, there is no provision to do this with .exes built using Windows VM - you will have to Create Exe using Windows YYC, which means using the Windows version of GameMaker also.
Please note that as you will be editing your runtime files, this change will apply to all Windows YYC builds you make until you revert the change. Be aware also that when you update runtime versions you will need to apply the change to the new runtime's files if you still require it.
Find The Runtime File
Open the folder %programdata%\GameMakerStudio2\Cache\runtimes\
This will open Explorer to your runtimes install folder, allowing you to pick the runtime you wish to edit:
From here, navigate to your chosen runtime's copy of the YYGML.h file - [runtime version number]\yyc\include\YYGML.h
E.g:
Edit The YYGML.h File
Open the file in a simple text editor (e.g., Notepad or Text Edit) and near the top you will see a block of #include lines. Create some empty lines underneath them, and then paste the following into the new gap:
#if defined(YYLLVM) && defined(_WIN32)
extern "C" {
_declspec(dllexport) _declspec(selectany) unsigned long NvOptimusEnablement = 0x00000001;
_declspec(dllexport) _declspec(selectany) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
It should now look a lot like this (screenshot shows an old version of the code - you must use the code we gave in the box above!):
Save the file and close it.
You're done editing your runtime.
Build Your Game
Now, just build your game as per normal for Windows YYC (again, not VM!). If you have built this project before, then we would recommend you clean your cache first.
Once the executable has been built, you can try it on a machine with dual GPUs or send it on to your players for them to compare performance before/after.
Note that this process will add two small text files into your output packages - a .lib file and a .exp file. These are not actually required by the game and can be removed before you send the game to others/upload it to Steam, etc.
A final reminder that always enabling this 100% for every project you make is probably not a wise move - you're just as likely to get negative ratings on marketplaces for "performance hog", "runs really badly, so has to fire up the GPU", and "why does this make my laptop so hot/noisy", etc.