Fixed test cases and other minor fixes (like doxy) 20/256920/3
authorAdam Bialogonski <adam.b@samsung.com>
Wed, 14 Apr 2021 14:18:01 +0000 (15:18 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Wed, 14 Apr 2021 15:13:39 +0000 (16:13 +0100)
Change-Id: Iacebc1160968b4ba92898a9ce0adfa5d028eb294

automated-tests/src/dali/dali-test-suite-utils/test-application.cpp
automated-tests/src/dali/dali-test-suite-utils/test-application.h
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp
dali/graphics-api/graphics-command-buffer.h
dali/graphics-api/graphics-render-pass-create-info.h
dali/graphics-api/graphics-render-target.h
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-algorithms.h
dali/internal/render/common/render-manager.cpp
dali/internal/render/renderers/render-frame-buffer.cpp
dali/internal/render/renderers/render-renderer.h

index a2a1848..22ff2fb 100644 (file)
@@ -76,6 +76,12 @@ void TestApplication::CreateScene()
 {
   mScene = Dali::Integration::Scene::New(Size(static_cast<float>(mSurfaceWidth), static_cast<float>(mSurfaceHeight)));
   mScene.SetDpi(Vector2(static_cast<float>(mDpi.x), static_cast<float>(mDpi.y)));
+
+  // Create render target for the scene
+  Graphics::RenderTargetCreateInfo rtInfo{};
+  rtInfo.SetExtent( {mSurfaceWidth, mSurfaceHeight });
+  mRenderTarget = mGraphicsController.CreateRenderTarget( rtInfo, nullptr );
+  mScene.SetSurfaceRenderTarget( mRenderTarget.get() );
 }
 
 void TestApplication::InitializeCore()
index e7d8c76..ad5d198 100644 (file)
@@ -108,6 +108,8 @@ protected:
   uint32_t mSurfaceHeight;
   uint32_t mFrame;
 
+  Graphics::UniquePtr<Graphics::RenderTarget> mRenderTarget;
+
   struct
   {
     uint32_t x;
index c42d372..282f7a4 100644 (file)
@@ -691,7 +691,24 @@ void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& com
 
             if(mask != 0)
             {
-              mGl.Clear(mask);
+              // Test scissor area and RT size
+              const auto& area = cmd.data.beginRenderPass.renderArea;
+              if( area.x == 0 &&
+              area.y == 0 &&
+              area.width == renderTarget->mCreateInfo.extent.width &&
+              area.height == renderTarget->mCreateInfo.extent.height )
+              {
+                mGl.Disable(GL_SCISSOR_TEST);
+                mGl.Clear(mask);
+              }
+              else
+              {
+                mGl.Enable(GL_SCISSOR_TEST);
+                mGl.Scissor(cmd.data.beginRenderPass.renderArea.x, cmd.data.beginRenderPass.renderArea.y,
+                            cmd.data.beginRenderPass.renderArea.width, cmd.data.beginRenderPass.renderArea.height);
+                mGl.Clear(mask);
+                mGl.Disable(GL_SCISSOR_TEST);
+              }
             }
           }
           else
index 9ba466b..881543b 100644 (file)
@@ -178,7 +178,6 @@ public:
    *
    * @param[in] renderPass valid render pass object
    * @param[in] renderTarget valid render target, must not be used when framebuffer set
-   * @param[in] framebuffer valid framebuffer, must not be used with renderTarget
    * @param[in] renderArea area to draw (clear operation is affected)
    * @param[in] clearValues clear values (compatible with renderpass spec)
    */
@@ -202,6 +201,9 @@ public:
   /**
    * @brief Executes a list of secondary command buffers
    *
+   * The secondary command buffers are executed as a part of a primary
+   * command buffer that calls this function.
+   *
    * @param[in] commandBuffers List of buffers to execute
    */
   virtual void ExecuteCommandBuffers( std::vector<CommandBuffer*>&& commandBuffers ) = 0;
index ab94242..9a8223e 100644 (file)
@@ -52,6 +52,9 @@ struct RenderPassCreateInfo
   /**
    * @brief Sets array of attachment descriptions
    *
+   * The attachment descriptions should be ordered as for the framebuffer
+   * or (in case of swapchain), color attachment preceeds depth/stencil.
+   *
    * @param[in] value pointer valid array of attachment descriptions
    * @return reference to this structure
    */
index a320119..0114638 100644 (file)
@@ -41,6 +41,6 @@ protected:
   RenderTarget& operator=(RenderTarget&&) = default;
 };
 
