Changes to constness of command buffer 49/257249/2
authorDavid Steele <david.steele@samsung.com>
Wed, 21 Apr 2021 17:00:28 +0000 (18:00 +0100)
committerDavid Steele <david.steele@samsung.com>
Wed, 21 Apr 2021 17:18:14 +0000 (18:18 +0100)
Change-Id: Ibfab9d24b937d3a616db5f41ad9caabd14603116

automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-command-buffer.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-command-buffer.h
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.cpp
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-controller.h
dali/internal/graphics/gles-impl/egl-graphics-controller.cpp
dali/internal/graphics/gles-impl/egl-graphics-controller.h
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h

index 78c6fbb..e34b852 100644 (file)
@@ -60,9 +60,9 @@ void TestGraphicsCommandBuffer::GetStateForDrawCall(int drawCallIndex)
   }
 }
 
-std::vector<Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask)
+std::vector<const Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMask mask) const
 {
-  std::vector<Command*> mCommandStack{};
+  std::vector<const Command*> mCommandStack{};
   for(auto& cmd : mCommands)
   {
     if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)))
@@ -73,9 +73,9 @@ std::vector<Command*> TestGraphicsCommandBuffer::GetCommandsByType(CommandTypeMa
   return mCommandStack;
 }
 
-std::vector<Command*> TestGraphicsCommandBuffer::GetChildCommandsByType(CommandTypeMask mask)
+std::vector<const Command*> TestGraphicsCommandBuffer::GetChildCommandsByType(CommandTypeMask mask) const
 {
-  std::vector<Command*> mCommandStack{};
+  std::vector<const Command*> mCommandStack{};
   for(auto& cmd : mCommands)
   {
     if(uint32_t(cmd.type) == (mask & uint32_t(cmd.type)))
index bc1ea7b..a68cb7f 100644 (file)
@@ -477,7 +477,7 @@ struct Command
 
     struct
     {
-      std::vector<TestGraphicsCommandBuffer*> buffers;
+      std::vector<const TestGraphicsCommandBuffer*> buffers;
     } executeCommandBuffers;
 
   } data;
@@ -624,7 +624,7 @@ public:
     mCallStack.PushCall("EndRenderPass", "");
   }
 
-  void ExecuteCommandBuffers(std::vector<CommandBuffer*>&& commandBuffers) override
+  void ExecuteCommandBuffers(std::vector<const CommandBuffer*>&& commandBuffers) override
   {
     mCommands.emplace_back();
     auto& cmd = mCommands.back();
@@ -632,7 +632,7 @@ public:
     cmd.data.executeCommandBuffers.buffers.reserve(commandBuffers.size());
     for(auto&& item : commandBuffers)
     {
-      cmd.data.executeCommandBuffers.buffers.emplace_back(static_cast<TestGraphicsCommandBuffer*>(item));
+      cmd.data.executeCommandBuffers.buffers.emplace_back(static_cast<const TestGraphicsCommandBuffer*>(item));
     }
     mCallStack.PushCall("ExecuteCommandBuffers", "");
   }
@@ -768,9 +768,9 @@ public:
   /**
    * Retrieves commands of specified type
    */
-  std::vector<Command*> GetCommandsByType(CommandTypeMask mask);
+  std::vector<const Command*> GetCommandsByType(CommandTypeMask mask) const;
 
-  std::vector<Command*> GetChildCommandsByType(CommandTypeMask mask);
+  std::vector<const Command*> GetChildCommandsByType(CommandTypeMask mask) const;
 
 private:
   TraceCallStack&    mCallStack;
index e398236..ddcf0f5 100644 (file)
@@ -543,21 +543,6 @@ void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& com
       case CommandType::BIND_PIPELINE:
       {
         currentPipeline = Uncast<TestGraphicsPipeline>(cmd.data.bindPipeline.pipeline);
-
-        // Bind framebuffer if different. @todo Move to RenderPass
-        auto framebuffer = currentPipeline->framebufferState.framebuffer;
-        if(framebuffer && framebuffer != currentFramebuffer)
-        {
-          auto graphicsFramebuffer = Uncast<TestGraphicsFramebuffer>(framebuffer);
-          graphicsFramebuffer->Bind();
-        }
-        else
-        {
-          if(currentFramebuffer)
-            currentFramebuffer->Bind();
-          else
-            mGl.BindFramebuffer(GL_FRAMEBUFFER, 0);
-        }
         BindPipeline(currentPipeline);
         break;
       }
@@ -622,7 +607,7 @@ void TestGraphicsController::ProcessCommandBuffer(TestGraphicsCommandBuffer& com
         // Process secondary command buffers
         for(auto& buf : cmd.data.executeCommandBuffers.buffers)
         {
-          ProcessCommandBuffer(*static_cast<TestGraphicsCommandBuffer*>(buf));
+          ProcessCommandBuffer(*Uncast<TestGraphicsCommandBuffer>(buf));
         }
         break;
       }
index b17e6f8..f4f7e60 100644 (file)
@@ -301,7 +301,7 @@ void EglGraphicsController::ProcessCreateQueues()
   ProcessCreateQueue(mCreateFramebufferQueue);
 }
 
