Skip to content

Instantly share code, notes, and snippets.

@icebreaker
Forked from statico/gpu.cpp
Created April 24, 2020 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebreaker/8848a4510974637c41a7c0eebbb2483a to your computer and use it in GitHub Desktop.
Save icebreaker/8848a4510974637c41a7c0eebbb2483a 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment