joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/gpu/GrDrawOpAtlas.h" |
Robert Phillips | 32f2818 | 2017-02-28 16:20:03 -0500 | [diff] [blame] | 9 | |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 10 | #include <memory> |
| 11 | |
Mike Klein | 8aa0edf | 2020-10-16 11:04:18 -0500 | [diff] [blame] | 12 | #include "include/private/SkTPin.h" |
Robert Phillips | 03e4c95 | 2019-11-26 16:20:22 -0500 | [diff] [blame] | 13 | #include "src/core/SkOpts.h" |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 14 | #include "src/gpu/GrBackendUtils.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/gpu/GrOnFlushResourceProvider.h" |
| 16 | #include "src/gpu/GrOpFlushState.h" |
| 17 | #include "src/gpu/GrProxyProvider.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/GrResourceProvider.h" |
Greg Daniel | 7fd7a8a | 2019-10-10 16:10:31 -0400 | [diff] [blame] | 19 | #include "src/gpu/GrResourceProviderPriv.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/gpu/GrSurfaceProxyPriv.h" |
Greg Daniel | 456f9b5 | 2020-03-05 19:14:18 +0000 | [diff] [blame] | 21 | #include "src/gpu/GrTexture.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 22 | #include "src/gpu/GrTracing.h" |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 23 | |
Jim Van Verth | fb39510 | 2020-02-03 10:11:19 -0500 | [diff] [blame] | 24 | #ifdef DUMP_ATLAS_DATA |
| 25 | static bool gDumpAtlasData = false; |
| 26 | #endif |
| 27 | |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 28 | #ifdef SK_DEBUG |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 29 | void GrDrawOpAtlas::validate(const AtlasLocator& atlasLocator) const { |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 30 | // Verify that the plotIndex stored in the PlotLocator is consistent with the glyph rectangle |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 31 | int numPlotsX = fTextureWidth / fPlotWidth; |
| 32 | int numPlotsY = fTextureHeight / fPlotHeight; |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 33 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 34 | int plotIndex = atlasLocator.plotIndex(); |
Herb Derby | e1a0089 | 2020-08-31 15:12:27 -0400 | [diff] [blame] | 35 | auto topLeft = atlasLocator.topLeft(); |
| 36 | int plotX = topLeft.x() / fPlotWidth; |
| 37 | int plotY = topLeft.y() / fPlotHeight; |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 38 | SkASSERT(plotIndex == (numPlotsY - plotY - 1) * numPlotsX + (numPlotsX - plotX - 1)); |
| 39 | } |
| 40 | #endif |
| 41 | |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 42 | // When proxy allocation is deferred until flush time the proxies acting as atlases require |
| 43 | // special handling. This is because the usage that can be determined from the ops themselves |
| 44 | // isn't sufficient. Independent of the ops there will be ASAP and inline uploads to the |
| 45 | // atlases. Extending the usage interval of any op that uses an atlas to the start of the |
| 46 | // flush (as is done for proxies that are used for sw-generated masks) also won't work because |
| 47 | // the atlas persists even beyond the last use in an op - for a given flush. Given this, atlases |
| 48 | // must explicitly manage the lifetime of their backing proxies via the onFlushCallback system |
| 49 | // (which calls this method). |
| 50 | void GrDrawOpAtlas::instantiate(GrOnFlushResourceProvider* onFlushResourceProvider) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 51 | for (uint32_t i = 0; i < fNumActivePages; ++i) { |
| 52 | // All the atlas pages are now instantiated at flush time in the activeNewPage method. |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 53 | SkASSERT(fViews[i].proxy() && fViews[i].proxy()->isInstantiated()); |
Robert Phillips | cd5099c | 2018-02-09 09:56:56 -0500 | [diff] [blame] | 54 | } |
| 55 | } |
| 56 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 57 | std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrProxyProvider* proxyProvider, |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 58 | const GrBackendFormat& format, |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 59 | GrColorType colorType, int width, |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 60 | int height, int plotWidth, int plotHeight, |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 61 | GenerationCounter* generationCounter, |
Brian Salomon | 9f545bc | 2017-11-06 10:36:57 -0500 | [diff] [blame] | 62 | AllowMultitexturing allowMultitexturing, |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 63 | EvictionCallback* evictor) { |
Robert Phillips | 0a15cc6 | 2019-07-30 12:49:10 -0400 | [diff] [blame] | 64 | if (!format.isValid()) { |
| 65 | return nullptr; |
| 66 | } |
| 67 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 68 | std::unique_ptr<GrDrawOpAtlas> atlas(new GrDrawOpAtlas(proxyProvider, format, colorType, |
| 69 | width, height, plotWidth, plotHeight, |
| 70 | generationCounter, |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 71 | allowMultitexturing)); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 72 | if (!atlas->getViews()[0].proxy()) { |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 73 | return nullptr; |
| 74 | } |
| 75 | |
Herb Derby | a90ed95 | 2020-01-28 15:55:58 -0500 | [diff] [blame] | 76 | if (evictor != nullptr) { |
| 77 | atlas->fEvictionCallbacks.emplace_back(evictor); |
| 78 | } |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 79 | return atlas; |
| 80 | } |
| 81 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 82 | //////////////////////////////////////////////////////////////////////////////// |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 83 | GrDrawOpAtlas::Plot::Plot(int pageIndex, int plotIndex, GenerationCounter* generationCounter, |
| 84 | int offX, int offY, int width, int height, GrColorType colorType) |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 85 | : fLastUpload(GrDeferredUploadToken::AlreadyFlushedToken()) |
| 86 | , fLastUse(GrDeferredUploadToken::AlreadyFlushedToken()) |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 87 | , fFlushesSinceLastUse(0) |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 88 | , fPageIndex(pageIndex) |
| 89 | , fPlotIndex(plotIndex) |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 90 | , fGenerationCounter(generationCounter) |
| 91 | , fGenID(fGenerationCounter->next()) |
Robert Phillips | bf5bf74 | 2020-04-13 09:29:08 -0400 | [diff] [blame] | 92 | , fPlotLocator(fPageIndex, fPlotIndex, fGenID) |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 93 | , fData(nullptr) |
| 94 | , fWidth(width) |
| 95 | , fHeight(height) |
| 96 | , fX(offX) |
| 97 | , fY(offY) |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 98 | , fRectanizer(width, height) |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 99 | , fOffset(SkIPoint16::Make(fX * fWidth, fY * fHeight)) |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 100 | , fColorType(colorType) |
| 101 | , fBytesPerPixel(GrColorTypeBytesPerPixel(colorType)) |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 102 | #ifdef SK_DEBUG |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 103 | , fDirty(false) |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 104 | #endif |
| 105 | { |
Jim Van Verth | a8c55fa | 2018-02-20 15:38:08 -0500 | [diff] [blame] | 106 | // We expect the allocated dimensions to be a multiple of 4 bytes |
| 107 | SkASSERT(((width*fBytesPerPixel) & 0x3) == 0); |
| 108 | // The padding for faster uploads only works for 1, 2 and 4 byte texels |
| 109 | SkASSERT(fBytesPerPixel != 3 && fBytesPerPixel <= 4); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 110 | fDirtyRect.setEmpty(); |
| 111 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 112 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 113 | GrDrawOpAtlas::Plot::~Plot() { |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 114 | sk_free(fData); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 115 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 116 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 117 | bool GrDrawOpAtlas::Plot::addSubImage( |
| 118 | int width, int height, const void* image, AtlasLocator* atlasLocator) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 119 | SkASSERT(width <= fWidth && height <= fHeight); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 120 | |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 121 | SkIPoint16 loc; |
| 122 | if (!fRectanizer.addRect(width, height, &loc)) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 123 | return false; |
joshualitt | b4c507e | 2015-04-08 08:07:59 -0700 | [diff] [blame] | 124 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 125 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 126 | GrIRect16 rect = GrIRect16::MakeXYWH(loc.fX, loc.fY, width, height); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 127 | |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 128 | if (!fData) { |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 129 | fData = reinterpret_cast<unsigned char*>( |
| 130 | sk_calloc_throw(fBytesPerPixel * fWidth * fHeight)); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 131 | } |
| 132 | size_t rowBytes = width * fBytesPerPixel; |
| 133 | const unsigned char* imagePtr = (const unsigned char*)image; |
| 134 | // point ourselves at the right starting spot |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 135 | unsigned char* dataPtr = fData; |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 136 | dataPtr += fBytesPerPixel * fWidth * rect.fTop; |
| 137 | dataPtr += fBytesPerPixel * rect.fLeft; |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 138 | // copy into the data buffer, swizzling as we go if this is ARGB data |
Greg Daniel | b58a3c7 | 2020-01-23 10:05:14 -0500 | [diff] [blame] | 139 | if (4 == fBytesPerPixel && kN32_SkColorType == kBGRA_8888_SkColorType) { |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 140 | for (int i = 0; i < height; ++i) { |
Mike Klein | 6e78ae5 | 2018-09-19 13:37:16 -0400 | [diff] [blame] | 141 | SkOpts::RGBA_to_BGRA((uint32_t*)dataPtr, (const uint32_t*)imagePtr, width); |
Brian Osman | cce3e58 | 2016-10-14 11:42:20 -0400 | [diff] [blame] | 142 | dataPtr += fBytesPerPixel * fWidth; |
| 143 | imagePtr += rowBytes; |
| 144 | } |
| 145 | } else { |
| 146 | for (int i = 0; i < height; ++i) { |
| 147 | memcpy(dataPtr, imagePtr, rowBytes); |
| 148 | dataPtr += fBytesPerPixel * fWidth; |
| 149 | imagePtr += rowBytes; |
| 150 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 153 | fDirtyRect.join({rect.fLeft, rect.fTop, rect.fRight, rect.fBottom}); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 154 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 155 | rect.offset(fOffset.fX, fOffset.fY); |
| 156 | atlasLocator->updateRect(rect); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 157 | SkDEBUGCODE(fDirty = true;) |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 158 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 159 | return true; |
| 160 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 161 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 162 | void GrDrawOpAtlas::Plot::uploadToTexture(GrDeferredTextureUploadWritePixelsFn& writePixels, |
Robert Phillips | acaa607 | 2017-07-28 10:54:53 -0400 | [diff] [blame] | 163 | GrTextureProxy* proxy) { |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 164 | // We should only be issuing uploads if we are in fact dirty |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 165 | SkASSERT(fDirty && fData && proxy && proxy->peekTexture()); |
Brian Osman | 39c08ac | 2017-07-26 09:36:09 -0400 | [diff] [blame] | 166 | TRACE_EVENT0("skia.gpu", TRACE_FUNC); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 167 | size_t rowBytes = fBytesPerPixel * fWidth; |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 168 | const unsigned char* dataPtr = fData; |
Jim Van Verth | a8c55fa | 2018-02-20 15:38:08 -0500 | [diff] [blame] | 169 | // Clamp to 4-byte aligned boundaries |
| 170 | unsigned int clearBits = 0x3 / fBytesPerPixel; |
| 171 | fDirtyRect.fLeft &= ~clearBits; |
| 172 | fDirtyRect.fRight += clearBits; |
| 173 | fDirtyRect.fRight &= ~clearBits; |
| 174 | SkASSERT(fDirtyRect.fRight <= fWidth); |
| 175 | // Set up dataPtr |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 176 | dataPtr += rowBytes * fDirtyRect.fTop; |
| 177 | dataPtr += fBytesPerPixel * fDirtyRect.fLeft; |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 178 | |
Brian Salomon | e2078f1 | 2021-05-24 12:40:46 -0400 | [diff] [blame] | 179 | writePixels(proxy, |
| 180 | fDirtyRect.makeOffset(fOffset.fX, fOffset.fY), |
| 181 | fColorType, |
| 182 | dataPtr, |
| 183 | rowBytes); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 184 | fDirtyRect.setEmpty(); |
| 185 | SkDEBUGCODE(fDirty = false;) |
| 186 | } |
| 187 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 188 | void GrDrawOpAtlas::Plot::resetRects() { |
Herb Derby | 73c7587 | 2020-01-22 18:09:16 -0500 | [diff] [blame] | 189 | fRectanizer.reset(); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 190 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 191 | fGenID = fGenerationCounter->next(); |
Robert Phillips | bf5bf74 | 2020-04-13 09:29:08 -0400 | [diff] [blame] | 192 | fPlotLocator = PlotLocator(fPageIndex, fPlotIndex, fGenID); |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 193 | fLastUpload = GrDeferredUploadToken::AlreadyFlushedToken(); |
| 194 | fLastUse = GrDeferredUploadToken::AlreadyFlushedToken(); |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 195 | |
| 196 | // zero out the plot |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 197 | if (fData) { |
| 198 | sk_bzero(fData, fBytesPerPixel * fWidth * fHeight); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 199 | } |
| 200 | |
joshualitt | 5df175e | 2015-11-18 13:37:54 -0800 | [diff] [blame] | 201 | fDirtyRect.setEmpty(); |
| 202 | SkDEBUGCODE(fDirty = false;) |
| 203 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 204 | |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 205 | /////////////////////////////////////////////////////////////////////////////// |
| 206 | |
Robert Phillips | a4bb064 | 2020-08-11 09:55:17 -0400 | [diff] [blame] | 207 | GrDrawOpAtlas::GrDrawOpAtlas(GrProxyProvider* proxyProvider, const GrBackendFormat& format, |
| 208 | GrColorType colorType, int width, int height, |
| 209 | int plotWidth, int plotHeight, GenerationCounter* generationCounter, |
| 210 | AllowMultitexturing allowMultitexturing) |
Greg Daniel | 4065d45 | 2018-11-16 15:43:41 -0500 | [diff] [blame] | 211 | : fFormat(format) |
Robert Phillips | 42dda08 | 2019-05-14 13:29:45 -0400 | [diff] [blame] | 212 | , fColorType(colorType) |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 213 | , fTextureWidth(width) |
| 214 | , fTextureHeight(height) |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 215 | , fPlotWidth(plotWidth) |
| 216 | , fPlotHeight(plotHeight) |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 217 | , fGenerationCounter(generationCounter) |
| 218 | , fAtlasGeneration(fGenerationCounter->next()) |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 219 | , fPrevFlushToken(GrDeferredUploadToken::AlreadyFlushedToken()) |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 220 | , fFlushesSinceLastUse(0) |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 221 | , fMaxPages(AllowMultitexturing::kYes == allowMultitexturing ? kMaxMultitexturePages : 1) |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 222 | , fNumActivePages(0) { |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 223 | int numPlotsX = width/plotWidth; |
| 224 | int numPlotsY = height/plotHeight; |
Herb Derby | bbf5fb5 | 2018-10-15 16:39:39 -0400 | [diff] [blame] | 225 | SkASSERT(numPlotsX * numPlotsY <= GrDrawOpAtlas::kMaxPlots); |
Jim Van Verth | d74f3f2 | 2017-08-31 16:44:08 -0400 | [diff] [blame] | 226 | SkASSERT(fPlotWidth * numPlotsX == fTextureWidth); |
| 227 | SkASSERT(fPlotHeight * numPlotsY == fTextureHeight); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 228 | |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 229 | fNumPlots = numPlotsX * numPlotsY; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 230 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 231 | this->createPages(proxyProvider, generationCounter); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 234 | inline void GrDrawOpAtlas::processEviction(PlotLocator plotLocator) { |
John Stiles | bd3ffa4 | 2020-07-30 20:24:57 -0400 | [diff] [blame] | 235 | for (EvictionCallback* evictor : fEvictionCallbacks) { |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 236 | evictor->evict(plotLocator); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 237 | } |
Herb Derby | 1a496c5 | 2020-01-22 17:26:56 -0500 | [diff] [blame] | 238 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 239 | fAtlasGeneration = fGenerationCounter->next(); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 242 | inline bool GrDrawOpAtlas::updatePlot(GrDeferredUploadTarget* target, |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 243 | AtlasLocator* atlasLocator, Plot* plot) { |
| 244 | int pageIdx = plot->pageIndex(); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 245 | this->makeMRU(plot, pageIdx); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 246 | |
| 247 | // If our most recent upload has already occurred then we have to insert a new |
| 248 | // upload. Otherwise, we already have a scheduled upload that hasn't yet ocurred. |
| 249 | // This new update will piggy back on that previously scheduled update. |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 250 | if (plot->lastUploadToken() < target->tokenTracker()->nextTokenToFlush()) { |
jvanverth | c3d706f | 2016-04-20 10:33:27 -0700 | [diff] [blame] | 251 | // With c+14 we could move sk_sp into lamba to only ref once. |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 252 | sk_sp<Plot> plotsp(SkRef(plot)); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 253 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 254 | GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy(); |
| 255 | SkASSERT(proxy && proxy->isInstantiated()); // This is occurring at flush time |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 256 | |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 257 | GrDeferredUploadToken lastUploadToken = target->addASAPUpload( |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 258 | [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) { |
| 259 | plotsp->uploadToTexture(writePixels, proxy); |
| 260 | }); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 261 | plot->setLastUploadToken(lastUploadToken); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 262 | } |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 263 | atlasLocator->updatePlotLocator(plot->plotLocator()); |
| 264 | SkDEBUGCODE(this->validate(*atlasLocator);) |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 265 | return true; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 268 | bool GrDrawOpAtlas::uploadToPage(unsigned int pageIdx, GrDeferredUploadTarget* target, int width, |
| 269 | int height, const void* image, AtlasLocator* atlasLocator) { |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 270 | SkASSERT(fViews[pageIdx].proxy() && fViews[pageIdx].proxy()->isInstantiated()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 271 | |
| 272 | // look through all allocated plots for one we can share, in Most Recently Refed order |
| 273 | PlotList::Iter plotIter; |
| 274 | plotIter.init(fPages[pageIdx].fPlotList, PlotList::Iter::kHead_IterStart); |
| 275 | |
| 276 | for (Plot* plot = plotIter.get(); plot; plot = plotIter.next()) { |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 277 | SkASSERT(GrBackendFormatBytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == |
| 278 | plot->bpp()); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 279 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 280 | if (plot->addSubImage(width, height, image, atlasLocator)) { |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 281 | return this->updatePlot(target, atlasLocator, plot); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 282 | } |
| 283 | } |
| 284 | |
| 285 | return false; |
| 286 | } |
| 287 | |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 288 | // Number of atlas-related flushes beyond which we consider a plot to no longer be in use. |
| 289 | // |
| 290 | // This value is somewhat arbitrary -- the idea is to keep it low enough that |
| 291 | // a page with unused plots will get removed reasonably quickly, but allow it |
| 292 | // to hang around for a bit in case it's needed. The assumption is that flushes |
| 293 | // are rare; i.e., we are not continually refreshing the frame. |
Jonathan Backer | 40c683a | 2020-05-04 15:00:02 -0400 | [diff] [blame] | 294 | static constexpr auto kPlotRecentlyUsedCount = 32; |
| 295 | static constexpr auto kAtlasRecentlyUsedCount = 128; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 296 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 297 | GrDrawOpAtlas::ErrorCode GrDrawOpAtlas::addToAtlas(GrResourceProvider* resourceProvider, |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 298 | GrDeferredUploadTarget* target, |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 299 | int width, int height, const void* image, |
| 300 | AtlasLocator* atlasLocator) { |
bsalomon | 6d6b6ad | 2016-07-13 14:45:28 -0700 | [diff] [blame] | 301 | if (width > fPlotWidth || height > fPlotHeight) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 302 | return ErrorCode::kError; |
bsalomon | 6d6b6ad | 2016-07-13 14:45:28 -0700 | [diff] [blame] | 303 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 304 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 305 | // Look through each page to see if we can upload without having to flush |
| 306 | // We prioritize this upload to the first pages, not the most recently used, to make it easier |
| 307 | // to remove unused pages in reverse page order. |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 308 | for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) { |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 309 | if (this->uploadToPage(pageIdx, target, width, height, image, atlasLocator)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 310 | return ErrorCode::kSucceeded; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 311 | } |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 312 | } |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 313 | |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 314 | // If the above fails, then see if the least recently used plot per page has already been |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 315 | // flushed to the gpu if we're at max page allocation, or if the plot has aged out otherwise. |
| 316 | // We wait until we've grown to the full number of pages to begin evicting already flushed |
| 317 | // plots so that we can maximize the opportunity for reuse. |
Jim Van Verth | 712fe73 | 2017-09-25 16:53:49 -0400 | [diff] [blame] | 318 | // As before we prioritize this upload to the first pages, not the most recently used. |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 319 | if (fNumActivePages == this->maxPages()) { |
| 320 | for (unsigned int pageIdx = 0; pageIdx < fNumActivePages; ++pageIdx) { |
| 321 | Plot* plot = fPages[pageIdx].fPlotList.tail(); |
| 322 | SkASSERT(plot); |
Jim Van Verth | ba98b7d | 2018-12-05 12:33:43 -0500 | [diff] [blame] | 323 | if (plot->lastUseToken() < target->tokenTracker()->nextTokenToFlush()) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 324 | this->processEvictionAndResetRects(plot); |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 325 | SkASSERT(GrBackendFormatBytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 326 | plot->bpp()); |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 327 | SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, atlasLocator); |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 328 | SkASSERT(verify); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 329 | if (!this->updatePlot(target, atlasLocator, plot)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 330 | return ErrorCode::kError; |
| 331 | } |
| 332 | return ErrorCode::kSucceeded; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 333 | } |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 334 | } |
| 335 | } else { |
| 336 | // If we haven't activated all the available pages, try to create a new one and add to it |
| 337 | if (!this->activateNewPage(resourceProvider)) { |
| 338 | return ErrorCode::kError; |
| 339 | } |
| 340 | |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 341 | if (this->uploadToPage(fNumActivePages-1, target, width, height, image, atlasLocator)) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 342 | return ErrorCode::kSucceeded; |
| 343 | } else { |
| 344 | // If we fail to upload to a newly activated page then something has gone terribly |
| 345 | // wrong - return an error |
| 346 | return ErrorCode::kError; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 347 | } |
| 348 | } |
| 349 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 350 | if (!fNumActivePages) { |
| 351 | return ErrorCode::kError; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 354 | // Try to find a plot that we can perform an inline upload to. |
| 355 | // We prioritize this upload in reverse order of pages to counterbalance the order above. |
| 356 | Plot* plot = nullptr; |
Robert Phillips | 6250f29 | 2018-03-01 10:53:45 -0500 | [diff] [blame] | 357 | for (int pageIdx = ((int)fNumActivePages)-1; pageIdx >= 0; --pageIdx) { |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 358 | Plot* currentPlot = fPages[pageIdx].fPlotList.tail(); |
Robert Phillips | 40a29d7 | 2018-01-18 12:59:22 -0500 | [diff] [blame] | 359 | if (currentPlot->lastUseToken() != target->tokenTracker()->nextDrawToken()) { |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 360 | plot = currentPlot; |
| 361 | break; |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 362 | } |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 365 | // If we can't find a plot that is not used in a draw currently being prepared by an op, then |
| 366 | // we have to fail. This gives the op a chance to enqueue the draw, and call back into this |
| 367 | // function. When that draw is enqueued, the draw token advances, and the subsequent call will |
| 368 | // continue past this branch and prepare an inline upload that will occur after the enqueued |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 369 | // draw which references the plot's pre-upload content. |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 370 | if (!plot) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 371 | return ErrorCode::kTryAgain; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 372 | } |
| 373 | |
Herb Derby | 4d72171 | 2020-01-24 14:31:16 -0500 | [diff] [blame] | 374 | this->processEviction(plot->plotLocator()); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 375 | int pageIdx = plot->pageIndex(); |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 376 | fPages[pageIdx].fPlotList.remove(plot); |
Robert Phillips | 6d3bc29 | 2020-04-06 10:29:28 -0400 | [diff] [blame] | 377 | sk_sp<Plot>& newPlot = fPages[pageIdx].fPlotArray[plot->plotIndex()]; |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 378 | newPlot.reset(plot->clone()); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 379 | |
Jim Van Verth | a950b63 | 2017-09-12 11:54:11 -0400 | [diff] [blame] | 380 | fPages[pageIdx].fPlotList.addToHead(newPlot.get()); |
Greg Daniel | 0eca74c | 2020-10-01 13:46:00 -0400 | [diff] [blame] | 381 | SkASSERT(GrBackendFormatBytesPerPixel(fViews[pageIdx].proxy()->backendFormat()) == |
| 382 | newPlot->bpp()); |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 383 | SkDEBUGCODE(bool verify = )newPlot->addSubImage(width, height, image, atlasLocator); |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 384 | SkASSERT(verify); |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 385 | |
robertphillips | 1f0e350 | 2015-11-10 10:19:50 -0800 | [diff] [blame] | 386 | // Note that this plot will be uploaded inline with the draws whereas the |
Brian Salomon | 29b60c9 | 2017-10-31 14:42:10 -0400 | [diff] [blame] | 387 | // one it displaced most likely was uploaded ASAP. |
Robert Phillips | e87106d | 2020-04-09 14:21:33 -0400 | [diff] [blame] | 388 | // With c++14 we could move sk_sp into lambda to only ref once. |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 389 | sk_sp<Plot> plotsp(SkRef(newPlot.get())); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 390 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 391 | GrTextureProxy* proxy = fViews[pageIdx].asTextureProxy(); |
| 392 | SkASSERT(proxy && proxy->isInstantiated()); |
bsalomon | 342bfc2 | 2016-04-01 06:06:20 -0700 | [diff] [blame] | 393 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 394 | GrDeferredUploadToken lastUploadToken = target->addInlineUpload( |
| 395 | [plotsp, proxy](GrDeferredTextureUploadWritePixelsFn& writePixels) { |
| 396 | plotsp->uploadToTexture(writePixels, proxy); |
| 397 | }); |
Robert Phillips | 256c37b | 2017-03-01 14:32:46 -0500 | [diff] [blame] | 398 | newPlot->setLastUploadToken(lastUploadToken); |
| 399 | |
Herb Derby | 06296c6 | 2020-08-28 13:42:31 -0400 | [diff] [blame] | 400 | atlasLocator->updatePlotLocator(newPlot->plotLocator()); |
| 401 | SkDEBUGCODE(this->validate(*atlasLocator);) |
robertphillips | 2b0536f | 2015-11-06 14:10:42 -0800 | [diff] [blame] | 402 | |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 403 | return ErrorCode::kSucceeded; |
joshualitt | 5bf99f1 | 2015-03-13 11:47:42 -0700 | [diff] [blame] | 404 | } |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 405 | |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 406 | void GrDrawOpAtlas::compact(GrDeferredUploadToken startTokenForNextFlush) { |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 407 | if (fNumActivePages < 1) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 408 | fPrevFlushToken = startTokenForNextFlush; |
| 409 | return; |
| 410 | } |
| 411 | |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 412 | // For all plots, reset number of flushes since used if used this frame. |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 413 | PlotList::Iter plotIter; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 414 | bool atlasUsedThisFlush = false; |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 415 | for (uint32_t pageIndex = 0; pageIndex < fNumActivePages; ++pageIndex) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 416 | plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 417 | while (Plot* plot = plotIter.get()) { |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 418 | // Reset number of flushes since used |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 419 | if (plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 420 | plot->resetFlushesSinceLastUsed(); |
| 421 | atlasUsedThisFlush = true; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 422 | } |
| 423 | |
| 424 | plotIter.next(); |
| 425 | } |
| 426 | } |
| 427 | |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 428 | if (atlasUsedThisFlush) { |
| 429 | fFlushesSinceLastUse = 0; |
| 430 | } else { |
| 431 | ++fFlushesSinceLastUse; |
| 432 | } |
| 433 | |
| 434 | // We only try to compact if the atlas was used in the recently completed flush or |
| 435 | // hasn't been used in a long time. |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 436 | // This is to handle the case where a lot of text or path rendering has occurred but then just |
| 437 | // a blinking cursor is drawn. |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 438 | if (atlasUsedThisFlush || fFlushesSinceLastUse > kAtlasRecentlyUsedCount) { |
Jim Van Verth | cad0acf | 2018-02-16 18:41:41 -0500 | [diff] [blame] | 439 | SkTArray<Plot*> availablePlots; |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 440 | uint32_t lastPageIndex = fNumActivePages - 1; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 441 | |
| 442 | // For all plots but the last one, update number of flushes since used, and check to see |
| 443 | // if there are any in the first pages that the last page can safely upload to. |
| 444 | for (uint32_t pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex) { |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 445 | #ifdef DUMP_ATLAS_DATA |
| 446 | if (gDumpAtlasData) { |
| 447 | SkDebugf("page %d: ", pageIndex); |
| 448 | } |
| 449 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 450 | plotIter.init(fPages[pageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 451 | while (Plot* plot = plotIter.get()) { |
| 452 | // Update number of flushes since plot was last used |
| 453 | // We only increment the 'sinceLastUsed' count for flushes where the atlas was used |
| 454 | // to avoid deleting everything when we return to text drawing in the blinking |
| 455 | // cursor case |
| 456 | if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 457 | plot->incFlushesSinceLastUsed(); |
| 458 | } |
| 459 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 460 | #ifdef DUMP_ATLAS_DATA |
| 461 | if (gDumpAtlasData) { |
| 462 | SkDebugf("%d ", plot->flushesSinceLastUsed()); |
| 463 | } |
| 464 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 465 | // Count plots we can potentially upload to in all pages except the last one |
| 466 | // (the potential compactee). |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 467 | if (plot->flushesSinceLastUsed() > kPlotRecentlyUsedCount) { |
Jim Van Verth | cad0acf | 2018-02-16 18:41:41 -0500 | [diff] [blame] | 468 | availablePlots.push_back() = plot; |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | plotIter.next(); |
| 472 | } |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 473 | #ifdef DUMP_ATLAS_DATA |
| 474 | if (gDumpAtlasData) { |
| 475 | SkDebugf("\n"); |
| 476 | } |
| 477 | #endif |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 478 | } |
| 479 | |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 480 | // Count recently used plots in the last page and evict any that are no longer in use. |
| 481 | // Since we prioritize uploading to the first pages, this will eventually |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 482 | // clear out usage of this page unless we have a large need. |
| 483 | plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 484 | unsigned int usedPlots = 0; |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 485 | #ifdef DUMP_ATLAS_DATA |
| 486 | if (gDumpAtlasData) { |
| 487 | SkDebugf("page %d: ", lastPageIndex); |
| 488 | } |
| 489 | #endif |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 490 | while (Plot* plot = plotIter.get()) { |
Jim Van Verth | 62ea0cd | 2017-09-27 12:59:45 -0400 | [diff] [blame] | 491 | // Update number of flushes since plot was last used |
| 492 | if (!plot->lastUseToken().inInterval(fPrevFlushToken, startTokenForNextFlush)) { |
| 493 | plot->incFlushesSinceLastUsed(); |
| 494 | } |
| 495 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 496 | #ifdef DUMP_ATLAS_DATA |
| 497 | if (gDumpAtlasData) { |
| 498 | SkDebugf("%d ", plot->flushesSinceLastUsed()); |
| 499 | } |
| 500 | #endif |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 501 | // If this plot was used recently |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 502 | if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 503 | usedPlots++; |
Brian Salomon | 943ed79 | 2017-10-30 09:37:55 -0400 | [diff] [blame] | 504 | } else if (plot->lastUseToken() != GrDeferredUploadToken::AlreadyFlushedToken()) { |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 505 | // otherwise if aged out just evict it. |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 506 | this->processEvictionAndResetRects(plot); |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 507 | } |
| 508 | plotIter.next(); |
| 509 | } |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 510 | #ifdef DUMP_ATLAS_DATA |
| 511 | if (gDumpAtlasData) { |
| 512 | SkDebugf("\n"); |
| 513 | } |
| 514 | #endif |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 515 | |
| 516 | // If recently used plots in the last page are using less than a quarter of the page, try |
| 517 | // to evict them if there's available space in earlier pages. Since we prioritize uploading |
| 518 | // to the first pages, this will eventually clear out usage of this page unless we have a |
| 519 | // large need. |
| 520 | if (availablePlots.count() && usedPlots && usedPlots <= fNumPlots / 4) { |
| 521 | plotIter.init(fPages[lastPageIndex].fPlotList, PlotList::Iter::kHead_IterStart); |
| 522 | while (Plot* plot = plotIter.get()) { |
| 523 | // If this plot was used recently |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 524 | if (plot->flushesSinceLastUsed() <= kPlotRecentlyUsedCount) { |
Jim Van Verth | 06f593c | 2018-02-20 11:30:10 -0500 | [diff] [blame] | 525 | // See if there's room in an earlier page and if so evict. |
| 526 | // We need to be somewhat harsh here so that a handful of plots that are |
| 527 | // consistently in use don't end up locking the page in memory. |
| 528 | if (availablePlots.count() > 0) { |
| 529 | this->processEvictionAndResetRects(plot); |
| 530 | this->processEvictionAndResetRects(availablePlots.back()); |
| 531 | availablePlots.pop_back(); |
| 532 | --usedPlots; |
| 533 | } |
| 534 | if (!usedPlots || !availablePlots.count()) { |
| 535 | break; |
| 536 | } |
| 537 | } |
| 538 | plotIter.next(); |
| 539 | } |
| 540 | } |
| 541 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 542 | // If none of the plots in the last page have been used recently, delete it. |
Jim Van Verth | 2665188 | 2020-03-18 15:30:07 +0000 | [diff] [blame] | 543 | if (!usedPlots) { |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 544 | #ifdef DUMP_ATLAS_DATA |
| 545 | if (gDumpAtlasData) { |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 546 | SkDebugf("delete %d\n", fNumActivePages-1); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 547 | } |
| 548 | #endif |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 549 | this->deactivateLastPage(); |
Jim Van Verth | 77eb96d | 2020-03-18 12:32:34 -0400 | [diff] [blame] | 550 | fFlushesSinceLastUse = 0; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 551 | } |
| 552 | } |
| 553 | |
| 554 | fPrevFlushToken = startTokenForNextFlush; |
| 555 | } |
| 556 | |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 557 | bool GrDrawOpAtlas::createPages( |
| 558 | GrProxyProvider* proxyProvider, GenerationCounter* generationCounter) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 559 | SkASSERT(SkIsPow2(fTextureWidth) && SkIsPow2(fTextureHeight)); |
Robert Phillips | 0bd24dc | 2018-01-16 08:06:32 -0500 | [diff] [blame] | 560 | |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 561 | SkISize dims = {fTextureWidth, fTextureHeight}; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 562 | |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 563 | int numPlotsX = fTextureWidth/fPlotWidth; |
| 564 | int numPlotsY = fTextureHeight/fPlotHeight; |
| 565 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 566 | for (uint32_t i = 0; i < this->maxPages(); ++i) { |
Greg Daniel | 47c20e8 | 2020-01-21 14:29:57 -0500 | [diff] [blame] | 567 | GrSwizzle swizzle = proxyProvider->caps()->getReadSwizzle(fFormat, fColorType); |
Brian Salomon | b43d699 | 2021-01-05 14:37:40 -0500 | [diff] [blame] | 568 | if (GrColorTypeIsAlphaOnly(fColorType)) { |
| 569 | swizzle = GrSwizzle::Concat(swizzle, GrSwizzle("aaaa")); |
| 570 | } |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 571 | sk_sp<GrSurfaceProxy> proxy = proxyProvider->createProxy( |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 572 | fFormat, dims, GrRenderable::kNo, 1, GrMipmapped::kNo, SkBackingFit::kExact, |
Brian Salomon | df1bd6d | 2020-03-26 20:37:01 -0400 | [diff] [blame] | 573 | SkBudgeted::kYes, GrProtected::kNo, GrInternalSurfaceFlags::kNone, |
| 574 | GrSurfaceProxy::UseAllocator::kNo); |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 575 | if (!proxy) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 576 | return false; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 577 | } |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 578 | fViews[i] = GrSurfaceProxyView(std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 579 | |
| 580 | // set up allocated plots |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 581 | fPages[i].fPlotArray = std::make_unique<sk_sp<Plot>[]>(numPlotsX * numPlotsY); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 582 | |
| 583 | sk_sp<Plot>* currPlot = fPages[i].fPlotArray.get(); |
| 584 | for (int y = numPlotsY - 1, r = 0; y >= 0; --y, ++r) { |
| 585 | for (int x = numPlotsX - 1, c = 0; x >= 0; --x, ++c) { |
| 586 | uint32_t plotIndex = r * numPlotsX + c; |
Herb Derby | 0ef780b | 2020-01-24 15:57:11 -0500 | [diff] [blame] | 587 | currPlot->reset(new Plot( |
| 588 | i, plotIndex, generationCounter, x, y, fPlotWidth, fPlotHeight, fColorType)); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 589 | |
| 590 | // build LRU list |
| 591 | fPages[i].fPlotList.addToHead(currPlot->get()); |
| 592 | ++currPlot; |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | } |
| 597 | |
| 598 | return true; |
| 599 | } |
| 600 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 601 | bool GrDrawOpAtlas::activateNewPage(GrResourceProvider* resourceProvider) { |
Robert Phillips | d2e9f76 | 2018-03-07 11:54:37 -0500 | [diff] [blame] | 602 | SkASSERT(fNumActivePages < this->maxPages()); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 603 | |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 604 | if (!fViews[fNumActivePages].proxy()->instantiate(resourceProvider)) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 605 | return false; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 606 | } |
| 607 | |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 608 | #ifdef DUMP_ATLAS_DATA |
| 609 | if (gDumpAtlasData) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 610 | SkDebugf("activated page#: %d\n", fNumActivePages); |
Jim Van Verth | c3269ae | 2017-09-28 15:04:00 -0400 | [diff] [blame] | 611 | } |
| 612 | #endif |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 613 | |
| 614 | ++fNumActivePages; |
Jim Van Verth | eafa64b | 2017-09-18 10:05:00 -0400 | [diff] [blame] | 615 | return true; |
| 616 | } |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 617 | |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 618 | |
| 619 | inline void GrDrawOpAtlas::deactivateLastPage() { |
| 620 | SkASSERT(fNumActivePages); |
| 621 | |
| 622 | uint32_t lastPageIndex = fNumActivePages - 1; |
| 623 | |
| 624 | int numPlotsX = fTextureWidth/fPlotWidth; |
| 625 | int numPlotsY = fTextureHeight/fPlotHeight; |
| 626 | |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 627 | fPages[lastPageIndex].fPlotList.reset(); |
Robert Phillips | 6250f29 | 2018-03-01 10:53:45 -0500 | [diff] [blame] | 628 | for (int r = 0; r < numPlotsY; ++r) { |
| 629 | for (int c = 0; c < numPlotsX; ++c) { |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 630 | uint32_t plotIndex = r * numPlotsX + c; |
| 631 | |
| 632 | Plot* currPlot = fPages[lastPageIndex].fPlotArray[plotIndex].get(); |
| 633 | currPlot->resetRects(); |
| 634 | currPlot->resetFlushesSinceLastUsed(); |
| 635 | |
| 636 | // rebuild the LRU list |
| 637 | SkDEBUGCODE(currPlot->fPrev = currPlot->fNext = nullptr); |
| 638 | SkDEBUGCODE(currPlot->fList = nullptr); |
| 639 | fPages[lastPageIndex].fPlotList.addToHead(currPlot); |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | // remove ref to the backing texture |
Greg Daniel | 9715b6c | 2019-12-10 15:03:10 -0500 | [diff] [blame] | 644 | fViews[lastPageIndex].proxy()->deinstantiate(); |
Robert Phillips | 4bc7011 | 2018-03-01 10:24:02 -0500 | [diff] [blame] | 645 | --fNumActivePages; |
Jim Van Verth | 106b5c4 | 2017-09-26 12:45:29 -0400 | [diff] [blame] | 646 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 647 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 648 | GrDrawOpAtlasConfig::GrDrawOpAtlasConfig(int maxTextureSize, size_t maxBytes) { |
| 649 | static const SkISize kARGBDimensions[] = { |
| 650 | {256, 256}, // maxBytes < 2^19 |
| 651 | {512, 256}, // 2^19 <= maxBytes < 2^20 |
| 652 | {512, 512}, // 2^20 <= maxBytes < 2^21 |
| 653 | {1024, 512}, // 2^21 <= maxBytes < 2^22 |
| 654 | {1024, 1024}, // 2^22 <= maxBytes < 2^23 |
| 655 | {2048, 1024}, // 2^23 <= maxBytes |
| 656 | }; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 657 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 658 | // Index 0 corresponds to maxBytes of 2^18, so start by dividing it by that |
| 659 | maxBytes >>= 18; |
| 660 | // Take the floor of the log to get the index |
| 661 | int index = maxBytes > 0 |
| 662 | ? SkTPin<int>(SkPrevLog2(maxBytes), 0, SK_ARRAY_COUNT(kARGBDimensions) - 1) |
| 663 | : 0; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 664 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 665 | SkASSERT(kARGBDimensions[index].width() <= kMaxAtlasDim); |
| 666 | SkASSERT(kARGBDimensions[index].height() <= kMaxAtlasDim); |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 667 | fARGBDimensions.set(std::min<int>(kARGBDimensions[index].width(), maxTextureSize), |
| 668 | std::min<int>(kARGBDimensions[index].height(), maxTextureSize)); |
| 669 | fMaxTextureSize = std::min<int>(maxTextureSize, kMaxAtlasDim); |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 670 | } |
| 671 | |
| 672 | SkISize GrDrawOpAtlasConfig::atlasDimensions(GrMaskFormat type) const { |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 673 | if (kA8_GrMaskFormat == type) { |
| 674 | // A8 is always 2x the ARGB dimensions, clamped to the max allowed texture size |
Brian Osman | 788b916 | 2020-02-07 10:36:46 -0500 | [diff] [blame] | 675 | return { std::min<int>(2 * fARGBDimensions.width(), fMaxTextureSize), |
| 676 | std::min<int>(2 * fARGBDimensions.height(), fMaxTextureSize) }; |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 677 | } else { |
| 678 | return fARGBDimensions; |
| 679 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 680 | } |
| 681 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 682 | SkISize GrDrawOpAtlasConfig::plotDimensions(GrMaskFormat type) const { |
| 683 | if (kA8_GrMaskFormat == type) { |
| 684 | SkISize atlasDimensions = this->atlasDimensions(type); |
| 685 | // For A8 we want to grow the plots at larger texture sizes to accept more of the |
| 686 | // larger SDF glyphs. Since the largest SDF glyph can be 170x170 with padding, this |
| 687 | // allows us to pack 3 in a 512x256 plot, or 9 in a 512x512 plot. |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 688 | |
Jim Van Verth | 578b089 | 2018-12-20 20:48:55 +0000 | [diff] [blame] | 689 | // This will give us 512x256 plots for 2048x1024, 512x512 plots for 2048x2048, |
| 690 | // and 256x256 plots otherwise. |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 691 | int plotWidth = atlasDimensions.width() >= 2048 ? 512 : 256; |
Jim Van Verth | 578b089 | 2018-12-20 20:48:55 +0000 | [diff] [blame] | 692 | int plotHeight = atlasDimensions.height() >= 2048 ? 512 : 256; |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 693 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 694 | return { plotWidth, plotHeight }; |
| 695 | } else { |
| 696 | // ARGB and LCD always use 256x256 plots -- this has been shown to be faster |
| 697 | return { 256, 256 }; |
| 698 | } |
Herb Derby | 15d9ef2 | 2018-10-18 13:41:32 -0400 | [diff] [blame] | 699 | } |
| 700 | |
Jim Van Verth | f6206f9 | 2018-12-14 08:22:24 -0500 | [diff] [blame] | 701 | constexpr int GrDrawOpAtlasConfig::kMaxAtlasDim; |