Update internal skia uses to use flushAndSubmit and submit calls.

Bug: skia:10118
Change-Id: Ieb7c0eece56d3d9df56ecb52e00e76c01f038de8
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/289888
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-05-14 15:45:44 -04:00 committed by Skia Commit-Bot
parent e5865f6f10
commit 0a2464f51f
58 changed files with 189 additions and 139 deletions

View File

@ -44,6 +44,7 @@ private:
GrFlushInfo info;
info.fFlags = kSyncCpu_GrFlushFlag;
context->flush(info);
context->submit(true);
for (int i = 0; i < fBackendTextures.count(); ++i) {
if (fBackendTextures[i].isValid()) {

View File

@ -46,12 +46,12 @@ void set_cache_budget(SkCanvas* canvas, int approxImagesInBudget) {
// to render an SkImage and add one additional resource for each image we'd like to fit.
GrContext* context = canvas->getGrContext();
SkASSERT(context);
context->flush();
context->flushAndSubmit();
context->priv().testingOnly_purgeAllUnlockedResources();
sk_sp<SkImage> image;
make_images(&image, 1);
draw_image(canvas, image.get());
context->flush();
context->flushAndSubmit();
int baselineCount;
context->getResourceCacheUsage(&baselineCount, nullptr);
baselineCount -= 1; // for the image's textures.

View File

@ -74,7 +74,7 @@ protected:
}
// Prevent any batching between "frames".
if (auto surf = canvas->getSurface()) {
surf->flush();
surf->flushAndSubmit();
}
}
}

View File

@ -118,7 +118,7 @@ void SKPBench::onDraw(int loops, SkCanvas* canvas) {
}
// Ensure the GrContext doesn't combine ops across draw loops.
if (GrContext* context = canvas->getGrContext()) {
context->flush();
context->flushAndSubmit();
}
}
}
@ -160,7 +160,7 @@ void SKPBench::getGpuStats(SkCanvas* canvas, SkTArray<SkString>* keys, SkTArray<
}
// TODO refactor this out if we want to test other subclasses of skpbench
context->flush();
context->flushAndSubmit();
context->freeGpuResources();
context->resetContext();
context->priv().getGpu()->resetShaderCacheForTesting();

View File

@ -333,7 +333,7 @@ public:
rtc->priv().testingOnly_addDrawOp(std::move(op));
}
context->flush();
context->flushAndSubmit();
}
}

View File

@ -67,7 +67,7 @@ void RunWithGPUTestContexts(GrContextTestFn* test, GrContextTypeFilterFn* contex
// In case the test changed the current context make sure we move it back before
// calling flush.
ctxInfo.testContext()->makeCurrent();
ctxInfo.grContext()->flush();
ctxInfo.grContext()->flushAndSubmit();
}
}
}

View File

@ -1467,7 +1467,7 @@ Result GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
if (!result.isOk()) {
return result;
}
surface->flush();
surface->flushAndSubmit();
if (FLAGS_gpuStats) {
canvas->getGrContext()->priv().dumpCacheStats(log);
canvas->getGrContext()->priv().dumpGpuStats(log);
@ -1708,6 +1708,7 @@ Result GPUDDLSink::ddlDraw(const Src& src,
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
gpuThreadCtx->flush(flushInfoSyncCpu);
gpuThreadCtx->submit(true);
});
// The backend textures are created on the gpuThread by the 'uploadAllToGPU' call.
@ -2178,6 +2179,7 @@ Result ViaDDL::draw(const Src& src, SkBitmap* bitmap, SkWStream* stream, SkStrin
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfoSyncCpu);
context->submit(true);
}
return Result::Ok();
};

View File

