From 861a168933b079817e48a61e3131e28364b54357 Mon Sep 17 00:00:00 2001 From: Richard Huang Date: Fri, 23 Apr 2021 16:02:45 +0100 Subject: [PATCH] Set correct GLES version in graphics controller Change-Id: I7e53b1c943dcce8644dda89ccac5bb6390e57649 --- .../graphics/gles-impl/egl-graphics-controller.h | 16 ++++-- dali/internal/graphics/gles-impl/gles-context.cpp | 60 ++++++++++------------ dali/internal/graphics/gles/egl-graphics.cpp | 2 + 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/dali/internal/graphics/gles-impl/egl-graphics-controller.h b/dali/internal/graphics/gles-impl/egl-graphics-controller.h index 18ea218..dce16a3 100644 --- a/dali/internal/graphics/gles-impl/egl-graphics-controller.h +++ b/dali/internal/graphics/gles-impl/egl-graphics-controller.h @@ -543,9 +543,17 @@ public: */ GLES::GLESVersion GetGLESVersion() const { - // TODO: return proper version but for now we can - // test fallbacks - return GLES::GLESVersion::GLES_20; + return mGLESVersion; + } + + /** + * @brief Sets runtime supported GLES version + * + * @param[in] glesVersion The runtime supported GLES version + */ + void SetGLESVersion(GLES::GLESVersion glesVersion) + { + mGLESVersion = glesVersion; } bool IsShuttingDown() const @@ -617,6 +625,8 @@ private: std::unique_ptr mPipelineCache{nullptr}; ///< Internal pipeline cache + GLES::GLESVersion mGLESVersion{GLES::GLESVersion::GLES_20}; ///< Runtime supported GLES version + bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down // todo: to be removed after renderpass diff --git a/dali/internal/graphics/gles-impl/gles-context.cpp b/dali/internal/graphics/gles-impl/gles-context.cpp index fc347e8..8618730 100644 --- a/dali/internal/graphics/gles-impl/gles-context.cpp +++ b/dali/internal/graphics/gles-impl/gles-context.cpp @@ -451,45 +451,41 @@ void Context::BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin) // to cache extra information inside GLES RenderTarget if we want to be // more specific in case of MRT) - // For GLES2.0 we clear only a single color attachment - if(mImpl->mController.GetGLESVersion() == GLESVersion::GLES_20) + const auto& attachments = *renderPass.GetCreateInfo().attachments; + const auto& color0 = attachments[0]; + GLuint mask = 0; + if(color0.loadOp == AttachmentLoadOp::CLEAR) { - const auto& attachments = *renderPass.GetCreateInfo().attachments; - const auto& color0 = attachments[0]; - GLuint mask = 0; - if(color0.loadOp == AttachmentLoadOp::CLEAR) + mask |= GL_COLOR_BUFFER_BIT; + + // Set clear color (todo: cache it!) + // Something goes wrong here if Alpha mask is GL_TRUE + gl.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + gl.ClearColor(renderPassBegin.clearValues[0].color.r, + renderPassBegin.clearValues[0].color.g, + renderPassBegin.clearValues[0].color.b, + renderPassBegin.clearValues[0].color.a); + } + + // check for depth stencil + if(attachments.size() > 1) + { + const auto& depthStencil = attachments.back(); + if(depthStencil.loadOp == AttachmentLoadOp::CLEAR) { - mask |= GL_COLOR_BUFFER_BIT; - - // Set clear color (todo: cache it!) - // Something goes wrong here if Alpha mask is GL_TRUE - gl.ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - gl.ClearColor(renderPassBegin.clearValues[0].color.r, - renderPassBegin.clearValues[0].color.g, - renderPassBegin.clearValues[0].color.b, - renderPassBegin.clearValues[0].color.a); + mask |= GL_DEPTH_BUFFER_BIT; } - - // check for depth stencil - if(attachments.size() > 1) + if(depthStencil.stencilLoadOp == AttachmentLoadOp::CLEAR) { - const auto& depthStencil = attachments.back(); - if(depthStencil.loadOp == AttachmentLoadOp::CLEAR) - { - mask |= GL_DEPTH_BUFFER_BIT; - } - if(depthStencil.stencilLoadOp == AttachmentLoadOp::CLEAR) - { - mask |= GL_STENCIL_BUFFER_BIT; - } + mask |= GL_STENCIL_BUFFER_BIT; } - - gl.Enable(GL_SCISSOR_TEST); - gl.Scissor(renderPassBegin.renderArea.x, renderPassBegin.renderArea.y, renderPassBegin.renderArea.width, renderPassBegin.renderArea.height); - gl.Clear(mask); - gl.Disable(GL_SCISSOR_TEST); } + gl.Enable(GL_SCISSOR_TEST); + gl.Scissor(renderPassBegin.renderArea.x, renderPassBegin.renderArea.y, renderPassBegin.renderArea.width, renderPassBegin.renderArea.height); + gl.Clear(mask); + gl.Disable(GL_SCISSOR_TEST); + mImpl->mCurrentRenderPass = &renderPass; mImpl->mCurrentRenderTarget = &renderTarget; } diff --git a/dali/internal/graphics/gles/egl-graphics.cpp b/dali/internal/graphics/gles/egl-graphics.cpp index c0eafdb..d19f824 100644 --- a/dali/internal/graphics/gles/egl-graphics.cpp +++ b/dali/internal/graphics/gles/egl-graphics.cpp @@ -62,6 +62,8 @@ void EglGraphics::SetGlesVersion(const int32_t glesVersion) } mGLES->SetGlesVersion(glesVersion); + + mGraphicsController.SetGLESVersion(static_cast(glesVersion)); } void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported) -- 2.7.4