Implement some more speed-up : don't copy geometry 34/271534/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Tue, 22 Feb 2022 12:48:33 +0000 (21:48 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Tue, 22 Feb 2022 12:48:33 +0000 (21:48 +0900)
Make some GraphicsCommand API's input as const vector<>&

These will not copy the internal values. and also we can assume that
inputed data didn't change in that API.

Change-Id: Iffd0e53aa114ccf194b63b1ae9648d7729e9b763
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-command-buffer.h
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.h

index 3df3219..96b0021 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_GRAPHICS_COMMAND_BUFFER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -647,9 +647,9 @@ public:
   {
   }
 
-  void BindVertexBuffers(uint32_t                             firstBinding,
-                         std::vector<const Graphics::Buffer*> buffers,
-                         std::vector<uint32_t>                offsets) override
+  void BindVertexBuffers(uint32_t                                    firstBinding,
+                         const std::vector<const Graphics::Buffer*>& buffers,
+                         const std::vector<uint32_t>&                offsets) override
   {
     mCommands.emplace_back();
     mCommands.back().type = CommandType::BIND_VERTEX_BUFFERS;
@@ -712,7 +712,7 @@ public:
     mCallStack.PushCall("BindPipeline", "");
   }
 
-  void BindTextures(std::vector<Graphics::TextureBinding>& textureBindings) override
+  void BindTextures(const std::vector<Graphics::TextureBinding>& textureBindings) override
   {
     mCommands.emplace_back();
     mCommands.back().type                              = CommandType::BIND_TEXTURES;
@@ -720,7 +720,7 @@ public:
     mCallStack.PushCall("BindTextures", "");
   }
 