@ -99,6 +99,7 @@ static sk_sp<SkImage> do_read_and_scale_yuv(SkSurface* surface, SkYUVColorSpace
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
gr->flush(flushInfo);
gr->submit(true);
gr->deleteBackendTexture(backendTextures[0]);
gr->deleteBackendTexture(backendTextures[1]);
gr->deleteBackendTexture(backendTextures[2]);

View File

@ -86,7 +86,7 @@ class FontRegenGM : public skiagm::GpuGM {
paint.setColor(SK_ColorBLACK);
canvas->drawTextBlob(fBlobs[0], 10, 80, paint);
canvas->drawTextBlob(fBlobs[1], 10, 225, paint);
context->flush();
context->flushAndSubmit();
paint.setColor(0xFF010101);
canvas->drawTextBlob(fBlobs[0], 10, 305, paint);
@ -142,7 +142,7 @@ class BadAppleGM : public skiagm::GpuGM {
paint.setColor(0xFF111111);
canvas->drawTextBlob(fBlobs[0], 10, 260, paint);
canvas->drawTextBlob(fBlobs[1], 10, 500, paint);
context->flush();
context->flushAndSubmit();
}
private:

View File

@ -141,6 +141,7 @@ protected:
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->submit(true);
for (int i = 0; i < n; ++i) {
context->deleteBackendTexture(textures[i]);

View File

@ -162,7 +162,7 @@ DEF_SIMPLE_GM(recordopts, canvas, (kTestRectSize+1)*2, (kTestRectSize+1)*15) {
TestVariantSequence drawTestSequence = funcs[k];
drawTestSequence(canvas, shapeColor, no_detector_install);
if (context) {
context->flush();
context->flushAndSubmit();
}
canvas->translate(SkIntToScalar(kTestRectSize) + SkIntToScalar(1), SkIntToScalar(0));
{
@ -172,7 +172,7 @@ DEF_SIMPLE_GM(recordopts, canvas, (kTestRectSize+1)*2, (kTestRectSize+1)*15) {
shapeColor, no_detector_install);
recorder.finishRecordingAsPicture()->playback(canvas);
if (context) {
context->flush();
context->flushAndSubmit();
}
}
canvas->restore();
@ -207,7 +207,7 @@ DEF_SIMPLE_GM(recordopts, canvas, (kTestRectSize+1)*2, (kTestRectSize+1)*15) {
canvas->save();
drawTestSequence(canvas, shapeColor, detectorInstallFunc);
if (context) {
context->flush();
context->flushAndSubmit();
}
canvas->translate(SkIntToScalar(kTestRectSize) + SkIntToScalar(1), SkIntToScalar(0));
{
@ -217,7 +217,7 @@ DEF_SIMPLE_GM(recordopts, canvas, (kTestRectSize+1)*2, (kTestRectSize+1)*15) {
shapeColor, detectorInstallFunc);
recorder.finishRecordingAsPicture()->playback(canvas);
if (context) {
context->flush();
context->flushAndSubmit();
}
}

View File

@ -1208,7 +1208,7 @@ protected:
SkRect::MakeWH(shrunkPlaneSize.width(), shrunkPlaneSize.height()),
&paint);
s->flush();
s->flushAndSubmit();
}
SkISize shrunkImageSize = { imageSize.width() / 2, imageSize.height() / 2 };
@ -1398,7 +1398,7 @@ protected:
}
if (auto context = canvas->getGrContext()) {
if (!context->abandoned()) {
context->flush();
context->flushAndSubmit();
GrGpu* gpu = context->priv().getGpu();
SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync();
@ -1547,7 +1547,7 @@ protected:
}
}
context->flush();
context->flushAndSubmit();
GrGpu* gpu = context->priv().getGpu();
SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync();

View File

@ -841,8 +841,13 @@ public:
*/
GrSemaphoresSubmitted flush(GrContext* context, const GrFlushInfo& flushInfo);
/** Version of flush() that uses a default GrFlushInfo. */
void flush(GrContext*);
/** Version of flush() that uses a default GrFlushInfo. Also submits the flushed work to the
GPU.
*/
void flushAndSubmit(GrContext*);
/** Deprecated. */
void flush(GrContext* context) { this->flushAndSubmit(context); }
/** Retrieves the back-end texture. If SkImage has no back-end texture, an invalid
object is returned. Call GrBackendTexture::isValid to determine if the result

View File

@ -51,7 +51,7 @@ void Sample::draw(SkCanvas* canvas) {
#if SK_SUPPORT_GPU
// Ensure the GrContext doesn't combine GrDrawOps across draw loops.
if (GrContext* context = canvas->getGrContext()) {
context->flush();
context->flushAndSubmit();
}
#endif

View File

@ -182,7 +182,7 @@ void GrContextPriv::testingOnly_purgeAllUnlockedResources() {
}
void GrContextPriv::testingOnly_flushAndRemoveOnFlushCallbackObject(GrOnFlushCallbackObject* cb) {
fContext->flush();
fContext->flushAndSubmit();
fContext->drawingManager()->testingOnly_removeOnFlushCallbackObject(cb);
}
#endif

View File

@ -48,7 +48,7 @@ public:
// this if-test protects against the case where the context is being destroyed
// before having been fully created
if (this->priv().getGpu()) {
this->flush();
this->flushAndSubmit();
}
delete fAtlasManager;
@ -65,7 +65,7 @@ public:
}
void freeGpuResources() override {
this->flush();
this->flushAndSubmit();
fAtlasManager->freeAll();
INHERITED::freeGpuResources();

View File

@ -63,7 +63,7 @@ static void textblobcache_overbudget_CB(void* data) {
// GrRenderTargetContext to perform a necessary flush. The solution is to move drawText calls
// to below the GrContext level, but this is not trivial because they call drawPath on
// SkGpuDevice.
direct->flush();
direct->flushAndSubmit();
}
bool GrRecordingContext::init(sk_sp<const GrCaps> caps) {

View File

@ -160,7 +160,7 @@ GrSemaphoresSubmitted SkImage::flush(GrContext* context, const GrFlushInfo& flus
return as_IB(this)->onFlush(context, flushInfo);
}
void SkImage::flush(GrContext* context) { as_IB(this)->onFlush(context, {}); }
void SkImage::flushAndSubmit(GrContext* context) { this->flush(context, {}); }
#else
@ -182,7 +182,7 @@ GrSemaphoresSubmitted SkImage::flush(GrContext*, const GrFlushInfo&) {
return GrSemaphoresSubmitted::kNo;
}
void SkImage::flush(GrContext*) {}
void SkImage::flushAndSubmit(GrContext*) {}
#endif

View File

@ -1658,7 +1658,7 @@ void SkPDFDevice::internalDrawImageRect(SkKeyedImage imageSubset,
canvas->setMatrix(offsetMatrix);
canvas->drawImage(imageSubset.image(), 0, 0);
// Make sure the final bits are in the bitmap.
surface->flush();
surface->flushAndSubmit();
// In the new space, we use the identity matrix translated
// and scaled to reflect DPI.

View File

@ -126,7 +126,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
SkCanvas* dstCanvas = dst->getCanvas();
dstCanvas->clear(SK_ColorRED);
dst->flush();
dst->flushAndSubmit();
SkPaint gammaPaint;
gammaPaint.setBlendMode(SkBlendMode::kSrc);
@ -134,7 +134,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ApplyGamma, reporter, ctxInfo) {
: SkColorFilters::SRGBToLinearGamma());
dstCanvas->drawBitmap(bm, 0, 0, &gammaPaint);
dst->flush();
dst->flushAndSubmit();
sk_memset32(read.get(), 0, kBaseSize.fWidth * kBaseSize.fHeight);
if (!dst->readPixels(ii, read.get(), kRowBytes, 0, 0)) {

View File

@ -72,7 +72,7 @@ static void bulk_fill_rect_create_test(skiatest::Reporter* reporter, GrContext*
REPORTER_ASSERT(reporter, expectedNumOps == actualNumOps);
REPORTER_ASSERT(reporter, requestedTotNumQuads == actualTotNumQuads);
context->flush();
context->flushAndSubmit();
delete[] quads;
}
@ -138,7 +138,7 @@ static void bulk_texture_rect_create_test(skiatest::Reporter* reporter, GrContex
REPORTER_ASSERT(reporter, expectedNumOps == actualNumOps);
REPORTER_ASSERT(reporter, requestedTotNumQuads == actualTotNumQuads);
context->flush();
context->flushAndSubmit();
delete[] set;
}

View File

@ -1552,7 +1552,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ClipMaskCache, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, 0 == strcmp(tex->getUniqueKey().tag(), kTag));
// Make sure mask isn't pinned in cache.
mask.reset(nullptr);
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, i + 1 == cache->countUniqueKeysWithTag(kTag));
}

View File

@ -340,7 +340,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
REPORTER_ASSERT(reporter, s->draw(ddl.get()));
s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
context->flush();
context->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
s = nullptr;
params.cleanUpBackEnd(context, backend);
@ -402,7 +402,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
REPORTER_ASSERT(reporter, !s->draw(ddl.get()),
"DDLSurfaceCharacterizationTest failed on parameter: %d\n", i);
context->flush();
context->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
s = nullptr;
params.cleanUpBackEnd(context, backend);
@ -437,7 +437,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
#endif
context->flush();
context->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
s = nullptr;
params.cleanUpBackEnd(context, backend);
@ -454,7 +454,7 @@ void DDLSurfaceCharacterizationTestImpl(GrContext* context, skiatest::Reporter*
if (s) {
REPORTER_ASSERT(reporter, !s->draw(ddl.get())); // bc the DDL was made w/ textureability
context->flush();
context->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
s = nullptr;
params.cleanUpBackEnd(context, backend);
@ -739,7 +739,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLNonTextureabilityTest, reporter, ctxInfo)
REPORTER_ASSERT(reporter, s->draw(ddl.get()));
s->readPixels(imageInfo, bitmap.getPixels(), bitmap.rowBytes(), 0, 0);
context->flush();
context->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
s = nullptr;
params.cleanUpBackEnd(context, backend);
@ -985,7 +985,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLFlushWhileRecording, reporter, ctxInfo) {
SkDeferredDisplayListRecorder recorder(characterization);
SkCanvas* canvas = recorder.getCanvas();
canvas->getGrContext()->flush();
canvas->getGrContext()->flushAndSubmit();
}
////////////////////////////////////////////////////////////////////////////////
@ -1061,12 +1061,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
ddl = recorder.detach();
}
context->flush();
context->flushAndSubmit();
s->draw(ddl.get());
GrFlushInfo flushInfo;
s->flush(SkSurface::BackendSurfaceAccess::kPresent, flushInfo);
context->submit();
REPORTER_ASSERT(reporter, fulfillInfo.fFulfilled);
REPORTER_ASSERT(reporter, fulfillInfo.fReleased);
@ -1078,6 +1079,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
s->flush(SkSurface::BackendSurfaceAccess::kPresent, flushInfoSyncCpu);
context->submit(true);
}
REPORTER_ASSERT(reporter, fulfillInfo.fDone);

View File

@ -85,7 +85,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
///////////////////////////////// CONTEXT 1 ///////////////////////////////////
// Use GL Context 1 to create a texture unknown to GrContext.
context1->flush();
context1->flushAndSubmit();
static const int kSize = 100;
CreateBackendTexture(context1.get(), &backendTexture1, kSize, kSize, kRGBA_8888_SkColorType,

View File

@ -289,7 +289,7 @@ static void gpu_tests(GrContext* context, skiatest::Reporter* reporter, const Te
}
img.reset();
context->flush();
context->flushAndSubmit();
context->deleteBackendTexture(backendTex);
}
}

View File

@ -83,7 +83,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLTextureParameters, reporter, ctxInfo) {
SkImageInfo::Make(1, 1, kRGBA_8888_SkColorType, kPremul_SkAlphaType), 1, nullptr);
REPORTER_ASSERT(reporter, surf);
surf->getCanvas()->drawImage(wrappedImage, 0, 0);
surf->flush();
surf->flushAndSubmit();
auto caps = static_cast<const GrGLCaps*>(context->priv().caps());
// Now the texture should be in a known state.
@ -95,7 +95,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLTextureParameters, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, surf);
surf->getCanvas()->drawImage(wrappedImage, 0, 0);
surf->flush();
surf->flushAndSubmit();
REPORTER_ASSERT(reporter, params_valid(*parameters, caps));
// Test invalidating from the copy.
@ -129,6 +129,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GLTextureParameters, reporter, ctxInfo) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->submit(true);
context->deleteBackendTexture(backendTex);
}
#endif

View File

@ -111,7 +111,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(GrDrawCollapsedPath, reporter, ctxInfo) {
-8.94321693e-06f, -0.00173384184f, 0.998692870f);
surface->getCanvas()->setMatrix(m);
surface->getCanvas()->drawPath(path, paint);
surface->flush();
surface->flushAndSubmit();
}
DEF_GPUTEST(GrPathKeys, reporter, /* options */) {

View File

@ -121,7 +121,7 @@ public:
void flush() const {
SkASSERT(this->valid());
fCtx->flush();
fCtx->flushAndSubmit();
}
private:

View File

@ -50,6 +50,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
GrFlushInfo flushInfoSyncCpu;
flushInfoSyncCpu.fFlags = kSyncCpu_GrFlushFlag;
ctx->flush(flushInfoSyncCpu);
ctx->submit(true);
int count = 0;
@ -58,6 +59,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
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);
ctx->submit();
REPORTER_ASSERT(reporter, count == 0 || count == 1);
// Busy waiting should detect that the work is done.
busy_wait_for_callback(&count, 1, ctx, reporter);
@ -65,6 +67,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
canvas->clear(SK_ColorRED);
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfoFinishedProc);
ctx->submit();
bool expectAsyncCallback =
ctx->backend() == GrBackendApi::kVulkan ||
@ -79,11 +82,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, count == 2);
}
ctx->flush(flushInfoSyncCpu);
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 2);
// Test flushing via the SkImage
canvas->drawImage(image, 0, 0);
image->flush(ctx, flushInfoFinishedProc);
ctx->submit();
if (expectAsyncCallback) {
// On Vulkan the command buffer we just submitted may or may not have finished immediately
// so the finish proc may not have been called.
@ -92,11 +97,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, count == 3);
}
ctx->flush(flushInfoSyncCpu);
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 3);
// Test flushing via the GrContext
canvas->clear(SK_ColorBLUE);
ctx->flush(flushInfoFinishedProc);
ctx->submit();
if (expectAsyncCallback) {
// On Vulkan the command buffer we just submitted may or may not have finished immediately
// so the finish proc may not have been called.
@ -105,10 +112,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, count == 4);
}
ctx->flush(flushInfoSyncCpu);
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 4);
// There is no work on the surface so flushing may immediately call the finished proc.
ctx->flush(flushInfoFinishedProc);
ctx->submit();
REPORTER_ASSERT(reporter, count == 4 || count == 5);
busy_wait_for_callback(&count, 5, ctx, reporter);
@ -116,13 +125,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(FlushFinishedProcTest, reporter, ctxInfo) {
int count2 = 0;
canvas->clear(SK_ColorGREEN);
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, 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.
flushInfoFinishedProc.fFinishedContext = (void*)&count2;
ctx->flush(flushInfoFinishedProc);
ctx->submit();
REPORTER_ASSERT(reporter, count <= 1 && count2 <= count);
ctx->flush(flushInfoSyncCpu);
ctx->submit(true);
REPORTER_ASSERT(reporter, count == 1);
REPORTER_ASSERT(reporter, count == count2);

View File

@ -237,7 +237,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
// Must make sure the uses of the backend texture have finished (we possibly have a
// queued up copy) before we delete the backend texture.
context->flush();
context->flushAndSubmit();
context->priv().getGpu()->testingOnly_flushGpuAndSync();
@ -304,7 +304,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
// Must flush the context to make sure all the cmds (copies, etc.) from above are sent
// to the gpu before we delete the backendHandle.
context->flush();
context->flushAndSubmit();
context->priv().getGpu()->testingOnly_flushGpuAndSync();
context->deleteBackendTexture(backendTex);
}
@ -337,14 +337,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo)
SkPaint paint;
// This should upload the image to a non mipped GrTextureProxy.
surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint);
surface->flush();
surface->flushAndSubmit();
// Now set the filter quality to high so we use mip maps. We should find the non mipped texture
// in the cache for the SkImage. Since the texture is 1x1 we should just use that texture
// instead of trying to do a copy to a mipped texture.
paint.setFilterQuality(kHigh_SkFilterQuality);
surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint);
surface->flush();
surface->flushAndSubmit();
}
// Create a new render target and draw 'mipmapView' into it using the provided 'filter'.
@ -443,7 +443,7 @@ DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
SkASSERT(!mipmapProxy->mipMapsAreDirty());
// Reset everything so we can go again, this time with the first draw not mipmapped.
context->flush();
context->flushAndSubmit();
// Mip regen tasks don't get added as dependencies until makeClosed().
REPORTER_ASSERT(reporter, rtc1Task->dependsOn(initialMipmapRegenTask));
@ -486,7 +486,7 @@ DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
SkASSERT(!mipmapProxy->mipMapsAreDirty());
// Mip regen tasks don't get added as dependencies until makeClosed().
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, rtc2Task->dependsOn(mipRegenTask2));
}
}

