Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Robert Phillips | 6d344c3 | 2020-07-06 10:56:46 -0400 | [diff] [blame] | 7 | |
| 8 | #include "include/gpu/GrDirectContext.h" |
Michael Ludwig | fe13ca3 | 2019-11-21 10:26:41 -0500 | [diff] [blame] | 9 | #include "src/core/SkBlendModePriv.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 10 | #include "src/gpu/GrDirectContextPriv.h" |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 11 | #include "src/gpu/GrOpsTypes.h" |
Robert Phillips | e19babf | 2020-04-06 13:57:30 -0400 | [diff] [blame] | 12 | #include "src/gpu/GrProxyProvider.h" |
Robert Phillips | 1a82a4e | 2021-07-01 10:27:44 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrResourceProvider.h" |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 14 | #include "src/gpu/ops/GrFillRectOp.h" |
| 15 | #include "src/gpu/ops/GrTextureOp.h" |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 16 | #include "src/gpu/v1/SurfaceDrawContext_v1.h" |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 17 | #include "tests/Test.h" |
| 18 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 19 | static std::unique_ptr<skgpu::v1::SurfaceDrawContext> new_SDC(GrRecordingContext* rContext) { |
| 20 | return skgpu::v1::SurfaceDrawContext::Make( |
Chris Dalton | f5b87f9 | 2021-04-19 17:27:09 -0600 | [diff] [blame] | 21 | rContext, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {128, 128}, |
| 22 | SkSurfaceProps()); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 23 | } |
| 24 | |
Robert Phillips | 089b7c9 | 2020-08-12 11:57:07 -0400 | [diff] [blame] | 25 | static sk_sp<GrSurfaceProxy> create_proxy(GrRecordingContext* rContext) { |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 26 | static constexpr SkISize kDimensions = {128, 128}; |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 27 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 28 | const GrBackendFormat format = rContext->priv().caps()->getDefaultBackendFormat( |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 29 | GrColorType::kRGBA_8888, |
| 30 | GrRenderable::kYes); |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 31 | return rContext->priv().proxyProvider()->createProxy( |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 32 | format, kDimensions, GrRenderable::kYes, 1, GrMipmapped::kNo, SkBackingFit::kExact, |
Brian Salomon | df1bd6d | 2020-03-26 20:37:01 -0400 | [diff] [blame] | 33 | SkBudgeted::kNo, GrProtected::kNo, GrInternalSurfaceFlags::kNone); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 34 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 35 | |
| 36 | typedef GrQuadAAFlags (*PerQuadAAFunc)(int i); |
| 37 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 38 | typedef void (*BulkRectTest)(skiatest::Reporter*, |
| 39 | GrDirectContext*, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 40 | PerQuadAAFunc, |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 41 | GrAAType overallAA, |
| 42 | SkBlendMode, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 43 | bool addOneByOne, |
| 44 | bool allUniqueProxies, |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 45 | int requestedTotNumQuads, |
| 46 | int expectedNumOps); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 47 | |
| 48 | //------------------------------------------------------------------------------------------------- |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 49 | static void fillrectop_creation_test(skiatest::Reporter* reporter, GrDirectContext* dContext, |
| 50 | PerQuadAAFunc perQuadAA, GrAAType overallAA, |
| 51 | SkBlendMode blendMode, bool addOneByOne, |
| 52 | bool allUniqueProxies, |
| 53 | int requestedTotNumQuads, int expectedNumOps) { |
| 54 | |
| 55 | if (addOneByOne || allUniqueProxies) { |
| 56 | return; |
| 57 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 58 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 59 | std::unique_ptr<skgpu::v1::SurfaceDrawContext> sdc = new_SDC(dContext); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 60 | |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 61 | auto quads = new GrQuadSetEntry[requestedTotNumQuads]; |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 62 | |
| 63 | for (int i = 0; i < requestedTotNumQuads; ++i) { |
| 64 | quads[i].fRect = SkRect::MakeWH(100.5f, 100.5f); // prevent the int non-AA optimization |
| 65 | quads[i].fColor = SK_PMColor4fWHITE; |
| 66 | quads[i].fLocalMatrix = SkMatrix::I(); |
| 67 | quads[i].fAAFlags = perQuadAA(i); |
| 68 | } |
| 69 | |
| 70 | GrPaint paint; |
Michael Ludwig | fe13ca3 | 2019-11-21 10:26:41 -0500 | [diff] [blame] | 71 | paint.setXPFactory(SkBlendMode_AsXPFactory(blendMode)); |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 72 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 73 | GrFillRectOp::AddFillRectOps(sdc.get(), nullptr, dContext, std::move(paint), overallAA, |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 74 | SkMatrix::I(), quads, requestedTotNumQuads); |
| 75 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 76 | GrOpsTask* opsTask = sdc->testingOnly_PeekLastOpsTask(); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 77 | int actualNumOps = opsTask->numOpChains(); |
| 78 | |
| 79 | int actualTotNumQuads = 0; |
| 80 | |
| 81 | for (int i = 0; i < actualNumOps; ++i) { |
| 82 | const GrOp* tmp = opsTask->getChain(i); |
| 83 | REPORTER_ASSERT(reporter, tmp->classID() == GrFillRectOp::ClassID()); |
| 84 | REPORTER_ASSERT(reporter, tmp->isChainTail()); |
| 85 | actualTotNumQuads += ((GrDrawOp*) tmp)->numQuads(); |
| 86 | } |
| 87 | |
| 88 | REPORTER_ASSERT(reporter, expectedNumOps == actualNumOps); |
| 89 | REPORTER_ASSERT(reporter, requestedTotNumQuads == actualTotNumQuads); |
| 90 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 91 | dContext->flushAndSubmit(); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 92 | |
| 93 | delete[] quads; |
| 94 | } |
| 95 | |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 96 | //------------------------------------------------------------------------------------------------- |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 97 | static void textureop_creation_test(skiatest::Reporter* reporter, GrDirectContext* dContext, |
| 98 | PerQuadAAFunc perQuadAA, GrAAType overallAA, |
| 99 | SkBlendMode blendMode, bool addOneByOne, |
| 100 | bool allUniqueProxies, |
| 101 | int requestedTotNumQuads, int expectedNumOps) { |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 102 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 103 | std::unique_ptr<skgpu::v1::SurfaceDrawContext> sdc = new_SDC(dContext); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 104 | |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 105 | GrSurfaceProxyView proxyViewA, proxyViewB; |
| 106 | |
| 107 | if (!allUniqueProxies) { |
| 108 | sk_sp<GrSurfaceProxy> proxyA = create_proxy(dContext); |
| 109 | sk_sp<GrSurfaceProxy> proxyB = create_proxy(dContext); |
| 110 | proxyViewA = GrSurfaceProxyView(std::move(proxyA), |
| 111 | kTopLeft_GrSurfaceOrigin, |
| 112 | GrSwizzle::RGBA()); |
| 113 | proxyViewB = GrSurfaceProxyView(std::move(proxyB), |
| 114 | kTopLeft_GrSurfaceOrigin, |
| 115 | GrSwizzle::RGBA()); |
| 116 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 117 | |
Robert Phillips | e40495d | 2021-07-20 09:40:13 -0400 | [diff] [blame] | 118 | auto set = new GrTextureSetEntry[requestedTotNumQuads]; |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 119 | |
| 120 | for (int i = 0; i < requestedTotNumQuads; ++i) { |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 121 | if (!allUniqueProxies) { |
| 122 | // Alternate between two proxies to prevent op merging if the batch API was forced to |
| 123 | // submit one op at a time (to work, this does require that all fDstRects overlap). |
| 124 | set[i].fProxyView = i % 2 == 0 ? proxyViewA : proxyViewB; |
| 125 | } else { |
| 126 | // Each op gets its own proxy to force chaining only |
| 127 | sk_sp<GrSurfaceProxy> proxyA = create_proxy(dContext); |
| 128 | set[i].fProxyView = GrSurfaceProxyView(std::move(proxyA), |
| 129 | kTopLeft_GrSurfaceOrigin, |
| 130 | GrSwizzle::RGBA()); |
| 131 | } |
| 132 | |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 133 | set[i].fSrcAlphaType = kPremul_SkAlphaType; |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 134 | set[i].fSrcRect = SkRect::MakeWH(100.0f, 100.0f); |
| 135 | set[i].fDstRect = SkRect::MakeWH(100.5f, 100.5f); // prevent the int non-AA optimization |
| 136 | set[i].fDstClipQuad = nullptr; |
| 137 | set[i].fPreViewMatrix = nullptr; |
Michael Ludwig | 1c66ad9 | 2020-07-10 08:59:44 -0400 | [diff] [blame] | 138 | set[i].fColor = {1.f, 1.f, 1.f, 1.f}; |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 139 | set[i].fAAFlags = perQuadAA(i); |
| 140 | } |
| 141 | |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 142 | if (addOneByOne) { |
| 143 | for (int i = 0; i < requestedTotNumQuads; ++i) { |
| 144 | DrawQuad quad; |
| 145 | |
| 146 | quad.fDevice = GrQuad::MakeFromRect(set[i].fDstRect, SkMatrix::I()); |
| 147 | quad.fLocal = GrQuad(set[i].fSrcRect); |
| 148 | quad.fEdgeFlags = set[i].fAAFlags; |
| 149 | |
Herb Derby | c76d409 | 2020-10-07 16:46:15 -0400 | [diff] [blame] | 150 | GrOp::Owner op = GrTextureOp::Make(dContext, |
| 151 | set[i].fProxyView, |
| 152 | set[i].fSrcAlphaType, |
| 153 | nullptr, |
| 154 | GrSamplerState::Filter::kNearest, |
| 155 | GrSamplerState::MipmapMode::kNone, |
| 156 | set[i].fColor, |
| 157 | GrTextureOp::Saturate::kYes, |
| 158 | blendMode, |
| 159 | overallAA, |
| 160 | &quad, |
| 161 | nullptr); |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 162 | sdc->addDrawOp(nullptr, std::move(op)); |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 163 | } |
| 164 | } else { |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 165 | GrTextureOp::AddTextureSetOps(sdc.get(), |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 166 | nullptr, |
| 167 | dContext, |
| 168 | set, |
| 169 | requestedTotNumQuads, |
| 170 | requestedTotNumQuads, // We alternate so proxyCnt == cnt |
| 171 | GrSamplerState::Filter::kNearest, |
| 172 | GrSamplerState::MipmapMode::kNone, |
| 173 | GrTextureOp::Saturate::kYes, |
| 174 | blendMode, |
| 175 | overallAA, |
| 176 | SkCanvas::kStrict_SrcRectConstraint, |
| 177 | SkMatrix::I(), |
| 178 | nullptr); |
| 179 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 180 | |
Robert Phillips | 4dca831 | 2021-07-28 15:13:20 -0400 | [diff] [blame] | 181 | GrOpsTask* opsTask = sdc->testingOnly_PeekLastOpsTask(); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 182 | int actualNumOps = opsTask->numOpChains(); |
| 183 | |
| 184 | int actualTotNumQuads = 0; |
| 185 | |
Michael Ludwig | fe13ca3 | 2019-11-21 10:26:41 -0500 | [diff] [blame] | 186 | if (blendMode != SkBlendMode::kSrcOver || |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 187 | !dContext->priv().caps()->dynamicStateArrayGeometryProcessorTextureSupport()) { |
Michael Ludwig | fe13ca3 | 2019-11-21 10:26:41 -0500 | [diff] [blame] | 188 | // In either of these two cases, GrTextureOp creates one op per quad instead. Since |
| 189 | // each entry alternates proxies but overlaps geometrically, this will prevent the ops |
| 190 | // from being merged back into fewer ops. |
| 191 | expectedNumOps = requestedTotNumQuads; |
| 192 | } |
| 193 | uint32_t expectedOpID = blendMode == SkBlendMode::kSrcOver ? GrTextureOp::ClassID() |
| 194 | : GrFillRectOp::ClassID(); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 195 | for (int i = 0; i < actualNumOps; ++i) { |
| 196 | const GrOp* tmp = opsTask->getChain(i); |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 197 | REPORTER_ASSERT(reporter, allUniqueProxies || tmp->isChainTail()); |
| 198 | while (tmp) { |
| 199 | REPORTER_ASSERT(reporter, tmp->classID() == expectedOpID); |
| 200 | actualTotNumQuads += ((GrDrawOp*) tmp)->numQuads(); |
| 201 | tmp = tmp->nextInChain(); |
| 202 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | REPORTER_ASSERT(reporter, expectedNumOps == actualNumOps); |
| 206 | REPORTER_ASSERT(reporter, requestedTotNumQuads == actualTotNumQuads); |
| 207 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 208 | dContext->flushAndSubmit(); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 209 | |
| 210 | delete[] set; |
| 211 | } |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 212 | |
| 213 | //------------------------------------------------------------------------------------------------- |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 214 | static void run_test(GrDirectContext* dContext, skiatest::Reporter* reporter, BulkRectTest test) { |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 215 | |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 216 | // This is the simple case where there is no AA at all. We expect 2 non-AA clumps of quads. |
| 217 | { |
| 218 | auto noAA = [](int i) -> GrQuadAAFlags { |
| 219 | return GrQuadAAFlags::kNone; |
| 220 | }; |
| 221 | |
| 222 | static const int kNumExpectedOps = 2; |
| 223 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 224 | test(reporter, dContext, noAA, GrAAType::kNone, SkBlendMode::kSrcOver, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 225 | false, false, 2*GrResourceProvider::MaxNumNonAAQuads(), kNumExpectedOps); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | // This is the same as the above case except the overall AA is kCoverage. However, since |
| 229 | // the per-quad AA is still none, all the quads should be downgraded to non-AA. |
| 230 | { |
| 231 | auto noAA = [](int i) -> GrQuadAAFlags { |
| 232 | return GrQuadAAFlags::kNone; |
| 233 | }; |
| 234 | |
| 235 | static const int kNumExpectedOps = 2; |
| 236 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 237 | test(reporter, dContext, noAA, GrAAType::kCoverage, SkBlendMode::kSrcOver, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 238 | false, false, 2*GrResourceProvider::MaxNumNonAAQuads(), kNumExpectedOps); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | // This case has an overall AA of kCoverage but the per-quad AA alternates. |
| 242 | // We should end up with several aa-sized clumps |
| 243 | { |
| 244 | auto alternateAA = [](int i) -> GrQuadAAFlags { |
| 245 | return (i % 2) ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone; |
| 246 | }; |
| 247 | |
| 248 | int numExpectedOps = 2*GrResourceProvider::MaxNumNonAAQuads() / |
| 249 | GrResourceProvider::MaxNumAAQuads(); |
| 250 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 251 | test(reporter, dContext, alternateAA, GrAAType::kCoverage, SkBlendMode::kSrcOver, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 252 | false, false, 2*GrResourceProvider::MaxNumNonAAQuads(), numExpectedOps); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | // In this case we have a run of MaxNumAAQuads non-AA quads and then AA quads. This |
| 256 | // exercises the case where we have a clump of quads that can't be upgraded to AA bc of |
| 257 | // its size. We expect one clump of non-AA quads followed by one clump of AA quads. |
| 258 | { |
| 259 | auto runOfNonAA = [](int i) -> GrQuadAAFlags { |
| 260 | return (i < GrResourceProvider::MaxNumAAQuads()) ? GrQuadAAFlags::kNone |
| 261 | : GrQuadAAFlags::kAll; |
| 262 | }; |
| 263 | |
| 264 | static const int kNumExpectedOps = 2; |
| 265 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 266 | test(reporter, dContext, runOfNonAA, GrAAType::kCoverage, SkBlendMode::kSrcOver, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 267 | false, false, 2*GrResourceProvider::MaxNumAAQuads(), kNumExpectedOps); |
Michael Ludwig | fe13ca3 | 2019-11-21 10:26:41 -0500 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | // In this case we use a blend mode other than src-over, which hits the GrFillRectOp fallback |
| 271 | // code path for GrTextureOp. We pass in the expected results if batching was successful, to |
| 272 | // that bulk_fill_rect_create_test batches on all modes; bulk_texture_rect_create_test is |
| 273 | // responsible for revising its expectations. |
| 274 | { |
| 275 | auto fixedAA = [](int i) -> GrQuadAAFlags { |
| 276 | return GrQuadAAFlags::kAll; |
| 277 | }; |
| 278 | |
| 279 | static const int kNumExpectedOps = 2; |
| 280 | |
Robert Phillips | fe4b481 | 2020-07-17 14:15:51 -0400 | [diff] [blame] | 281 | test(reporter, dContext, fixedAA, GrAAType::kCoverage, SkBlendMode::kSrcATop, |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 282 | false, false, 2*GrResourceProvider::MaxNumAAQuads(), kNumExpectedOps); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 283 | } |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 284 | |
| 285 | // This repros crbug.com/1108475, where we create 1024 non-AA texture ops w/ one coverage-AA |
| 286 | // texture op in the middle. Because each op has its own texture, all the texture ops |
| 287 | // get chained together so the quad count can exceed the AA maximum. |
| 288 | { |
| 289 | auto onlyOneAA = [](int i) -> GrQuadAAFlags { |
| 290 | return i == 256 ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone; |
| 291 | }; |
| 292 | |
| 293 | static const int kNumExpectedOps = 3; |
| 294 | |
| 295 | test(reporter, dContext, onlyOneAA, GrAAType::kCoverage, SkBlendMode::kSrcOver, |
| 296 | true, true, 1024, kNumExpectedOps); |
| 297 | } |
| 298 | |
| 299 | // This repros a problem related to crbug.com/1108475. In this case, the bulk creation |
| 300 | // method had no way to break up the set of texture ops at the AA quad limit. |
| 301 | { |
| 302 | auto onlyOneAA = [](int i) -> GrQuadAAFlags { |
| 303 | return i == 256 ? GrQuadAAFlags::kAll : GrQuadAAFlags::kNone; |
| 304 | }; |
| 305 | |
| 306 | static const int kNumExpectedOps = 2; |
| 307 | |
| 308 | test(reporter, dContext, onlyOneAA, GrAAType::kCoverage, SkBlendMode::kSrcOver, |
| 309 | false, true, 1024, kNumExpectedOps); |
| 310 | } |
| 311 | |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BulkFillRectTest, reporter, ctxInfo) { |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 315 | run_test(ctxInfo.directContext(), reporter, fillrectop_creation_test); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 316 | } |
| 317 | |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 318 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(BulkTextureRectTest, reporter, ctxInfo) { |
Robert Phillips | 6bf1125 | 2020-07-31 12:15:00 -0400 | [diff] [blame] | 319 | run_test(ctxInfo.directContext(), reporter, textureop_creation_test); |
Robert Phillips | e837e61 | 2019-11-15 11:02:50 -0500 | [diff] [blame] | 320 | } |