aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkGpu.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2016-09-20 09:20:03 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-20 09:20:03 -0700
commit9d54afc38b171c01a03b34e773d154fcf83d97dc (patch)
treec618bac30c9ced452300c5835993fad6bb41fb36 /src/gpu/vk/GrVkGpu.cpp
parenta624bf3d1cb454c1959c5bbbf23a3afdfa3481f3 (diff)
Support use of non-coherent memory allocations in Vulkan.
Diffstat (limited to 'src/gpu/vk/GrVkGpu.cpp')
-rw-r--r--src/gpu/vk/GrVkGpu.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 4d410a7b3a..a892e1b71c 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -494,6 +494,7 @@ bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex,
}
}
+ GrVkMemory::FlushMappedAlloc(this, alloc);
GR_VK_CALL(interface, UnmapMemory(fDevice, alloc.fMemory));
return true;
@@ -606,6 +607,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
@@ -963,12 +965,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));
@@ -984,7 +986,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;
}
@@ -1019,7 +1022,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)
@@ -1070,7 +1073,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));
@@ -1098,7 +1101,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);
@@ -1107,7 +1110,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);
@@ -1756,7 +1759,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) {