View File

@ -65,7 +65,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrOpsTaskFlushCount, reporter, ctxInfo) {
canvas1->drawImageRect(image.get(), srcRect, dstRect, nullptr);
}
}
context->flush();
context->flushAndSubmit();
// In total we make 2000 oplists. Our current limit on max oplists between flushes is 100, so we
// should do 20 flushes while executing oplists. Additionaly we always do 1 flush at the end of

View File

@ -386,7 +386,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
auto writeResult = surfContext->writePixels(srcPixmap.info(), write.addr(), 0, {0, 0});
REPORTER_ASSERT(reporter, writeResult == (ioType == kRW_GrIOType));
// Try the low level write.
context->flush();
context->flushAndSubmit();
auto gpuWriteResult = context->priv().getGpu()->writePixels(
proxy->peekTexture(), 0, 0, kSize, kSize, GrColorType::kRGBA_8888,
GrColorType::kRGBA_8888, write.addr32(),
@ -405,7 +405,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
auto copyResult = surfContext->testCopy(copySrc.proxy());
REPORTER_ASSERT(reporter, copyResult == (ioType == kRW_GrIOType));
// Try the low level copy.
context->flush();
context->flushAndSubmit();
auto gpuCopyResult = context->priv().getGpu()->copySurface(
proxy->peekSurface(), copySrc.proxy()->peekSurface(), SkIRect::MakeWH(kSize, kSize),
{0, 0});
@ -420,7 +420,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
GrProtected::kNo);
proxy = proxyProvider->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType);
context->flush();
context->flushAndSubmit();
proxy->peekTexture()->texturePriv().markMipMapsDirty(); // avoids assert in GrGpu.
auto regenResult =
context->priv().getGpu()->regenerateMipMapLevels(proxy->peekTexture());
@ -578,7 +578,7 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
// We still have the proxy, which should remain instantiated, thereby keeping the
// texture not purgeable.
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
context->priv().getGpu()->testingOnly_flushGpuAndSync();
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
@ -590,7 +590,7 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
GrAA::kNo, GrQuadAAFlags::kNone,
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
REPORTER_ASSERT(reporter, idleIDs.find(2) == idleIDs.end());
context->flush();
context->flushAndSubmit();
context->priv().getGpu()->testingOnly_flushGpuAndSync();
// Now that the draw is fully consumed by the GPU, the texture should be idle.
REPORTER_ASSERT(reporter, idleIDs.find(2) != idleIDs.end());
@ -641,7 +641,7 @@ DEF_GPUTEST(TextureIdleProcTest, reporter, options) {
GrAA::kNo, GrQuadAAFlags::kNone,
SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), nullptr);
if (drawType == DrawType::kDrawAndFlush) {
context->flush();
context->flushAndSubmit();
}
if (unrefFirst) {
texture.reset();
@ -717,7 +717,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcFlushTest, reporter, contextInfo) {
GrContext* context = contextInfo.grContext();
// idle proc that flushes the context.
auto idleProc = [](void* context) { reinterpret_cast<GrContext*>(context)->flush(); };
auto idleProc = [](void* context) { reinterpret_cast<GrContext*>(context)->flushAndSubmit(); };
for (const auto& idleMaker : {make_wrapped_texture, make_normal_texture}) {
for (auto idleState : {GrTexture::IdleState::kFlushed, GrTexture::IdleState::kFinished}) {
@ -761,7 +761,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleProcRerefTest, reporter, contextInfo) {
// This test assumes the texture won't be cached (or else the release proc doesn't get
// called).
idleTexture->resourcePriv().removeScratchKey();
context->flush();
context->flushAndSubmit();
idleTexture->addIdleProc(idleProc, idleTexture.get(), idleState);
idleTexture->setRelease(releaseProc, &isReleased);
auto* raw = idleTexture.get();
@ -793,7 +793,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleStateTest, reporter, contextInfo) {
auto rtc = rt->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
auto proxy =
context->priv().proxyProvider()->testingOnly_createWrapped(std::move(idleTexture));
context->flush();
context->flushAndSubmit();
SkAssertResult(rtc->testCopy(proxy.get()));
proxy.reset();
REPORTER_ASSERT(reporter, flags == 0);
@ -801,7 +801,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TextureIdleStateTest, reporter, contextInfo) {
// After a flush we expect idleTexture to have reached the kFlushed state on all backends.
// On "managed" backends we expect it to reach kFinished as well. On Vulkan, the only
// current "unmanaged" backend, we *may* need a sync to reach kFinished.
context->flush();
context->flushAndSubmit();
if (contextInfo.backend() == kVulkan_GrBackend) {
REPORTER_ASSERT(reporter, flags & kFlushFlag);
} else {

View File

@ -40,7 +40,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTextureMipMapInvalidationTest, reporter, ct
auto surf2 = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
// Draw something just in case we ever had a solid color optimization
surf1->getCanvas()->drawCircle(128, 128, 50, SkPaint());
surf1->flush();
surf1->flushAndSubmit();
// No mipmaps initially
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
@ -52,13 +52,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrTextureMipMapInvalidationTest, reporter, ct
paint.setFilterQuality(kMedium_SkFilterQuality);
surf2->getCanvas()->scale(0.2f, 0.2f);
surf2->getCanvas()->drawImage(surf1->makeImageSnapshot(), 0, 0, &paint);
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
REPORTER_ASSERT(reporter, !allocateMips || !mipsAreDirty(surf1.get()));
// Changing the contents of the surface should invalidate the mipmap, but not de-allocate
surf1->getCanvas()->drawCircle(128, 128, 100, SkPaint());
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, isMipped(surf1.get()) == allocateMips);
REPORTER_ASSERT(reporter, mipsAreDirty(surf1.get()));
}

View File

@ -388,7 +388,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn
[otherContextInfo] {
auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo.grContext());
otherContextInfo.grContext()->flush();
otherContextInfo.grContext()->flushAndSubmit();
return otherContextImage;
}};
for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
@ -444,7 +444,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn
}
}
}
context->flush();
context->flushAndSubmit();
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contextInfo) {
@ -494,7 +494,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter
colorType);
img.reset();
context->flush();
context->flushAndSubmit();
context->deleteBackendTexture(backendTex);
}
}
@ -900,7 +900,7 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
sk_sp<SkImage> refImg(imageMaker(ctx));
canvas->drawImage(refImg, 0, 0);
surface->flush();
surface->flushAndSubmit();
refImg.reset(nullptr); // force a release of the image
}
@ -912,7 +912,7 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
canvas->drawImage(refImg, 0, 0);
refImg.reset(nullptr); // force a release of the image
surface->flush();
surface->flushAndSubmit();
}
// Configure second context
@ -937,7 +937,7 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
otherTestContext->makeCurrent();
canvas->drawImage(refImg, 0, 0);
surface->flush();
surface->flushAndSubmit();
testContext->makeCurrent();
refImg.reset(nullptr); // force a release of the image
@ -955,7 +955,7 @@ static void test_cross_context_image(skiatest::Reporter* reporter, const GrConte
refImg.reset(nullptr); // force a release of the image
otherTestContext->makeCurrent();
surface->flush();
surface->flushAndSubmit();
// This is specifically here for vulkan to guarantee the command buffer will finish
// which is when we call the ReleaseProc.
@ -1077,7 +1077,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
{ [otherContextInfo] {
auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo.grContext());
otherContextInfo.grContext()->flush();
otherContextInfo.grContext()->flushAndSubmit();
return otherContextImage;
}, false, false },
// Create an image that is too large to be texture backed.
@ -1117,7 +1117,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
kExpectedState[testCase.fCanTakeDirectly]);
}
context->flush();
context->flushAndSubmit();
}
}
@ -1378,7 +1378,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
// Flush all the setup work we did above and then make little lambda that reports the flush
// count delta since the last time it was called.
c->flush();
c->flushAndSubmit();
auto numFlushes = [c, flushCnt = c->priv().getGpu()->stats()->numSubmitToGpus()]() mutable {
int curr = c->priv().getGpu()->stats()->numSubmitToGpus();
int n = curr - flushCnt;
@ -1387,43 +1387,46 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
};
// Images aren't used therefore flush is ignored.
i0->flush(c);
i1->flush(c);
i2->flush(c);
i0->flushAndSubmit(c);
i1->flushAndSubmit(c);
i2->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Syncing forces the flush to happen even if the images aren't used.
GrFlushInfo syncInfo;
syncInfo.fFlags = kSyncCpu_GrFlushFlag;
i0->flush(c, syncInfo);
c->submit(true);
REPORTER_ASSERT(reporter, numFlushes() == 1);
i1->flush(c, syncInfo);
c->submit(true);
REPORTER_ASSERT(reporter, numFlushes() == 1);
i2->flush(c, syncInfo);
c->submit(true);
REPORTER_ASSERT(reporter, numFlushes() == 1);
// Use image 1
s->getCanvas()->drawImage(i1, 0, 0);
// Flushing image 0 should do nothing.
i0->flush(c);
i0->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 1 should flush.
i1->flush(c);
i1->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 1);
// Flushing image 2 should do nothing.
i2->flush(c);
i2->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Use image 2
s->getCanvas()->drawImage(i2, 0, 0);
// Flushing image 0 should do nothing.
i0->flush(c);
i0->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 1 do nothing.
i1->flush(c);
i1->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 2 should flush.
i2->flush(c);
i2->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 1);
// Since we just did a simple image draw it should not have been flattened.
REPORTER_ASSERT(reporter,
@ -1437,13 +1440,13 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
s->getCanvas()->drawImage(i2, 0, 0);
// Flushing image 0 should do nothing.
i0->flush(c);
i0->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 1 do nothing.
i1->flush(c);
i1->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 2 should flush.
i2->flush(c);
i2->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 1);
// Test case where flatten happens before the first flush.
@ -1459,12 +1462,12 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ImageFlush, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, static_cast<SkImage_GpuYUVA*>(as_IB(i2.get()))->isTextureBacked());
s->getCanvas()->drawImage(i2, 0, 0);
// Flushing image 0 should do nothing.
i0->flush(c);
i0->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 1 do nothing.
i1->flush(c);
i1->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 0);
// Flushing image 2 should flush.
i2->flush(c);
i2->flushAndSubmit(c);
REPORTER_ASSERT(reporter, numFlushes() == 1);
}

