From 311cc6b39a3e5f792dc9081ea19e42b930426b99 Mon Sep 17 00:00:00 2001 From: Jim Van Verth Date: Wed, 20 Sep 2017 17:51:59 -0400 Subject: Another attempt to fix TSAN Change-Id: I1d6aebcd679a406a13911f4b91f72f4198fc8dc1 Reviewed-on: https://skia-review.googlesource.com/49461 Reviewed-by: Jim Van Verth Commit-Queue: Jim Van Verth --- tests/ProxyRefTest.cpp | 101 +++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 49 deletions(-) (limited to 'tests/ProxyRefTest.cpp') diff --git a/tests/ProxyRefTest.cpp b/tests/ProxyRefTest.cpp index 202dd6aeed..16f4f42632 100644 --- a/tests/ProxyRefTest.cpp +++ b/tests/ProxyRefTest.cpp @@ -54,10 +54,6 @@ static void check_refs(skiatest::Reporter* reporter, int32_t expectedBackingRefs, int32_t expectedNumReads, int32_t expectedNumWrites) { - REPORTER_ASSERT(reporter, proxy); - if (!proxy) { - return; - } REPORTER_ASSERT(reporter, proxy->getProxyRefCnt_TestOnly() == expectedProxyRefs); REPORTER_ASSERT(reporter, proxy->getBackingRefCnt_TestOnly() == expectedBackingRefs); REPORTER_ASSERT(reporter, proxy->getPendingReadCnt_TestOnly() == expectedNumReads); @@ -102,95 +98,102 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ProxyRefTest, reporter, ctxInfo) { // A single write { sk_sp proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource fWrite(proxy.get()); - GrPendingIOResource fWrite(proxy.get()); - - static const int kExpectedReads = 0; - static const int kExpectedWrites = 1; + static const int kExpectedReads = 0; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // A single read { sk_sp proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource fRead(proxy.get()); - GrPendingIOResource fRead(proxy.get()); + static const int kExpectedReads = 1; + static const int kExpectedWrites = 0; - static const int kExpectedReads = 1; - static const int kExpectedWrites = 0; + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + proxy->instantiate(provider); - proxy->instantiate(provider); - - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // A single read/write pair { sk_sp proxy((*make)(ctxInfo.grContext())); + if (proxy.get()) { + GrPendingIOResource fRW(proxy.get()); - GrPendingIOResource fRW(proxy.get()); - - static const int kExpectedReads = 1; - static const int kExpectedWrites = 1; + static const int kExpectedReads = 1; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transferred to the GrSurface + check_refs(reporter, proxy.get(), 1, 1, kExpectedReads, kExpectedWrites); + } } // Multiple normal refs { sk_sp proxy((*make)(ctxInfo.grContext())); - proxy->ref(); - proxy->ref(); + if (proxy.get()) { + proxy->ref(); + proxy->ref(); - static const int kExpectedReads = 0; - static const int kExpectedWrites = 0; + static const int kExpectedReads = 0; + static const int kExpectedWrites = 0; - check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites); + check_refs(reporter, proxy.get(), 3, 3,kExpectedReads, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transferred to the GrSurface - check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites); + // In the deferred case, this checks that the refs transferred to the GrSurface + check_refs(reporter, proxy.get(), 3, 3, kExpectedReads, kExpectedWrites); - proxy->unref(); - proxy->unref(); + proxy->unref(); + proxy->unref(); + } } // Continue using (reffing) proxy after instantiation { sk_sp proxy((*make)(ctxInfo.grContext())); - proxy->ref(); + if (proxy.get()) { + proxy->ref(); - GrPendingIOResource fWrite(proxy.get()); + GrPendingIOResource fWrite(proxy.get()); - static const int kExpectedWrites = 1; + static const int kExpectedWrites = 1; - check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); - proxy->instantiate(provider); + proxy->instantiate(provider); - // In the deferred case, this checks that the refs transfered to the GrSurface - check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); + // In the deferred case, this checks that the refs transfered to the GrSurface + check_refs(reporter, proxy.get(), 2, 2, 0, kExpectedWrites); - proxy->unref(); - check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites); + proxy->unref(); + check_refs(reporter, proxy.get(), 1, 1, 0, kExpectedWrites); - GrPendingIOResource fRead(proxy.get()); - check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites); + GrPendingIOResource fRead(proxy.get()); + check_refs(reporter, proxy.get(), 1, 1, 1, kExpectedWrites); + } } } } -- cgit v1.2.3