Skip to content

Commit

Permalink
Fix another case where we trusted std::move to clear the origin, whic…
Browse files Browse the repository at this point in the history
…h is not guaranteed.
  • Loading branch information
hrydgard committed Dec 10, 2017
1 parent 91b089d commit cca4e0b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Common/Vulkan/VulkanContext.cpp
Expand Up @@ -1039,6 +1039,8 @@ void VulkanDeleteList::Take(VulkanDeleteList &del) {
assert(pipelineCaches_.size() == 0);
assert(renderPasses_.size() == 0);
assert(framebuffers_.size() == 0);
assert(pipelineLayouts_.size() == 0);
assert(descSetLayouts_.size() == 0);
assert(callbacks_.size() == 0);
cmdPools_ = std::move(del.cmdPools_);
descPools_ = std::move(del.descPools_);
Expand All @@ -1056,6 +1058,21 @@ void VulkanDeleteList::Take(VulkanDeleteList &del) {
pipelineLayouts_ = std::move(del.pipelineLayouts_);
descSetLayouts_ = std::move(del.descSetLayouts_);
callbacks_ = std::move(del.callbacks_);
del.cmdPools_.clear();
del.descPools_.clear();
del.modules_.clear();
del.buffers_.clear();
del.images_.clear();
del.imageViews_.clear();
del.deviceMemory_.clear();
del.samplers_.clear();
del.pipelines_.clear();
del.pipelineCaches_.clear();
del.renderPasses_.clear();
del.framebuffers_.clear();
del.pipelineLayouts_.clear();
del.descSetLayouts_.clear();
del.callbacks_.clear();
}

void VulkanDeleteList::PerformDeletes(VkDevice device) {
Expand Down
2 changes: 1 addition & 1 deletion Common/Vulkan/VulkanMemory.cpp
Expand Up @@ -353,7 +353,7 @@ void VulkanDeviceAllocator::ExecuteFree(FreeInfo *userdata) {
slab.allocSizes.erase(it);
} else {
// Ack, a double free?
Crash();
_assert_msg_(G3D, false, "Double free? Block missing at offset %d", userdata->offset);
}
found = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion Common/Vulkan/VulkanMemory.h
Expand Up @@ -180,7 +180,7 @@ class VulkanDeviceAllocator {

static void DispatchFree(void *userdata) {
auto freeInfo = static_cast<FreeInfo *>(userdata);
freeInfo->allocator->ExecuteFree(freeInfo);
freeInfo->allocator->ExecuteFree(freeInfo); // this deletes freeInfo
}

bool AllocateSlab(VkDeviceSize minBytes);
Expand Down

0 comments on commit cca4e0b

Please sign in to comment.