View File

@ -389,7 +389,7 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
int executeTestValue = 0;
rtc->priv().testingOnly_addDrawOp(LazyFailedInstantiationTestOp::Make(
ctx.get(), proxyProvider, &executeTestValue, failInstantiation));
ctx->flush();
ctx->flushAndSubmit();
if (failInstantiation) {
REPORTER_ASSERT(reporter, 1 == executeTestValue);

View File

@ -97,7 +97,7 @@ static void test_path(skiatest::Reporter* reporter,
// Draw the path, check that new resource count matches expectations
draw_path(ctx.get(), rtc.get(), path, pathRenderer.get(), aaType, style);
ctx->flush();
ctx->flushAndSubmit();
REPORTER_ASSERT(reporter, cache_non_scratch_resources_equals(cache, expected));
// Nothing should be purgeable yet
@ -121,7 +121,7 @@ static void test_path(skiatest::Reporter* reporter,
float scaleX = 1 + ((float)i + 1)/20.f;
draw_path(ctx.get(), rtc.get(), path, pathRenderer.get(), aaType, style, scaleX);
}
ctx->flush();
ctx->flushAndSubmit();
REPORTER_ASSERT(reporter, SkPathPriv::GenIDChangeListenersCount(path) == 20);
cache->purgeAllUnlocked();
// The listeners don't actually purge until we try to add another one.

View File

@ -183,7 +183,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
ERRORF(reporter, "No attributes allowed?!");
return;
}
context->flush();
context->flushAndSubmit();
context->priv().resetGpuStats();
#if GR_GPU_STATS
REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0);
@ -195,14 +195,14 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
GrPaint grPaint;
// This one should succeed.
renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(context, attribCnt));
context->flush();
context->flushAndSubmit();
#if GR_GPU_STATS
REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 1);
REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 0);
#endif
context->priv().resetGpuStats();
renderTargetContext->priv().testingOnly_addDrawOp(Op::Make(context, attribCnt + 1));
context->flush();
context->flushAndSubmit();
#if GR_GPU_STATS
REPORTER_ASSERT(reporter, gpu->stats()->numDraws() == 0);
REPORTER_ASSERT(reporter, gpu->stats()->numFailedDraws() == 1);

