Moved program resource hints to Controller 31/316131/1
authorDavid Steele <david.steele@samsung.com>
Tue, 10 Dec 2024 14:30:14 +0000 (14:30 +0000)
committerDavid Steele <david.steele@samsung.com>
Tue, 10 Dec 2024 14:30:14 +0000 (14:30 +0000)
In each scene, the main command buffer also is used to inform the
backend of all used program resources; in Vk, this is used to create
descriptor pools.

Moved this resource hint from CommandBuffer::Begin() info struct, to
Controller::SetResourceBindingHint()

Change-Id: I6cd66af23ad1981f56e06f962404a2602c6e3026
Signed-off-by: David Steele <david.steele@samsung.com>
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.cpp
automated-tests/src/dali/dali-test-suite-utils/test-graphics-controller.h
dali/graphics-api/graphics-controller.h
dali/graphics-api/graphics-types.h
dali/internal/render/common/render-algorithms.cpp
dali/internal/render/common/render-algorithms.h
dali/internal/render/common/render-manager.cpp

index c12f6a95ce72ce87d499704027c74bbbfee5d4cd..9e22ad3a15def88ed80e5e9af4615f7b75d2f6fc 100644 (file)
@@ -613,6 +613,11 @@ TestGraphicsController::TestGraphicsController()
   trace.EnableLogging(false);
 }
 
+void TestGraphicsController::SetResourceBindingHints(const std::vector<Graphics::SceneResourceBinding>& resourceBindings)
+{
+  mCallStack.PushCall("SetResourceBindingHints", "");
+}
+
 void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
 {
   TraceCallStack::NamedParams namedParams;
index 0ccda591394c70c526b9ca9a15c672636ff2389b..c007a1db6b264506cab709cab8debafca8d44c80 100644 (file)
@@ -118,6 +118,8 @@ public:
     return mGraphicsSyncImpl;
   }
 
+  void SetResourceBindingHints(const std::vector<Graphics::SceneResourceBinding>& resourceBindings) override;
+
   void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override;
 
   /**
index 45a48db73749f2c1c53ba2bab30f29e56e9b76f3..bc89c4c52dd084e4da544c5d71078cce55ae939f 100644 (file)
@@ -75,6 +75,13 @@ public:
    */
   virtual ~Controller() = default;
 
+  /**
+   * @brief Sets resource binding hints for the scene
+   *
+   * Backend may choose to allocate memory for the resources.
+   */
+  virtual void SetResourceBindingHints(const std::vector<SceneResourceBinding>& resourceBindings) = 0;
+
   /**
    * @brief Submits array of command buffers
    *
index acb86e849eec7c54a0f7572f52fb513a920c3746..0e0b7c490896adb121e14caa60709bb7b1678cf3 100644 (file)
@@ -1373,7 +1373,7 @@ struct BufferResourceBindingInfo;
 struct TextureResourceBindingInfo;
 struct SamplerResourceBindingInfo;
 
-struct CommandBufferResourceBinding
+struct SceneResourceBinding
 {
   ResourceType type; ///< Type of resource
 
@@ -1390,10 +1390,9 @@ struct CommandBufferBeginInfo
 {
   CommandBufferUsageFlags usage;
 
-  std::vector<CommandBufferResourceBinding>* resourceBindings{nullptr}; ///< Sets resource binding hints
-  const RenderPass*                          renderPass{nullptr};
-  const RenderTarget*                        renderTarget{nullptr};
-  auto&                                      SetUsage(CommandBufferUsageFlags flags)
+  const RenderPass*   renderPass{nullptr};
+  const RenderTarget* renderTarget{nullptr};
+  auto&               SetUsage(CommandBufferUsageFlags flags)
   {
     usage = flags;
     return *this;
@@ -1628,8 +1627,7 @@ struct DefaultDeleter
   template<class P, template<typename> typename U>
   DefaultDeleter(const U<P>& deleter)
   {
-    deleteFunction = [](T* object)
-    { U<P>()(static_cast<P*>(object)); };
+    deleteFunction = [](T* object) { U<P>()(static_cast<P*>(object)); };
   }
 
   /**
index 3d783d358a07953bfeed013b2a325b28c8a34050..59a2c64d6e99a1f03961d3c31fa6a6c8d33eb60b 100644 (file)
@@ -741,7 +741,7 @@ RenderAlgorithms::RenderAlgorithms(Graphics::Controller& graphicsController)
 {
 }
 
-void RenderAlgorithms::ResetCommandBuffer(std::vector<Graphics::CommandBufferResourceBinding>* resourceBindings)
+void RenderAlgorithms::ResetCommandBuffer()
 {
   // Reset main command buffer
   if(!mGraphicsCommandBuffer)
@@ -757,8 +757,7 @@ void RenderAlgorithms::ResetCommandBuffer(std::vector<Graphics::CommandBufferRes
   }
 
   Graphics::CommandBufferBeginInfo info;
-  info.resourceBindings = resourceBindings; // set resource bindings, currently only programs
-  info.usage            = 0 | Graphics::CommandBufferUsageFlagBits::ONE_TIME_SUBMIT;
+  info.usage = 0 | Graphics::CommandBufferUsageFlagBits::ONE_TIME_SUBMIT;
   mGraphicsCommandBuffer->Begin(info);
 }
 
index 7acbad1acae82f519f48d512913b74cc69f94d1e..7411f5f637ac9a598202c187c9b4a451e63e6352 100644 (file)
@@ -75,14 +75,12 @@ public:
                                 Graphics::RenderTarget*              renderTarget);
 
   /**
-   * Resets main command buffer (per scene)
-   *
-   * @param[in] bindings list of resource bindings (optional, can be null)
+   * Resets main command buffer
    */
-  void ResetCommandBuffer(std::vector<Graphics::CommandBufferResourceBinding>* bindings);
+  void ResetCommandBuffer();
 
   /**
-   * Submits main command buffer (per scene)
+   * Submits main command buffer
    */
   void SubmitCommandBuffer();
 
index 866e3530e4ba19384620ed67e98ad5948bffcdbf..971bbb7a44e71c982a793b35233a715f782912aa 100644 (file)
@@ -1055,12 +1055,12 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
   {
     mImpl->graphicsController.EnableDepthStencilBuffer(*sceneObject->GetSurfaceRenderTarget(), sceneNeedsDepthBuffer, sceneNeedsStencilBuffer);
   }
-  // Fill resource binding for the command buffer
-  std::vector<Graphics::CommandBufferResourceBinding> commandBufferResourceBindings;
+  // Fill resource binding for the scene
+  std::vector<Graphics::SceneResourceBinding> sceneResourceBindings;
   if(!programUsageCount.empty())
   {
-    commandBufferResourceBindings.resize(programUsageCount.size());
-    auto iter = commandBufferResourceBindings.begin();
+    sceneResourceBindings.resize(programUsageCount.size());
+    auto iter = sceneResourceBindings.begin();
     for(auto& item : programUsageCount)
     {
       iter->type           = Graphics::ResourceType::PROGRAM;
@@ -1068,9 +1068,10 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::
       ++iter;
     }
   }
+  mImpl->graphicsController.SetResourceBindingHints(sceneResourceBindings);
 
   // Reset main algorithms command buffer
-  mImpl->renderAlgorithms.ResetCommandBuffer(commandBufferResourceBindings.empty() ? nullptr : &commandBufferResourceBindings);
+  mImpl->renderAlgorithms.ResetCommandBuffer();
 
   auto mainCommandBuffer = mImpl->renderAlgorithms.GetMainCommandBuffer();