-} // Namespace Dali
+} // Namespace Dali::Graphics
 
 #endif
\ No newline at end of file
index 7ab6f37..1b871a6 100644 (file)
@@ -344,7 +344,10 @@ inline void RenderAlgorithms::SetupScissorClipping(const RenderItem& item, Conte
     const bool scissorEnabled = (mScissorStack.size() > 0u) || mHasLayerScissor;
 
     // Enable the scissor test based on the above calculation
-    context.SetScissorTest(scissorEnabled);
+    if(scissorEnabled)
+    {
+      mGraphicsCommandBuffer->SetScissorTestEnable( scissorEnabled );
+    }
 
     // If scissor is enabled, we use the calculated screen-space coordinates (now in the stack).
     if(scissorEnabled)
@@ -355,7 +358,11 @@ inline void RenderAlgorithms::SetupScissorClipping(const RenderItem& item, Conte
       {
         useScissorBox.y = (instruction.mFrameBuffer->GetHeight() - useScissorBox.height) - useScissorBox.y;
       }
-      context.Scissor(useScissorBox.x, useScissorBox.y, useScissorBox.width, useScissorBox.height);
+     Graphics::Rect2D scissorBox = {
+        useScissorBox.x, useScissorBox.y,
+       uint32_t(useScissorBox.width), uint32_t(useScissorBox.height)
+      };
+     mGraphicsCommandBuffer->SetScissor( scissorBox );
     }
   }
 }
@@ -506,11 +513,6 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
     mHasLayerScissor = true;
   }
 
-  // Submit scissor/viewport
-  //Graphics::SubmitInfo submitInfo{{}, 0 | Graphics::SubmitFlagBits::FLUSH};
-  //submitInfo.cmdBuffer.push_back(mGraphicsCommandBuffer.get());
-  //mGraphicsController.SubmitCommandBuffers(submitInfo);
-
   mGraphicsRenderItemCommandBuffers.clear();
   // Loop through all RenderList in the RenderList, set up any prerequisites to render them, then perform the render.
   for(uint32_t index = 0u; index < count; ++index)
@@ -539,8 +541,6 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
     // The Renderer API will be used if specified. If AUTO, the Actors automatic clipping feature will be used.
     SetupClipping(item, context, usedStencilBuffer, lastClippingDepth, lastClippingId, stencilBufferAvailable, instruction);
 
