Make UBOV2::AlignSize() API as inline 32/322632/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 14 Apr 2025 01:17:10 +0000 (10:17 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 14 Apr 2025 04:11:21 +0000 (13:11 +0900)
Since we don't change mAlighment ever, we can mark it as const,
and move calculate Aligned size as inline function.

Change-Id: I7aeab753325aff16dca19ab53d13e9cb9f94d975
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/render/renderers/uniform-buffer.cpp
dali/internal/render/renderers/uniform-buffer.h

index 99bdbf7b0f9ef23259afe441b45fc95d6d32d94b..4f664fed4d623fc99c4b52fc1b7e7399139bb605 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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::Internal::Render
 {
 // GPU UBOs need to be double-buffered in order to avoid stalling the CPU during mapping/unmapping
 constexpr uint32_t INTERNAL_UBO_BUFFER_COUNT = 2u;
+constexpr uint32_t DEFAUT_MEMORY_ALIGNMENT{1};
 
 Graphics::UniquePtr<UniformBufferV2> UniformBufferV2::New(Dali::Graphics::Controller* controller, bool emulated, uint32_t alignment)
 {
@@ -37,7 +38,7 @@ Graphics::UniquePtr<UniformBufferV2> UniformBufferV2::New(Dali::Graphics::Contro
 
 UniformBufferV2::UniformBufferV2(Dali::Graphics::Controller* controller, bool emulated, uint32_t alignment)
 : mController(controller),
-  mBlockAlignment(alignment),
+  mBlockAlignment(alignment ? alignment : DEFAUT_MEMORY_ALIGNMENT),
   mCurrentGraphicsBufferIndex(0),
   mEmulated(emulated)
 {
@@ -132,15 +133,6 @@ void UniformBufferV2::Rollback()
   }
 }
 
-uint32_t UniformBufferV2::AlignSize(uint32_t size)
-{
-  if(size % mBlockAlignment != 0)
-  {
-    size = ((size / mBlockAlignment) + 1) * mBlockAlignment;
-  }
-  return size;
-}
-
 uint32_t UniformBufferV2::IncrementOffsetBy(uint32_t value)
 {
   if(mEmulated && !mBufferList.empty())
index 2b5396cbfb8782ab2b226fdac3465fc2c935733c..d1e4f3835963a131848a040991b6c77f8dbfa953 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_UNIFORM_BUFFER_H
 
 /*
- * Copyright (c) 2024 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2025 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.
@@ -66,7 +66,14 @@ public:
   /**
    * Align size to the current block size
    */
-  uint32_t AlignSize(uint32_t size);
+  uint32_t AlignSize(uint32_t size) const
+  {
+    if(size % mBlockAlignment != 0)
+    {
+      size = ((size / mBlockAlignment) + 1) * mBlockAlignment;
+    }
+    return size;
+  }
 
   uint32_t IncrementOffsetBy(uint32_t value);
 
@@ -102,7 +109,7 @@ private:
 private:
   Graphics::Controller* mController{nullptr};
 
-  uint32_t mBlockAlignment{0u};
+  const uint32_t mBlockAlignment;
 
   struct GfxBuffer
   {