Passing down render target to compile the pipeline 18/317218/1
authorAdam Bialogonski <adam.b@samsung.com>
Thu, 5 Sep 2024 15:35:32 +0000 (16:35 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Thu, 5 Sep 2024 15:35:37 +0000 (16:35 +0100)
Change-Id: Ia544d2661ffbef7c6392e550ee8119e9dc993818

dali/graphics-api/graphics-pipeline-create-info.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/pipeline-cache.cpp
dali/internal/render/renderers/pipeline-cache.h
dali/internal/render/renderers/render-renderer.cpp
dali/internal/render/renderers/render-renderer.h

index 0ddcbd7de9309faa68587e98e9566c1d5984fd66..b44f0027b3c2ca974d121a0785ab6c7679390040 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@ namespace Dali
 {
 namespace Graphics
 {
+class RenderTarget;
 /**
  * @brief Interface class for generating Pipeline types in the graphics API.
  *
@@ -190,6 +191,25 @@ struct PipelineCreateInfo
     return *this;
   }
 
+  /**
+   * @brief Sets render target that pipeline will be used with
+   *
+   * The pipeline must know which render target (this or compatible)
+   * it will be used with.
+   *
+   * It is valid not to set render target but only if device supports
+   * 'dynamic rendering'. Our current implementation doesn't support it
+   * but it may in the future.
+   *
+   * @param[in] value Pointer to valid RenderTarget objet
+   * @return reference to this structure
+   */
+  auto& SetRenderTarget(RenderTarget* value)
+  {
+    renderTarget = value;
+    return *this;
+  }
+
   GraphicsStructureType type{GraphicsStructureType::PIPELINE_CREATE_INFO_STRUCT};
   ExtensionCreateInfo*  nextExtension{nullptr};
 
@@ -203,6 +223,8 @@ struct PipelineCreateInfo
   InputAssemblyState*      inputAssemblyState{nullptr};
   PipelineDynamicStateMask dynamicStateMask{0u};
 
+  RenderTarget* renderTarget{nullptr};
+
   const AllocationCallbacks* allocationCallbacks{nullptr};
 };
 
index 3dd8b4f98fa4235dfc277d7a56a8e7f575fbbf32..ced4aebe386e5e093ee862fbcfbc2adfab2acce6 100644 (file)
@@ -592,7 +592,8 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
                                                 const Rect<int32_t>&                viewport,
                                                 const Rect<int>&                    rootClippingRect,
                                                 int                                 orientation,
-                                                const Uint16Pair&                   sceneSize)
+                                                const Uint16Pair&                   sceneSize,
+                                                Graphics::RenderTarget*             renderTarget)
 {
   DALI_PRINT_RENDER_LIST(renderList);
 
@@ -704,7 +705,7 @@ inline void RenderAlgorithms::ProcessRenderList(const RenderList&
         for(auto queue = 0u; queue < MAX_QUEUE; ++queue)
         {
           // Render the item. It will write into the command buffer everything it has to render
-          item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mScale, item.mSize, !item.mIsOpaque, instruction, queue);
+          item.mRenderer->Render(secondaryCommandBuffer, bufferIndex, *item.mNode, item.mModelMatrix, item.mModelViewMatrix, viewMatrix, projectionMatrix, item.mScale, item.mSize, !item.mIsOpaque, instruction, renderTarget, queue);
         }
       }
     }
@@ -757,7 +758,8 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
                                                 const Rect<int32_t>&                viewport,
                                                 const Rect<int>&                    rootClippingRect,
                                                 int                                 orientation,
-                                                const Uint16Pair&                   sceneSize)
+                                                const Uint16Pair&                   sceneSize,
+                                                Graphics::RenderTarget*             renderTarget)
 {
   DALI_TRACE_BEGIN_WITH_MESSAGE_GENERATOR(gTraceFilter, "DALI_RENDER_INSTRUCTION_PROCESS", [&](std::ostringstream& oss) { oss << "[" << instruction.RenderListCount() << "]"; });
 
@@ -792,7 +794,8 @@ void RenderAlgorithms::ProcessRenderInstruction(const RenderInstruction&
                           viewport,
                           rootClippingRect,
                           orientation,
-                          sceneSize);
+                          sceneSize,
+                          renderTarget);
 
         // Execute command buffer
         auto* commandBuffer = renderList->GetCommandBuffer();
index 04b2fe6baeca436616ce243d0297ea3813571649..38b4d6d670c5750305875b364b21ec1e77b4735f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_RENDER_ALGORITHMS_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@ public:
    * @param[in] rootClippingRect       The clipping rectangle
    * @param[in] orientation            The Scene's surface orientation.
    * @param[in] sceneSize              The Scene's surface size.