-
-
     if(DALI_LIKELY(item.mRenderer))
     {
       // Set up the depth buffer based on per-renderer flags if depth buffer is available
index c7f6994..4654bf7 100644 (file)
@@ -82,6 +82,14 @@ public:
    */
   void SubmitCommandBuffer();
 
+  /**
+   * Returns main command buffer
+   *
+   * 'Main' command buffer exists per each scene and it is used
+   * to bake all render instructions for the scene.
+   *
+   * @return main command buffer
+   */
   [[nodiscard]] Graphics::CommandBuffer* GetMainCommandBuffer() const
   {
     return mGraphicsCommandBuffer.get();
@@ -166,7 +174,7 @@ private:
   Graphics::Controller&                        mGraphicsController;
   Graphics::UniquePtr<Graphics::CommandBuffer> mGraphicsCommandBuffer{};
 
-  std::vector<Graphics::CommandBuffer*> mGraphicsRenderItemCommandBuffers{};
+  std::vector<Graphics::CommandBuffer*> mGraphicsRenderItemCommandBuffers{}; ///< Collection of command buffers issuing single draw call
 
   ScissorStackType  mScissorStack;        ///< Contains the currently applied scissor hierarchy (so we can undo clips)
   Dali::ClippingBox mViewportRectangle;   ///< The viewport dimensions, used to translate AABBs to scissor coordinates
index f58e2d1..cd710bd 100644 (file)
@@ -88,9 +88,6 @@ struct RenderManager::Impl
 
     uniformBufferManager.reset(new Render::UniformBufferManager(&graphicsController));
 
-    // initialize main command buffer
-    auto info         = Graphics::CommandBufferCreateInfo().SetLevel(Graphics::CommandBufferLevel::PRIMARY);
-    mainCommandBuffer = graphicsController.CreateCommandBuffer(info, nullptr);
   }
 
   ~Impl()
@@ -181,11 +178,7 @@ struct RenderManager::Impl
 
   std::unique_ptr<Dali::ThreadPool> threadPool;            ///< The thread pool
   Vector<Graphics::Texture*>        boundTextures;         ///< The textures bound for rendering
-  Vector<Graphics::Texture*>        textureDependencyList; ///< The dependency list of binded textures
-
-  Graphics::UniquePtr<Graphics::CommandBuffer> mainCommandBuffer; ///< Main command buffer
-
-  Graphics::UniquePtr<Graphics::RenderPass> mainRenderPass; ///< Main renderpass
+  Vector<Graphics::Texture*>        textureDependencyList; ///< The dependency list of bound textures
 };
 
 RenderManager* RenderManager::New(Graphics::Controller&               graphicsController,
@@ -497,9 +490,6 @@ void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear
 
   const bool haveInstructions = count > 0u;
 
-  // Reset main command buffer
-  mImpl->mainCommandBuffer->Reset();
-
   DALI_LOG_INFO(gLogFilter, Debug::General, "Render: haveInstructions(%s) || mImpl->lastFrameWasRendered(%s) || forceClear(%s)\n", haveInstructions ? "true" : "false", mImpl->lastFrameWasRendered ? "true" : "false", forceClear ? "true" : "false");
 
   // Only render if we have instructions to render, or the last frame was rendered (and therefore a clear is required).
@@ -512,12 +502,6 @@ void RenderManager::PreRender(Integration::RenderStatus& status, bool forceClear
     {
       mImpl->currentContext = &mImpl->context;
 
-      // Context switch now happens when the uploading happens in graphics side
-      //      if(mImpl->currentContext->IsSurfacelessContextSupported())
-      //      {
-      //        mImpl->graphicsController.GetGlContextHelperAbstraction().MakeSurfacelessContextCurrent();
-      //      }
-
       // Clear the current cached program when the context is switched
       mImpl->programController.ClearCurrentProgram();
     }
@@ -884,12 +868,6 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
         // Switch to shared context for off-screen buffer
         mImpl->currentContext = &mImpl->context;
 
-        // Context switch now happens when render pass starts
-        //        if(mImpl->currentContext->IsSurfacelessContextSupported())
-        //        {
-        //          mImpl->graphicsController.GetGlContextHelperAbstraction().MakeSurfacelessContextCurrent();
-        //        }
-
         // Clear the current cached program when the context is switched
         mImpl->programController.ClearCurrentProgram();
       }
@@ -945,53 +923,7 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
         mImpl->textureDependencyList.PushBack(instruction.mFrameBuffer->GetTexture(i0));
       }
     }
