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

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

Issue 2018933004: Add offset to memory allocations (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Take care of some additional FreeMemorys Created 4 years, 7 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
Index: src/gpu/vk/GrVkBuffer.cpp
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp
index 6fbdaac8673afdab207c44f91e00138e49a538b2..75e0a6a645fb49eb099668cba26ef752409fa219 100644
--- a/src/gpu/vk/GrVkBuffer.cpp
+++ b/src/gpu/vk/GrVkBuffer.cpp
@@ -21,6 +21,7 @@
const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& desc) {
VkBuffer buffer;
VkDeviceMemory alloc;
+ VkDeviceSize offset;
// create the buffer object
VkBufferCreateInfo bufInfo;
@@ -63,23 +64,25 @@ const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& d
if (!GrVkMemory::AllocAndBindBufferMemory(gpu,
buffer,
requiredMemProps,
- &alloc)) {
+ &alloc,
+ &offset)) {
// Try again without requiring host cached memory
requiredMemProps = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
if (!GrVkMemory::AllocAndBindBufferMemory(gpu,
buffer,
requiredMemProps,
- &alloc)) {
+ &alloc,
+ &offset)) {
VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr));
return nullptr;
}
}
- const GrVkBuffer::Resource* resource = new GrVkBuffer::Resource(buffer, alloc);
+ const GrVkBuffer::Resource* resource = new GrVkBuffer::Resource(buffer, alloc, offset);
if (!resource) {
VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), alloc, nullptr));
+ GrVkMemory::FreeBufferMemory(gpu, alloc, offset);
return nullptr;
}
@@ -113,7 +116,7 @@ void GrVkBuffer::Resource::freeGPUData(const GrVkGpu* gpu) const {
SkASSERT(fBuffer);
SkASSERT(fAlloc);
VK_CALL(gpu, DestroyBuffer(gpu->device(), fBuffer, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
+ GrVkMemory::FreeBufferMemory(gpu, fAlloc, fOffset);
}
void GrVkBuffer::vkRelease(const GrVkGpu* gpu) {

Powered by Google App Engine
This is Rietveld 408576698