Added RenderPass and RenderTarget support 16/255316/15
authoradam.b <adam.b@samsung.com>
Thu, 1 Apr 2021 12:57:59 +0000 (13:57 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Tue, 13 Apr 2021 11:01:01 +0000 (12:01 +0100)
Change-Id: I8e596dc6bcb63f121d8f4511c3a4840b3f196f05

15 files changed:
dali/internal/graphics/gles-impl/egl-graphics-controller.cpp
dali/internal/graphics/gles-impl/egl-graphics-controller.h
dali/internal/graphics/gles-impl/gles-context.cpp
dali/internal/graphics/gles-impl/gles-context.h
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h
dali/internal/graphics/gles-impl/gles-graphics-framebuffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-framebuffer.h
dali/internal/graphics/gles-impl/gles-graphics-pipeline-cache.cpp
dali/internal/graphics/gles-impl/gles-graphics-pipeline.cpp
dali/internal/graphics/gles-impl/gles-graphics-render-pass.cpp
dali/internal/graphics/gles-impl/gles-graphics-render-pass.h
dali/internal/graphics/gles-impl/gles-graphics-render-target.cpp
dali/internal/graphics/gles-impl/gles-graphics-render-target.h
dali/internal/graphics/gles-impl/gles-graphics-types.h

index 2441515..d38eaba 100644 (file)
@@ -23,6 +23,8 @@
 #include <dali/integration-api/gl-defines.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-pipeline.h>
+#include <dali/internal/graphics/gles-impl/gles-graphics-render-pass.h>
+#include <dali/internal/graphics/gles-impl/gles-graphics-render-target.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-shader.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-texture.h>
 #include <dali/internal/graphics/gles-impl/gles-graphics-types.h>
@@ -147,8 +149,13 @@ Graphics::UniquePtr<CommandBuffer> EglGraphicsController::CreateCommandBuffer(
   return NewObject<GLES::CommandBuffer>(commandBufferCreateInfo, *this, std::move(oldCommandBuffer));
 }
 
-Graphics::UniquePtr<Texture> EglGraphicsController::CreateTexture(
-  const TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Texture>&& oldTexture)
+Graphics::UniquePtr<RenderPass> EglGraphicsController::CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<RenderPass>&& oldRenderPass)
+{
+  return NewObject<GLES::RenderPass>(renderPassCreateInfo, *this, std::move(oldRenderPass));
+}
+
+Graphics::UniquePtr<Texture>
+EglGraphicsController::CreateTexture(const TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Texture>&& oldTexture)
 {
   return NewObject<GLES::Texture>(textureCreateInfo, *this, std::move(oldTexture));
 }
@@ -199,6 +206,11 @@ Graphics::UniquePtr<Sampler> EglGraphicsController::CreateSampler(const SamplerC
   return NewObject<GLES::Sampler>(samplerCreateInfo, *this, std::move(oldSampler));
 }
 
+Graphics::UniquePtr<RenderTarget> EglGraphicsController::CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<RenderTarget>&& oldRenderTarget)
+{
+  return NewObject<GLES::RenderTarget>(renderTargetCreateInfo, *this, std::move(oldRenderTarget));
+}
+
 const Graphics::Reflection& EglGraphicsController::GetProgramReflection(const Graphics::Program& program)
 {
   return static_cast<const Graphics::GLES::Program*>(&program)->GetReflection();
@@ -261,110 +273,122 @@ void EglGraphicsController::ProcessCreateQueues()
   ProcessCreateQueue(mCreateFramebufferQueue);
 }
 