+   * @param[in] renderTarget           The RenderTarget associated with instruction
    */
   void ProcessRenderInstruction(const SceneGraph::RenderInstruction& instruction,
                                 BufferIndex                          bufferIndex,
@@ -69,7 +70,8 @@ public:
                                 const Rect<int32_t>&                 viewport,
                                 const Rect<int>&                     rootClippingRect,
                                 int                                  orientation,
-                                const Uint16Pair&                    sceneSize);
+                                const Uint16Pair&                    sceneSize,
+                                Graphics::RenderTarget*              renderTarget);
 
   /**
    * Resets main command buffer (per scene)
@@ -95,15 +97,6 @@ public:
   }
 
 private:
-  /**
-   * @brief Calculate a 2D AABB (axis aligned bounding box) in screen space.
-   * The RenderItems dimensions are translated and a Z value of 0 is assumed for this purpose.
-   * No projection is performed, but rotation on Z is supported.
-   * @param[in] item The RenderItem to generate an AABB for
-   * @return         The generated AABB in screen space
-   */
-  inline Dali::ClippingBox CalculateScreenSpaceAABB(const Dali::Internal::SceneGraph::RenderItem& item);
-
   /**
    * @brief Perform any scissor clipping related operations based on the current RenderItem.
    * This includes:
@@ -155,6 +148,7 @@ private:
    * @param[in] rootClippingRect       The root clipping rectangle
    * @param[in] orientation            The Scene's surface orientation
    * @param[in] sceneSize              The Scene's surface size.
+   * @param[in] renderTarget           The render target associated with render instruction
    */
   inline void ProcessRenderList(const Dali::Internal::SceneGraph::RenderList&        renderList,
                                 BufferIndex                                          bufferIndex,
@@ -166,7 +160,8 @@ private:
                                 const Rect<int32_t>&                                 viewport,
                                 const Rect<int>&                                     rootClippingRect,
                                 int                                                  orientation,
-                                const Uint16Pair&                                    sceneSize);
+                                const Uint16Pair&                                    sceneSize,
+                                Graphics::RenderTarget*                              renderTarget);
 
   // Member variables:
 
index 784ad85432450233d844051eae8deb93108bb150..aca9fece738644c89e79a08b9690c8b76be65568 100644 (file)
@@ -1194,7 +1194,8 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       viewportRect,
       clippingRect,
       surfaceOrientation,
-      Uint16Pair(surfaceRect.width, surfaceRect.height));
+      Uint16Pair(surfaceRect.width, surfaceRect.height),
+      currentRenderTarget);
 
     Graphics::SyncObject* syncObject{nullptr};
     // If the render instruction has an associated render tracker (owned separately)
index c73ab4e797db7269a779cb6aab65de9267e5d9dd..dfbd1ab3ba7a83581d1b8825b796591398f921c0 100644 (file)
@@ -543,7 +543,8 @@ PipelineResult PipelineCache::GetPipeline(const PipelineCacheQueryInfo& queryInf
       .SetVertexInputState(&level0->inputState)
       .SetRasterizationState(&level1->rs)
       .SetColorBlendState(&level2->colorBlendState)
-      .SetProgramState(&programState);
+      .SetProgramState(&programState)
+      .SetRenderTarget(queryInfo.renderTarget);
 
     // Store a pipeline per renderer per render (renderer can be owned by multiple nodes,
     // and re-drawn in multiple instructions).
index 17bc6a030024eee10f8e2a7a58dedb15ff26dbaa..0f2f5ad86534aaa2fbd64d1d17922dab1742f298 100644 (file)
@@ -102,6 +102,8 @@ struct PipelineCacheQueryInfo
   Program*  program;
   Geometry* geometry;
 
+  Graphics::RenderTarget* renderTarget;
+
   bool cameraUsingReflection;
 
   // Blending
index 231af2a2c3eaab1d316573faf022ed5538111bfb..d7c5c4eda05ededc57aa2a0af448d18dd08a5446 100644 (file)
@@ -492,6 +492,7 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
                       const Vector3&                                       size,
                       bool                                                 blend,
                       const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+                      Graphics::RenderTarget*                              renderTarget,
                       uint32_t                                             queueIndex)
 {
   // Before doing anything test if the call happens in the right queue
@@ -591,7 +592,7 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
   if(program)
   {
     // Prepare the graphics pipeline. This may either re-use an existing pipeline or create a new one.
-    auto& pipeline = PrepareGraphicsPipeline(*program, instruction, node, blend);
+    auto& pipeline = PrepareGraphicsPipeline(*program, instruction, renderTarget, node, blend);
 
     commandBuffer.BindPipeline(pipeline);
 
@@ -1062,6 +1063,7 @@ Vector4 Renderer::GetTextureUpdateArea() const noexcept
 Graphics::Pipeline& Renderer::PrepareGraphicsPipeline(
   Program&                                             program,
   const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+  Graphics::RenderTarget*                              renderTarget,
   const SceneGraph::NodeDataProvider&                  node,
   bool                                                 blend)
 {
@@ -1074,6 +1076,7 @@ Graphics::Pipeline& Renderer::PrepareGraphicsPipeline(
   queryInfo.blendingOptions       = &mBlendingOptions;
   queryInfo.alphaPremultiplied    = mPremultipliedAlphaEnabled;
   queryInfo.cameraUsingReflection = instruction.GetCamera()->GetReflectionUsed();
+  queryInfo.renderTarget          = renderTarget;
 
   queryInfo.GenerateHash();
 
index 1726d518ef073e224ec2cc1c9844225548887179..6ab32254ae1296c2986a5caa4a26ea7a7359126f 100644 (file)
@@ -412,6 +412,8 @@ public:
    * @param[in] size Size of the render item
    * @param[in] blend If true, blending is enabled
    * @param[in] instruction. for use case like reflection where CullFace needs to be adjusted
+   * @param[in] renderTarget render target associated with instruction
+   * @param[in] queueIndex Index of the render queue
    *
    * @return True if commands have been added to the command buffer
    */
@@ -426,6 +428,7 @@ public:
               const Vector3&                                       size,
               bool                                                 blend,
               const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+              Graphics::RenderTarget*                              renderTarget,
               uint32_t                                             queueIndex);
 
   /**
@@ -583,6 +586,7 @@ private:
   Graphics::Pipeline& PrepareGraphicsPipeline(
     Program&                                             program,
     const Dali::Internal::SceneGraph::RenderInstruction& instruction,
+    Graphics::RenderTarget*                              renderTarget,
     const SceneGraph::NodeDataProvider&                  node,
     bool                                                 blend);