Index: src/gpu/vk/GrVkGpu.cpp |
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp |
index 82e7394330459fa6ccd78c4db6cac7ad63503682..bf1bb26a4253ba2a45a911e255b20979ae86cacf 100644 |
--- a/src/gpu/vk/GrVkGpu.cpp |
+++ b/src/gpu/vk/GrVkGpu.cpp |
@@ -487,6 +487,7 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, |
} |
} |
+ GrVkMemory::FlushMappedAlloc(this, alloc); |
GR_VK_CALL(interface, UnmapMemory(fDevice, alloc.fMemory)); |
return true; |
@@ -599,6 +600,7 @@ bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, |
currentHeight = SkTMax(1, currentHeight/2); |
} |
+ // no need to flush non-coherent memory, unmap will do that for us |
transferBuffer->unmap(); |
// Change layout of our target so it can be copied to |
@@ -956,12 +958,12 @@ GrStencilAttachment* GrVkGpu::createStencilAttachmentForRenderTarget(const GrRen |
//////////////////////////////////////////////////////////////////////////////// |
-bool copy_testing_data(GrVkGpu* gpu, void* srcData, GrVkAlloc* alloc, |
+bool copy_testing_data(GrVkGpu* gpu, void* srcData, const GrVkAlloc& alloc, |
size_t srcRowBytes, size_t dstRowBytes, int h) { |
void* mapPtr; |
VkResult err = GR_VK_CALL(gpu->vkInterface(), MapMemory(gpu->device(), |
- alloc->fMemory, |
- alloc->fOffset, |
+ alloc.fMemory, |
+ alloc.fOffset, |
dstRowBytes * h, |
0, |
&mapPtr)); |
@@ -977,7 +979,8 @@ bool copy_testing_data(GrVkGpu* gpu, void* srcData, GrVkAlloc* alloc, |
SkRectMemcpy(mapPtr, static_cast<size_t>(dstRowBytes), srcData, srcRowBytes, |
srcRowBytes, h); |
} |
- GR_VK_CALL(gpu->vkInterface(), UnmapMemory(gpu->device(), alloc->fMemory)); |
+ GrVkMemory::FlushMappedAlloc(gpu, alloc); |
+ GR_VK_CALL(gpu->vkInterface(), UnmapMemory(gpu->device(), alloc.fMemory)); |
return true; |
} |
@@ -1012,7 +1015,7 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i |
} |
VkImage image = VK_NULL_HANDLE; |
- GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0 }; |
+ GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0, 0 }; |
VkImageTiling imageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL; |
VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageTiling) |
@@ -1063,7 +1066,7 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i |
VK_CALL(GetImageSubresourceLayout(fDevice, image, &subres, &layout)); |
- if (!copy_testing_data(this, srcData, &alloc, rowCopyBytes, |
+ if (!copy_testing_data(this, srcData, alloc, rowCopyBytes, |
static_cast<size_t>(layout.rowPitch), h)) { |
GrVkMemory::FreeImageMemory(this, linearTiling, alloc); |
VK_CALL(DestroyImage(fDevice, image, nullptr)); |
@@ -1091,7 +1094,7 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i |
return 0; |
} |
- GrVkAlloc bufferAlloc = { VK_NULL_HANDLE, 0, 0 }; |
+ GrVkAlloc bufferAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; |
if (!GrVkMemory::AllocAndBindBufferMemory(this, buffer, GrVkBuffer::kCopyRead_Type, |
true, &bufferAlloc)) { |
GrVkMemory::FreeImageMemory(this, linearTiling, alloc); |
@@ -1100,7 +1103,7 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i |
return 0; |
} |
- if (!copy_testing_data(this, srcData, &bufferAlloc, rowCopyBytes, rowCopyBytes, h)) { |
+ if (!copy_testing_data(this, srcData, bufferAlloc, rowCopyBytes, rowCopyBytes, h)) { |
GrVkMemory::FreeImageMemory(this, linearTiling, alloc); |
VK_CALL(DestroyImage(fDevice, image, nullptr)); |
GrVkMemory::FreeBufferMemory(this, GrVkBuffer::kCopyRead_Type, bufferAlloc); |
@@ -1749,7 +1752,7 @@ bool GrVkGpu::onReadPixels(GrSurface* surface, |
// We need to submit the current command buffer to the Queue and make sure it finishes before |
// we can copy the data out of the buffer. |
this->submitCommandBuffer(kForce_SyncQueue); |
- |
+ GrVkMemory::InvalidateMappedAlloc(this, transferBuffer->alloc()); |
egdaniel
2016/09/20 15:23:22
Is this a call we can put into map similar to Flus
jvanverth1
2016/09/20 15:30:54
I left it outside because we often map to write, a
|
void* mappedMemory = transferBuffer->map(); |
if (copyFromOrigin) { |