Skip to content

Instantly share code, notes, and snippets.

@statico
Last active January 25, 2024 01:06
Show Gist options
  • Star 27 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save statico/6809850727c708f08458 to your computer and use it in GitHub Desktop.
Save statico/6809850727c708f08458 to your computer and use it in GitHub Desktop.
Trick to tell AMD and Nvidia drivers to use the most powerful GPU instead of a lower-performance (such as integrated) GPU
#ifdef _WIN32
// Use discrete GPU by default.
extern "C" {
// http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
// http://developer.amd.com/community/blog/2015/10/02/amd-enduro-system-for-developers/
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
#endif
@SubBastion
Copy link

SubBastion commented Jan 25, 2024

Dumb question: Are these relevant in Linux (or OSX for that matter)?

If they have the right AMD drivers it should in theory work for linux based on how it's detected of literally dumping strings and looking for the field.
MacOs doesn't use NVIDIA in any recent years nor AMD they create their own now I believe and also I believe on macos only supports onegpu. The GPU being either intel iris neither integrated nor dedicated, or their own

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment