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 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.
Find The Runtime File
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 install if you still require it.
The file you will be editing is [runtime version number]\yyc\include\YYGML.h
Windows IDE
%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. E.g:
macOS IDE (for those using the remote worker tool)
- Please note, the Remote Worker can only be found if you are using GMS2 2.3.7 (Dec 2021) or older. The Remote Worker is no longer supported as of January 2022 and has already been removed from GameMaker in January Betas, so this information should be treated as legacy.
/Users/Shared/GameMakerStudio2/Cache/runtimes/
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 __attribute__((weak)) NvOptimusEnablement = 0x00000001; _declspec(dllexport) _declspec(selectany) int __attribute__((weak)) AmdPowerXpressRequestHighPerformance = 1; } #endif
It should now look a lot like this (this screenshot shows an earlier version of that code block above - yours needs to use the content 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.