-  void BindSamplers(std::vector<Graphics::SamplerBinding>& samplerBindings) override
+  void BindSamplers(const std::vector<Graphics::SamplerBinding>& samplerBindings) override
   {
     mCommands.emplace_back();
     mCommands.back().data.bindSamplers.samplerBindings = std::move(samplerBindings);
@@ -747,10 +747,10 @@ public:
   }
 
   void BeginRenderPass(
-    Graphics::RenderPass*             renderPass,
-    Graphics::RenderTarget*           renderTarget,
-    Graphics::Rect2D                  renderArea,
-    std::vector<Graphics::ClearValue> clearValues) override
+    Graphics::RenderPass*                    renderPass,
+    Graphics::RenderTarget*                  renderTarget,
+    Graphics::Rect2D                         renderArea,
+    const std::vector<Graphics::ClearValue>& clearValues) override
   {
     mCommands.emplace_back(CommandType::BEGIN_RENDER_PASS);
     auto& cmd                             = mCommands.back();
index 98f4830..8a4cfc9 100644 (file)
@@ -32,8 +32,8 @@ namespace Dali::Graphics::GLES
 class CommandPool
 {
   static constexpr uint32_t COMMAND_POOL_DEFAULT_INCREMENT = 1024 * 32 / sizeof(Command); // 32kb banks
-  static const     uint32_t MEMORY_POOL_DEFAULT_INCREMENT  = 1024;                        // 1kb memory pool increment
-  static const     uint32_t MEMORY_POOL_DEFAULT_ALIGNMENT  = 64;                          // 64bytes alignment
+  static const uint32_t     MEMORY_POOL_DEFAULT_INCREMENT  = 1024;                        // 1kb memory pool increment
+  static const uint32_t     MEMORY_POOL_DEFAULT_ALIGNMENT  = 64;                          // 64bytes alignment
 
   template<class T>
   struct Block
@@ -234,9 +234,9 @@ CommandBuffer::CommandBuffer(const Graphics::CommandBufferCreateInfo& createInfo
 
 CommandBuffer::~CommandBuffer() = default;
 
-void CommandBuffer::BindVertexBuffers(uint32_t                             firstBinding,
-                                      std::vector<const Graphics::Buffer*> buffers,
-                                      std::vector<uint32_t>                offsets)
+void CommandBuffer::BindVertexBuffers(uint32_t                                    firstBinding,
+                                      const std::vector<const Graphics::Buffer*>& buffers,
+                                      const std::vector<uint32_t>&                offsets)
 {
   auto command                                         = mCommandPool->AllocateCommand(CommandType::BIND_VERTEX_BUFFERS);
   command->bindVertexBuffers.vertexBufferBindingsCount = firstBinding + buffers.size();
@@ -314,7 +314,7 @@ void CommandBuffer::BindPipeline(const Graphics::Pipeline& pipeline)
   command->bindPipeline.pipeline = static_cast<const GLES::Pipeline*>(&pipeline);
 }
 
-void CommandBuffer::BindTextures(std::vector<TextureBinding>& textureBindings)
+void CommandBuffer::BindTextures(const std::vector<TextureBinding>& textureBindings)
 {
   auto  command                        = mCommandPool->AllocateCommand(CommandType::BIND_TEXTURES);
   auto& bindTexturesCmd                = command->bindTextures;
@@ -323,7 +323,7 @@ void CommandBuffer::BindTextures(std::vector<TextureBinding>& textureBindings)
   memcpy(bindTexturesCmd.textureBindings.Ptr(), textureBindings.data(), sizeof(TextureBinding) * textureBindings.size());
 }
 
-void CommandBuffer::BindSamplers(std::vector<SamplerBinding>& samplerBindings)
+void CommandBuffer::BindSamplers(const std::vector<SamplerBinding>& samplerBindings)
 {
   auto  command                        = mCommandPool->AllocateCommand(CommandType::BIND_SAMPLERS);
   auto& bindSamplersCmd                = command->bindSamplers;
@@ -349,10 +349,10 @@ void CommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer,
 }
 
 void CommandBuffer::BeginRenderPass(
-  Graphics::RenderPass*   renderPass,
-  Graphics::RenderTarget* renderTarget,
-  Rect2D                  renderArea,
-  std::vector<ClearValue> clearValues)
+  Graphics::RenderPass*          renderPass,
+  Graphics::RenderTarget*        renderTarget,
+  Rect2D                         renderArea,
+  const std::vector<ClearValue>& clearValues)
 {
   auto  command                    = mCommandPool->AllocateCommand(CommandType::BEGIN_RENDERPASS);
   auto& cmd                        = *command;
index 8e2aeac..983bc9c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_GLES_COMMAND_BUFFER_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -230,9 +230,9 @@ public:
   /**
    * @copydoc Dali::Graphics::CommandBuffer::BindVertexBuffers
    */
-  void BindVertexBuffers(uint32_t                             firstBinding,
-                         std::vector<const Graphics::Buffer*> buffers,
-                         std::vector<uint32_t>                offsets) override;
+  void BindVertexBuffers(uint32_t                                    firstBinding,
+                         const std::vector<const Graphics::Buffer*>& buffers,
+                         const std::vector<uint32_t>&                offsets) override;
 
   /**
    * @copydoc Dali::Graphics::CommandBuffer::BindUniformBuffers
@@ -247,12 +247,12 @@ public:
   /**
    * @copydoc Dali::Graphics::CommandBuffer::BindTextures
    */
-  void BindTextures(std::vector<TextureBinding>& textureBindings) override;
+  void BindTextures(const std::vector<TextureBinding>& textureBindings) override;
 
   /**
    * @copydoc Dali::Graphics::CommandBuffer::BindSamplers
    */
-  void BindSamplers(std::vector<SamplerBinding>& samplerBindings) override;
+  void BindSamplers(const std::vector<SamplerBinding>& samplerBindings) override;
 
   /**
    * @copydoc Dali::Graphics::CommandBuffer::BindPushConstants
@@ -272,10 +272,10 @@ public:
    * @copydoc Dali::Graphics::CommandBuffer::BeginRenderPass
    */
   void BeginRenderPass(
-    Graphics::RenderPass*   renderPass,
-    Graphics::RenderTarget* renderTarget,
-    Rect2D                  renderArea,
-    std::vector<ClearValue> clearValues) override;
+    Graphics::RenderPass*          renderPass,
+    Graphics::RenderTarget*        renderTarget,
+    Rect2D                         renderArea,
+    const std::vector<ClearValue>& clearValues) override;
 
   /**
    * @copydoc Dali::Graphics::CommandBuffer::EndRenderPass