Remove unused GrFlushFlags.

This also adds back default flush() calls which simply do a flush
without any submit.

Change-Id: Ia8c92bbdecd515d871abfa6364592f502e98656b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298818
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Greg Daniel 2020-06-30 13:42:46 -04:00 committed by Skia Commit-Bot
parent 511cf4fca7
commit ce9f016ed3
19 changed files with 43 additions and 99 deletions

View File

@ -6,8 +6,12 @@ This file includes a list of high level updates for each milestone release.
Milestone 86
------------
* Remove obsolete GrFlushFlags.
https://review.skia.org/298818
* Adds default flush() calls to SkSurface, SkImage, and GrContext. These calls do
a basic flush without a submit. If you haven't updated Skia in a couple release
a basic flush without a submit. If you haven't updated Skia in a couple releases
and still have flush() calls in your code that you expect to do a flush and
submit, you should update all those to the previously added flushAndSubmit() calls
instead.

View File

@ -41,9 +41,7 @@ private:
void onPerCanvasPostDraw(SkCanvas* canvas) override {
GrContext* context = canvas->getGrContext();
GrFlushInfo info;
info.fFlags = kSyncCpu_GrFlushFlag;
context->flush(info);
context->flush();
context->submit(true);
for (int i = 0; i < fBackendTextures.count(); ++i) {

View File

@ -1863,9 +1863,7 @@ Result GPUDDLSink::ddlDraw(const Src& src,
// 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);
gpuThreadCtx->flush();
gpuThreadCtx->submit(true);
});
@ -2334,9 +2332,7 @@ Result ViaDDL::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
// We need to ensure all the GPU work is finished so the promise image callback
// contexts will delete all the backend textures.
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->flush();
context->submit(true);
}
return Result::Ok();

View File