-    else
-    {
-      //mImpl->currentContext->BindFramebuffer(GL_FRAMEBUFFER, 0u);
-    }
-
-    // @todo Should this be a command in it's own right?
-    // @todo yes
-    if(!instruction.mFrameBuffer)
-    {
-      /*
-      mImpl->currentContext->Viewport(surfaceRect.x,
-                                      surfaceRect.y,
-                                      surfaceRect.width,
-                                      surfaceRect.height);
-                                      */
-
-      /*
-      mainCommandBuffer->SetViewport( {surfaceRect.x,
-                                        surfaceRect.y,
-                                        surfaceRect.width,
-                                        surfaceRect.height} );
-      */
-    }
-
-    // Clear the entire color, depth and stencil buffers for the default framebuffer, if required.
-    // It is important to clear all 3 buffers when they are being used, for performance on deferred renderers
-    // e.g. previously when the depth & stencil buffers were NOT cleared, it caused the DDK to exceed a "vertex count limit",
-    // and then stall. That problem is only noticeable when rendering a large number of vertices per frame.
-
-    /*
-    GLbitfield clearMask = GL_COLOR_BUFFER_BIT;
 
-    mImpl->currentContext->ColorMask(true);
-
-    if(depthBufferAvailable == Integration::DepthBufferAvailable::TRUE)
-    {
-      mImpl->currentContext->DepthMask(true);
-      clearMask |= GL_DEPTH_BUFFER_BIT;
-    }
-
-    if(stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
-    {
-      mImpl->currentContext->ClearStencil(0);
-      mImpl->currentContext->StencilMask(0xFF); // 8 bit stencil mask, all 1's
-      clearMask |= GL_STENCIL_BUFFER_BIT;
-    }
-    */
     if(!instruction.mIgnoreRenderToFbo && (instruction.mFrameBuffer != nullptr))
     {
       // Offscreen buffer rendering
@@ -1048,54 +980,30 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       clearFullFrameRect = false;
     }
 
-    // Begin render pass
-    mainCommandBuffer->BeginRenderPass(
-      currentRenderPass,
-      currentRenderTarget,
-      {
-        viewportRect.x, viewportRect.y,
-        uint32_t(viewportRect.width), uint32_t(viewportRect.height)
-      },
-      currentClearValues);
-
-    // @todo The following block should be a command in it's own right.
-    // Currently takes account of surface orientation in Context.
-    // Or move entirely to RenderPass implementation
-    mainCommandBuffer->SetViewport({float(viewportRect.x),
-                                    float(viewportRect.y),
-                                    float(viewportRect.width),
-                                    float(viewportRect.height)});
-
-    //mImpl->currentContext->Viewport(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height);
+    Graphics::Rect2D scissorArea{ viewportRect.x, viewportRect.y, uint32_t(viewportRect.width), uint32_t(viewportRect.height) };
     if(instruction.mIsClearColorSet)
     {
       if(!clearFullFrameRect)
       {
         if(!clippingRect.IsEmpty())
         {
-          Graphics::Rect2D scissorArea = {clippingRect.x, clippingRect.y, uint32_t(clippingRect.width), uint32_t(clippingRect.height)};
-          mainCommandBuffer->SetScissor( scissorArea );
-          mainCommandBuffer->SetScissorTestEnable( true );
-          //mImpl->currentContext->SetScissorTest(true);
-          //mImpl->currentContext->Scissor(clippingRect.x, clippingRect.y, clippingRect.width, clippingRect.height);
-          //mImpl->currentContext->Clear(clearMask, Context::FORCE_CLEAR);
-          //mImpl->currentContext->SetScissorTest(false);
-        }
-        else
-        {
-          //mImpl->currentContext->SetScissorTest(true);
-          //mImpl->currentContext->Scissor(viewportRect.x, viewportRect.y, viewportRect.width, viewportRect.height);
-          //mImpl->currentContext->Clear(clearMask, Context::FORCE_CLEAR);
-          //mImpl->currentContext->SetScissorTest(false);
+          scissorArea = {clippingRect.x, clippingRect.y, uint32_t(clippingRect.width), uint32_t(clippingRect.height)};
         }
       }
-      else
-      {
-        //mImpl->currentContext->SetScissorTest(false);
-        //mImpl->currentContext->Clear(clearMask, Context::FORCE_CLEAR);
-      }
     }
 
