aboutsummaryrefslogtreecommitdiff
path: root/src/porting.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2022-05-17 22:12:00 +0200
commit21df26984da91143c15587f5a03c98d68c3adc4e (patch)
treeaaa707a628ad331f67890023dffe1b4f60dd01d3 /src/porting.cpp
parentb09fc5de5cdb021f43ad32b7e3f50dc75c0bc622 (diff)
parenteabf05758e3ba5f6f4bb1b8d1d1f02179b84e410 (diff)
downloaddragonfireclient-21df26984da91143c15587f5a03c98d68c3adc4e.tar.xz
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'src/porting.cpp')
-rw-r--r--src/porting.cpp15
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;