summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7e48ef1)
An allocation is now always mapped in its entirety. Unmapping is done
by ID instead of mapped address.
void *VulkanBuffer::map()
{
void *VulkanBuffer::map()
{
- size_t size = static_cast<const Buffer *>(this)->size;
- mapped_address = device.get_allocator().map(memory_id, 0, size);
+ mapped_address = device.get_allocator().map(memory_id);
return mapped_address;
}
bool VulkanBuffer::unmap()
{
return mapped_address;
}
bool VulkanBuffer::unmap()
{
- device.get_allocator().unmap(mapped_address);
+ device.get_allocator().unmap(memory_id);
mapped_address = 0;
return true;
}
mapped_address = 0;
return true;
}
vk.FreeMemory(allocations[id-1].memory);
}
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);
{
if(!id || id>allocations.size() || !allocations[id-1].memory)
throw key_error(id);
const VulkanFunctions &vk = device.get_functions();
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;
}
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();
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;
unsigned allocate(VkImage, MemoryType);
void release(unsigned);
unsigned allocate(VkImage, MemoryType);
void release(unsigned);
- void *map(unsigned, std::size_t, std::size_t);
- void unmap(void *);
+ void *map(unsigned);
+ void unmap(unsigned);
MemoryAllocator &allocator = device.get_allocator();
memory_id = allocator.allocate(buffer, STAGING_MEMORY);
MemoryAllocator &allocator = device.get_allocator();
memory_id = allocator.allocate(buffer, STAGING_MEMORY);
- mapped_address = allocator.map(memory_id, 0, size);
+ mapped_address = allocator.map(memory_id);
}
TransferQueue::StagingBuffer::StagingBuffer(StagingBuffer &&other):
}
TransferQueue::StagingBuffer::StagingBuffer(StagingBuffer &&other):
- allocator.unmap(mapped_address);
+ allocator.unmap(memory_id);
allocator.release(memory_id);
}
if(buffer)
allocator.release(memory_id);
}
if(buffer)