View File

@ -200,7 +200,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
CheckSingleThreadedProxyRefs(reporter, proxy.get(), expectedProxyRefs, -1);
context->flush();
context->flushAndSubmit();
// just one from the 'proxy' sk_sp
CheckSingleThreadedProxyRefs(reporter, proxy.get(), 1, 1);

View File

@ -197,7 +197,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
canvas->drawImage(refImg, 0, 0);
check_unfulfilled(promiseChecker, reporter);
surface->flush();
surface->flushAndSubmit();
// We still own the image so we should not have called Release or Done.
check_only_fulfilled(reporter, promiseChecker);
@ -207,14 +207,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
canvas->drawImage(refImg, 0, 0);
canvas->drawImage(refImg, 0, 0);
surface->flush();
surface->flushAndSubmit();
gpu->testingOnly_flushGpuAndSync();
// Image should still be fulfilled from the first time we drew/flushed it.
check_only_fulfilled(reporter, promiseChecker);
canvas->drawImage(refImg, 0, 0);
surface->flush();
surface->flushAndSubmit();
check_only_fulfilled(reporter, promiseChecker);
canvas->drawImage(refImg, 0, 0);
@ -222,7 +222,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
// We no longer own the image but the last draw is still unflushed.
check_only_fulfilled(reporter, promiseChecker);
surface->flush();
surface->flushAndSubmit();
// Flushing should have called Release. Depending on the backend and timing it may have called
// done.
check_all_flushed_but_not_synced(reporter, promiseChecker, ctx->backend());
@ -291,7 +291,7 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
// to destroy the context (and instead will release-all-and-abandon).
surface.reset();
ctx->flush();
ctx->flushAndSubmit();
contextDeath(&factory, ctx);
check_all_done(reporter, promiseChecker);
@ -346,20 +346,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
// Relying on the asserts in the promiseImageChecker to ensure that fulfills and releases are
// properly ordered.
canvas->drawImage(image, 0, 0);
surface->flush();
surface->flushAndSubmit();
canvas->drawImage(image, 1, 0);
surface->flush();
surface->flushAndSubmit();
canvas->drawImage(image, 2, 0);
surface->flush();
surface->flushAndSubmit();
canvas->drawImage(image, 3, 0);
surface->flush();
surface->flushAndSubmit();
canvas->drawImage(image, 4, 0);
surface->flush();
surface->flushAndSubmit();
canvas->drawImage(image, 5, 0);
surface->flush();
surface->flushAndSubmit();
// Must call these to ensure that all callbacks are performed before the checker is destroyed.
image.reset();
ctx->flush();
ctx->flushAndSubmit();
ctx->priv().getGpu()->testingOnly_flushGpuAndSync();
ctx->deleteBackendTexture(backendTex);
@ -417,7 +417,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
canvas->drawRect(SkRect::MakeWH(1,1), paint);
paint.setShader(nullptr);
refImg.reset();
surface->flush();
surface->flushAndSubmit();
// We should only call each callback once and we should have made all the calls by this point.
REPORTER_ASSERT(reporter, counts.fFulfillCount == 1);
REPORTER_ASSERT(reporter, counts.fReleaseCount == 1);

