[Bf-blender-cvs] [11e6de71877] tmp-drw-callbatching: BLI_memblock: Use aligned memory blocks

Clément Foucault noreply at git.blender.org
Sat Aug 17 14:50:01 CEST 2019


Commit: 11e6de7187746663f63e59cc2b297800687192fa
Author: Clément Foucault
Date:   Mon Jun 3 12:49:29 2019 +0200
Branches: tmp-drw-callbatching
https://developer.blender.org/rB11e6de7187746663f63e59cc2b297800687192fa

BLI_memblock: Use aligned memory blocks

This is because we upload certain chunks directly as UBO data and
AMD suggests to use aligned block to speedup memcpy.

However, this implies the driver is also doing an aligned allocation
which seems not to be the case on linux_x64 + radeon + mesa.

===================================================================

M	source/blender/blenlib/intern/BLI_memblock.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_memblock.c b/source/blender/blenlib/intern/BLI_memblock.c
index b357c5ed4eb..f7239f1b9d1 100644
--- a/source/blender/blenlib/intern/BLI_memblock.c
+++ b/source/blender/blenlib/intern/BLI_memblock.c
@@ -71,7 +71,8 @@ BLI_memblock *BLI_memblock_create_ex(uint elem_size, uint chunk_size)
   mblk->chunk_size = (int)chunk_size;
   mblk->chunk_len = CHUNK_LIST_SIZE;
   mblk->chunk_list = MEM_callocN(sizeof(void *) * (uint)mblk->chunk_len, "chunk list");
-  mblk->chunk_list[0] = MEM_callocN((uint)mblk->chunk_size, "BLI_memblock chunk");
+  mblk->chunk_list[0] = MEM_mallocN_aligned((uint)mblk->chunk_size, 32, "BLI_memblock chunk");
+  memset(mblk->chunk_list[0], 0x0, (uint)mblk->chunk_size);
   mblk->chunk_max_ofs = (mblk->chunk_size / mblk->elem_size) * mblk->elem_size;
   mblk->elem_next_ofs = 0;
   mblk->chunk_next = 0;
@@ -142,8 +143,9 @@ void *BLI_memblock_alloc(BLI_memblock *mblk)
     }
 
     if (UNLIKELY(mblk->chunk_list[mblk->chunk_next] == NULL)) {
-      mblk->chunk_list[mblk->chunk_next] = MEM_callocN((uint)mblk->chunk_size,
-                                                       "BLI_memblock chunk");
+      mblk->chunk_list[mblk->chunk_next] = MEM_mallocN_aligned(
+          (uint)mblk->chunk_size, 32, "BLI_memblock chunk");
+      memset(mblk->chunk_list[mblk->chunk_next], 0x0, (uint)mblk->chunk_size);
     }
   }
   return ptr;



More information about the Bf-blender-cvs mailing list