diff options
Diffstat (limited to 'src/porting.cpp')
-rw-r--r-- | src/porting.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/porting.cpp b/src/porting.cpp index 4c87bddee..09627431c 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <algorithm> #include <shlwapi.h> #include <shellapi.h> + #include <mmsystem.h> #endif #if !defined(_WIN32) #include <unistd.h> @@ -69,6 +70,15 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <cstdarg> #include <cstdio> +#if !defined(SERVER) && defined(_WIN32) +// On Windows export some driver-specific variables to encourage Minetest to be +// executed on the discrete GPU in case of systems with two. Portability is fun. +extern "C" { + __declspec(dllexport) DWORD NvOptimusEnablement = 1; + __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 1; +} +#endif + namespace porting { @@ -598,7 +608,7 @@ void initializePaths() // First try $XDG_CACHE_HOME/PROJECT_NAME const char *cache_dir = getenv("XDG_CACHE_HOME"); const char *home_dir = getenv("HOME"); - if (cache_dir) { + if (cache_dir && cache_dir[0] != '\0') { path_cache = std::string(cache_dir) + DIR_DELIM + PROJECT_NAME; } else if (home_dir) { // Then try $HOME/.cache/PROJECT_NAME @@ -766,6 +776,9 @@ bool open_directory(const std::string &path) inline double get_perf_freq() { + // Also use this opportunity to enable high-res timers + timeBeginPeriod(1); + LARGE_INTEGER freq; QueryPerformanceFrequency(&freq); return freq.QuadPart; |