-void EglGraphicsController::ProcessCommandBuffer(GLES::CommandBuffer& commandBuffer)
+void EglGraphicsController::ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer)
 {
   for(auto& cmd : commandBuffer.GetCommands())
   {
@@ -397,7 +397,7 @@ void EglGraphicsController::ProcessCommandBuffer(GLES::CommandBuffer& commandBuf
         ResolvePresentRenderTarget(cmd.presentRenderTarget.targetToPresent);
 
         // push this command buffer to the discard queue
-        mDiscardCommandBufferQueue.push(&commandBuffer);
+        mDiscardCommandBufferQueue.push(const_cast<GLES::CommandBuffer*>(&commandBuffer));
         break;
       }
       case GLES::CommandType::EXECUTE_COMMAND_BUFFERS:
@@ -408,7 +408,7 @@ void EglGraphicsController::ProcessCommandBuffer(GLES::CommandBuffer& commandBuf
         //       within secondaries.
         for(auto& buf : cmd.executeCommandBuffers.buffers)
         {
-          ProcessCommandBuffer(*static_cast<GLES::CommandBuffer*>(buf));
+          ProcessCommandBuffer(*static_cast<const GLES::CommandBuffer*>(buf));
         }
         break;
       }
index 702b028..b806126 100644 (file)
@@ -478,7 +478,7 @@ public:
   {
     while(!queue.empty())
     {
-      auto* object = queue.front();
+      auto* object = const_cast<U*>(queue.front());
 
       // Destroy
       object->DestroyResource();
@@ -553,7 +553,7 @@ public:
     return mIsShuttingDown;
   }
 
-  void ProcessCommandBuffer(GLES::CommandBuffer& commandBuffer);
+  void ProcessCommandBuffer(const GLES::CommandBuffer& commandBuffer);
 
   // Resolves presentation
   void ResolvePresentRenderTarget(GLES::RenderTarget* renderTarget);
@@ -571,13 +571,13 @@ private:
   std::queue<GLES::Buffer*> mCreateBufferQueue;  ///< Create queue for buffer resource
   std::queue<GLES::Buffer*> mDiscardBufferQueue; ///< Discard queue for buffer resource
 
-  std::queue<GLES::Program*>       mDiscardProgramQueue;       ///< Discard queue for program resource
-  std::queue<GLES::Pipeline*>      mDiscardPipelineQueue;      ///< Discard queue of pipelines
-  std::queue<GLES::Shader*>        mDiscardShaderQueue;        ///< Discard queue of shaders
-  std::queue<GLES::Sampler*>       mDiscardSamplerQueue;       ///< Discard queue of samplers
-  std::queue<GLES::CommandBuffer*> mDiscardCommandBufferQueue; ///< Discard queue of command buffers
-  std::queue<GLES::Framebuffer*>   mCreateFramebufferQueue;    ///< Create queue for framebuffer resource
-  std::queue<GLES::Framebuffer*>   mDiscardFramebufferQueue;   ///< Discard queue for framebuffer resource
+  std::queue<GLES::Program*>             mDiscardProgramQueue;       ///< Discard queue for program resource
+  std::queue<GLES::Pipeline*>            mDiscardPipelineQueue;      ///< Discard queue of pipelines
+  std::queue<GLES::Shader*>              mDiscardShaderQueue;        ///< Discard queue of shaders
+  std::queue<GLES::Sampler*>             mDiscardSamplerQueue;       ///< Discard queue of samplers
+  std::queue<const GLES::CommandBuffer*> mDiscardCommandBufferQueue; ///< Discard queue of command buffers
+  std::queue<GLES::Framebuffer*>         mCreateFramebufferQueue;    ///< Create queue for framebuffer resource
+  std::queue<GLES::Framebuffer*>         mDiscardFramebufferQueue;   ///< Discard queue for framebuffer resource
 
   std::queue<GLES::CommandBuffer*> mCommandQueue; ///< we may have more in the future
 
index c200de5..83f010e 100644 (file)
@@ -142,14 +142,14 @@ void CommandBuffer::EndRenderPass()
   mCommands.emplace_back(CommandType::END_RENDERPASS);
 }
 
-void CommandBuffer::ExecuteCommandBuffers(std::vector<Graphics::CommandBuffer*>&& commandBuffers)
+void CommandBuffer::ExecuteCommandBuffers(std::vector<const 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));
+    cmd.executeCommandBuffers.buffers.emplace_back(static_cast<const GLES::CommandBuffer*>(item));
   }
 }
 
@@ -255,4 +255,4 @@ void CommandBuffer::DiscardResource()
   GetController().DiscardResource(this);
 }
 
-} // namespace Dali::Graphics::GLES
\ No newline at end of file
+} // namespace Dali::Graphics::GLES
index 5996863..214f19c 100644 (file)
@@ -389,7 +389,7 @@ struct Command
 
     struct
     {
-      std::vector<GLES::CommandBuffer*> buffers;
+      std::vector<const GLES::CommandBuffer*> buffers;
     } executeCommandBuffers;
 
     struct
@@ -445,7 +445,7 @@ public:
    */
   void EndRenderPass() override;
 
-  void ExecuteCommandBuffers(std::vector<Graphics::CommandBuffer*>&& commandBuffers) override;
+  void ExecuteCommandBuffers(std::vector<const Graphics::CommandBuffer*>&& commandBuffers) override;
 
   void Draw(
     uint32_t vertexCount,