@ -112,9 +112,7 @@ static sk_sp<SkImage> do_read_and_scale_yuv(Src* src,
};
*cleanup = {[context, backendTextures] {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->flush();
context->submit(true);
context->deleteBackendTexture(backendTextures[0]);
context->deleteBackendTexture(backendTextures[1]);

View File

@ -238,9 +238,7 @@ protected:
// Some backends (e.g., Vulkan) require all work be completed for backend textures
// before they are deleted. Since we don't know when we'll next have access to a
// direct context, flush all the work now.
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->flush();
context->submit(true);
return DrawResult::kOk;

View File

@ -1365,9 +1365,7 @@ protected:
// Some backends (e.g., Vulkan) require all work be completed for backend textures
// before they are deleted. Since we don't know when we'll next have access to a
// direct context, flush all the work now.
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->flush();
context->submit(true);
}
@ -1594,9 +1592,7 @@ protected:
// Some backends (e.g., Vulkan) require all work be completed for backend textures before
// they are deleted. Since we don't know when we'll next have access to a direct context,
// flush all the work now.
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->flush();
context->submit(true);
return true;

View File

@ -225,12 +225,6 @@ enum GrGLBackendState {
*/
static const uint32_t kAll_GrBackendState = 0xffffffff;
enum GrFlushFlags {
kNone_GrFlushFlags = 0,
// Deprecated: Use syncCpu call on submit instead.
kSyncCpu_GrFlushFlag = 0x1,
};
typedef void* GrGpuFinishedContext;
typedef void (*GrGpuFinishedProc)(GrGpuFinishedContext finishedContext);
@ -273,7 +267,6 @@ typedef void (*GrGpuSubmittedProc)(GrGpuSubmittedContext submittedContext, bool
* backend APIs the same in terms of how the submitted procs are treated.
*/
struct GrFlushInfo {
GrFlushFlags fFlags = kNone_GrFlushFlags;
int fNumSemaphores = 0;
GrBackendSemaphore* fSignalSemaphores = nullptr;
GrGpuFinishedProc fFinishedProc = nullptr;

View File

@ -200,8 +200,8 @@ bool GrDrawingManager::flush(
SkDEBUGCODE(this->validate());
if (kNone_GrFlushFlags == info.fFlags && !info.fNumSemaphores && !info.fFinishedProc &&
access == SkSurface::BackendSurfaceAccess::kNoAccess && !newState) {
if (!info.fNumSemaphores && !info.fFinishedProc &&
access == SkSurface::BackendSurfaceAccess::kNoAccess && !newState) {
bool canSkip = numProxies > 0;
for (int i = 0; i < numProxies && canSkip; ++i) {
canSkip = !fDAG.isUsed(proxies[i]) && !this->isDDLTarget(proxies[i]);

View File

@ -753,10 +753,8 @@ sk_sp<SkImage> SkImage::MakeFromAHardwareBufferWithData(GrContext* context,
std::move(cs));
surfaceContext.writePixels(srcInfo, pixmap.addr(0, 0), pixmap.rowBytes(), {0, 0});
GrFlushInfo info;
info.fFlags = kSyncCpu_GrFlushFlag;
GrSurfaceProxy* p[1] = {surfaceContext.asSurfaceProxy()};
drawingManager->flush(p, 1, SkSurface::BackendSurfaceAccess::kNoAccess, info, nullptr);
drawingManager->flush(p, 1, SkSurface::BackendSurfaceAccess::kNoAccess, {}, nullptr);
return image;
}

View File

@ -1089,9 +1089,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
GrBackendApi::kMetal == context->backend()) {
// In order to receive the done callback with Vulkan we need to perform the equivalent
// of a glFinish
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
s->flush(SkSurface::BackendSurfaceAccess::kPresent, flushInfoSyncCpu);
s->flush();
context->submit(true);
}

View File

@ -126,9 +126,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLTextureParameters, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, invalidTexture));
wrappedImage.reset();
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->flush();
context->submit(true);
context->deleteBackendTexture(backendTex);
}

View File

@ -47,9 +47,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
canvas->clear(SK_ColorGREEN);
auto image = surface->makeImageSnapshot();
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
ctx->flush(flushInfoSyncCpu);
ctx->flush();
ctx->submit(true);
int count = 0;
@ -58,7 +56,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
flushInfoFinishedProc.fFinishedProc = testing_finished_proc;
flushInfoFinishedProc.fFinishedContext = (void*)&count;
// There is no work on the surface so flushing may immediately call the finished proc.
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
surface->flush(flushInfoFinishedProc);
ctx->submit();
REPORTER_ASSERT(reporter, count == 0 || count == 1);
// Busy waiting should detect that the work is done.
@ -66,7 +64,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
canvas->clear(SK_ColorRED);
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
surface->flush(flushInfoFinishedProc);
ctx->submit();
bool expectAsyncCallback =
@ -82,7 +80,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
} else {
REPORTER_ASSERT(reporter, count == 2);
}
ctx->flush(flushInfoSyncCpu);
ctx->flush();
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 2);
@ -97,7 +95,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
} else {
REPORTER_ASSERT(reporter, count == 3);
}
ctx->flush(flushInfoSyncCpu);
ctx->flush();
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 3);
@ -112,7 +110,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
} else {
REPORTER_ASSERT(reporter, count == 4);
}
ctx->flush(flushInfoSyncCpu);
ctx->flush();
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 4);
@ -125,7 +123,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
count = 0;
int count2 = 0;
canvas->clear(SK_ColorGREEN);
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
surface->flush(flushInfoFinishedProc);
ctx->submit();
// There is no work to be flushed here so this will return immediately, but make sure the
// finished call from this proc isn't called till the previous surface flush also is finished.
@ -134,7 +132,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
ctx->submit();
REPORTER_ASSERT(reporter, count <= 1 && count2 <= count);
ctx->flush(flushInfoSyncCpu);
ctx->flush();
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 1);

View File

