Add heap tests for Vulkan.
Also fixes some bugs that were found.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2072453002
Review-Url: https://codereview.chromium.org/2072453002
diff --git a/src/gpu/vk/GrVkMemory.cpp b/src/gpu/vk/GrVkMemory.cpp
index 407a2c1..984e327 100644
--- a/src/gpu/vk/GrVkMemory.cpp
+++ b/src/gpu/vk/GrVkMemory.cpp
@@ -375,11 +375,11 @@
// find the block right after this allocation
FreeList::Iter iter = fFreeList.headIter();
+ FreeList::Iter prev;
while (iter.get() && iter.get()->fOffset < alloc.fOffset) {
+ prev = iter;
iter.next();
}
- FreeList::Iter prev = iter;
- prev.prev();
// we have four cases:
// we exactly follow the previous one
Block* block;
@@ -446,7 +446,7 @@
for (auto i = 0; i < fSubHeaps.count(); ++i) {
if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex) {
VkDeviceSize heapSize = fSubHeaps[i]->largestBlockSize();
- if (heapSize > alignedSize && heapSize < bestFitSize) {
+ if (heapSize >= alignedSize && heapSize < bestFitSize) {
bestFitIndex = i;
bestFitSize = heapSize;
}
@@ -484,7 +484,7 @@
for (auto i = 0; i < fSubHeaps.count(); ++i) {
if (fSubHeaps[i]->memoryTypeIndex() == memoryTypeIndex && fSubHeaps[i]->unallocated()) {
VkDeviceSize heapSize = fSubHeaps[i]->size();
- if (heapSize > alignedSize && heapSize < bestFitSize) {
+ if (heapSize >= alignedSize && heapSize < bestFitSize) {
bestFitIndex = i;
bestFitSize = heapSize;
}