| Index: src/gpu/vk/GrVkGpu.cpp
|
| diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
|
| index a3393777bb924324e5f7af7f304716c71a014a28..cd4df97e9278b4e2d49eda0e248a69a3db884776 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();
|
|
|
| // make sure the unmap has finished
|
| @@ -964,12 +966,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));
|
| @@ -985,7 +987,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;
|
| }
|
|
|
| @@ -1020,7 +1023,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)
|
| @@ -1071,7 +1074,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));
|
| @@ -1099,7 +1102,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);
|
| @@ -1108,7 +1111,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);
|
| @@ -1757,7 +1760,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());
|
| void* mappedMemory = transferBuffer->map();
|
|
|
| if (copyFromOrigin) {
|
|
|