View File

@ -73,7 +73,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
}
// flush here just to clear the playing field
context->flush();
context->flushAndSubmit();
size_t beforeBytes = cache->getResourceBytes();
@ -100,7 +100,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(RepeatedClippedBlurTest, reporter, ctxInfo) {
dstCanvas->drawImageRect(filteredImg, outSubset, dstRect, nullptr);
// Flush here to mimic Chrome's SkiaHelper::ApplyImageFilter
context->flush();
context->flushAndSubmit();
clip.fRight -= 16;
}

View File

@ -247,7 +247,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceAllocatorStressTest, reporter, ctxInf
draw(context);
draw(context);
draw(context);
context->flush();
context->flushAndSubmit();
context->setResourceCacheLimit(maxBytes);
}

View File

@ -224,7 +224,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
borrowed.reset(nullptr);
adopted.reset(nullptr);
context->flush();
context->flushAndSubmit();
bool borrowedIsAlive = gpu->isTestingOnlyBackendTexture(backendTextures[0]);
bool adoptedIsAlive = gpu->isTestingOnlyBackendTexture(backendTextures[1]);
@ -1259,7 +1259,7 @@ static void test_time_purge(skiatest::Reporter* reporter) {
// Verify that calling flush() on a GrContext with nothing to do will not trigger resource
// eviction
context->flush();
context->flushAndSubmit();
for (int i = 0; i < 10; ++i) {
TestResource* r = new TestResource(gpu);
GrUniqueKey k;
@ -1268,7 +1268,7 @@ static void test_time_purge(skiatest::Reporter* reporter) {
r->unref();
}
REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
context->flush();
context->flushAndSubmit();
REPORTER_ASSERT(reporter, 10 == cache->getResourceCount());
cache->purgeResourcesNotUsedSince(nowish());
REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
@ -1720,8 +1720,8 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(OverbudgetFlush, reporter, ctxInfo) {
drawToSurf(surf2.get());
// Flush each surface once to ensure that their backing stores are allocated.
surf1->flush();
surf2->flush();
surf1->flushAndSubmit();
surf2->flushAndSubmit();
REPORTER_ASSERT(reporter, overbudget());
getFlushCountDelta();
@ -1733,7 +1733,7 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(OverbudgetFlush, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, overbudget());
// Make surf1 purgeable. Drawing to surf2 should flush.
surf1->flush();
surf1->flushAndSubmit();
surf1.reset();
drawToSurf(surf2.get());
REPORTER_ASSERT(reporter, getFlushCountDelta());

View File

@ -163,6 +163,7 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
mainCtx->flush(info);
break;
}
mainCtx->submit();
sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
GrBackendTexture backendTexture = mainImage->getBackendTexture(false);
@ -238,7 +239,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(EmptySurfaceSemaphoreTest, reporter, ctxInfo)
nullptr));
// Flush surface once without semaphores to make sure there is no peneding IO for it.
mainSurface->flush();
mainSurface->flushAndSubmit();
GrBackendSemaphore semaphore;
GrSemaphoresSubmitted submitted = mainSurface->flushAndSignalSemaphores(1, &semaphore);

