Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(772)

Unified Diff: src/gpu/vk/GrVkMemory.cpp

Issue 2232803003: Check allignment of sub heap allocation in vulkan (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkMemory.cpp
diff --git a/src/gpu/vk/GrVkMemory.cpp b/src/gpu/vk/GrVkMemory.cpp
index 19150c62a735feb51a2a86138a9616a7a38d534b..1dac9f344094299ca20a288530a7c26e49a8d5f2 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698