vk.FreeMemory(r.memory);
}
-unsigned MemoryAllocator::find_memory_pool(unsigned mask, MemoryType type)
+unsigned MemoryAllocator::find_memory_pool(unsigned mask, MemoryType type) const
{
for(unsigned i=0; i<pools.size(); ++i)
if((mask&(1<<i)) && pools[i].type==type)
return regions.size()-1;
}
-vector<unsigned>::iterator MemoryAllocator::lower_bound_by_size(vector<unsigned> &indices, size_t size)
+vector<unsigned>::iterator MemoryAllocator::lower_bound_by_size(vector<unsigned> &indices, size_t size) const
{
return lower_bound(indices, size, [this](unsigned j, unsigned s){ return blocks[j].size<s; });
}
{
Block block;
block.region = create_region(pool_index, default_region_size, false);
- block.size = default_region_size;
+ block.size = regions[block.region].size;
blocks.push_back(block);
block_index = blocks.size()-1;
~MemoryAllocator();
private:
- unsigned find_memory_pool(unsigned, MemoryType);
+ unsigned find_memory_pool(unsigned, MemoryType) const;
unsigned create_region(unsigned, size_t, bool);
- std::vector<unsigned>::iterator lower_bound_by_size(std::vector<unsigned> &, std::size_t);
+ std::vector<unsigned>::iterator lower_bound_by_size(std::vector<unsigned> &, std::size_t) const;
unsigned allocate(std::size_t, std::size_t, unsigned, MemoryType);
unsigned split_block(unsigned, std::size_t);
void consolidate(unsigned);