From a5fb4294f00386b0029d8488c7c439887f6c3f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Re=C4=87ko?= Date: Sun, 2 Dec 2018 22:41:22 +0100 Subject: [PATCH 1/3] Feature: Add the Discrete GPU force header for use in executables. Used on Windows to force Optimus and Xpress to use Nvidia/AMD discrete GPU's instead of Intel integrated graphics. --- .../RenderAPI/BsWin32DiscreteGpuForce.h | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h diff --git a/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h new file mode 100644 index 000000000..25d130ce3 --- /dev/null +++ b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h @@ -0,0 +1,27 @@ +//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// +//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// + +/** + * This Header file is used on Windows-based systems to force the operating system + * to use discrete graphics chips on laptops instead of the integrated graphics chips. + * This only affects Direct3D and OpenGL based RenderAPI back-ends. + * @note This header shouldn't be used on non-Windows based operating systems and + * and it should only be included by final executables. + * Incorrect usage will cause error during compilation. + */ + +#if BS_PLATFORM == BS_PLATFORM_WIN32 +#if defined(BS_FORCE_DISCRETE_GPUS_INCLUDE_CHECK) + #error GPU force header file already included. Please, only include it in the program's executable. Aborting compilation. +#else +#define BS_FORCE_DISCRETE_GPUS_INCLUDE_CHECK + +extern "C" +{ +__declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; +__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +} + +#endif + +#endif \ No newline at end of file From 6af5090dc6109feeb601ff938f81e533e97b3d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Re=C4=87ko?= Date: Sat, 15 Dec 2018 14:47:33 +0100 Subject: [PATCH 2/3] Other: Minor remains for BsWin32DiscreteGpuForce.h - Add the file into CMakeSources.cmake - Minor wording fixes --- Source/Foundation/bsfCore/CMakeSources.cmake | 1 + Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Foundation/bsfCore/CMakeSources.cmake b/Source/Foundation/bsfCore/CMakeSources.cmake index 446089fc3..1de523522 100644 --- a/Source/Foundation/bsfCore/CMakeSources.cmake +++ b/Source/Foundation/bsfCore/CMakeSources.cmake @@ -163,6 +163,7 @@ set(BS_CORE_INC_RENDERAPI "bsfCore/RenderAPI/BsGpuPipelineState.h" "bsfCore/RenderAPI/BsGpuPipelineParamInfo.h" "bsfCore/RenderAPI/BsVertexDataDesc.h" + "bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h" ) set(BS_CORE_INC_RENDERAPI_MANAGERS diff --git a/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h index 25d130ce3..3c52cae5a 100644 --- a/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h +++ b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h @@ -12,7 +12,7 @@ #if BS_PLATFORM == BS_PLATFORM_WIN32 #if defined(BS_FORCE_DISCRETE_GPUS_INCLUDE_CHECK) - #error GPU force header file already included. Please, only include it in the program's executable. Aborting compilation. + #error GPU force header file already included. Please, only include it once and preferably in the program's executable. Aborting compilation. #else #define BS_FORCE_DISCRETE_GPUS_INCLUDE_CHECK From b7cded026f421231d2183150d8823e63706d1b53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Re=C4=87ko?= Date: Sat, 15 Dec 2018 14:53:37 +0100 Subject: [PATCH 3/3] Remove ambiguous comment on BsWin32DiscreteGpuForce.h --- Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h index 3c52cae5a..ebaddf88b 100644 --- a/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h +++ b/Source/Foundation/bsfCore/RenderAPI/BsWin32DiscreteGpuForce.h @@ -4,7 +4,6 @@ /** * This Header file is used on Windows-based systems to force the operating system * to use discrete graphics chips on laptops instead of the integrated graphics chips. - * This only affects Direct3D and OpenGL based RenderAPI back-ends. * @note This header shouldn't be used on non-Windows based operating systems and * and it should only be included by final executables. * Incorrect usage will cause error during compilation.