From b74fd6d4a2f2d61cf38c31117645cae8e5f9e0f1 Mon Sep 17 00:00:00 2001 From: Stan Date: Thu, 30 Dec 2021 13:57:40 +0000 Subject: [PATCH] Use the high performance GPU on Windows by default. Reviewed by: @vladislavbelov Accepted by: @asterix Differential Revision: https://code.wildfiregames.com/D4401 This was SVN commit r26140. --- source/main.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/main.cpp b/source/main.cpp index 408f19fe7b..ed67c69b67 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -100,6 +100,24 @@ that of Atlas depending on commandline parameters. #define getpid _getpid // Use the non-deprecated function name #endif +#if OS_WIN +// We don't want to include Windows.h as it might mess up the rest +// of the file so we just define DWORD as done in Windef.h. +#ifndef DWORD +typedef unsigned long DWORD; +#endif // !DWORD +// Request the high performance GPU on Windows by default if no system override is specified. +// See: +// - https://github.com/supertuxkart/stk-code/pull/4693/commits/0a99c667ef513b2ce0f5755729a6e05df8aac48a +// - https://docs.nvidia.com/gameworks/content/technologies/desktop/optimus.htm +// - https://gpuopen.com/learn/amdpowerxpressrequesthighperformance/ +extern "C" +{ + __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001; +} +#endif + #include extern CStrW g_UniqueLogPostfix;