From 6d5753c54863877020a4f3d12960e417fb04824b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 29 May 2015 13:08:12 +0200 Subject: [PATCH] Added support for AMD PowerXpress override. Generalized _GLFW_USE_OPTIMUS_HPG to _GLFW_USE_HYBRID_HPG to reflect the change. Fixes #520. --- CMakeLists.txt | 6 +++--- README.md | 2 ++ docs/compile.dox | 10 +++++----- src/glfw_config.h.in | 4 ++-- src/win32_init.c | 15 +++++++++++---- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41d56bf6..e990b85b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF) if (WIN32) - option(GLFW_USE_OPTIMUS_HPG "Force use of high-performance GPU on Optimus systems" OFF) + option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF) endif() if (APPLE) @@ -235,8 +235,8 @@ if (_GLFW_WIN32) list(APPEND glfw_PKG_LIBS "-lgdi32") - if (GLFW_USE_OPTIMUS_HPG) - set(_GLFW_USE_OPTIMUS_HPG 1) + if (GLFW_USE_HYBRID_HPG) + set(_GLFW_USE_HYBRID_HPG 1) endif() endif() diff --git a/README.md b/README.md index 40335f86..c404cfde 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. ## Changelog - Minimum required CMake version updated to 2.8.12 + - Renamed hybrid GPU override compile-time option to `_GLFW_USE_HYBRID_HPG` and + added support for AMD PowerXpress systems - Bugfix: Initialization failed on headless systems - Bugfix: The cached current context could get out of sync - [Cocoa] Bugfix: The cached `NSScreen` for a monitor could get out of sync diff --git a/docs/compile.dox b/docs/compile.dox index 11d06f7a..f4112d62 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -221,11 +221,11 @@ DLL version of the Visual C++ library is used. It is recommended to set this to `ON`, as this keeps the executable smaller and benefits from security and bug fix updates of the Visual C++ runtime. -`GLFW_USE_OPTIMUS_HPG` determines whether to export the `NvOptimusEnablement` -symbol, which forces the use of the high-performance GPU on Nvidia Optimus -systems. This symbol needs to be exported by the EXE to be detected by the -driver, so the override will not work if GLFW is built as a DLL. See _Enabling -High Performance Graphics Rendering on Optimus Systems_ for more details. +`GLFW_USE_HYBRID_HPG` determines whether to export the `NvOptimusEnablement` and +`AmdPowerXpressRequestHighPerformance` symbols, which force the use of the +high-performance GPU on Nvidia Optimus and AMD PowerXpress systems. These symbols +need to be exported by the EXE to be detected by the driver, so the override +will not work if GLFW is built as a DLL. @subsubsection compile_options_egl EGL specific CMake options diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index b805a7af..33296f5c 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -57,8 +57,8 @@ // Define this to 1 if building as a shared library / dynamic library / DLL #cmakedefine _GLFW_BUILD_DLL -// Define this to 1 to force use of high-performance GPU on Optimus systems -#cmakedefine _GLFW_USE_OPTIMUS_HPG +// Define this to 1 to force use of high-performance GPU on hybrid systems +#cmakedefine _GLFW_USE_HYBRID_HPG // Define this to 1 if the XInput X11 extension is available #cmakedefine _GLFW_HAS_XINPUT diff --git a/src/win32_init.c b/src/win32_init.c index 068a82ac..7c3bd093 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -31,14 +31,21 @@ #include -#if defined(_GLFW_USE_OPTIMUS_HPG) +#if defined(_GLFW_USE_HYBRID_HPG) || defined(_GLFW_USE_OPTIMUS_HPG) // Applications exporting this symbol with this value will be automatically -// directed to the high-performance GPU on Nvidia Optimus systems +// directed to the high-performance GPU on Nvidia Optimus systems with +// up-to-date drivers // -__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +__declspec(dllexport) DWORD NvOptimusEnablement = 1; -#endif // _GLFW_USE_OPTIMUS_HPG +// Applications exporting this symbol with this value will be automatically +// directed to the high-performance GPU on AMD PowerXpress systems with +// up-to-date drivers +// +__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; + +#endif // _GLFW_USE_HYBRID_HPG #if defined(_GLFW_BUILD_DLL)