]> git.vomp.tv Git - vompclient.git/commitdiff
OsdOpenVG Render-on-demand experiment
authorChris Tallon <chris@vomp.tv>
Fri, 22 May 2020 13:48:54 +0000 (14:48 +0100)
committerChris Tallon <chris@vomp.tv>
Fri, 22 May 2020 13:48:54 +0000 (14:48 +0100)
An experiment to switch from a timed render loop to rendering
only on demand, in order to increase responsiveness of OSD and
reduce CPU usage.

There could be major negatives to this, therefore all changes
are marked with OSDOVG-ROD-EXPERIMENT for easy greppage. See
notes in source.

There will certainly be temporary breakages.

osd.h
osdopenvg.cc
osdopenvg.h
osdvector.cc

diff --git a/osd.h b/osd.h
index 1aa473f542bcdb61958722ec879a89c0d8e534c5..dfe696cc65d5621e1443c1133a470b2b52aa5609 100644 (file)
--- a/osd.h
+++ b/osd.h
@@ -46,6 +46,9 @@ class Osd
 
     virtual float getPixelAspect() { return 1.f; };
 
+    // OSDOVG-ROD-EXPERIMENT - hack to allow OsdVector to call OsdOpenVG::nudge/signal render thread. work out a better way.
+    virtual void nudgeRenderThread() { };
+
   protected:
     static Osd* instance;
     bool initted{};
index c79eaa5510e7f5243238767f177592cb908e7e4e..290fd1c0cbb056af4162407ec3c9a34f431016e8 100644 (file)
@@ -412,6 +412,41 @@ int OsdOpenVG::shutdown()
   return 1;
 }
 
+// OSDOVG-ROD-EXPERIMENT - temp hack to allow OsdVector to signal the thread in OsdOpenVG
+void OsdOpenVG::nudgeRenderThread()
+{
+  Log::getInstance()->log("OSD", Log::DEBUG, "Nudge render thread");
+
+  // signal renderLoop to go-around (from putOpenVGCommand)
+  renderThreadMutex.lock();
+  if (renderThreadReq == 0) renderThreadReq = 1;
+  renderThreadCond.notify_one();
+  renderThreadMutex.unlock();
+}
+
+/*
+ * OSDOVG-ROD-EXPERIMENT
+ *
+ * To switch OsdOpenVG to render-on-demand instead of rendering in a loop
+ *
+ * Pros:
+ *   More responsive OSD
+ *   Cuts 5% constant CPU usage
+ *   Seems to have tickled the GFX corruption bug, might make it easier to find that
+ *
+ * Cons:
+ *   There's a comment about video tearing if render is called too often.
+ *     Will tearing show up in on-demand mode?
+ *   Moves away from conventional FPS type render loop. VOMP doesn't use 3D GFX / animations
+ *     currently, so this doesn't matter at the moment?
+ *   Code needs updating to call nudgeRenderThread,
+ *   e.g. FIXME backing out of the options screen doesn't redraw VWelcome
+ *
+ *   Maybe have a hybrid system. One that normally works on-demand but can
+ *   also switch to looping on the fly if necessary.
+ */
+
+
 void OsdOpenVG::renderLoop()
 {
   // We have to claim the egl context for this thread
@@ -438,7 +473,8 @@ void OsdOpenVG::renderLoop()
 
     long long time1 = getTimeMS();
 
-    if ((time1 - lastrendertime) > 200)  //5 fps for OSD updates are enough, avoids tearing
+    // OSDOVG-ROD-EXPERIMENT - always render, but only when signalled to
+    if (1) // ((time1 - lastrendertime) > 200)  //5 fps for OSD updates are enough, avoids tearing
     {
       #if DEV
       dumpStyles();
@@ -467,6 +503,8 @@ void OsdOpenVG::renderLoop()
 
     if (ts != 0)
     {
+      // OSDOVG-ROD-EXPERIMENT
+      // renderThreadCond.wait(ul, [this]{ return renderThreadReq != 0; }); // experiment! always wait, no time limit
       renderThreadCond.wait_for(ul, std::chrono::milliseconds(ts), [this]{ return renderThreadReq != 0; });
 
       if (renderThreadReq == 2)
@@ -477,6 +515,8 @@ void OsdOpenVG::renderLoop()
         return;
       }
 
+      if (renderThreadReq == 0) abort(); // OSDOVG-ROD-EXPERIMENT - check this never happens
+
       // Either timeout or renderThreadReq == 1 - go around
 
       renderThreadReq = 0;
index 45e9915eda56d2ed914948be76362ff4b4d18015..43645ca273a78a782a096aafb3a4ec182c147263 100644 (file)
@@ -104,6 +104,10 @@ class OsdOpenVG : public OsdVector
     void updateBackgroundColor(DrawStyle bg);
 
   protected:
+
+    // OSDOVG-ROD-EXPERIMENT
+    void nudgeRenderThread();
+
     /*osd vector implementation*/
     void destroyImageRef(ImageIndex index);
     // ImageIndex createJpeg(const char* fileName, int *width,int *height);
index 74f783f1cf32cc4f443094c7a34a0d255636c80f..88f536bdadf2cd4d71da0038c88e2fc928d83f30 100644 (file)
@@ -335,6 +335,9 @@ void OsdVector::updateOrAddSurface(const SurfaceVector* surf, float x, float y,
   Log::getInstance()->log("OsdVector", Log::CRAZY, "After UOAS:");
   dumpStyles();
   #endif
+
+  // OSDOVG-ROD-EXPERIMENT
+  nudgeRenderThread();
 }
 
 void OsdVector::removeSurface(const SurfaceVector* surf)