Commit f8e33807 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Add GUI switch for disabling AVX optimization on Widnows

If you happen to have any random crashes while normal painting
with a brush, and you are on Windows, then try to disable this
option, it might help.

BUG:406209
parent da5d38cb
......@@ -72,10 +72,12 @@ createOptimizedClass(typename FactoryType::ParamType param)
{
static bool isConfigInitialized = false;
static bool useVectorization = true;
static bool disableAVXOptimizations = false;
if (!isConfigInitialized) {
KConfigGroup cfg = KSharedConfig::openConfig()->group("");
useVectorization = !cfg.readEntry("amdDisableVectorWorkaround", false);
disableAVXOptimizations = cfg.readEntry("disableAVXOptimizations", false);
isConfigInitialized = true;
}
......@@ -83,16 +85,24 @@ createOptimizedClass(typename FactoryType::ParamType param)
qWarning() << "WARNING: vector instructions disabled by \'amdDisableVectorWorkaround\' option!";
return FactoryType::template create<Vc::ScalarImpl>(param);
}
#ifdef HAVE_VC
if (disableAVXOptimizations &&
(Vc::isImplementationSupported(Vc::AVXImpl) ||
Vc::isImplementationSupported(Vc::AVX2Impl))) {
qWarning() << "WARNING: AVX and AVX2 optimizations are disabled by \'disableAVXOptimizations\' option!";
}
/**
* We use SSE2, SSSE3, SSE4.1, AVX and AVX2.
* The rest are integer and string instructions mostly.
*
* TODO: Add FMA3/4 when it is adopted by Vc
*/
if (Vc::isImplementationSupported(Vc::AVX2Impl)) {
if (!disableAVXOptimizations && Vc::isImplementationSupported(Vc::AVX2Impl)) {
return FactoryType::template create<Vc::AVX2Impl>(param);
} else if (Vc::isImplementationSupported(Vc::AVXImpl)) {
} else if (!disableAVXOptimizations && Vc::isImplementationSupported(Vc::AVXImpl)) {
return FactoryType::template create<Vc::AVXImpl>(param);
} else if (Vc::isImplementationSupported(Vc::SSE41Impl)) {
return FactoryType::template create<Vc::SSE41Impl>(param);
......
......@@ -875,6 +875,11 @@ PerformanceTab::PerformanceTab(QWidget *parent, const char *name)
connect(chkCachedFramesSizeLimit, SIGNAL(toggled(bool)), intCachedFramesSizeLimit, SLOT(setEnabled(bool)));
connect(chkUseRegionOfInterest, SIGNAL(toggled(bool)), intRegionOfInterestMargin, SLOT(setEnabled(bool)));
#ifndef Q_OS_WIN
// AVX workaround is needed on Windows+GCC only
chkDisableAVXOptimizations->setVisible(false);
#endif
load(false);
}
......@@ -910,6 +915,9 @@ void PerformanceTab::load(bool requestDefault)
chkOpenGLFramerateLogging->setChecked(cfg2.enableOpenGLFramerateLogging(requestDefault));
chkBrushSpeedLogging->setChecked(cfg2.enableBrushSpeedLogging(requestDefault));
chkDisableVectorOptimizations->setChecked(cfg2.enableAmdVectorizationWorkaround(requestDefault));
#ifdef Q_OS_WIN
chkDisableAVXOptimizations->setChecked(cfg2.disableAVXOptimizations(requestDefault));
#endif
chkBackgroundCacheGeneration->setChecked(cfg2.calculateAnimationCacheInBackground(requestDefault));
}
......@@ -952,6 +960,9 @@ void PerformanceTab::save()
cfg2.setEnableOpenGLFramerateLogging(chkOpenGLFramerateLogging->isChecked());
cfg2.setEnableBrushSpeedLogging(chkBrushSpeedLogging->isChecked());
cfg2.setEnableAmdVectorizationWorkaround(chkDisableVectorOptimizations->isChecked());
#ifdef Q_OS_WIN
cfg2.setDisableAVXOptimizations(chkDisableAVXOptimizations->isChecked());
#endif
cfg2.setCalculateAnimationCacheInBackground(chkBackgroundCacheGeneration->isChecked());
}
......
......@@ -352,10 +352,17 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDisableAVXOptimizations">
<property name="text">
<string>Disable AVX vector optimizations</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkDisableVectorOptimizations">
<property name="text">
<string>Disable vector optimizations (for AMD CPUs)</string>
<string>Disable all vector optimizations (for AMD CPUs)</string>
</property>
</widget>
</item>
......
......@@ -1886,6 +1886,16 @@ bool KisConfig::enableAmdVectorizationWorkaround(bool defaultValue) const
return (defaultValue ? false : m_cfg.readEntry("amdDisableVectorWorkaround", false));
}
void KisConfig::setDisableAVXOptimizations(bool value)
{
m_cfg.writeEntry("disableAVXOptimizations", value);
}
bool KisConfig::disableAVXOptimizations(bool defaultValue) const
{
return (defaultValue ? false : m_cfg.readEntry("disableAVXOptimizations", false));
}
void KisConfig::setAnimationDropFrames(bool value)
{
bool oldValue = animationDropFrames();
......
......@@ -537,6 +537,9 @@ public:
void setEnableAmdVectorizationWorkaround(bool value);
bool enableAmdVectorizationWorkaround(bool defaultValue = false) const;
void setDisableAVXOptimizations(bool value);
bool disableAVXOptimizations(bool defaultValue = false) const;
bool animationDropFrames(bool defaultValue = false) const;
void setAnimationDropFrames(bool value);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment