Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-09-14 00:02:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-09-14 00:03:10 +0300
commitfd5c1972cd5c8a826c0d40effb0e2d367389666a (patch)
tree6a093944267ff888e9fb4323bac22d52468ab7ec /source/blender/blenlib/intern/BLI_memblock.c
parentc80564ef9f557fadd235b87533b24d126e2138c9 (diff)
Revert "DRW: Refactor to support draw call batching"
This reverts commit ce34a6b0d727bbde6ae373afa8ec6c42bc8980ce.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_memblock.c')
-rw-r--r--source/blender/blenlib/intern/BLI_memblock.c23
1 files changed, 7 insertions, 16 deletions
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;
-}