-void EglGraphicsController::ProcessCommandQueues()
+void EglGraphicsController::ProcessCommandBuffer(GLES::CommandBuffer& commandBuffer)
 {
-  // TODO: command queue per context, sync between queues should be
-  // done externally
-  const Graphics::Framebuffer* currentFramebuffer{nullptr};
-
-  while(!mCommandQueue.empty())
+  for(auto& cmd : commandBuffer.GetCommands())
   {
-    auto cmdBuf = mCommandQueue.front();
-    mCommandQueue.pop();
-
-    for(auto& cmd : cmdBuf->GetCommands())
+    // process command
+    switch(cmd.type)
     {
-      // process command
-      switch(cmd.type)
+      case GLES::CommandType::FLUSH:
       {
-        case GLES::CommandType::FLUSH:
-        {
-          // Nothing to do here
-          break;
-        }
-        case GLES::CommandType::BIND_TEXTURES:
-        {
-          mContext->BindTextures(cmd.bindTextures.textureBindings);
-          break;
-        }
-        case GLES::CommandType::BIND_VERTEX_BUFFERS:
-        {
-          auto& bindings = cmd.bindVertexBuffers.vertexBufferBindings;
-          mContext->BindVertexBuffers(bindings);
-          break;
-        }
-        case GLES::CommandType::BIND_UNIFORM_BUFFER:
-        {
-          auto& bindings = cmd.bindUniformBuffers;
-          mContext->BindUniformBuffers(bindings.uniformBufferBindings, bindings.standaloneUniformsBufferBinding);
-          break;
-        }
-        case GLES::CommandType::BIND_INDEX_BUFFER:
-        {
-          mContext->BindIndexBuffer(cmd.bindIndexBuffer);
-          break;
-        }
-        case GLES::CommandType::BIND_SAMPLERS:
-        {
-          break;
-        }
-        case GLES::CommandType::BIND_PIPELINE:
-        {
-          auto pipeline = static_cast<const GLES::Pipeline*>(cmd.bindPipeline.pipeline);
-
-          // Bind framebuffer if different. @todo Move to RenderPass
-          auto fbState = pipeline->GetCreateInfo().framebufferState;
-          if(fbState && fbState->framebuffer != currentFramebuffer)
-          {
-            currentFramebuffer = fbState->framebuffer;
-            static_cast<const GLES::Framebuffer*>(currentFramebuffer)->Bind();
-          }
-
-          mContext->BindPipeline(pipeline);
-          break;
-        }
-        case GLES::CommandType::DRAW:
-        {
-          mContext->Flush(false, cmd.draw);
-          break;
-        }
-        case GLES::CommandType::DRAW_INDEXED:
-        {
-          mContext->Flush(false, cmd.draw);
-          break;
-        }
-        case GLES::CommandType::DRAW_INDEXED_INDIRECT:
-        {
-          mContext->Flush(false, cmd.draw);
-          break;
-        }
-        case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here?
+        // Nothing to do here
+        break;
+      }
+      case GLES::CommandType::BIND_TEXTURES:
+      {
+        mContext->BindTextures(cmd.bindTextures.textureBindings);
+        break;
+      }
+      case GLES::CommandType::BIND_VERTEX_BUFFERS:
+      {
+        auto& bindings = cmd.bindVertexBuffers.vertexBufferBindings;
+        mContext->BindVertexBuffers(bindings);
+        break;
+      }
+      case GLES::CommandType::BIND_UNIFORM_BUFFER:
+      {
+        auto& bindings = cmd.bindUniformBuffers;
+        mContext->BindUniformBuffers(bindings.uniformBufferBindings, bindings.standaloneUniformsBufferBinding);
+        break;
+      }
+      case GLES::CommandType::BIND_INDEX_BUFFER:
+      {
+        mContext->BindIndexBuffer(cmd.bindIndexBuffer);
+        break;
+      }
+      case GLES::CommandType::BIND_SAMPLERS:
+      {
+        break;
+      }
+      case GLES::CommandType::BIND_PIPELINE:
+      {
+        auto pipeline = static_cast<const GLES::Pipeline*>(cmd.bindPipeline.pipeline);
+        mContext->BindPipeline(pipeline);
+        break;
+      }
+      case GLES::CommandType::DRAW:
+      {
+        mContext->Flush(false, cmd.draw);
+        break;
+      }
+      case GLES::CommandType::DRAW_INDEXED:
+      {
+        mContext->Flush(false, cmd.draw);
+        break;
+      }
+      case GLES::CommandType::DRAW_INDEXED_INDIRECT:
+      {
+        mContext->Flush(false, cmd.draw);
+        break;
+      }
+      case GLES::CommandType::SET_SCISSOR: // @todo Consider correcting for orientation here?
+      {
+        mGlAbstraction->Scissor(cmd.scissor.region.x, cmd.scissor.region.y, cmd.scissor.region.width, cmd.scissor.region.height);
+        break;
+      }
+      case GLES::CommandType::SET_SCISSOR_TEST:
+      {
+        if(cmd.scissorTest.enable)
         {
-          mGlAbstraction->Scissor(cmd.scissor.region.x, cmd.scissor.region.y, cmd.scissor.region.width, cmd.scissor.region.height);
-          break;
+          mGlAbstraction->Enable(GL_SCISSOR_TEST);
         }
-        case GLES::CommandType::SET_SCISSOR_TEST:
+        else
         {
-          if(cmd.scissorTest.enable)
-          {
-            mGlAbstraction->Enable(GL_SCISSOR_TEST);
-          }
-          else
-          {
-            mGlAbstraction->Disable(GL_SCISSOR_TEST);
-          }
-          break;
+          mGlAbstraction->Disable(GL_SCISSOR_TEST);
         }
-        case GLES::CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
+        break;
+      }
+      case GLES::CommandType::SET_VIEWPORT: // @todo Consider correcting for orientation here?
+      {
+        mGlAbstraction->Viewport(cmd.viewport.region.x, cmd.viewport.region.y, cmd.viewport.region.width, cmd.viewport.region.height);
+        break;
+      }
+      case GLES::CommandType::BEGIN_RENDERPASS:
+      {
+        mContext->BeginRenderPass(cmd.beginRenderPass);
+        break;
+      }
+      case GLES::CommandType::EXECUTE_COMMAND_BUFFERS:
+      {
+        // Process secondary command buffers
+        // todo: check validity of the secondaries
+        //       there are operations which are illigal to be done
+        //       within secondaries.
+        for(auto& buf : cmd.executeCommandBuffers.buffers)
         {
-          mGlAbstraction->Viewport(cmd.viewport.region.x, cmd.viewport.region.y, cmd.viewport.region.width, cmd.viewport.region.height);
-          break;
+          ProcessCommandBuffer(*static_cast<GLES::CommandBuffer*>(buf));
         }
+        break;
       }
     }
   }
 }
 
