Invalidate depth and stencil buffers after finishing the rendering 80/260180/2
authorRichard Huang <r.huang@samsung.com>
Mon, 21 Jun 2021 13:45:02 +0000 (14:45 +0100)
committerRichard Huang <r.huang@samsung.com>
Mon, 21 Jun 2021 14:12:56 +0000 (15:12 +0100)
Change-Id: I140a525cc748c9c411f5493aa8b34a2b7db237e8

automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h
dali/internal/adaptor/common/combined-update-render-controller.cpp
dali/internal/graphics/common/graphics-interface.h
dali/internal/graphics/gles-impl/egl-graphics-controller.cpp
dali/internal/graphics/gles-impl/gles-context.cpp
dali/internal/graphics/gles-impl/gles-context.h
dali/internal/graphics/gles/egl-graphics.cpp
dali/internal/graphics/gles/egl-graphics.h

index b51bbda..3705eee 100644 (file)
@@ -111,6 +111,11 @@ public:
     mCallstack.PushCall("ActivateResourceContext()", namedParams.str(), namedParams);
   }
 
+  void PostRender() override
+  {
+    mCallstack.PushCall("PostRender()", "");
+  }
+
   /**
    * Inform graphics interface that this is the first frame after a resume.
    */
index 6e95b09..356cec0 100644 (file)
@@ -720,7 +720,7 @@ void CombinedUpdateRenderController::UpdateRenderThread()
 
     if(!mUploadWithoutRendering)
     {
-      graphics.ActivateResourceContext();
+      graphics.PostRender();
     }
 
     mCore.PostRender(mUploadWithoutRendering);
index b26738c..6575a0c 100644 (file)
@@ -93,6 +93,13 @@ public:
   virtual void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) = 0;
 
   /**
+   * Inform graphics interface that all the surfaces have been rendered.
+   *
+   * @note This should not be called if uploading resource only without rendering any surface.
+   */
+  virtual void PostRender() = 0;
+
+  /**
    * Inform graphics interface that this is the first frame after a resume.
    */
   virtual void SetFirstFrameAfterResume() = 0;
index 545c257..bd0d499 100644 (file)
@@ -158,6 +158,8 @@ void EglGraphicsController::PresentRenderTarget(RenderTarget* renderTarget)
 
 void EglGraphicsController::ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget)
 {
+  mCurrentContext->InvalidateDepthStencilBuffers();
+
   auto* rt = static_cast<GLES::RenderTarget*>(renderTarget);
   if(rt->GetCreateInfo().surface)
   {
index 2a6677d..89a6010 100644 (file)
@@ -654,6 +654,14 @@ void Context::ClearBuffer(uint32_t mask, bool forceClear)
   }
 }
 
+void Context::InvalidateDepthStencilBuffers()
+{
+  auto& gl = *mImpl->mController.GetGL();
+
+  GLenum attachments[] = {GL_DEPTH, GL_STENCIL};
+  gl.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
+}
+
 void Context::SetScissorTestEnabled(bool scissorEnabled)
 {
   if(mImpl->mGlStateCache.mScissorTestEnabled != scissorEnabled)
index 2bba73f..973536a 100644 (file)
@@ -176,6 +176,7 @@ public:
   void ClearStencilBuffer();
   void ClearDepthBuffer();
   void ClearBuffer(uint32_t mask, bool forceClear);
+  void InvalidateDepthStencilBuffers();
   void SetScissorTestEnabled(bool scissorEnabled);
   void SetStencilTestEnable(bool stencilEnable);
   void StencilMask(uint32_t writeMask);
index 3f00195..62563e1 100644 (file)
@@ -93,6 +93,16 @@ void EglGraphics::ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface)
   mGraphicsController.ActivateSurfaceContext(surface);
 }
 
+void EglGraphics::PostRender()
+{
+  ActivateResourceContext();
+
+  if(mGraphicsController.GetCurrentContext())
+  {
+    mGraphicsController.GetCurrentContext()->InvalidateDepthStencilBuffers();
+  }
+}
+
 void EglGraphics::SetFirstFrameAfterResume()
 {
   if(mEglImplementation)
index 8c8d80c..1caa4a6 100644 (file)
@@ -91,6 +91,13 @@ public:
   void ActivateSurfaceContext(Dali::RenderSurfaceInterface* surface) override;
 
   /**
+   * This is called after all the surfaces have been rendered.
+   *
+   * @note This should not be called if uploading resource only without rendering any surface.
+   */
+  void PostRender() override;
+
+  /**
    * Inform graphics interface that this is the first frame after a resume.
    * (For debug only)
    */