X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbackends%2Fvulkan%2Fmemoryallocator.cpp;h=b15344c7aeb39280a2f9c5d2e26ef765314687e0;hb=bec8444ce5f844d156f5aac90ce9f0a92750cf62;hp=fad6787307fa955fb15d5a9ac5d6bae2974f44a0;hpb=7e48ef177b668f2ed4c0346fa268e3dbfbb63203;p=libs%2Fgl.git diff --git a/source/backends/vulkan/memoryallocator.cpp b/source/backends/vulkan/memoryallocator.cpp index fad67873..b15344c7 100644 --- a/source/backends/vulkan/memoryallocator.cpp +++ b/source/backends/vulkan/memoryallocator.cpp @@ -106,7 +106,7 @@ void MemoryAllocator::release(unsigned id) vk.FreeMemory(allocations[id-1].memory); } -void *MemoryAllocator::map(unsigned id, size_t offset, size_t size) +void *MemoryAllocator::map(unsigned id) { if(!id || id>allocations.size() || !allocations[id-1].memory) throw key_error(id); @@ -115,21 +115,24 @@ void *MemoryAllocator::map(unsigned id, size_t offset, size_t size) const VulkanFunctions &vk = device.get_functions(); - vk.MapMemory(alloc.memory, offset, size, 0, &alloc.mapped_address); + vk.MapMemory(alloc.memory, 0, alloc.size, 0, &alloc.mapped_address); return alloc.mapped_address; } -void MemoryAllocator::unmap(void *ptr) +void MemoryAllocator::unmap(unsigned id) { - auto i = find_member(allocations, ptr, &Allocation::mapped_address); - if(i==allocations.end()) + if(!id || id>allocations.size() || !allocations[id-1].memory) + throw key_error(id); + + Allocation &alloc = allocations[id-1]; + if(!alloc.mapped_address) throw invalid_operation("MemoryAllocator::unmap"); const VulkanFunctions &vk = device.get_functions(); - vk.UnmapMemory(i->memory); - i->mapped_address = 0; + vk.UnmapMemory(alloc.memory); + alloc.mapped_address = 0; } } // namespace GL