vcl/inc/opengl/watchdog.hxx        |   46 +++++++++++++++++++------------------
 vcl/source/opengl/OpenGLHelper.cxx |   38 +++++++++---------------------
 2 files changed, 36 insertions(+), 48 deletions(-)

New commits:
commit 134ec707ab78ddcdcb290bb301871f9465507c91
Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
Date:   Tue Sep 20 18:36:46 2016 +0900

    tdf#102295: remove mutex - use atomic for watchdog timings
    
    Change-Id: I6587bad8b7906faeae39735343278b10be78c05b

diff --git a/vcl/inc/opengl/watchdog.hxx b/vcl/inc/opengl/watchdog.hxx
index ced3cf2..c266de6 100644
--- a/vcl/inc/opengl/watchdog.hxx
+++ b/vcl/inc/opengl/watchdog.hxx
@@ -14,40 +14,42 @@
 #include <sal/types.h>
 #include <rtl/ref.hxx>
 #include <salhelper/thread.hxx>
-#include <osl/mutex.hxx>
+#include <atomic>
 
-struct WatchdogTimings
+struct WatchdogTimingsValues
 {
-    osl::Mutex maMutex;
-
-    int mnMode;
-
     /// delays to take various actions in 1/4 of a second increments.
-    std::vector<int> maDisableEntries;
-    std::vector<int> maAbortAfter;
+    int mnDisableEntries;
+    int mnAbortAfter;
+};
 
-    WatchdogTimings();
+enum class WatchdogTimingMode
+{
+    NORMAL,
+    SHADER_COMPILE
+};
 
-    void relax();
+class WatchdogTimings
+{
+private:
+    std::vector<WatchdogTimingsValues> maTimingValues;
+    std::atomic<bool> mbRelaxed;
 
-    int getMode()
-    {
-        return mnMode;
-    }
+public:
+    WatchdogTimings();
 
-    void setMode(int nMode)
+    void setRelax(bool bRelaxed)
     {
-        mnMode = nMode;
+        mbRelaxed = bRelaxed;
     }
 
-    int getDisableEntries()
+    WatchdogTimingsValues getWatchdogTimingsValues(WatchdogTimingMode eMode)
     {
-       return maDisableEntries[mnMode];
-    }
+        size_t index = 0;
+        index = (eMode == WatchdogTimingMode::SHADER_COMPILE) ? 1 : 0;
+        index = mbRelaxed ? index + 2 : index;
 
-    int getAbortAfter()
-    {
-        return maAbortAfter[mnMode];
+        return maTimingValues[index];
     }
 };
 
diff --git a/vcl/source/opengl/OpenGLHelper.cxx 
b/vcl/source/opengl/OpenGLHelper.cxx
index 6b58a4d..12f6151 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -818,20 +818,10 @@ namespace {
 }
 
 WatchdogTimings::WatchdogTimings()
-    : mnMode(0)
-    , maDisableEntries({ 6 /* 1.5s */,  20 /* 5s */ })
-    , maAbortAfter({ 20 /* 5s */, 120 /* 30s */ })
-{}
-
-void WatchdogTimings::relax()
+    : maTimingValues({{6,   20} /* 1.5s,  5s */, {20, 120} /*  5s, 30s */,
+                      {60, 240} /*  15s, 60s */, {60, 240} /* 15s, 60s */})
+    , mbRelaxed(false)
 {
-    osl::MutexGuard g(maMutex);
-
-    maDisableEntries[0] = 60; /* 15s */
-    maDisableEntries[1] = 60; /* 15s */
-
-    maAbortAfter[0] = 240; /* 60s */
-    maAbortAfter[1] = 240; /* 60s */
 }
 
 OpenGLWatchdogThread::OpenGLWatchdogThread()
