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; }