Skip to content

Commit

Permalink
Fix bugs in VulkanImage allocator support
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Dec 3, 2017
1 parent 5d53f5e commit 6abdbde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Common/Vulkan/VulkanImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,18 @@ void VulkanTexture::Unlock(VkCommandBuffer cmd) {
mem_alloc.memoryTypeIndex = 0;
mem_alloc.allocationSize = mem_reqs.size;

// Find memory type - don't specify any mapping requirements
bool pass = vulkan_->MemoryTypeFromProperties(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &mem_alloc.memoryTypeIndex);
assert(pass);

res = vkAllocateMemory(vulkan_->GetDevice(), &mem_alloc, NULL, &mem);
assert(res == VK_SUCCESS);
if (allocator_) {
offset_ = allocator_->Allocate(mem_reqs, &mem);
} else {
offset_ = 0;
// Find memory type - don't specify any mapping requirements
bool pass = vulkan_->MemoryTypeFromProperties(mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &mem_alloc.memoryTypeIndex);
assert(pass);
res = vkAllocateMemory(vulkan_->GetDevice(), &mem_alloc, NULL, &mem);
assert(res == VK_SUCCESS);
}

res = vkBindImageMemory(vulkan_->GetDevice(), image, mem, 0);
res = vkBindImageMemory(vulkan_->GetDevice(), image, mem, offset_);
assert(res == VK_SUCCESS);

// Since we're going to blit from the mappable image, set its layout to SOURCE_OPTIMAL
Expand Down
1 change: 1 addition & 0 deletions ext/native/thin3d/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit)
}

VKContext::~VKContext() {
allocator_->Destroy();
delete allocator_;
// This also destroys all descriptor sets.
for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) {
Expand Down

0 comments on commit 6abdbde

Please sign in to comment.