@@ -852,13 +842,9 @@ void OpenGLWatchdogThread::execute()
 
         if (OpenGLZone::isInZone())
         {
-            osl::MutexGuard g(gWatchdogTimings.maMutex);
-
             // The shader compiler can take a long time, first time.
-            if (gbInShaderCompile)
-                gWatchdogTimings.setMode(1);
-            else
-                gWatchdogTimings.setMode(0);
+            WatchdogTimingMode eMode = gbInShaderCompile ? 
WatchdogTimingMode::SHADER_COMPILE : WatchdogTimingMode::NORMAL;
+            WatchdogTimingsValues aTimingValues = 
gWatchdogTimings.getWatchdogTimingsValues(eMode);
 
             if (nLastEnters == OpenGLZone::gnEnterCount)
                 nUnchanged++;
@@ -867,12 +853,12 @@ void OpenGLWatchdogThread::execute()
             SAL_INFO("vcl.opengl", "GL watchdog - unchanged " <<
                      nUnchanged << " enter count " <<
                      OpenGLZone::gnEnterCount << " type " <<
-                     (gWatchdogTimings.getMode() ? "in shader" : "normal gl") 
<<
-                     "breakpoints mid: " << 
gWatchdogTimings.getDisableEntries() <<
-                     " max " << gWatchdogTimings.getAbortAfter());
+                     (eMode == WatchdogTimingMode::SHADER_COMPILE ? "in 
shader" : "normal gl") <<
+                     "breakpoints mid: " << aTimingValues.mnDisableEntries <<
+                     " max " << aTimingValues.mnAbortAfter);
 
             // Not making progress
-            if (nUnchanged >= gWatchdogTimings.getDisableEntries())
+            if (nUnchanged >= aTimingValues.mnDisableEntries)
             {
                 static bool bFired = false;
                 if (!bFired)
@@ -893,7 +879,7 @@ void OpenGLWatchdogThread::execute()
             }
 
             // Not making even more progress
-            if (nUnchanged >= gWatchdogTimings.getAbortAfter())
+            if (nUnchanged >= aTimingValues.mnAbortAfter)
             {
                 if (!bAbortFired)
                 {
@@ -969,7 +955,7 @@ void OpenGLZone::hardDisable()
 
 void OpenGLZone::relaxWatchdogTimings()
 {
-    gWatchdogTimings.relax();
+    gWatchdogTimings.setRelax(true);
 }
 
 OpenGLVCLContextZone::OpenGLVCLContextZone()
commit 073fc31c049056919c6a46d43dccb6a94981491d
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Tue Sep 20 09:38:49 2016 +0200

    tdf#102295: The relaxed values were actually too pessimistic.
    
    Change-Id: Ia117ae4a60a10994f3c59316e8c9a161aa8e5baf

diff --git a/vcl/source/opengl/OpenGLHelper.cxx 
b/vcl/source/opengl/OpenGLHelper.cxx
index e8dbce6..6b58a4d 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -827,8 +827,8 @@ void WatchdogTimings::relax()
 {
     osl::MutexGuard g(maMutex);
 
-    maDisableEntries[0] = 180; /* 45s */
-    maDisableEntries[1] = 180; /* 45s */
+    maDisableEntries[0] = 60; /* 15s */
+    maDisableEntries[1] = 60; /* 15s */
 
     maAbortAfter[0] = 240; /* 60s */
     maAbortAfter[1] = 240; /* 60s */
commit 3be4477c4bcfc7b0bdb813726d59d0d85ee5e344
Author: Jan Holesovsky <ke...@collabora.com>
Date:   Tue Sep 20 09:47:36 2016 +0200

    tdf#102295: AMD actually has two vendor id's.
    
    Change-Id: I9cc1341c8f8d154927a778dfa15b8d3013a9a487

diff --git a/vcl/source/opengl/OpenGLHelper.cxx 
b/vcl/source/opengl/OpenGLHelper.cxx
index f36b4da..e8dbce6 100644
--- a/vcl/source/opengl/OpenGLHelper.cxx
+++ b/vcl/source/opengl/OpenGLHelper.cxx
@@ -782,7 +782,7 @@ bool OpenGLHelper::isDeviceBlacklisted()
         bBlacklisted = aInfo.isDeviceBlocked();
 
         if (aInfo.GetWindowsVersion() == 0x00060001 && /* Windows 7 */
-            aInfo.GetAdapterVendorID() == "0x1022")    /* AMD */
+            (aInfo.GetAdapterVendorID() == "0x1002" || 
aInfo.GetAdapterVendorID() == "0x1022")) /* AMD */
         {
             SAL_INFO("vcl.opengl", "Relaxing watchdog timings.");
             OpenGLZone::relaxWatchdogTimings();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to