Performance Improvements: Remove unnecessary SwapBuffer calls 87/148087/1
authorTom Robinson <tom.robinson@samsung.com>
Tue, 22 Aug 2017 10:29:51 +0000 (11:29 +0100)
committerVictor Cebollada <v.cebollada@samsung.com>
Wed, 6 Sep 2017 16:06:42 +0000 (17:06 +0100)
Change-Id: I68c6e3a4b1b841bc7b0ca923905a9397b74bb82d

dali/integration-api/core.h
dali/internal/render/common/render-manager.cpp

index 19693d8..06efad2 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_INTEGRATION_CORE_H__
-#define __DALI_INTEGRATION_CORE_H__
+#ifndef DALI_INTEGRATION_CORE_H
+#define DALI_INTEGRATION_CORE_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -119,26 +119,52 @@ public:
    * Constructor
    */
   RenderStatus()
-  : needsUpdate(false)
+  : needsUpdate( false ),
+    needsPostRender( false )
   {
   }
 
   /**
    * Set whether update needs to run following a render.
-   * This might be because render has sent messages to update, or it has
-   * some textures to upload over several frames.
+   * @param[in] updateRequired Set to true if an update is required to be run
    */
-  void SetNeedsUpdate(bool updateRequired) { needsUpdate = updateRequired; }
+  void SetNeedsUpdate( bool updateRequired )
+  {
+    needsUpdate = updateRequired;
+  }
 
   /**
    * Query the update status following rendering of a frame.
-   * @return true if update should run.
+   * @return True if update is required to be run
+   */
+  bool NeedsUpdate() const
+  {
+    return needsUpdate;
+  }
+
+  /**
+   * Sets if a post-render should be run.
+   * If nothing is rendered this frame, we can skip post-render.
+   * @param[in] postRenderRequired Set to True if post-render is required to be run
    */
-  bool NeedsUpdate() { return needsUpdate; }
+  void SetNeedsPostRender( bool postRenderRequired )
+  {
+    needsPostRender = postRenderRequired;
+  }
+
+  /**
+   * Queries if a post-render should be run.
+   * @return True if post-render is required to be run
+   */
+  bool NeedsPostRender() const
+  {
+    return needsPostRender;
+  }
 
 private:
 
-  bool needsUpdate;
+  bool needsUpdate      :1;  ///< True if update is required to be run
+  bool needsPostRender  :1;  ///< True if post-render is required to be run.
 };
 
 /**
@@ -414,4 +440,4 @@ private:
 
 } // namespace Dali
 
-#endif // __DALI_INTEGRATION_CORE_H__
+#endif // DALI_INTEGRATION_CORE_H
index 269cec0..cb21612 100644 (file)
@@ -523,6 +523,9 @@ bool RenderManager::Render( Integration::RenderStatus& status )
   // No need to make any gl calls if we've done 1st glClear & don't have any renderers to render during startup.
   if( !mImpl->firstRenderCompleted || mImpl->renderersAdded )
   {
+    // Mark that we will require a post-render step to be performed (includes swap-buffers).
+    status.SetNeedsPostRender( true );
+
     // switch rendering to adaptor provided (default) buffer
     mImpl->context.BindFramebuffer( GL_FRAMEBUFFER, 0 );
 
@@ -566,9 +569,9 @@ bool RenderManager::Render( Integration::RenderStatus& status )
       mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
 
       mImpl->UpdateTrackers();
-
-      mImpl->firstRenderCompleted = true;
     }
+
+    mImpl->firstRenderCompleted = true;
   }
 
   //Notify RenderGeometries that rendering has finished