From fd5c1972cd5c8a826c0d40effb0e2d367389666a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 13 Sep 2019 23:02:45 +0200 Subject: Revert "DRW: Refactor to support draw call batching" This reverts commit ce34a6b0d727bbde6ae373afa8ec6c42bc8980ce. --- source/blender/blenlib/intern/BLI_memblock.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to '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 f7239f1b9d1..f26860afe77 100644 --- a/source/blender/blenlib/intern/BLI_memblock.c +++ b/source/blender/blenlib/intern/BLI_memblock.c @@ -37,6 +37,7 @@ #include "BLI_strict_flags.h" /* keep last */ +#define BLI_MEM_BLOCK_CHUNK_SIZE (1 << 15) /* 32KiB */ #define CHUNK_LIST_SIZE 16 struct BLI_memblock { @@ -60,19 +61,18 @@ struct BLI_memblock { int chunk_len; }; -BLI_memblock *BLI_memblock_create_ex(uint elem_size, uint chunk_size) +BLI_memblock *BLI_memblock_create(uint elem_size) { - BLI_assert(elem_size < chunk_size); + BLI_assert(elem_size < BLI_MEM_BLOCK_CHUNK_SIZE); BLI_memblock *mblk = MEM_mallocN(sizeof(BLI_memblock), "BLI_memblock"); mblk->elem_size = (int)elem_size; mblk->elem_next = 0; mblk->elem_last = -1; - mblk->chunk_size = (int)chunk_size; + mblk->chunk_size = BLI_MEM_BLOCK_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_mallocN_aligned((uint)mblk->chunk_size, 32, "BLI_memblock chunk"); - memset(mblk->chunk_list[0], 0x0, (uint)mblk->chunk_size); + mblk->chunk_list[0] = MEM_callocN((uint)mblk->chunk_size, "BLI_memblock chunk"); mblk->chunk_max_ofs = (mblk->chunk_size / mblk->elem_size) * mblk->elem_size; mblk->elem_next_ofs = 0; mblk->chunk_next = 0; @@ -143,9 +143,8 @@ void *BLI_memblock_alloc(BLI_memblock *mblk) } if (UNLIKELY(mblk->chunk_list[mblk->chunk_next] == NULL)) { - 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); + mblk->chunk_list[mblk->chunk_next] = MEM_callocN((uint)mblk->chunk_size, + "BLI_memblock chunk"); } } return ptr; @@ -181,11 +180,3 @@ void *BLI_memblock_iterstep(BLI_memblock_iter *iter) } return ptr; } - -/* Direct access. elem is element index inside the chosen chunk. */ -void *BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) -{ - BLI_assert(chunk < mblk->chunk_len); - BLI_assert(elem < (mblk->chunk_size / mblk->elem_size)); - return (char *)(mblk->chunk_list[chunk]) + mblk->elem_size * elem; -} -- cgit v1.2.3