]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/vulkan/memoryallocator.cpp
Minor tweaks to MemoryAllocator
[libs/gl.git] / source / backends / vulkan / memoryallocator.cpp
index 4b3595b64df8b9d6f61c9922d005a54a59b65f5e..82155faf41624ef03829cd994ebbbfc2eab246ab 100644 (file)
@@ -56,7 +56,7 @@ MemoryAllocator::~MemoryAllocator()
                        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)
@@ -86,7 +86,7 @@ unsigned MemoryAllocator::create_region(unsigned pool_index, size_t size, bool d
        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; });
 }
@@ -131,7 +131,7 @@ unsigned MemoryAllocator::allocate(size_t size, size_t align, unsigned type_bits
        {
                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;