commit 92695072116ae26dc922b6e9b2bfdbb07d30e166
parent 7e7592755d354921f38c2d6c1e13f07c646d9694
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Fri, 16 Jul 2021 22:31:13 +0200
set FPU bit to flush denormals to zero
Diffstat:
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/source/synthLib/os.cpp b/source/synthLib/os.cpp
@@ -1,6 +1,7 @@
#include "os.h"
#include "../dsp56300/source/dsp56kEmu/logging.h"
+#include "../dsp56300/source/dsp56kEmu/buildconfig.h"
#ifndef _WIN32
// filesystem is only available on Mac OS Catalina 10.15+
@@ -23,7 +24,11 @@
# include <dlfcn.h>
#endif
-#pragma optimize("",off)
+#ifdef _MSC_VER
+# include <cfloat>
+#elif defined(HAVE_SSE)
+# include <immintrin.h>
+#endif
namespace synthLib
{
@@ -177,4 +182,13 @@ namespace synthLib
return std::string();
}
+
+ void setFlushDenormalsToZero()
+ {
+#if defined(_MSC_VER)
+ _controlfp(_DN_FLUSH, _MCW_DN);
+#elif defined(HAVE_SSE)
+ _MM_SET_FLUSH_ZERO_MODE (_MM_FLUSH_ZERO_ON);
+#endif
+ }
}
diff --git a/source/synthLib/os.h b/source/synthLib/os.h
@@ -5,4 +5,5 @@ namespace synthLib
{
std::string getModulePath();
std::string findROM(size_t _expectedSize = 524288);
+ void setFlushDenormalsToZero();
}
diff --git a/source/synthLib/plugin.cpp b/source/synthLib/plugin.cpp
@@ -3,6 +3,8 @@
#include <cmath>
+#include "os.h"
+
using namespace synthLib;
namespace synthLib
@@ -67,6 +69,8 @@ namespace synthLib
if(!m_device->isValid())
return;
+ setFlushDenormalsToZero();
+
processMidiClock(_bpm, _ppqPos, _isPlaying, _count);
float* inputs[8] {};