@ -1393,15 +1393,13 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, numSubmits() == 3);
// Syncing forces the flush to happen even if the images aren't used.
GrFlushInfo syncInfo;
syncInfo.fFlags = kSyncCpu_GrFlushFlag;
i0->flush(c, syncInfo);
i0->flush(c);
c->submit(true);
REPORTER_ASSERT(reporter, numSubmits() == 1);
i1->flush(c, syncInfo);
i1->flush(c);
c->submit(true);
REPORTER_ASSERT(reporter, numSubmits() == 1);
i2->flush(c, syncInfo);
i2->flush(c);
c->submit(true);
REPORTER_ASSERT(reporter, numSubmits() == 1);

View File

@ -975,9 +975,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWrappedWithRelease_Gpu, reporter, ctxI
}
surface->getCanvas()->clear(SK_ColorRED);
GrFlushInfo info;
info.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, info);
surface->flush();
ctx->submit(true);
// Now exercise the release proc

View File

@ -142,9 +142,7 @@ bool CreateBackendTexture(GrContext* context,
}
void DeleteBackendTexture(GrContext* context, const GrBackendTexture& backendTex) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->flush();
context->submit(true);
context->deleteBackendTexture(backendTex);
}

View File

@ -357,9 +357,7 @@ bool EGLTestHelper::importAndWaitOnSemaphore(skiatest::Reporter* reporter, int f
}
void EGLTestHelper::doClientSync() {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
this->grContext()->flush(flushInfo);
this->grContext()->flush();
this->grContext()->submit(true);
}
#endif // SK_GL

View File

@ -179,9 +179,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangle, reporter, options) {
paint.setColor(SK_ColorBLACK);
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -203,9 +201,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithAntiAlias, reporter, options) {
paint.setAntiAlias(true);
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -227,9 +223,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithBlendMode, reporter, options) {
paint.setBlendMode(SkBlendMode::kColorDodge);
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -253,9 +247,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithFilter, reporter, options) {
SkBlurStyle::kOuter_SkBlurStyle, 1.1f));
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -279,9 +271,7 @@ DEF_GPUTEST(VkProtectedContext_DrawThinPath, reporter, options) {
paint.setStrokeWidth(.4f);
canvas->drawPath(SkPath().moveTo(4, 4).lineTo(6, 6), paint);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -304,9 +294,7 @@ DEF_GPUTEST(VkProtectedContext_SaveLayer, reporter, options) {
canvas->drawRect(SkRect::MakeWH(4, 4), paint);
canvas->restore();
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
@ -334,13 +322,11 @@ DEF_GPUTEST(VkProtectedContext_DrawProtectedImageOnProtectedSurface, reporter, o
canvas->drawImage(image, 0, 0);
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface1->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface1->flush();
surface1->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface1->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
surface2->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface2->flush();
surface2->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface2->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));

View File

@ -91,13 +91,10 @@ void YUVABackendReleaseContext::Unwind(GrContext* context, YUVABackendReleaseCon
// Some backends (e.g., Vulkan) require that all work associated w/ texture
// creation be completed before deleting the textures.
if (fullFlush) {
// If the release context client performed some operations other than backend texture
// creation then we may require a full flush to ensure that all the work is completed.
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->flush();
context->submit(true);
} else {
context->submit();

View File

@ -324,9 +324,7 @@ static void run_ddl_benchmark(sk_gpu_test::TestContext* testContext, GrContext *
// Make sure the gpu has finished all its work before we exit this function and delete the
// fence.
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->flush();
context->submit(true);
promiseImageHelper.deleteAllFromGPU(nullptr, context);
@ -364,9 +362,7 @@ static void run_benchmark(GrContext* context, SkSurface* surface, SkpProducer* s
// Make sure the gpu has finished all its work before we exit this function and delete the
// fence.
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
context->submit(true);
}
@ -434,9 +430,7 @@ static void run_gpu_time_benchmark(sk_gpu_test::GpuTimer* gpuTimer, GrContext* c
// Make sure the gpu has finished all its work before we exit this function and delete the
// fence.
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->flush();
context->submit(true);
}