Removed memcpy() from uniform write 57/261157/4
authorAdam Bialogonski <adam.b@samsung.com>
Mon, 12 Jul 2021 11:58:30 +0000 (12:58 +0100)
committerAdam Bialogonski <adam.b@samsung.com>
Fri, 16 Jul 2021 08:54:55 +0000 (09:54 +0100)
memcpy() replaced by word-size writes.

Change-Id: I6d6c02327424fac69beec4b98ef547076775aecf

dali/internal/render/renderers/uniform-buffer.cpp

index ecae483..c944880 100644 (file)
@@ -181,7 +181,13 @@ void UniformBuffer::Write(const void* data, uint32_t size, uint32_t dstOffset)
     void* ptr = bufferDesc.memory->LockRegion(bufferOffset, size);
     if(ptr && bufferOffset + size < mSize)
     {
-      memcpy(ptr, data, size);
+      // size always divides by 4 (std140 alignment rules, so we can replace memcpy with unrolled assignments)
+      auto ptr32 = reinterpret_cast<uint32_t*>(ptr);
+      auto data32 = reinterpret_cast<const uint32_t*>(data);
+      for(auto i = 0u; i < size; i +=4 )
+      {
+        *ptr32++ = *data32++;;
+      }
     }
     bufferDesc.memory->Unlock(true);
   }