+void EglGraphicsController::ProcessCommandQueues()
+{
+  // TODO: command queue per context, sync between queues should be
+  // done externally
+  currentFramebuffer = nullptr;
+
+  while(!mCommandQueue.empty())
+  {
+    auto cmdBuf = mCommandQueue.front();
+    mCommandQueue.pop();
+    ProcessCommandBuffer(*cmdBuf);
+  }
+}
+
 void EglGraphicsController::ProcessTextureUpdateQueue()
 {
   while(!mTextureUpdateRequests.empty())
index a4acea4..479db2a 100644 (file)
@@ -194,10 +194,7 @@ public:
   /**
    * @copydoc Dali::Graphics::CreateRenderPass()
    */
-  Graphics::UniquePtr<RenderPass> CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<RenderPass>&& oldRenderPass) override
-  {
-    return nullptr;
-  }
+  Graphics::UniquePtr<RenderPass> CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<RenderPass>&& oldRenderPass) override;
 
   /**
    * @copydoc Dali::Graphics::CreateTexture()
@@ -232,10 +229,7 @@ public:
   /**
    * @copydoc Dali::Graphics::CreateRenderTarget()
    */
-  Graphics::UniquePtr<RenderTarget> CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<RenderTarget>&& oldRenderTarget) override
-  {
-    return nullptr;
-  }
+  Graphics::UniquePtr<RenderTarget> CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<RenderTarget>&& oldRenderTarget) override;
 
   /**
    * @copydoc Dali::Graphics::MapBufferRange()
@@ -552,6 +546,8 @@ public:
     return mIsShuttingDown;
   }
 
+  void ProcessCommandBuffer(GLES::CommandBuffer& commandBuffer);
+
 private:
   Integration::GlAbstraction*              mGlAbstraction{nullptr};
   Integration::GlSyncAbstraction*          mGlSyncAbstraction{nullptr};
@@ -581,6 +577,9 @@ private:
   std::unique_ptr<GLES::PipelineCache> mPipelineCache{nullptr}; ///< Internal pipeline cache
 
   bool mIsShuttingDown{false}; ///< Indicates whether the controller is shutting down
+
+  // todo: to be removed after renderpass
+  const Graphics::Framebuffer* currentFramebuffer{nullptr};
 };
 
 } // namespace Graphics
index f7cf80d..d682f83 100644 (file)
@@ -22,6 +22,8 @@
 #include "gles-graphics-buffer.h"
 #include "gles-graphics-pipeline.h"
 #include "gles-graphics-program.h"
+#include "gles-graphics-render-pass.h"
+#include "gles-graphics-render-target.h"
 
 namespace Dali::Graphics::GLES
 {
@@ -55,6 +57,10 @@ struct Context::Impl
   // Currently bound UBOs (check if it's needed per program!)
   std::vector<UniformBufferBindingDescriptor> mCurrentUBOBindings{};
   UniformBufferBindingDescriptor              mCurrentStandaloneUBOBinding{};
+
+  // Current render pass and render target
+  const GLES::RenderTarget* mCurrentRenderTarget{nullptr};
+  const GLES::RenderPass*   mCurrentRenderPass{nullptr};
 };
 
 Context::Context(EglGraphicsController& controller)
@@ -403,6 +409,85 @@ void Context::ResolveStandaloneUniforms()
   }
 }
 
+void Context::BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin)
+{
+  auto& renderPass   = *renderPassBegin.renderPass;
+  auto& renderTarget = *renderPassBegin.renderTarget;
+
+  if(mImpl->mCurrentRenderPass == &renderPass &&
+     mImpl->mCurrentRenderTarget == &renderTarget)
+  {
+    return;
+  }
+  const auto& passInfo   = renderPass.GetCreateInfo();
+  const auto& targetInfo = renderTarget.GetCreateInfo();
+
+  auto& gl = *mImpl->mController.GetGL();
+
+  if(targetInfo.surface)
+  {
+    // switch context to surface bound
+
+    // Bind surface FB
+    gl.BindFramebuffer(GL_FRAMEBUFFER, 0);
+  }
+
+  if(targetInfo.framebuffer)
+  {
+    // bind framebuffer and swap (if needed to shared context)
+    renderTarget.GetFramebuffer()->Bind();
+  }
+
+  // clear (ideally cache the setup)
+
+  // In GL we assume that the last attachment is depth/stencil (we may need
+  // 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)
+    {
+      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_FALSE);
+      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_DEPTH_BUFFER_BIT;
+      }
+      if(depthStencil.stencilLoadOp == AttachmentLoadOp::CLEAR)
+      {
+        mask |= GL_STENCIL_BUFFER_BIT;
+      }
+    }
+
+    gl.Clear(mask);
+  }
+
+  mImpl->mCurrentRenderPass   = &renderPass;
+  mImpl->mCurrentRenderTarget = &renderTarget;
+}
+
+void Context::EndRenderPass()
+{
+}
+
 void Context::ClearState()
 {
   mImpl->mCurrentTextureBindings.clear();
index cc4e243..2c09adf 100644 (file)
@@ -27,8 +27,8 @@ class EglGraphicsController;
 namespace GLES
 {
 class Pipeline;
-class Texture;
-
+class RenderPass;
+class RenderTarget;
 /**
  * @brief Context represents single GLES context
  */
