(Gles) Minor optimize UBOBinding 38/322938/2
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 18 Apr 2025 06:50:27 +0000 (15:50 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 21 Apr 2025 06:19:57 +0000 (15:19 +0900)
1.
std::vector<bool> is specialize for bitfields, which has less memory
and might have overhead at get/set. Let we avoid this panalty if possible.

2.
Remove unused member values for UniformBufferBindingDescriptor.

Change-Id: Ic09d0130cb103e9e6cbde843486c752c3e7abb1a
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/graphics/gles-impl/gles-context.cpp
dali/internal/graphics/gles-impl/gles-graphics-command-buffer.cpp
dali/internal/graphics/gles-impl/gles-graphics-types.h

index a5c4f1de87e66d7626d6fca2a9de84e758d3548b..eed36755a963f7963ff2559de8eacbbc70f0b60c 100644 (file)
@@ -775,12 +775,11 @@ void Context::ResolveGpuUniformBuffers()
 {
   if(auto* gl = mImpl->GetGL())
   {
-    auto i = 0u;
     for(const auto& binding : mImpl->mCurrentUBOBindings)
     {
       if(DALI_LIKELY(binding.buffer && binding.dataSize > 0u))
       {
-        gl->BindBufferRange(GL_UNIFORM_BUFFER, i++, binding.buffer->GetGLBuffer(), GLintptr(binding.offset), GLintptr(binding.dataSize));
+        gl->BindBufferRange(GL_UNIFORM_BUFFER, binding.binding, binding.buffer->GetGLBuffer(), GLintptr(binding.offset), GLintptr(binding.dataSize));
       }
     }
   }
index b068d42d36a9ead5a597c551cd87e5d8ba7d5c45..1d4c9e7f30fb47a91ffe068a620de5b99fde4a12 100644 (file)
@@ -278,9 +278,9 @@ void CommandBuffer::BindUniformBuffers(const std::vector<Graphics::UniformBuffer
   // temporary static set of binding slots (thread local)
   static constexpr auto MAX_UNIFORM_BUFFER_BINDINGS = 64; // TODO: this should be read from introspection
 
-  static constexpr UniformBufferBindingDescriptor                 NULL_DESCRIPTOR{nullptr, 0, 0, 0, 0, false};
+  static constexpr UniformBufferBindingDescriptor                 NULL_DESCRIPTOR{nullptr, 0, 0, 0};
   static thread_local std::vector<UniformBufferBindingDescriptor> sTempBindings(MAX_UNIFORM_BUFFER_BINDINGS, NULL_DESCRIPTOR);
-  static thread_local std::vector<bool>                           sTempBindingsUsed(MAX_UNIFORM_BUFFER_BINDINGS, false);
+  static thread_local std::vector<uint8_t>                        sTempBindingsUsed(MAX_UNIFORM_BUFFER_BINDINGS, 0);
 
   memset(&bindCmd.standaloneUniformsBufferBinding, 0, sizeof(UniformBufferBindingDescriptor));
 
@@ -294,21 +294,18 @@ void CommandBuffer::BindUniformBuffers(const std::vector<Graphics::UniformBuffer
       const auto* glesBuffer = static_cast<const GLES::Buffer*>(binding.buffer);
       if(glesBuffer->IsCPUAllocated()) // standalone uniforms
       {
-        bindCmd.standaloneUniformsBufferBinding.buffer   = glesBuffer;
-        bindCmd.standaloneUniformsBufferBinding.binding  = binding.binding;
-        bindCmd.standaloneUniformsBufferBinding.offset   = binding.offset;
-        bindCmd.standaloneUniformsBufferBinding.emulated = true;
+        bindCmd.standaloneUniformsBufferBinding.buffer  = glesBuffer;
+        bindCmd.standaloneUniformsBufferBinding.offset  = binding.offset;
+        bindCmd.standaloneUniformsBufferBinding.binding = binding.binding;
       }
       else // Bind regular UBO
       {
         auto& slot = sTempBindings[binding.binding];
 
-        slot.buffer     = glesBuffer;
-        slot.binding    = binding.binding;
-        slot.offset     = binding.offset;
-        slot.dataSize   = binding.dataSize;
-        slot.blockIndex = 0;
-        slot.emulated   = false;
+        slot.buffer   = glesBuffer;
+        slot.offset   = binding.offset;
+        slot.dataSize = binding.dataSize;
+        slot.binding  = binding.binding;
 
         sTempBindingsUsed[binding.binding] = true;
 
index 600127425dae82ccb6f17d4e43c34c68ad382480..fc8e2d7dcafd15b33397ea63fe3ac49e23fc070d 100644 (file)
@@ -1146,11 +1146,9 @@ struct IndexBufferBindingDescriptor
 struct UniformBufferBindingDescriptor
 {
   const GLES::Buffer* buffer;
-  uint32_t            binding;
   uint32_t            offset;
   uint32_t            dataSize;
-  uint32_t            blockIndex;
-  bool                emulated; ///<true if UBO is emulated for old gfx API
+  uint32_t            binding;
 };
 
 /**