skia2/tests/LazyProxyTest.cpp

437 lines
20 KiB
C++
Raw Normal View History

/*
* Copyright 2017 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
#include "include/core/SkColorSpace.h"
#include "include/gpu/mock/GrMockTypes.h"
#include "src/core/SkRectPriv.h"
#include "src/gpu/ganesh/GrClip.h"
#include "src/gpu/ganesh/GrDirectContextPriv.h"
#include "src/gpu/ganesh/GrMemoryPool.h"
#include "src/gpu/ganesh/GrOnFlushResourceProvider.h"
#include "src/gpu/ganesh/GrProxyProvider.h"
#include "src/gpu/ganesh/GrRecordingContextPriv.h"
#include "src/gpu/ganesh/GrResourceProvider.h"
#include "src/gpu/ganesh/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrSurfaceProxyPriv.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/GrTextureProxy.h"
#include "src/gpu/ganesh/GrTextureProxyPriv.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/mock/GrMockGpu.h"
#include "src/gpu/ganesh/ops/GrDrawOp.h"
#include "src/gpu/ganesh/v1/SurfaceDrawContext_v1.h"
// This test verifies that lazy proxy callbacks get invoked during flush, after onFlush callbacks,
// but before Ops are executed. It also ensures that lazy proxy callbacks are invoked both for
// regular Ops and for clips.
class LazyProxyTest final : public GrOnFlushCallbackObject {
public:
LazyProxyTest(skiatest::Reporter* reporter)
: fReporter(reporter)
, fHasOpTexture(false)
, fHasClipTexture(false) {
}
~LazyProxyTest() override {
REPORTER_ASSERT(fReporter, fHasOpTexture);
REPORTER_ASSERT(fReporter, fHasClipTexture);
}
bool preFlush(GrOnFlushResourceProvider* onFlushRP) override {
#if GR_TEST_UTILS
if (onFlushRP->failFlushTimeCallbacks()) {
return false;
}
#endif
REPORTER_ASSERT(fReporter, !fHasOpTexture);
REPORTER_ASSERT(fReporter, !fHasClipTexture);
return true;
}
void postFlush(skgpu::DrawToken) override {
REPORTER_ASSERT(fReporter, fHasOpTexture);
REPORTER_ASSERT(fReporter, fHasClipTexture);
}
class Op final : public GrDrawOp {
public:
DEFINE_OP_CLASS_ID
static GrOp::Owner Make(GrRecordingContext* context,
GrProxyProvider* proxyProvider,
LazyProxyTest* test,
bool nullTexture) {
return GrOp::Make<Op>(context, context, proxyProvider, test, nullTexture);
}
void visitProxies(const GrVisitProxyFunc& func) const override {
func(fProxy.get(), GrMipmapped::kNo);
}
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override {
REPORTER_ASSERT(fTest->fReporter, fTest->fHasOpTexture);
REPORTER_ASSERT(fTest->fReporter, fTest->fHasClipTexture);
}
private:
friend class GrOp; // for ctor
Op(GrRecordingContext* ctx, GrProxyProvider* proxyProvider,
LazyProxyTest* test, bool nullTexture)
: GrDrawOp(ClassID()), fTest(test) {
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
const GrBackendFormat format =
ctx->priv().caps()->getDefaultBackendFormat(GrColorType::kBGR_565,
GrRenderable::kNo);
fProxy = GrProxyProvider::MakeFullyLazyProxy(
[this, nullTexture](GrResourceProvider* rp,
const GrSurfaceProxy::LazySurfaceDesc& desc)
-> GrSurfaceProxy::LazyCallbackResult {
REPORTER_ASSERT(fTest->fReporter, !fTest->fHasOpTexture);
fTest->fHasOpTexture = true;
if (nullTexture) {
return {};
} else {
static constexpr SkISize kDimensions = {1234, 567};
sk_sp<GrTexture> texture = rp->createTexture(kDimensions,
desc.fFormat,
desc.fTextureType,
desc.fRenderable,
desc.fSampleCnt,
desc.fMipmapped,
desc.fBudgeted,
desc.fProtected,
/*label=*/{});
REPORTER_ASSERT(fTest->fReporter, texture);
return texture;
}
},
format, GrRenderable::kNo, 1, GrProtected::kNo, *proxyProvider->caps(),
GrSurfaceProxy::UseAllocator::kYes);
this->setBounds(SkRectPriv::MakeLargest(), GrOp::HasAABloat::kNo,
GrOp::IsHairline::kNo);
}
const char* name() const override { return "LazyProxyTest::Op"; }
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip* clip,
GrClampType) override {
return GrProcessorSet::EmptySetAnalysis();
}
void onPrePrepare(GrRecordingContext*,
const GrSurfaceProxyView& writeView,
GrAppliedClip*,
const GrDstProxyView&,
GrXferBarrierFlags renderPassXferBarriers,
GrLoadOp colorLoadOp) override {}
void onPrepare(GrOpFlushState*) override {}
LazyProxyTest* const fTest;
sk_sp<GrTextureProxy> fProxy;
};
class ClipFP : public GrFragmentProcessor {
public:
ClipFP(GrRecordingContext* ctx, GrProxyProvider* proxyProvider, LazyProxyTest* test,
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
GrTextureProxy* atlas)
: GrFragmentProcessor(kTestFP_ClassID, kNone_OptimizationFlags)
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
, fContext(ctx)
, fProxyProvider(proxyProvider)
, fTest(test)
, fAtlas(atlas) {
Reland "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView." This reverts commit c5c024791bb7a587223b807e00ffba4a3eb5fdb7. Reason for revert: Doh Original change's description: > Revert "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView." > > This reverts commit acf5929ae0addc5188117142fd3fb39828baa8d5. > > Reason for revert: May be blocking Chrome roll > Original change's description: > > Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView. > > > > In future CLs I will update the Ops that create the TextureSamplers to pass > > the GrSurfaceProxyView in. > > > > Bug: skia:9556 > > Change-Id: I550dab64974d32e4c3047188063efa2d0832328e > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259164 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > > TBR=egdaniel@google.com,michaelludwig@google.com > > Change-Id: Ic804a52c5c6d16a13a9cc2d85bb959f305134177 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9556 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259433 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: If2af5b5b323858e59c0c8db3b75477d74d78abfd No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9556 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259434 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2019-12-12 13:26:58 +00:00
static const GrColorType kColorType = GrColorType::kAlpha_F16;
static const GrSurfaceOrigin kOrigin = kBottomLeft_GrSurfaceOrigin;
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
const GrBackendFormat format =
Reland "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView." This reverts commit c5c024791bb7a587223b807e00ffba4a3eb5fdb7. Reason for revert: Doh Original change's description: > Revert "Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView." > > This reverts commit acf5929ae0addc5188117142fd3fb39828baa8d5. > > Reason for revert: May be blocking Chrome roll > Original change's description: > > Update FragmentProcessor TextureSampler to hold an GrSurfaceProxyView. > > > > In future CLs I will update the Ops that create the TextureSamplers to pass > > the GrSurfaceProxyView in. > > > > Bug: skia:9556 > > Change-Id: I550dab64974d32e4c3047188063efa2d0832328e > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259164 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > > TBR=egdaniel@google.com,michaelludwig@google.com > > Change-Id: Ic804a52c5c6d16a13a9cc2d85bb959f305134177 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:9556 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259433 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> TBR=egdaniel@google.com,robertphillips@google.com,michaelludwig@google.com Change-Id: If2af5b5b323858e59c0c8db3b75477d74d78abfd No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:9556 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/259434 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
2019-12-12 13:26:58 +00:00
ctx->priv().caps()->getDefaultBackendFormat(kColorType, GrRenderable::kYes);
skgpu::Swizzle readSwizzle = ctx->priv().caps()->getReadSwizzle(format, kColorType);
fLazyProxy = GrProxyProvider::MakeFullyLazyProxy(
[this](GrResourceProvider* rp, const GrSurfaceProxy::LazySurfaceDesc&)
-> GrSurfaceProxy::LazyCallbackResult {
REPORTER_ASSERT(fTest->fReporter, !fTest->fHasClipTexture);
fTest->fHasClipTexture = true;
fAtlas->instantiate(rp);
return sk_ref_sp(fAtlas->peekTexture());
},
format, GrRenderable::kYes, 1, GrProtected::kNo, *proxyProvider->caps(),
GrSurfaceProxy::UseAllocator::kYes);
auto atlasEffect = GrTextureEffect::Make({fLazyProxy, kOrigin, readSwizzle},
kPremul_SkAlphaType);
this->registerChild(std::move(atlasEffect));
}
private:
const char* name() const override { return "LazyProxyTest::ClipFP"; }
std::unique_ptr<GrFragmentProcessor> clone() const override {
return std::make_unique<ClipFP>(fContext, fProxyProvider, fTest, fAtlas);
}
std::unique_ptr<ProgramImpl> onMakeProgramImpl() const override {
return nullptr;
}
void onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder*) const override {}
bool onIsEqual(const GrFragmentProcessor&) const override { return false; }
GrRecordingContext* const fContext;
GrProxyProvider* const fProxyProvider;
LazyProxyTest* const fTest;
GrTextureProxy* const fAtlas;
sk_sp<GrTextureProxy> fLazyProxy;
};
class Clip : public GrClip {
public:
Clip(LazyProxyTest* test, GrTextureProxy* atlas)
: fTest(test)
, fAtlas(atlas) {}
private:
SkIRect getConservativeBounds() const final {
return SkIRect::MakeSize(fAtlas->dimensions());
}
Effect apply(GrRecordingContext* rContext,
skgpu::v1::SurfaceDrawContext*,
GrDrawOp*,
GrAAType,
GrAppliedClip* out,
SkRect* bounds) const override {
GrProxyProvider* proxyProvider = rContext->priv().proxyProvider();
out->addCoverageFP(std::make_unique<ClipFP>(rContext, proxyProvider, fTest, fAtlas));
Reland "Simplify GrClip API" This is a reland of 9716414e93f7b279e547595fab08b68235c4b2be Original change's description: > Simplify GrClip API > > Removes quickContains(SkRect), quickContains(SkRRect), and isRRect(). > Replaces these three functions with preApply() that conservatively > determines the clip effect up to a single rrect intersection. The major > motivation for this is the new GrClipStack implementation. preApply() > and apply() will be able to reuse much more code compared to separating > the preApply functionality across the older three functions that were > removed. Additionally, preApply is able to convey more information for > less work, since it can usually determine being skipped or unclipped while > determining if the clip is a single rrect. > > As part of using this API, the attemptQuadOptimiziation and the equivalent > rrect optimization are overhauled. Hopefully legibility is improved, and > the rrect case is now applied outside of the android framework (but with > tighter AA requirements). > > Bug: skia:10205 > Change-Id: I33249dd75a28a611495f87b211cb7ec74ebb7ba4 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298506 > Reviewed-by: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> Bug: skia:10205, 10456 Change-Id: I500eeda36ea50e95eb8cb658b36aa2373d5166c0 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298823 Reviewed-by: Chris Dalton <csmartdalton@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-06-30 15:12:46 +00:00
return Effect::kClipped;
}
LazyProxyTest* const fTest;
GrTextureProxy* fAtlas;
};
private:
skiatest::Reporter* fReporter;
bool fHasOpTexture;
bool fHasClipTexture;
};
DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
GrMockOptions mockOptions;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fRenderability =
GrMockOptions::ConfigOptions::Renderability::kNonMSAA;
mockOptions.fConfigOptions[(int)GrColorType::kAlpha_F16].fTexturable = true;
sk_sp<GrDirectContext> ctx = GrDirectContext::MakeMock(&mockOptions, GrContextOptions());
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
for (bool nullTexture : {false, true}) {
LazyProxyTest test(reporter);
ctx->priv().addOnFlushCallbackObject(&test);
auto sdc = skgpu::v1::SurfaceDrawContext::Make(ctx.get(), GrColorType::kRGBA_8888, nullptr,
SkBackingFit::kExact, {100, 100},
SkSurfaceProps());
REPORTER_ASSERT(reporter, sdc);
auto mockAtlas = skgpu::v1::SurfaceDrawContext::Make(ctx.get(), GrColorType::kAlpha_F16,
nullptr, SkBackingFit::kExact,
{10, 10}, SkSurfaceProps());
REPORTER_ASSERT(reporter, mockAtlas);
Reland "GrClips provided as pointers to GrRTC" This reverts commit 074414fed53efcab7f33b06454958707419e37d8. Reason for revert: updated to guard against nullptr before calling quickContains(rrect). Original change's description: > Revert "GrClips provided as pointers to GrRTC" > > This reverts commit 226b689471a0fbb7400bc166032458278957541b. > > Reason for revert: Breaks Android roller > > Original change's description: > > GrClips provided as pointers to GrRTC > > > > A null clip represents no high-level clipping is necessary (the implicit > > clip to the render target's logical dimensions is fine). > > > > This also removes GrNoClip and GrFixedClip::Disabled() since they are > > replaced with just nullptr. > > > > By allowing nullptr to represent no intended clipping, it makes it easier > > to require GrClip and GrAppliedClip objects to know about the dimensions > > of the device. If we required a non-null clip object to represent no > > clipping, we'd have to have an instance for each device based on its > > size and that just became cumbersome. > > > > Bug: skia:10205 > > Change-Id: Ie30cc71820b92d99356d393a4c98c8677082e761 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290539 > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I42c4828bcf016ee3d30d5c20b771be96e125817b > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292856 > Reviewed-by: Weston Tracey <westont@google.com> > Commit-Queue: Weston Tracey <westont@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com,westont@google.com # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: I5715a4de3b7c8847b73020dc4937d3816d879803 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292876 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-29 13:54:07 +00:00
LazyProxyTest::Clip clip(&test, mockAtlas->asTextureProxy());
sdc->addDrawOp(&clip,
LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture));
ctx->priv().testingOnly_flushAndRemoveOnFlushCallbackObject(&test);
}
}
static const int kSize = 16;
DEF_GPUTEST(LazyProxyReleaseTest, reporter, /* options */) {
GrMockOptions mockOptions;
sk_sp<GrDirectContext> ctx = GrDirectContext::MakeMock(&mockOptions, GrContextOptions());
auto proxyProvider = ctx->priv().proxyProvider();
const GrCaps* caps = ctx->priv().caps();
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
Reland "Remove GrBackendFormat's textureType use from isFormatTexturable call." This reverts commit d90777ada391dffa9a19101fe7917d0c13a606b3. Reason for revert: relanding with fix to GrBackendTexture Original change's description: > Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call." > > This reverts commit 832c817bc8a9567aa379181e71e7c602d2480de8. > > Reason for revert: uninitialized value in GrBackendTexture > > Original change's description: > > Remove GrBackendFormat's textureType use from isFormatTexturable call. > > > > The goal of this change was to remove the use of GrBackendFormat::textureType() > > from GrCaps::isFormatTexturable call. Instead we will always pass in a > > GrTextureType into this call. > > > > To do this a lot of plumbing of GrTextureType was added to various call > > sites. However, this CL halts the plubming up at the proxy level where we > > get it from the GrBackendFormat still. Future CLs will continue removing > > these call sites and others that use GrBackendFormat::textureType(). > > > > Bug: skia:12342 > > Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com > > Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12342 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:12342 Change-Id: I151196f149f9e191d2975b8fe81334f4f8720744 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439339 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 20:20:18 +00:00
auto tex = ctx->priv().resourceProvider()->createTexture({kSize, kSize},
format,
GrTextureType::k2D,
GrRenderable::kNo,
1,
GrMipmapped::kNo,
SkBudgeted::kNo,
GrProtected::kNo,
/*label=*/{});
using LazyInstantiationResult = GrSurfaceProxy::LazyCallbackResult;
for (bool doInstantiate : {true, false}) {
for (bool releaseCallback : {false, true}) {
int testCount = 0;
// Sets an integer to 1 when the callback is called and -1 when it is deleted.
class TestCallback {
public:
TestCallback(int* value, bool releaseCallback, sk_sp<GrTexture> tex)
: fValue(value)
, fReleaseCallback(releaseCallback)
, fTexture(std::move(tex)) {}
TestCallback(const TestCallback& that) { SkASSERT(0); }
TestCallback(TestCallback&& that)
: fValue(that.fValue)
, fReleaseCallback(that.fReleaseCallback)
, fTexture(std::move(that.fTexture)) {
that.fValue = nullptr;
}
~TestCallback() { fValue ? (void)(*fValue = -1) : void(); }
TestCallback& operator=(TestCallback&& that) {
fValue = std::exchange(that.fValue, nullptr);
return *this;
}
TestCallback& operator=(const TestCallback& that) = delete;
LazyInstantiationResult operator()(GrResourceProvider*,
const GrSurfaceProxy::LazySurfaceDesc&) const {
*fValue = 1;
return {fTexture, fReleaseCallback};
}
private:
int* fValue = nullptr;
bool fReleaseCallback;
sk_sp<GrTexture> fTexture;
};
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
TestCallback(&testCount, releaseCallback, tex), format, {kSize, kSize},
GrMipmapped::kNo, GrMipmapStatus::kNotAllocated, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo, GrProtected::kNo,
GrSurfaceProxy::UseAllocator::kYes);
REPORTER_ASSERT(reporter, proxy.get());
REPORTER_ASSERT(reporter, 0 == testCount);
if (doInstantiate) {
proxy->priv().doLazyInstantiation(ctx->priv().resourceProvider());
if (releaseCallback) {
// We will call the cleanup and delete the callback in the
// doLazyInstantiationCall.
REPORTER_ASSERT(reporter, -1 == testCount);
} else {
REPORTER_ASSERT(reporter, 1 == testCount);
}
proxy.reset();
REPORTER_ASSERT(reporter, -1 == testCount);
} else {
proxy.reset();
REPORTER_ASSERT(reporter, -1 == testCount);
}
}
}
}
class LazyFailedInstantiationTestOp : public GrDrawOp {
public:
DEFINE_OP_CLASS_ID
static GrOp::Owner Make(GrRecordingContext* rContext,
GrProxyProvider* proxyProvider,
int* testExecuteValue,
bool shouldFailInstantiation) {
return GrOp::Make<LazyFailedInstantiationTestOp>(rContext,
rContext->priv().caps(),
proxyProvider,
testExecuteValue,
shouldFailInstantiation);
}
void visitProxies(const GrVisitProxyFunc& func) const override {
func(fLazyProxy.get(), GrMipmapped::kNo);
}
private:
friend class GrOp; // for ctor
LazyFailedInstantiationTestOp(const GrCaps* caps, GrProxyProvider* proxyProvider,
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies."" This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2018-11-16 20:43:41 +00:00
int* testExecuteValue, bool shouldFailInstantiation)
: INHERITED(ClassID())
, fTestExecuteValue(testExecuteValue) {
SkISize dims = {kSize, kSize};
GrBackendFormat format = caps->getDefaultBackendFormat(GrColorType::kRGBA_8888,
GrRenderable::kNo);
fLazyProxy = proxyProvider->createLazyProxy(
[testExecuteValue, shouldFailInstantiation](
GrResourceProvider* rp, const GrSurfaceProxy::LazySurfaceDesc& desc)
-> GrSurfaceProxy::LazyCallbackResult {
if (shouldFailInstantiation) {
*testExecuteValue = 1;
return {};
}
Reland "Remove GrBackendFormat's textureType use from isFormatTexturable call." This reverts commit d90777ada391dffa9a19101fe7917d0c13a606b3. Reason for revert: relanding with fix to GrBackendTexture Original change's description: > Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call." > > This reverts commit 832c817bc8a9567aa379181e71e7c602d2480de8. > > Reason for revert: uninitialized value in GrBackendTexture > > Original change's description: > > Remove GrBackendFormat's textureType use from isFormatTexturable call. > > > > The goal of this change was to remove the use of GrBackendFormat::textureType() > > from GrCaps::isFormatTexturable call. Instead we will always pass in a > > GrTextureType into this call. > > > > To do this a lot of plumbing of GrTextureType was added to various call > > sites. However, this CL halts the plubming up at the proxy level where we > > get it from the GrBackendFormat still. Future CLs will continue removing > > these call sites and others that use GrBackendFormat::textureType(). > > > > Bug: skia:12342 > > Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com > > Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12342 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:12342 Change-Id: I151196f149f9e191d2975b8fe81334f4f8720744 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439339 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 20:20:18 +00:00
return {rp->createTexture(desc.fDimensions,
desc.fFormat,
desc.fTextureType,
Reland "Remove GrBackendFormat's textureType use from isFormatTexturable call." This reverts commit d90777ada391dffa9a19101fe7917d0c13a606b3. Reason for revert: relanding with fix to GrBackendTexture Original change's description: > Revert "Remove GrBackendFormat's textureType use from isFormatTexturable call." > > This reverts commit 832c817bc8a9567aa379181e71e7c602d2480de8. > > Reason for revert: uninitialized value in GrBackendTexture > > Original change's description: > > Remove GrBackendFormat's textureType use from isFormatTexturable call. > > > > The goal of this change was to remove the use of GrBackendFormat::textureType() > > from GrCaps::isFormatTexturable call. Instead we will always pass in a > > GrTextureType into this call. > > > > To do this a lot of plumbing of GrTextureType was added to various call > > sites. However, this CL halts the plubming up at the proxy level where we > > get it from the GrBackendFormat still. Future CLs will continue removing > > these call sites and others that use GrBackendFormat::textureType(). > > > > Bug: skia:12342 > > Change-Id: Ic0f02b9c7f7402405623b8aa31aa32a9a7c22297 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439277 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,skcq-be@skia-corp.google.com.iam.gserviceaccount.com > > Change-Id: I354bbbf00be7a86c480009f3e7b36a8777a6bf3a > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:12342 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439338 > Reviewed-by: Greg Daniel <egdaniel@google.com> > Commit-Queue: Greg Daniel <egdaniel@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:12342 Change-Id: I151196f149f9e191d2975b8fe81334f4f8720744 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/439339 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
2021-08-13 20:20:18 +00:00
desc.fRenderable,
desc.fSampleCnt,
desc.fMipmapped,
desc.fBudgeted,
desc.fProtected,
/*label=*/{}),
true, GrSurfaceProxy::LazyInstantiationKeyMode::kUnsynced};
},
format, dims, GrMipmapped::kNo, GrMipmapStatus::kNotAllocated,
GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo,
GrProtected::kNo, GrSurfaceProxy::UseAllocator::kYes);
SkASSERT(fLazyProxy.get());
this->setBounds(SkRect::Make(dims), HasAABloat::kNo, IsHairline::kNo);
}
const char* name() const override { return "LazyFailedInstantiationTestOp"; }
FixedFunctionFlags fixedFunctionFlags() const override { return FixedFunctionFlags::kNone; }
GrProcessorSet::Analysis finalize(const GrCaps&, const GrAppliedClip*, GrClampType) override {
return GrProcessorSet::EmptySetAnalysis();
}
void onPrePrepare(GrRecordingContext*,
const GrSurfaceProxyView& writeView,
GrAppliedClip*,
const GrDstProxyView&,
GrXferBarrierFlags renderPassXferBarriers,
GrLoadOp colorLoadOp) override {}
void onPrepare(GrOpFlushState*) override {}
void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override {
*fTestExecuteValue = 2;
}
int* fTestExecuteValue;
sk_sp<GrTextureProxy> fLazyProxy;
using INHERITED = GrDrawOp;
};
// Test that when a lazy proxy fails to instantiate during flush that we drop the Op that it was
// associated with.
DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
GrMockOptions mockOptions;
sk_sp<GrDirectContext> ctx = GrDirectContext::MakeMock(&mockOptions, GrContextOptions());
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
for (bool failInstantiation : {false, true}) {
auto sdc = skgpu::v1::SurfaceDrawContext::Make(ctx.get(), GrColorType::kRGBA_8888, nullptr,
SkBackingFit::kExact, {100, 100},
SkSurfaceProps());
REPORTER_ASSERT(reporter, sdc);
sdc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
int executeTestValue = 0;
sdc->addDrawOp(LazyFailedInstantiationTestOp::Make(ctx.get(), proxyProvider,
&executeTestValue, failInstantiation));
ctx->flushAndSubmit();
if (failInstantiation) {
REPORTER_ASSERT(reporter, 1 == executeTestValue);
} else {
REPORTER_ASSERT(reporter, 2 == executeTestValue);
}
}
}