@@ -121,6 +121,22 @@ public:
    */
   void ResolveStandaloneUniforms();
 
+  /**
+   * @brief Begins render pass for sepcified render target
+   *
+   * @param[in] renderPass render pass object to begin
+   * @param[in] renderTarget render target to be drawn onto
+   */
+  void BeginRenderPass(const BeginRenderPassDescriptor& renderPassBegin);
+
+  /**
+   * @brief Ends render pass
+   *
+   * Ending render pass is necessary in order to ensure
+   * proper implicit synchronization is in place
+   */
+  void EndRenderPass();
+
 private:
   /**
    * @brief Clear current state
index 8cb90b1..dad204b 100644 (file)
 // INTERNAL INCLUDES
 #include "egl-graphics-controller.h"
 #include "gles-graphics-buffer.h"
+#include "gles-graphics-framebuffer.h"
 #include "gles-graphics-pipeline.h"
+#include "gles-graphics-render-pass.h"
+#include "gles-graphics-render-target.h"
 #include "gles-graphics-texture.h"
 
 namespace Dali::Graphics::GLES
@@ -121,24 +124,33 @@ void CommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer,
 }
 
 void CommandBuffer::BeginRenderPass(
-  Graphics::RenderPass&   renderPass,
-  Graphics::RenderTarget& renderTarget,
+  Graphics::RenderPass*   renderPass,
+  Graphics::RenderTarget* renderTarget,
   Extent2D                renderArea,
   std::vector<ClearValue> clearValues)
 {
+  mCommands.emplace_back(CommandType::BEGIN_RENDERPASS);
+  auto& cmd                        = mCommands.back();
+  cmd.beginRenderPass.renderPass   = static_cast<GLES::RenderPass*>(renderPass);
+  cmd.beginRenderPass.renderTarget = static_cast<GLES::RenderTarget*>(renderTarget);
+  cmd.beginRenderPass.renderArea   = renderArea;
+  cmd.beginRenderPass.clearValues  = clearValues;
 }
 
-/**
- * @brief Ends current render pass
- *
- * This command must be issued in order to finalize the render pass.
- * It's up to the implementation whether anything has to be done but
- * the Controller may use end RP marker in order to resolve resource
- * dependencies (for example, to know when target texture is ready
- * before passing it to another render pass).
- */
 void CommandBuffer::EndRenderPass()
 {
+  mCommands.emplace_back(CommandType::END_RENDERPASS);
+}
+
+void CommandBuffer::ExecuteCommandBuffers(std::vector<Graphics::CommandBuffer*>&& commandBuffers)
+{
+  mCommands.emplace_back(CommandType::EXECUTE_COMMAND_BUFFERS);
+  auto& cmd = mCommands.back();
+  cmd.executeCommandBuffers.buffers.reserve(commandBuffers.size());
+  for(auto&& item : commandBuffers)
+  {
+    cmd.executeCommandBuffers.buffers.emplace_back(static_cast<GLES::CommandBuffer*>(item));
+  }
 }
 
 void CommandBuffer::Draw(
index cad69bd..c6888b9 100644 (file)
 
 namespace Dali::Graphics::GLES
 {
-class Texture;
 class Pipeline;
-
+class RenderPass;
+class Framebuffer;
+class CommandBuffer;
 enum class CommandType
 {
   FLUSH,
@@ -46,7 +47,10 @@ enum class CommandType
   DRAW_INDEXED_INDIRECT,
   SET_SCISSOR,
   SET_SCISSOR_TEST,
-  SET_VIEWPORT
+  SET_VIEWPORT,
+  BEGIN_RENDERPASS,
+  END_RENDERPASS,
+  EXECUTE_COMMAND_BUFFERS,
 };
 
 /**
@@ -80,6 +84,12 @@ struct Command
         new(&bindTextures) decltype(bindTextures);
         break;
       }
+      case CommandType::BEGIN_RENDERPASS:
+      {
+        // run destructor
+        new(&beginRenderPass) decltype(beginRenderPass);
+        break;
+      }
       default:
       {
       }
@@ -100,6 +110,12 @@ struct Command
         InvokeDestructor(bindTextures);
         break;
       }
+      case CommandType::BEGIN_RENDERPASS:
+      {
+        // run destructor
+        InvokeDestructor(beginRenderPass);
+        break;
+      }
       default:
       {
       }
@@ -164,6 +180,20 @@ struct Command
         draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
         break;
       }
+      case CommandType::BEGIN_RENDERPASS:
+      {
+        new(&beginRenderPass) BeginRenderPassDescriptor(rhs.beginRenderPass);
+        break;
+      }
+      case CommandType::END_RENDERPASS:
+      {
+        break;
+      }
+      case CommandType::EXECUTE_COMMAND_BUFFERS:
+      {
+        executeCommandBuffers = rhs.executeCommandBuffers;
+        break;
+      }
       case CommandType::FLUSH:
       {
         // Nothing to do
@@ -246,6 +276,20 @@ struct Command
         draw.drawIndexedIndirect = rhs.draw.drawIndexedIndirect;
         break;
       }
+      case CommandType::BEGIN_RENDERPASS:
+      {
+        new(&beginRenderPass) BeginRenderPassDescriptor(std::move(rhs.beginRenderPass));
+        break;
+      }
+      case CommandType::END_RENDERPASS:
+      {
+        break;
+      }
+      case CommandType::EXECUTE_COMMAND_BUFFERS:
+      {
+        executeCommandBuffers = std::move(rhs.executeCommandBuffers);
+        break;
+      }
       case CommandType::FLUSH:
       {
         // Nothing to do
@@ -324,6 +368,18 @@ struct Command
     {
       Graphics::Viewport region;
     } viewport;
+
+    struct BeginRenderPassDescriptor
+      beginRenderPass;
+
+    struct
+    {
+    } endRenderPass;
+
+    struct
+    {
+      std::vector<GLES::CommandBuffer*> buffers;
+    } executeCommandBuffers;
   };
 };
 
@@ -357,8 +413,8 @@ public:
                        Format                  format) override;
 
   void BeginRenderPass(
-    Graphics::RenderPass&   renderPass,
-    Graphics::RenderTarget& renderTarget,
+    Graphics::RenderPass*   renderPass,
+    Graphics::RenderTarget* renderTarget,
     Extent2D                renderArea,
     std::vector<ClearValue> clearValues) override;
 
@@ -373,6 +429,8 @@ public:
    */
   void EndRenderPass() override;
 
+  void ExecuteCommandBuffers(std::vector<Graphics::CommandBuffer*>&& commandBuffers) override;
+
   void Draw(
     uint32_t vertexCount,
     uint32_t instanceCount,
index 30ef207..2fb30a2 100644 (file)
@@ -88,6 +88,8 @@ Framebuffer::Framebuffer(const Graphics::FramebufferCreateInfo& createInfo, Grap
   mController.AddFramebuffer(*this);
 }
 
+Framebuffer::~Framebuffer() = default;
+
 bool Framebuffer::InitializeResource()
 {
   if(!mInitialized)
@@ -184,4 +186,19 @@ void Framebuffer::AttachTexture(const Graphics::Texture* texture, uint32_t attac
   }
 }
 
+uint32_t Framebuffer::GetGlFramebufferId() const
+{
+  return mFramebufferId;
+}
+
+uint32_t Framebuffer::GetGlDepthBufferId() const
+{
+  return mDepthBufferId;
+}
+
+uint32_t Framebuffer::GetGlStencilBufferId() const
+{
+  return mStencilBufferId;
+}
+
 } //namespace Dali::Graphics::GLES
index 5a63696..b48af2c 100644 (file)
@@ -42,7 +42,7 @@ public:
   /**
    * @brief Destructor
    */
-  ~Framebuffer() override = default;
+  ~Framebuffer() override;
 
   /**
    * @brief Called when GL resources are destroyed
@@ -66,6 +66,12 @@ public:
    */
   void Bind() const;
 
+  [[nodiscard]] uint32_t GetGlFramebufferId() const;
+
+  [[nodiscard]] uint32_t GetGlDepthBufferId() const;
+
+  [[nodiscard]] uint32_t GetGlStencilBufferId() const;
+
 private:
   /**
    * Attach a texture to the specified attachment point
index ad98fb0..f9a7d16 100644 (file)
@@ -65,13 +65,12 @@ enum class StateLookupIndex : uint32_t
 {
   COLOR_BLEND_STATE_BIT    = 0,
   VIEWPORT_STATE_BIT       = 1,
-  FRAMEBUFFER_STATE_BIT    = 2,
-  BASE_PIPELINE_STATE_BIT  = 3,
-  DEPTH_STENCIL_STATE_BIT  = 4,
-  RASTERIZATION_STATE_BIT  = 5,
-  VERTEX_INPUT_STATE_BIT   = 6,
-  INPUT_ASSEMBLY_STATE_BIT = 7,
-  MAX_STATE                = 8
+  BASE_PIPELINE_STATE_BIT  = 2,
+  DEPTH_STENCIL_STATE_BIT  = 3,
+  RASTERIZATION_STATE_BIT  = 4,
+  VERTEX_INPUT_STATE_BIT   = 5,
+  INPUT_ASSEMBLY_STATE_BIT = 6,
+  MAX_STATE                = 7
 };
 
 /**
@@ -169,12 +168,6 @@ void InitialiseStateCompareLookupTable()
              lvp.scissor == rvp.scissor &&
              lvp.scissorTestEnable == rvp.scissorTestEnable;
     },
-    [](const auto* lhs, const auto* rhs) -> bool // framebufferState
-    {
-      const auto& lfb = *lhs->framebufferState;
-      const auto& rfb = *rhs->framebufferState;
-      return lfb.framebuffer == rfb.framebuffer;
-    },
     [](const auto* lhs, const auto* rhs) -> bool // basePipeline
     {
       return lhs->basePipeline == rhs->basePipeline;
@@ -232,7 +225,6 @@ inline uint32_t GetStateBitmask(const PipelineCreateInfo& info)
   uint32_t mask{0u};
   mask |= bool(info.colorBlendState) << int(StateLookupIndex::COLOR_BLEND_STATE_BIT);
   mask |= bool(info.viewportState) << int(StateLookupIndex::VIEWPORT_STATE_BIT);
-  mask |= bool(info.framebufferState) << int(StateLookupIndex::FRAMEBUFFER_STATE_BIT);
   mask |= bool(info.basePipeline) << int(StateLookupIndex::BASE_PIPELINE_STATE_BIT);
   mask |= bool(info.depthStencilState) << int(StateLookupIndex::DEPTH_STENCIL_STATE_BIT);
   mask |= bool(info.rasterizationState) << int(StateLookupIndex::RASTERIZATION_STATE_BIT);
index 8cc9491..603039b 100644 (file)
@@ -45,7 +45,6 @@ struct PipelineImpl::PipelineState
   DepthStencilState  depthStencilState;
   ProgramState       programState;
   ViewportState      viewportState;
-  FramebufferState   framebufferState;
   RasterizationState rasterizationState;
   VertexInputState   vertexInputState;
   InputAssemblyState inputAssemblyState;
@@ -65,7 +64,6 @@ PipelineImpl::PipelineImpl(const Graphics::PipelineCreateInfo& createInfo, Graph
   CopyStateIfSet(createInfo.vertexInputState, mPipelineState->vertexInputState, &mCreateInfo.vertexInputState);
   CopyStateIfSet(createInfo.rasterizationState, mPipelineState->rasterizationState, &mCreateInfo.rasterizationState);
   CopyStateIfSet(createInfo.programState, mPipelineState->programState, &mCreateInfo.programState);
-  CopyStateIfSet(createInfo.framebufferState, mPipelineState->framebufferState, &mCreateInfo.framebufferState);
   CopyStateIfSet(createInfo.colorBlendState, mPipelineState->colorBlendState, &mCreateInfo.colorBlendState);
   CopyStateIfSet(createInfo.depthStencilState, mPipelineState->depthStencilState, &mCreateInfo.depthStencilState);
   CopyStateIfSet(createInfo.programState, mPipelineState->programState, &mCreateInfo.programState);
index a5e0a25..0e569ab 100644 (file)
 
 // CLASS HEADER
 #include "gles-graphics-render-pass.h"
+
+namespace Dali::Graphics::GLES
+{
+struct RenderPass::Impl
+{
+  Impl()  = default;
+  ~Impl() = default;
+
+  std::vector<AttachmentDescription> attachments;
+};
+
+RenderPass::RenderPass(const Graphics::RenderPassCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
+: RenderPassResource(createInfo, controller)
+{
+  mImpl = std::make_unique<Impl>();
+
+  // copy attachment description
+  if(createInfo.attachments)
+  {
+    mCreateInfo.attachments = &mImpl->attachments;
+    mImpl->attachments.insert(mImpl->attachments.end(), createInfo.attachments->begin(), createInfo.attachments->end());
+  }
+}
+
+} // namespace Dali::Graphics::GLES
\ No newline at end of file
index 53cc572..1186f61 100644 (file)
@@ -37,10 +37,7 @@ public:
    * @param[in] createInfo Valid createInfo structure
    * @param[in] controller Reference to the controller
    */
-  RenderPass(const Graphics::RenderPassCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
-  : RenderPassResource(createInfo, controller)
-  {
-  }
+  RenderPass(const Graphics::RenderPassCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
 
   /**
    * @brief Destructor
@@ -73,6 +70,10 @@ public:
   {
     // TODO: Implement moving to the discard queue
   }
+
+private:
+  struct Impl;
+  std::unique_ptr<Impl> mImpl{nullptr};
 };
 
 } // namespace Dali::Graphics::GLES
index 090bb71..df9c4dd 100644 (file)
 
 // CLASS HEADER
 #include "gles-graphics-render-target.h"
+#include "gles-graphics-framebuffer.h"
+
+namespace Dali::Graphics::GLES
+{
+RenderTarget::RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
+: RenderTargetResource(createInfo, controller)
+{
+}
+
+GLES::Framebuffer* RenderTarget::GetFramebuffer() const
+{
+  return static_cast<GLES::Framebuffer*>(mCreateInfo.framebuffer);
+}
+
+Surface* RenderTarget::GetSurface() const
+{
+  return mCreateInfo.surface;
+}
+
+} // namespace Dali::Graphics::GLES
\ No newline at end of file
index 57169d8..532427f 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace Dali::Graphics::GLES
 {
+class Framebuffer;
 using RenderTargetResource = Resource<Graphics::RenderTarget, Graphics::RenderTargetCreateInfo>;
 
 class RenderTarget : public RenderTargetResource
@@ -37,10 +38,7 @@ public:
    * @param[in] createInfo Valid createInfo structure
    * @param[in] controller Reference to the controller
    */
-  RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
-  : RenderTargetResource(createInfo, controller)
-  {
-  }
+  RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller);
 
   /**
    * @brief Destructor
@@ -73,6 +71,16 @@ public:
   {
     // TODO: Implement moving to the discard queue
   }
+
+  /**
+   * @brief Returns framebuffer associated with the render target
+   */
+  GLES::Framebuffer* GetFramebuffer() const;
+
+  /**
+   * @brief Returns surface associated with the render target
+   */
+  Surface* GetSurface() const;
 };
 
 } // namespace Dali::Graphics::GLES
index b8b6fcd..9e9a464 100644 (file)
@@ -9,6 +9,12 @@
 namespace Dali::Graphics::GLES
 {
 class Buffer;
+class RenderPass;
+class RenderTarget;
+class Framebuffer;
+
+using Surface = void*;
+
 // Conversion functions
 /**
  * Stucture delivers format and type that can be used
@@ -1866,6 +1872,18 @@ enum class GLESVersion
   GLES_32 = 32
 };
 
+/**
+ * The descriptor of BeginRenderPass command
+ */
+struct BeginRenderPassDescriptor
+{
+  const GLES::RenderPass*   renderPass;
+  const GLES::Framebuffer*  framebuffer;
+  const GLES::RenderTarget* renderTarget;
+  Extent2D                  renderArea;
+  std::vector<ClearValue>   clearValues;
+};
+
 } // namespace Dali::Graphics::GLES
 
 #endif //DALI_GRAPHICS_API_TYPES_H