From 177e1023cdb7fb21f9a9cfad861c1688c179eecd Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Mon, 21 Jun 2021 14:45:02 +0100 Subject: [PATCH] Invalidate depth and stencil buffers after finishing the rendering Change-Id: I140a525cc748c9c411f5493aa8b34a2b7db237e8 --- .../dali-test-suite-utils/test-graphics-application.h | 5 +++++ .../adaptor/common/combined-update-render-controller.cpp | 2 +- dali/internal/graphics/common/graphics-interface.h | 7 +++++++ dali/internal/graphics/gles-impl/egl-graphics-controller.cpp | 2 ++ dali/internal/graphics/gles-impl/gles-context.cpp | 8 ++++++++ dali/internal/graphics/gles-impl/gles-context.h | 1 + dali/internal/graphics/gles/egl-graphics.cpp | 10 ++++++++++ dali/internal/graphics/gles/egl-graphics.h | 7 +++++++ 8 files changed, 41 insertions(+), 1 deletion(-) diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h index b51bbda..3705eee 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-application.h @@ -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. */ diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 6e95b09..356cec0 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -720,7 +720,7 @@ void CombinedUpdateRenderController::UpdateRenderThread() if(!mUploadWithoutRendering) { - graphics.ActivateResourceContext(); + graphics.PostRender(); } mCore.PostRender(mUploadWithoutRendering); diff --git a/dali/internal/graphics/common/graphics-interface.h b/dali/internal/graphics/common/graphics-interface.h index b26738c..6575a0c 100644 --- a/dali/internal/graphics/common/graphics-interface.h +++ b/dali/internal/graphics/common/graphics-interface.h @@ -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; diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp index 545c257..bd0d499 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.cpp @@ -158,6 +158,8 @@ void EglGraphicsController::PresentRenderTarget(RenderTarget* renderTarget) void EglGraphicsController::ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget) { + mCurrentContext->InvalidateDepthStencilBuffers(); + auto* rt = static_cast(renderTarget); if(rt->GetCreateInfo().surface) { diff --git a/dali/internal/graphics/gles-impl/gles-context.cpp b/dali/internal/graphics/gles-impl/gles-context.cpp index 2a6677d..89a6010 100644 --- a/dali/internal/graphics/gles-impl/gles-context.cpp +++ b/dali/internal/graphics/gles-impl/gles-context.cpp @@ -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) diff --git a/dali/internal/graphics/gles-impl/gles-context.h b/dali/internal/graphics/gles-impl/gles-context.h index 2bba73f..973536a 100644 --- a/dali/internal/graphics/gles-impl/gles-context.h +++ b/dali/internal/graphics/gles-impl/gles-context.h @@ -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); diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index 3f00195..62563e1 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -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) diff --git a/dali/internal/graphics/gles/egl-graphics.h b/dali/internal/graphics/gles/egl-graphics.h index 8c8d80c..1caa4a6 100644 --- a/dali/internal/graphics/gles/egl-graphics.h +++ b/dali/internal/graphics/gles/egl-graphics.h @@ -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) */ -- 2.7.4