Make sure we invalidate mapped memory from vk transfer buffers before reading.

When doing asyncRead we were not calling invalidatemappedMemory after calling
map on the transfer buffer. This is an issue if we happen to be using
non-coherent memory to back the buffer. Our normal read pixels call was manually
calling invalidate so that was working fine.

Bug: skia:9867
Change-Id: I765d12f75c914db0dba008433836463898a9712c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/268681
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-02-04 15:44:49 -05:00 committed by Skia Commit-Bot
parent 14d64afaa8
commit 3b23de5878
2 changed files with 8 additions and 3 deletions

View File

@ -2561,8 +2561,6 @@ bool GrVkGpu::onReadPixels(GrSurface* surface, int left, int top, int width, int
return false;
}
void* mappedMemory = transferBuffer->map();
const GrVkAlloc& transAlloc = transferBuffer->alloc();
GrVkMemory::InvalidateMappedAlloc(this, transAlloc, 0, transAlloc.fSize);
if (copyFromOrigin) {
uint32_t skipRows = region.imageExtent.height - height;

View File

@ -28,7 +28,14 @@ private:
void setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,
const SkString& dumpName) const override;
void onMap() override { this->GrGpuBuffer::fMapPtr = this->vkMap(this->getVkGpu()); }
void onMap() override {
this->GrGpuBuffer::fMapPtr = this->vkMap(this->getVkGpu());
if (this->GrGpuBuffer::fMapPtr &&
this->intendedType() == GrGpuBufferType::kXferGpuToCpu) {
const GrVkAlloc& alloc = this->alloc();
GrVkMemory::InvalidateMappedAlloc(this->getVkGpu(), alloc, 0, alloc.fSize);
}
}
void onUnmap() override { this->vkUnmap(this->getVkGpu()); }