From 4e3ceb96b8a135143c137ed666bb22737ed85422 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Thu, 16 Apr 2020 15:42:50 -0400 Subject: [PATCH] Fix up GPUDDLSink for Vulkan Change-Id: If38afff3d07f51fd0f5a989c2f59e3c788086f8b Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284099 Reviewed-by: Greg Daniel Commit-Queue: Robert Phillips --- dm/DMSrcSink.cpp | 12 +++++++++++- tools/DDLPromiseImageHelper.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 58e53a1f27..73199c4718 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -1671,7 +1671,17 @@ Result GPUDDLSink::ddlDraw(const Src& src, recordingTaskGroup->wait(); // This should be the only explicit flush for the entire DDL draw - gpuTaskGroup->add([gpuThreadCtx]() { gpuThreadCtx->flush(); }); + gpuTaskGroup->add([gpuThreadCtx]() { + // We need to ensure all the GPU work is finished so + // the following 'deleteAllFromGPU' call will work + // on Vulkan. + // TODO: switch over to using the promiseImage callbacks + // to free the backendTextures. This is complicated a + // bit by which thread possesses the direct context. + GrFlushInfo flushInfoSyncCpu; + flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag; + gpuThreadCtx->flush(flushInfoSyncCpu); + }); // The backend textures are created on the gpuThread by the 'uploadAllToGPU' call. // It is simpler to also delete them at this point on the gpuThread. diff --git a/tools/DDLPromiseImageHelper.h b/tools/DDLPromiseImageHelper.h index cc08abe0f2..c0509c0b65 100644 --- a/tools/DDLPromiseImageHelper.h +++ b/tools/DDLPromiseImageHelper.h @@ -88,6 +88,10 @@ private: void destroyBackendTexture() { SkASSERT(!fPromiseImageTexture || fPromiseImageTexture->unique()); + + if (fPromiseImageTexture) { + fContext->deleteBackendTexture(fPromiseImageTexture->backendTexture()); + } fPromiseImageTexture = nullptr; }