Index: src/gpu/vk/GrVkBuffer.cpp |
diff --git a/src/gpu/vk/GrVkBuffer.cpp b/src/gpu/vk/GrVkBuffer.cpp |
index 049fe414f3b6c3e0814a33b9ca0fc73372b1ab74..0228cd8b2b896580ba6ba3e16bb659afa0d46423 100644 |
--- a/src/gpu/vk/GrVkBuffer.cpp |
+++ b/src/gpu/vk/GrVkBuffer.cpp |
@@ -125,6 +125,9 @@ void* GrVkBuffer::vkMap(const GrVkGpu* gpu) { |
VALIDATE(); |
SkASSERT(!this->vkIsMapped()); |
+ // we should be the only owner |
+ SkASSERT(fResource->unique()); |
+ |
VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, VK_WHOLE_SIZE, 0, &fMapPtr)); |
if (err) { |
fMapPtr = nullptr; |
@@ -155,6 +158,12 @@ bool GrVkBuffer::vkUpdateData(const GrVkGpu* gpu, const void* src, size_t srcSiz |
return false; |
} |
+ if (!fResource->unique()) { |
+ // in use by the command buffer, so we need to create a new one |
+ fResource->unref(gpu); |
+ fResource = Create(gpu, fDesc); |
+ } |
+ |
void* mapPtr; |
VkResult err = VK_CALL(gpu, MapMemory(gpu->device(), alloc(), 0, srcSizeInBytes, 0, &mapPtr)); |