View File

@ -122,7 +122,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
colorType, can, SkToBool(surf));
surf.reset();
context->flush();
context->flushAndSubmit();
context->deleteBackendTexture(backendTex);
}
@ -175,7 +175,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
}
surf.reset();
context->flush();
context->flushAndSubmit();
context->deleteBackendTexture(backendTex);
}
@ -191,7 +191,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", colorType,
can, SkToBool(surf));
surf.reset();
context->flush();
context->flushAndSubmit();
if (backendRenderTarget.isValid()) {
gpu->deleteTestingOnlyBackendRenderTarget(backendRenderTarget);
}
@ -960,8 +960,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWrappedWithRelease_Gpu, reporter, ctxI
}
surface->getCanvas()->clear(SK_ColorRED);
surface->flush();
gpu->testingOnly_flushGpuAndSync();
GrFlushInfo info;
info.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, info);
ctx->submit(true);
// Now exercise the release proc
REPORTER_ASSERT(reporter, 0 == releaseChecker.fReleaseCount);

View File

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

View File

@ -68,7 +68,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
};
// Initialize texture unit/target combo bindings to 0.
context->flush();
context->flushAndSubmit();
resetBindings();
context->resetContext();
@ -96,7 +96,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
paint.setFilterQuality(kHigh_SkFilterQuality);
surf->getCanvas()->drawImage(img, 0, 0, &paint);
surf->getCanvas()->restore();
surf->flush();
surf->flushAndSubmit();
context->resetGLTextureBindings();
checkBindings();
resetBindings();
@ -124,7 +124,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
REPORTER_ASSERT(reporter, img);
surf->getCanvas()->drawImage(img, 0, 0);
img.reset();
surf->flush();
surf->flushAndSubmit();
context->resetGLTextureBindings();
checkBindings();
resetBindings();
@ -151,7 +151,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
REPORTER_ASSERT(reporter, img);
surf->getCanvas()->drawImage(img, 0, 0);
img.reset();
surf->flush();
surf->flushAndSubmit();
context->resetGLTextureBindings();
checkBindings();
resetBindings();

View File

@ -741,7 +741,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TriangulatingPathRendererTests, reporter, ctxInfo)
return;
}
ctx->flush();
ctx->flushAndSubmit();
// Adding discard to appease vulkan validation warning about loading uninitialized data on draw
rtc->discard();

View File

@ -310,6 +310,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, report
}
context->flush(GrFlushInfo(), externalRequests);
context->submit();
if (useSurface) {
newBackendTexture = surface->getBackendTexture(
@ -330,6 +331,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, report
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->submit(true);
context->deleteBackendTexture(backendTex);
}
}

View File

