From 1119dc366e15ef737d05d3a087410ea40c508101 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 11 Apr 2017 12:54:57 -0400 Subject: Remove discard from GrRenderTarget & force it to always go through a RenderTargetContext This is a bit sloppy in that it ignores some instances where discards were being issued before. The creation of the temp RTContext in the RenderTarget's discard method was causing an extra split in the opLists. This is split out of: https://skia-review.googlesource.com/c/10284/ (Omnibus: Remove GrSurface-derived classes from ops) Change-Id: Ic366d303280635763b0fae238c4df37c04fb8503 Reviewed-on: https://skia-review.googlesource.com/11125 Commit-Queue: Robert Phillips Reviewed-by: Brian Salomon --- tests/ProxyRefTest.cpp | 64 +++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 42 deletions(-) (limited to 'tests/ProxyRefTest.cpp') diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index f5fe6a4047..dc48ef0cf6 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -86,20 +86,12 @@ static sk_sp make_wrapped(GrContext* context) { sk_sp tex(context->resourceProvider()->createTexture(desc, SkBudgeted::kNo)); - sk_sp proxy = GrSurfaceProxy::MakeWrapped(std::move(tex)); - - // Flush the IOWrite from the initial discard or it will confuse the later ref count checks - context->contextPriv().flushSurfaceWrites(proxy.get()); - - return proxy; + return GrSurfaceProxy::MakeWrapped(std::move(tex)); } DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrResourceProvider* provider = ctxInfo.grContext()->resourceProvider(); - const GrCaps& caps = *ctxInfo.grContext()->caps(); - // Currently the op itself takes a pending write and the render target op list does as well. - static const int kWritesForDiscard = 2; for (auto make : { make_deferred, make_wrapped }) { // A single write { @@ -107,18 +99,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrPendingIOResource fWrite(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 0, 1); + static const int kExpectedReads = 0; + static const int kExpectedWrites = 1; - // In the deferred case, the discard op created on instantiation adds an - // extra ref and write - bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() && - caps.discardRenderTargetSupport(); - int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); proxy->instantiate(provider); // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, 0, expectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); } // A single read @@ -127,18 +116,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrPendingIOResource fRead(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 1, 0); + static const int kExpectedReads = 1; + static const int kExpectedWrites = 0; - // In the deferred case, the discard op created on instantiation adds an - // extra ref and write - bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() && - caps.discardRenderTargetSupport(); - int expectedWrites = proxyGetsDiscardRef ? kWritesForDiscard : 0; + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); proxy->instantiate(provider); // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); } // A single read/write pair @@ -147,18 +133,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrPendingIOResource fRW(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 1, 1); + static const int kExpectedReads = 1; + static const int kExpectedWrites = 1; - // In the deferred case, the discard op created on instantiation adds an - // extra ref and write - bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() && - caps.discardRenderTargetSupport(); - int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); proxy->instantiate(provider); // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); } // Multiple normal refs @@ -167,16 +150,15 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { proxy->ref(); proxy->ref(); - check_refs(reporter, proxy.get(), 3, 3, 0, 0); + static const int kExpectedReads = 0; + static const int kExpectedWrites = 0; - bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() && - caps.discardRenderTargetSupport(); - int expectedWrites = proxyGetsDiscardRef ? kWritesForDiscard : 0; + check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites); proxy->instantiate(provider); // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 3, 3, 0, expectedWrites); + check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites); proxy->unref(); proxy->unref(); @@ -189,22 +171,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { GrPendingIOResource fWrite(proxy.get()); - check_refs(reporter, proxy.get(), 2, 2, 0, 1); + static const int kExpectedWrites = 1; - bool proxyGetsDiscardRef = !proxy->isWrapped_ForTesting() && - caps.discardRenderTargetSupport(); - int expectedWrites = 1 + (proxyGetsDiscardRef ? kWritesForDiscard : 0); + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); proxy->instantiate(provider); // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 2, 2, 0, expectedWrites); + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); proxy->unref(); - check_refs(reporter, proxy.get(), 1, 1, 0, expectedWrites); + check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites); GrPendingIOResource fRead(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 1, expectedWrites); + check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites); } } } -- cgit v1.2.3