[Libreoffice-commits] core.git: Branch 'feature/fixes36' - vcl/inc vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Mon Sep 19 16:19:45 UTC 2016
vcl/inc/opengl/watchdog.hxx | 35 +++++++++++++++++++++++++
vcl/inc/opengl/zone.hxx | 1
vcl/source/opengl/OpenGLHelper.cxx | 51 ++++++++++++++++++++++++++++++-------
3 files changed, 78 insertions(+), 9 deletions(-)
New commits:
commit a3ec258976fb305a4b38012a45fd9f591faedf5d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Sep 19 18:03:47 2016 +0200
vcl: relax timeout timings for the GL watchdog
Some OS/GPU combinations need more relaxed watchdog timeout timings
as the shader compilation takes too long to complete.
Change-Id: Ifd9ff7ecfa4b004d5411d6d364dd01a389a3fcec
diff --git a/vcl/inc/opengl/watchdog.hxx b/vcl/inc/opengl/watchdog.hxx
index 0213efb..ce97064 100644
--- a/vcl/inc/opengl/watchdog.hxx
+++ b/vcl/inc/opengl/watchdog.hxx
@@ -14,6 +14,41 @@
#include <sal/types.h>
#include <rtl/ref.hxx>
#include <salhelper/thread.hxx>
+#include <osl/mutex.hxx>
+
+struct WatchdogTimings
+{
+ osl::Mutex maMutex;
+
+ int mnMode;
+
+ std::vector<int> maDisableEntries;
+ std::vector<int> maAbortAfter;
+
+ WatchdogTimings();
+
+ void relax();
+
+ int getMode()
+ {
+ return mnMode;
+ }
+
+ void setMode(int nMode)
+ {
+ mnMode = nMode;
+ }
+
+ int getDisableEntries()
+ {
+ return maDisableEntries[mnMode];
+ }
+
+ int getAbortAfter()
+ {
+ return maAbortAfter[mnMode];
+ }
+};
class OpenGLWatchdogThread : private salhelper::Thread
{
diff --git a/vcl/inc/opengl/zone.hxx b/vcl/inc/opengl/zone.hxx
index 11f6ed0..65a7249 100644
--- a/vcl/inc/opengl/zone.hxx
+++ b/vcl/inc/opengl/zone.hxx
@@ -38,6 +38,7 @@ public:
~OpenGLZone() { gnLeaveCount++; }
static bool isInZone() { return gnEnterCount != gnLeaveCount; }
static void hardDisable();
+ static void relaxWatchdogTimings();
};
/// Create this to not only enter the zone, but set VCL context.
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index 5dff689..38317e5 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -780,6 +780,13 @@ bool OpenGLHelper::isDeviceBlacklisted()
#elif defined( _WIN32 )
WinOpenGLDeviceInfo aInfo;
bBlacklisted = aInfo.isDeviceBlocked();
+
+ if (aInfo.GetWindowsVersion() == 0x00060001 && /* Windows 7 */
+ aInfo.GetAdapterVendorID() == "0x1022") /* AMD */
+ {
+ SAL_INFO("vcl.opengl", "Relaxing watchdog timings.");
+ OpenGLZone::relaxWatchdogTimings();
+ }
#else
bBlacklisted = false;
#endif
@@ -806,9 +813,27 @@ void OpenGLZone::leave() { gnLeaveCount++; }
namespace {
static volatile bool gbWatchdogFiring = false;
static oslCondition gpWatchdogExit = nullptr;
+ static WatchdogTimings gWatchdogTimings;
static rtl::Reference<OpenGLWatchdogThread> gxWatchdog;
}
+WatchdogTimings::WatchdogTimings()
+ : mnMode(0)
+ , maDisableEntries({ 6 /* 1.5s */, 20 /* 5s */ })
+ , maAbortAfter({ 20 /* 5s */, 120 /* 30s */ })
+{}
+
+void WatchdogTimings::relax()
+{
+ osl::MutexGuard g(maMutex);
+
+ maDisableEntries[0] = 20; /* 5s */
+ maDisableEntries[1] = 60; /* 15s */
+
+ maAbortAfter[0] = 40; /* 10s */
+ maAbortAfter[1] = 240; /* 60s */
+}
+
OpenGLWatchdogThread::OpenGLWatchdogThread()
: salhelper::Thread("OpenGL Watchdog")
{
@@ -821,20 +846,23 @@ void OpenGLWatchdogThread::execute()
static const int nAbortAfter[2] = { 20 /* 10s */, 120 /* 30s */ };
int nUnchanged = 0; // how many unchanged nEnters
- TimeValue aHalfSecond(0, 1000*1000*1000*0.25);
+ TimeValue aQuarterSecond(0, 1000*1000*1000*0.25);
bool bAbortFired = false;
do {
sal_uInt64 nLastEnters = OpenGLZone::gnEnterCount;
- osl_waitCondition(gpWatchdogExit, &aHalfSecond);
+ osl_waitCondition(gpWatchdogExit, &aQuarterSecond);
if (OpenGLZone::isInZone())
{
- int nType = 0;
+ osl::MutexGuard g(gWatchdogTimings.maMutex);
+
// The shader compiler can take a long time, first time.
if (gbInShaderCompile)
- nType = 1;
+ gWatchdogTimings.setMode(1);
+ else
+ gWatchdogTimings.setMode(0);
if (nLastEnters == OpenGLZone::gnEnterCount)
nUnchanged++;
@@ -843,12 +871,12 @@ void OpenGLWatchdogThread::execute()
SAL_INFO("vcl.opengl", "GL watchdog - unchanged " <<
nUnchanged << " enter count " <<
OpenGLZone::gnEnterCount << " type " <<
- (nType ? "in shader" : "normal gl") <<
- "breakpoints mid: " << nDisableEntries[nType] <<
- " max " << nAbortAfter[nType]);
+ (gWatchdogTimings.getMode() ? "in shader" : "normal gl") <<
+ "breakpoints mid: " << gWatchdogTimings.getDisableEntries() <<
+ " max " << gWatchdogTimings.getAbortAfter());
// Not making progress
- if (nUnchanged >= nDisableEntries[nType])
+ if (nUnchanged >= gWatchdogTimings.getDisableEntries())
{
static bool bFired = false;
if (!bFired)
@@ -869,7 +897,7 @@ void OpenGLWatchdogThread::execute()
}
// Not making even more progress
- if (nUnchanged >= nAbortAfter[nType])
+ if (nUnchanged >= gWatchdogTimings.getAbortAfter())
{
if (!bAbortFired)
{
@@ -943,6 +971,11 @@ void OpenGLZone::hardDisable()
}
}
+void OpenGLZone::relaxWatchdogTimings()
+{
+ gWatchdogTimings.relax();
+}
+
OpenGLVCLContextZone::OpenGLVCLContextZone()
{
OpenGLContext::makeVCLCurrent();
More information about the Libreoffice-commits
mailing list