+    // Begin render pass
+    mainCommandBuffer->BeginRenderPass(
+      currentRenderPass,
+      currentRenderTarget,
+      scissorArea,
+      currentClearValues);
+
+    mainCommandBuffer->SetViewport({float(viewportRect.x),
+                                     float(viewportRect.y),
+                                     float(viewportRect.width),
+                                     float(viewportRect.height)});
+
     // Clear the list of bound textures
     mImpl->boundTextures.Clear();
 
@@ -1132,9 +1040,6 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
         {
           // For off-screen buffer
 
-          // Wait until all rendering calls for the currently context are executed
-          // mImpl->graphicsController.GetGlContextHelperAbstraction().WaitClient();
-
           // Clear the dependency list
           mImpl->textureDependencyList.Clear();
         }
@@ -1175,12 +1080,6 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       instruction.mRenderTracker = nullptr; // Only create once.
     }
 
-    // This now happens when the render pass for frame buffer finishes
-    //    if(renderToFbo)
-    //    {
-    //      mImpl->currentContext->Flush();
-    //    }
-
     // End render pass
     mainCommandBuffer->EndRenderPass();
   }
@@ -1197,29 +1096,11 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       rt = target;
     }
   }
-
-  GLenum attachments[] = {GL_DEPTH, GL_STENCIL};
-  mImpl->currentContext->InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
 }
 
 void RenderManager::PostRender(bool uploadOnly)
 {
-  // Submit main command buffer
-  //mImpl->renderAlgorithms.SubmitCommandBuffer();
-
-  if(!uploadOnly)
-  {
-    // Context switch now happens outside the render manager
-    //    if(mImpl->currentContext->IsSurfacelessContextSupported())
-    //    {
-    //      mImpl->graphicsController.GetGlContextHelperAbstraction().MakeSurfacelessContextCurrent();
-    //    }
-
-    GLenum attachments[] = {GL_DEPTH, GL_STENCIL};
-    mImpl->context.InvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
-  }
-
-  //Notify RenderGeometries that rendering has finished
+  // Notify RenderGeometries that rendering has finished
   for(auto&& iter : mImpl->geometryContainer)
   {
     iter->OnRenderFinished();
index fd2f7c5..f668a1c 100644 (file)
@@ -117,9 +117,6 @@ bool FrameBuffer::CreateGraphicsObjects()
       std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
 
       // Default behaviour for color attachments is to CLEAR and STORE
-      //@todo Ideally, we should create new render pass whenever
-      //      the loadop, storeop changes and the list of such renderpasses
-      //      should be managed accordingly (as in Vulkan)
       mClearValues.clear();
       for(auto& attachments : mCreateInfo.colorAttachments)
       {
index 2d4e19e..2e6ffeb 100644 (file)
@@ -375,7 +375,8 @@ public:
    * @param[in] blend If true, blending is enabled
    * @param[in] boundTextures The textures bound for rendering
    * @param[in] instruction. for use case like reflection where CullFace needs to be adjusted
-
+   *
+   * @return True if the content has been rendered, false if skipped.
    */
   bool Render(Context&                                             context,
               BufferIndex                                          bufferIndex,
@@ -431,6 +432,14 @@ public:
                     const void*                                        data,
                     uint32_t                                           size);
 
+  /**
+   * Returns the pointer to valid command buffer
+   *
+   * CommandBuffer associated with Renderer contains baked commands
+   * needed to issue draw call for this renderer.
+   *
+   * @return Pointer to valid CommandBuffer
+   */
   [[nodiscard]] Graphics::CommandBuffer* GetGraphicsCommandBuffer() const
   {
     return mGraphicsCommandBuffer.get();