@ -318,7 +318,7 @@ bool EGLTestHelper::flushSurfaceAndSignalSemaphore(skiatest::Reporter* reporter,
return false;
}
surface->flush();
surface->flushAndSubmit();
GR_GL_CALL(fGLCtx->gl(), Flush());
fFdHandle = fEGLDupNativeFenceFDANDROID(eglDisplay, eglsync);
@ -361,6 +361,7 @@ void EGLTestHelper::doClientSync() {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
this->grContext()->flush(flushInfo);
this->grContext()->submit(true);
}
#endif // SK_GL
@ -821,7 +822,7 @@ sk_sp<SkImage> VulkanTestHelper::importHardwareBufferForRead(skiatest::Reporter*
bool VulkanTestHelper::flushSurfaceAndSignalSemaphore(skiatest::Reporter* reporter,
sk_sp<SkSurface> surface) {
surface->flush();
surface->flushAndSubmit();
surface.reset();
GrBackendSemaphore semaphore;
if (!this->setupSemaphoreForSignaling(reporter, &semaphore)) {
@ -831,6 +832,7 @@ bool VulkanTestHelper::flushSurfaceAndSignalSemaphore(skiatest::Reporter* report
info.fNumSemaphores = 1;
info.fSignalSemaphores = &semaphore;
GrSemaphoresSubmitted submitted = fGrContext->flush(info);
fGrContext->submit();
if (GrSemaphoresSubmitted::kNo == submitted) {
ERRORF(reporter, "Failing call to flush on GrContext");
return false;

View File

@ -308,6 +308,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangle, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -331,6 +332,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithAntiAlias, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -354,6 +356,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithBlendMode, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -379,6 +382,7 @@ DEF_GPUTEST(VkProtectedContext_DrawRectangleWithFilter, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -404,6 +408,7 @@ DEF_GPUTEST(VkProtectedContext_DrawThinPath, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -428,6 +433,7 @@ DEF_GPUTEST(VkProtectedContext_SaveLayer, reporter, options) {
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}
@ -457,9 +463,11 @@ DEF_GPUTEST(VkProtectedContext_DrawProtectedImageOnProtectedSurface, reporter, o
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface1->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface1->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface1->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
surface2->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
surface2->getContext()->submit(true);
protectedTestHelper->grContext()->deleteBackendTexture(
surface2->getBackendTexture(SkSurface::kFlushRead_BackendHandleAccess));
}

View File

@ -363,7 +363,7 @@ DEF_GPUTEST(VkYCbcrSampler_DrawImageWithYcbcrSampler, reporter, options) {
return;
}
surface->getCanvas()->drawImage(srcImage, 0, 0);
surface->flush();
surface->flushAndSubmit();
std::vector<uint8_t> readbackData(kImageWidth * kImageHeight * 4);
if (!surface->readPixels(SkImageInfo::Make(kImageWidth, kImageHeight, kRGBA_8888_SkColorType,

View File

@ -486,7 +486,7 @@ static sk_sp<SkSurface> create_surf(GrContext* context, int width, int height) {
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, ii);
surf->flush();
surf->flushAndSubmit();
return surf;
}

View File

@ -772,7 +772,7 @@ void TestSVGTypeface::exportTtxCbdt(SkWStream* out, SkSpan<unsigned> strikeSizes
-bounds.fTop,
font,
paint);
surface->flush();
surface->flushAndSubmit();
sk_sp<SkImage> image = surface->makeImageSnapshot();
sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 100);
@ -994,7 +994,7 @@ void TestSVGTypeface::exportTtxSbix(SkWStream* out, SkSpan<unsigned> strikeSizes
-bounds.fTop,
font,
paint);
surface->flush();
surface->flushAndSubmit();
sk_sp<SkImage> image = surface->makeImageSnapshot();
sk_sp<SkData> data = image->encodeToData(SkEncodedImageFormat::kPNG, 100);

View File

@ -54,6 +54,7 @@ void TestContext::flushAndWaitOnSync(GrContext* context) {
flushInfo.fFinishedContext = fFinishTrackers[fCurrentFlushIdx].get();
context->flush(flushInfo);
context->submit();
fCurrentFlushIdx = (fCurrentFlushIdx + 1) % SK_ARRAY_COUNT(fFinishTrackers);
}

View File

@ -526,6 +526,7 @@ void VulkanWindowContext::swapBuffers() {
info.fNumSemaphores = 1;
info.fSignalSemaphores = &beSemaphore;
surface->flush(SkSurface::BackendSurfaceAccess::kPresent, info);
surface->getContext()->submit();
// Submit present operation to present queue
const VkPresentInfoKHR presentInfo =

View File

@ -89,7 +89,7 @@ void Window::onPaint() {
this->visitLayers([](Layer* layer) { layer->onPrePaint(); });
this->visitLayers([=](Layer* layer) { layer->onPaint(backbuffer.get()); });
backbuffer->flush();
backbuffer->flushAndSubmit();
fWindowContext->swapBuffers();
}

View File

@ -286,7 +286,7 @@ static void run_ddl_benchmark(GrContext* context, sk_sp<SkSurface> dstSurface,
if (!FLAGS_png.isEmpty()) {
// The user wants to see the final result
dstSurface->draw(tiles.composeDDL());
dstSurface->flush();
dstSurface->flushAndSubmit();
}
tiles.resetAllTiles();
@ -296,6 +296,7 @@ static void run_ddl_benchmark(GrContext* context, sk_sp<SkSurface> dstSurface,
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo);
context->submit(true);
promiseImageHelper.deleteAllFromGPU(nullptr, context);
@ -335,6 +336,7 @@ static void run_benchmark(GrContext* context, SkSurface* surface, SkpProducer* s
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
context->submit(true);
}
static void run_gpu_time_benchmark(sk_gpu_test::GpuTimer* gpuTimer, GrContext* context,
@ -402,6 +404,7 @@ static void run_gpu_time_benchmark(sk_gpu_test::GpuTimer* gpuTimer, GrContext* c
GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag;
surface->flush(SkSurface::BackendSurfaceAccess::kNoAccess, flushInfo);
context->submit(true);
}
void print_result(const std::vector<Sample>& samples, const char* config, const char* bench) {
@ -621,6 +624,7 @@ static void flush_with_sync(GrContext* context, GpuSync& gpuSync) {
flushInfo.fFinishedContext = gpuSync.newFlushTracker(context);
context->flush(flushInfo);
context->submit();
}
static void draw_skp_and_flush_with_sync(GrContext* context, SkSurface* surface,

View File

@ -1450,7 +1450,7 @@ void Viewer::drawSlide(SkSurface* surface) {
// Force a flush so we can time that, too
fStatsLayer.beginTiming(fFlushTimer);
slideSurface->flush();
slideSurface->flushAndSubmit();
fStatsLayer.endTiming(fFlushTimer);
// If we rendered offscreen, snap an image and push the results to the window's canvas