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

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: Fix tests 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
« no previous file with comments | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkBuffer.cpp
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp
index 6fbdaac8673afdab207c44f91e00138e49a538b2..12925db008d06f10b7e72df0e957164a199a40f6 100644
--- a/src/gpu/vk/GrVkBuffer.cpp
+++ b/src/gpu/vk/GrVkBuffer.cpp
@@ -20,7 +20,7 @@
const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& desc) {
VkBuffer buffer;
- VkDeviceMemory alloc;
+ GrVkAlloc alloc;
// create the buffer object
VkBufferCreateInfo bufInfo;
@@ -79,7 +79,7 @@ const GrVkBuffer::Resource* GrVkBuffer::Create(const GrVkGpu* gpu, const Desc& d
const GrVkBuffer::Resource* resource = new GrVkBuffer::Resource(buffer, alloc);
if (!resource) {
VK_CALL(gpu, DestroyBuffer(gpu->device(), buffer, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), alloc, nullptr));
+ GrVkMemory::FreeBufferMemory(gpu, alloc);
return nullptr;
}
@@ -111,9 +111,9 @@ void GrVkBuffer::addMemoryBarrier(const GrVkGpu* gpu,
void GrVkBuffer::Resource::freeGPUData(const GrVkGpu* gpu) const {
SkASSERT(fBuffer);
- SkASSERT(fAlloc);
+ SkASSERT(fAlloc.fMemory);
VK_CALL(gpu, DestroyBuffer(gpu->device(), fBuffer, nullptr));
- VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
+ GrVkMemory::FreeBufferMemory(gpu, fAlloc);
}
void GrVkBuffer::vkRelease(const GrVkGpu* gpu) {
@@ -141,7 +141,9 @@ void* GrVkBuffer::vkMap(const GrVkGpu* gpu) {
fResource = Create(gpu, fDesc);
}
- VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SIZE, 0, &fMapPtr));
+ const GrVkAlloc& alloc = this->alloc();
+ VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
+ VK_WHOLE_SIZE, 0, &fMapPtr));
egdaniel 2016/06/01 16:02:46 Does whole size here just mean from offset to end?
if (err) {
fMapPtr = nullptr;
}
@@ -154,7 +156,7 @@ void GrVkBuffer::vkUnmap(const GrVkGpu* gpu) {
VALIDATE();
SkASSERT(this->vkIsMapped());
- VK_CALL(gpu, UnmapMemory(gpu->device(), alloc()));
+ VK_CALL(gpu, UnmapMemory(gpu->device(), this->alloc().fMemory));
fMapPtr = nullptr;
}
@@ -182,7 +184,9 @@ bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz
}
void* mapPtr;
- VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBytes, 0, &mapPtr));
+ const GrVkAlloc& alloc = this->alloc();
+ VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc.fMemory, alloc.fOffset,
+ srcSizeInBytes, 0, &mapPtr));
if (VK_SUCCESS != err) {
return false;
@@ -190,7 +194,7 @@ bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz
memcpy(mapPtr, src, srcSizeInBytes);
- VK_CALL(gpu, UnmapMemory(gpu->device(), alloc()));
+ VK_CALL(gpu, UnmapMemory(gpu->device(), alloc.fMemory));
return true;
}
« no previous file with comments | « src/gpu/vk/GrVkBuffer.h ('k') | src/gpu/vk/GrVkGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698