Set correct GLES version in graphics controller 13/257413/1
authorRichard Huang <r.huang@samsung.com>
Fri, 23 Apr 2021 15:02:45 +0000 (16:02 +0100)
committerRichard Huang <r.huang@samsung.com>
Fri, 23 Apr 2021 15:02:45 +0000 (16:02 +0100)
Change-Id: I7e53b1c943dcce8644dda89ccac5bb6390e57649

dali/internal/graphics/gles-impl/egl-graphics-controller.h
dali/internal/graphics/gles-impl/gles-context.cpp
dali/internal/graphics/gles/egl-graphics.cpp

index 18ea218..dce16a3 100644 (file)
@@ -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<GLES::PipelineCache> 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
index fc347e8..8618730 100644 (file)
@@ -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;
 }
index c0eafdb..d19f824 100644 (file)
@@ -62,6 +62,8 @@ void EglGraphics::SetGlesVersion(const int32_t glesVersion)
   }
 
   mGLES->SetGlesVersion(glesVersion);
+
+  mGraphicsController.SetGLESVersion(static_cast<Graphics::GLES::GLESVersion>(glesVersion));
 }
 
 void EglGraphics::SetIsSurfacelessContextSupported(const bool isSupported)