diff options
author | 2016-08-10 08:29:53 -0700 | |
---|---|---|
committer | 2016-08-10 08:29:53 -0700 | |
commit | 6e90d42d3d5b8e51e60afbe97b27a0c16c2bacf1 (patch) | |
tree | b6aabd59decbe388ffa3e2afbb9186e6fc175a8c /src/gpu/vk/GrVkMemory.cpp | |
parent | 80ac591f9928f36ea1dac80f34b9ad048e92ef73 (diff) |
Check allignment of sub heap allocation in vulkan
Certain Vulkan devices will return difference alignment requirements for
a given allocation even if using the same heap. Thus we need to check
this alignment as well when deciding which subheap we want to use in our
memory allocation.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2232803003
Review-Url: https://codereview.chromium.org/2232803003
Diffstat (limited to 'src/gpu/vk/GrVkMemory.cpp')
-rw-r--r-- | src/gpu/vk/GrVkMemory.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gpu/vk/GrVkMemory.cpp b/src/gpu/vk/GrVkMemory.cpp index 19150c62a7..1dac9f3440 100644 --- a/src/gpu/vk/GrVkMemory.cpp +++ b/src/gpu/vk/GrVkMemory.cpp @@ -82,7 +82,7 @@ bool GrVkMemory::AllocAndBindBufferMemory(const GrVkGpu* gpu, } // Bind Memory to device - VkResult err = GR_VK_CALL(iface, BindBufferMemory(device, buffer, + VkResult err = GR_VK_CALL(iface, BindBufferMemory(device, buffer, alloc->fMemory, alloc->fOffset)); if (err) { SkASSERT_RELEASE(heap->free(*alloc)); @@ -429,7 +429,7 @@ void GrVkSubHeap::free(const GrVkAlloc& alloc) { INHERITED::free(alloc.fOffset, alloc.fSize); } -bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment, +bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeIndex, GrVkAlloc* alloc) { VkDeviceSize alignedSize = align_size(size, alignment); @@ -451,7 +451,7 @@ bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment, } alloc->fOffset = 0; alloc->fSize = 0; // hint that this is not a subheap allocation - + return true; } @@ -459,7 +459,8 @@ bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment, int bestFitIndex = -1; VkDeviceSize bestFitSize = 0x7FFFFFFF; for (auto i = 0; i < fSubHeaps.count(); ++i) { - if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex) { + if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex && + fSubHeaps[i]->alignment() == alignment) { VkDeviceSize heapSize = fSubHeaps[i]->largestBlockSize(); if (heapSize >= alignedSize && heapSize < bestFitSize) { bestFitIndex = i; @@ -497,7 +498,7 @@ bool GrVkHeap::subAlloc(VkDeviceSize size, VkDeviceSize alignment, return false; } -bool GrVkHeap::singleAlloc(VkDeviceSize size, VkDeviceSize alignment, +bool GrVkHeap::singleAlloc(VkDeviceSize size, VkDeviceSize alignment, uint32_t memoryTypeIndex, GrVkAlloc* alloc) { VkDeviceSize alignedSize = align_size(size, alignment); @@ -505,7 +506,9 @@ bool GrVkHeap::singleAlloc(VkDeviceSize size, VkDeviceSize alignment, int bestFitIndex = -1; VkDeviceSize bestFitSize = 0x7FFFFFFF; for (auto i = 0; i < fSubHeaps.count(); ++i) { - if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex && fSubHeaps[i]->unallocated()) { + if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex && + fSubHeaps[i]->alignment() == alignment && + fSubHeaps[i]->unallocated()) { VkDeviceSize heapSize = fSubHeaps[i]->size(); if (heapSize >= alignedSize && heapSize < bestFitSize) { bestFitIndex = i; |