Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 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 "include/core/SkTypes.h" |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/core/SkCanvas.h" |
| 11 | #include "include/core/SkPoint.h" |
| 12 | #include "include/core/SkSurface.h" |
| 13 | #include "include/gpu/GrBackendSurface.h" |
| 14 | #include "include/gpu/GrContext.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/gpu/GrBackendTextureImageGenerator.h" |
| 16 | #include "src/gpu/GrContextPriv.h" |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 17 | #include "src/gpu/GrDrawingManager.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/GrGpu.h" |
| 19 | #include "src/gpu/GrRenderTargetContext.h" |
| 20 | #include "src/gpu/GrSemaphore.h" |
| 21 | #include "src/gpu/GrSurfaceProxyPriv.h" |
| 22 | #include "src/gpu/GrTexturePriv.h" |
Greg Daniel | f91aeb2 | 2019-06-18 09:58:02 -0400 | [diff] [blame] | 23 | #include "src/gpu/GrTextureProxy.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "src/gpu/SkGpuDevice.h" |
| 25 | #include "src/image/SkImage_Base.h" |
| 26 | #include "src/image/SkSurface_Gpu.h" |
| 27 | #include "tests/Test.h" |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 28 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 29 | static constexpr int kSize = 8; |
| 30 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 31 | // Test that the correct mip map states are on the GrTextures when wrapping GrBackendTextures in |
| 32 | // SkImages and SkSurfaces |
| 33 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) { |
| 34 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 35 | if (!context->priv().caps()->mipMapSupport()) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 36 | return; |
| 37 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 38 | |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 39 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 40 | for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) { |
Robert Phillips | 9b16f81 | 2019-05-17 10:01:21 -0400 | [diff] [blame] | 41 | // createBackendTexture currently doesn't support uploading data to mip maps |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 42 | // so we don't send any. However, we pretend there is data for the checks below which is |
| 43 | // fine since we are never actually using these textures for any work on the gpu. |
Robert Phillips | 4bdd36f | 2019-06-04 11:03:06 -0400 | [diff] [blame] | 44 | GrBackendTexture backendTex = context->createBackendTexture( |
Robert Phillips | 8062679 | 2019-06-04 07:16:10 -0400 | [diff] [blame] | 45 | kSize, kSize, kRGBA_8888_SkColorType, |
Robert Phillips | da2e67a | 2019-07-01 15:04:06 -0400 | [diff] [blame] | 46 | SkColors::kTransparent, mipMapped, renderable, GrProtected::kNo); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 47 | |
Robert Phillips | e0070c0 | 2017-11-13 12:47:24 -0500 | [diff] [blame] | 48 | sk_sp<GrTextureProxy> proxy; |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 49 | sk_sp<SkImage> image; |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 50 | if (GrRenderable::kYes == renderable) { |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 51 | sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture( |
| 52 | context, |
| 53 | backendTex, |
| 54 | kTopLeft_GrSurfaceOrigin, |
| 55 | 0, |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 56 | kRGBA_8888_SkColorType, |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 57 | nullptr, |
| 58 | nullptr); |
| 59 | |
| 60 | SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); |
Robert Phillips | e0070c0 | 2017-11-13 12:47:24 -0500 | [diff] [blame] | 61 | proxy = device->accessRenderTargetContext()->asTextureProxyRef(); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 62 | } else { |
| 63 | image = SkImage::MakeFromTexture(context, backendTex, |
| 64 | kTopLeft_GrSurfaceOrigin, |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 65 | kRGBA_8888_SkColorType, |
| 66 | kPremul_SkAlphaType, nullptr, |
| 67 | nullptr, nullptr); |
Robert Phillips | 6603a17 | 2019-03-05 12:35:44 -0500 | [diff] [blame] | 68 | proxy = as_IB(image)->asTextureProxyRef(context); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 69 | } |
| 70 | REPORTER_ASSERT(reporter, proxy); |
| 71 | if (!proxy) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 72 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 73 | return; |
| 74 | } |
| 75 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 76 | REPORTER_ASSERT(reporter, proxy->isInstantiated()); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 77 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 78 | GrTexture* texture = proxy->peekTexture(); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 79 | REPORTER_ASSERT(reporter, texture); |
| 80 | if (!texture) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 81 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 82 | return; |
| 83 | } |
| 84 | |
| 85 | if (GrMipMapped::kYes == mipMapped) { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 86 | REPORTER_ASSERT(reporter, GrMipMapped::kYes == texture->texturePriv().mipMapped()); |
Robert Phillips | 9dbcdcc | 2019-05-13 10:40:06 -0400 | [diff] [blame] | 87 | if (GrRenderable::kYes == renderable) { |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 88 | REPORTER_ASSERT(reporter, texture->texturePriv().mipMapsAreDirty()); |
| 89 | } else { |
| 90 | REPORTER_ASSERT(reporter, !texture->texturePriv().mipMapsAreDirty()); |
| 91 | } |
| 92 | } else { |
Greg Daniel | e252f08 | 2017-10-23 16:05:23 -0400 | [diff] [blame] | 93 | REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped()); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 94 | } |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 95 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 177e695 | 2017-10-12 12:27:11 -0400 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 100 | // Test that we correctly copy or don't copy GrBackendTextures in the GrBackendTextureImageGenerator |
| 101 | // based on if we will use mips in the draw and the mip status of the GrBackendTexture. |
| 102 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter, ctxInfo) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 103 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 104 | if (!context->priv().caps()->mipMapSupport()) { |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 105 | return; |
| 106 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 107 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 108 | for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { |
| 109 | for (auto willUseMips : {false, true}) { |
Robert Phillips | 4bdd36f | 2019-06-04 11:03:06 -0400 | [diff] [blame] | 110 | GrBackendTexture backendTex = context->createBackendTexture( |
Robert Phillips | 8062679 | 2019-06-04 07:16:10 -0400 | [diff] [blame] | 111 | kSize, kSize, kRGBA_8888_SkColorType, |
Robert Phillips | da2e67a | 2019-07-01 15:04:06 -0400 | [diff] [blame] | 112 | SkColors::kTransparent, mipMapped, GrRenderable::kNo, GrProtected::kNo); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 113 | |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 114 | sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex, |
| 115 | kTopLeft_GrSurfaceOrigin, |
Greg Daniel | f5d8758 | 2017-12-18 14:48:15 -0500 | [diff] [blame] | 116 | kRGBA_8888_SkColorType, |
| 117 | kPremul_SkAlphaType, nullptr, |
| 118 | nullptr, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 119 | |
| 120 | GrTextureProxy* proxy = as_IB(image)->peekProxy(); |
| 121 | REPORTER_ASSERT(reporter, proxy); |
| 122 | if (!proxy) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 123 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 124 | return; |
| 125 | } |
| 126 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 127 | REPORTER_ASSERT(reporter, proxy->isInstantiated()); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 128 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 129 | sk_sp<GrTexture> texture = sk_ref_sp(proxy->peekTexture()); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 130 | REPORTER_ASSERT(reporter, texture); |
| 131 | if (!texture) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 132 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 133 | return; |
| 134 | } |
| 135 | |
| 136 | std::unique_ptr<SkImageGenerator> imageGen = GrBackendTextureImageGenerator::Make( |
Brian Osman | 052ef69 | 2018-03-27 09:56:31 -0400 | [diff] [blame] | 137 | texture, kTopLeft_GrSurfaceOrigin, nullptr, kRGBA_8888_SkColorType, |
| 138 | kPremul_SkAlphaType, nullptr); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 139 | REPORTER_ASSERT(reporter, imageGen); |
| 140 | if (!imageGen) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 141 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 142 | return; |
| 143 | } |
| 144 | |
| 145 | SkIPoint origin = SkIPoint::Make(0,0); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 146 | SkImageInfo imageInfo = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 147 | kPremul_SkAlphaType); |
| 148 | sk_sp<GrTextureProxy> genProxy = imageGen->generateTexture(context, imageInfo, |
Brian Osman | c87cfb6 | 2018-07-11 09:08:46 -0400 | [diff] [blame] | 149 | origin, willUseMips); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 150 | |
| 151 | REPORTER_ASSERT(reporter, genProxy); |
| 152 | if (!genProxy) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 153 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 154 | return; |
| 155 | } |
| 156 | |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 157 | if (genProxy->isLazy()) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 158 | genProxy->priv().doLazyInstantiation(context->priv().resourceProvider()); |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 159 | } else if (!genProxy->isInstantiated()) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 160 | genProxy->instantiate(context->priv().resourceProvider()); |
Greg Daniel | e728f67 | 2018-01-17 10:52:04 -0500 | [diff] [blame] | 161 | } |
| 162 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 163 | REPORTER_ASSERT(reporter, genProxy->isInstantiated()); |
| 164 | if (!genProxy->isInstantiated()) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 165 | context->deleteBackendTexture(backendTex); |
Greg Daniel | bddcc95 | 2018-01-24 13:22:24 -0500 | [diff] [blame] | 166 | return; |
| 167 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 168 | |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 169 | GrTexture* genTexture = genProxy->peekTexture(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 170 | REPORTER_ASSERT(reporter, genTexture); |
| 171 | if (!genTexture) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 172 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 173 | return; |
| 174 | } |
| 175 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 176 | GrBackendTexture genBackendTex = genTexture->getBackendTexture(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 177 | |
Greg Daniel | bdf12ad | 2018-10-12 09:31:11 -0400 | [diff] [blame] | 178 | if (GrBackendApi::kOpenGL == genBackendTex.backend()) { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 179 | GrGLTextureInfo genTexInfo; |
| 180 | GrGLTextureInfo origTexInfo; |
| 181 | if (genBackendTex.getGLTextureInfo(&genTexInfo) && |
| 182 | backendTex.getGLTextureInfo(&origTexInfo)) { |
| 183 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 184 | // We did a copy so the texture IDs should be different |
| 185 | REPORTER_ASSERT(reporter, origTexInfo.fID != genTexInfo.fID); |
| 186 | } else { |
| 187 | REPORTER_ASSERT(reporter, origTexInfo.fID == genTexInfo.fID); |
| 188 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 189 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 190 | ERRORF(reporter, "Failed to get GrGLTextureInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 191 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 192 | #ifdef SK_VULKAN |
Greg Daniel | bdf12ad | 2018-10-12 09:31:11 -0400 | [diff] [blame] | 193 | } else if (GrBackendApi::kVulkan == genBackendTex.backend()) { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 194 | GrVkImageInfo genImageInfo; |
| 195 | GrVkImageInfo origImageInfo; |
| 196 | if (genBackendTex.getVkImageInfo(&genImageInfo) && |
| 197 | backendTex.getVkImageInfo(&origImageInfo)) { |
| 198 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 199 | // We did a copy so the texture IDs should be different |
| 200 | REPORTER_ASSERT(reporter, origImageInfo.fImage != genImageInfo.fImage); |
| 201 | } else { |
| 202 | REPORTER_ASSERT(reporter, origImageInfo.fImage == genImageInfo.fImage); |
| 203 | } |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 204 | } else { |
Greg Daniel | 52e16d9 | 2018-04-10 09:34:07 -0400 | [diff] [blame] | 205 | ERRORF(reporter, "Failed to get GrVkImageInfo"); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 206 | } |
| 207 | #endif |
Jim Van Verth | 9896a0d | 2019-04-10 15:11:12 -0400 | [diff] [blame] | 208 | #ifdef SK_METAL |
| 209 | } else if (GrBackendApi::kMetal == genBackendTex.backend()) { |
| 210 | GrMtlTextureInfo genImageInfo; |
| 211 | GrMtlTextureInfo origImageInfo; |
| 212 | if (genBackendTex.getMtlTextureInfo(&genImageInfo) && |
| 213 | backendTex.getMtlTextureInfo(&origImageInfo)) { |
| 214 | if (willUseMips && GrMipMapped::kNo == mipMapped) { |
| 215 | // We did a copy so the texture IDs should be different |
| 216 | REPORTER_ASSERT(reporter, origImageInfo.fTexture != genImageInfo.fTexture); |
| 217 | } else { |
| 218 | REPORTER_ASSERT(reporter, origImageInfo.fTexture == genImageInfo.fTexture); |
| 219 | } |
| 220 | } else { |
| 221 | ERRORF(reporter, "Failed to get GrMtlTextureInfo"); |
| 222 | } |
| 223 | #endif |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 224 | } else { |
| 225 | REPORTER_ASSERT(reporter, false); |
| 226 | } |
| 227 | |
| 228 | // Must make sure the uses of the backend texture have finished (we possibly have a |
Greg Daniel | 26b50a4 | 2018-03-08 09:49:58 -0500 | [diff] [blame] | 229 | // queued up copy) before we delete the backend texture. |
| 230 | context->flush(); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 231 | |
Robert Phillips | 9b16f81 | 2019-05-17 10:01:21 -0400 | [diff] [blame] | 232 | context->priv().getGpu()->testingOnly_flushGpuAndSync(); |
| 233 | |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 234 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 261b8aa | 2017-10-23 09:37:36 -0400 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 239 | // Test that when we call makeImageSnapshot on an SkSurface we retains the same mip status as the |
| 240 | // resource we took the snapshot of. |
| 241 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxInfo) { |
| 242 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 243 | if (!context->priv().caps()->mipMapSupport()) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 244 | return; |
| 245 | } |
| 246 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 247 | auto resourceProvider = context->priv().resourceProvider(); |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 248 | |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 249 | for (auto willUseMips : {false, true}) { |
| 250 | for (auto isWrapped : {false, true}) { |
| 251 | GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo; |
| 252 | sk_sp<SkSurface> surface; |
Robert Phillips | 4bdd36f | 2019-06-04 11:03:06 -0400 | [diff] [blame] | 253 | GrBackendTexture backendTex = context->createBackendTexture( |
Robert Phillips | 8062679 | 2019-06-04 07:16:10 -0400 | [diff] [blame] | 254 | kSize, kSize, kRGBA_8888_SkColorType, |
Robert Phillips | da2e67a | 2019-07-01 15:04:06 -0400 | [diff] [blame] | 255 | SkColors::kTransparent, mipMapped, GrRenderable::kYes, GrProtected::kNo); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 256 | if (isWrapped) { |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 257 | surface = SkSurface::MakeFromBackendTexture(context, |
| 258 | backendTex, |
| 259 | kTopLeft_GrSurfaceOrigin, |
| 260 | 0, |
Greg Daniel | faa095e | 2017-12-19 13:15:02 -0500 | [diff] [blame] | 261 | kRGBA_8888_SkColorType, |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 262 | nullptr, |
| 263 | nullptr); |
| 264 | } else { |
| 265 | SkImageInfo info = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, |
| 266 | kPremul_SkAlphaType); |
| 267 | surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 0, |
| 268 | kTopLeft_GrSurfaceOrigin, nullptr, |
| 269 | willUseMips); |
| 270 | } |
| 271 | REPORTER_ASSERT(reporter, surface); |
| 272 | if (!surface) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 273 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 274 | } |
| 275 | SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); |
| 276 | GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy(); |
| 277 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 278 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 279 | texProxy->instantiate(resourceProvider); |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 280 | GrTexture* texture = texProxy->peekTexture(); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 281 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 282 | |
| 283 | sk_sp<SkImage> image = surface->makeImageSnapshot(); |
| 284 | REPORTER_ASSERT(reporter, image); |
| 285 | if (!image) { |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 286 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 287 | } |
| 288 | texProxy = as_IB(image)->peekProxy(); |
| 289 | REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); |
| 290 | |
Robert Phillips | 6be756b | 2018-01-16 15:07:54 -0500 | [diff] [blame] | 291 | texProxy->instantiate(resourceProvider); |
Brian Salomon | fd98c2c | 2018-07-31 17:25:29 -0400 | [diff] [blame] | 292 | texture = texProxy->peekTexture(); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 293 | REPORTER_ASSERT(reporter, mipMapped == texture->texturePriv().mipMapped()); |
| 294 | |
| 295 | // Must flush the context to make sure all the cmds (copies, etc.) from above are sent |
| 296 | // to the gpu before we delete the backendHandle. |
| 297 | context->flush(); |
Robert Phillips | 9b16f81 | 2019-05-17 10:01:21 -0400 | [diff] [blame] | 298 | context->priv().getGpu()->testingOnly_flushGpuAndSync(); |
Robert Phillips | 5c7a25b | 2019-05-20 08:38:07 -0400 | [diff] [blame] | 299 | context->deleteBackendTexture(backendTex); |
Greg Daniel | 45d6303 | 2017-10-30 13:41:26 -0400 | [diff] [blame] | 300 | } |
| 301 | } |
| 302 | } |
Greg Daniel | 8e9b4c4 | 2018-07-20 10:30:48 -0400 | [diff] [blame] | 303 | |
| 304 | // Test that we don't create a mip mapped texture if the size is 1x1 even if the filter mode is set |
| 305 | // to use mips. This test passes by not crashing or hitting asserts in code. |
| 306 | DEF_GPUTEST_FOR_RENDERING_CONTEXTS(Gr1x1TextureMipMappedTest, reporter, ctxInfo) { |
| 307 | GrContext* context = ctxInfo.grContext(); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 308 | if (!context->priv().caps()->mipMapSupport()) { |
Greg Daniel | 8e9b4c4 | 2018-07-20 10:30:48 -0400 | [diff] [blame] | 309 | return; |
| 310 | } |
| 311 | |
| 312 | // Make surface to draw into |
| 313 | SkImageInfo info = SkImageInfo::MakeN32(16, 16, kPremul_SkAlphaType); |
| 314 | sk_sp<SkSurface> surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); |
| 315 | |
| 316 | // Make 1x1 raster bitmap |
| 317 | SkBitmap bmp; |
| 318 | bmp.allocN32Pixels(1, 1); |
| 319 | SkPMColor* pixel = reinterpret_cast<SkPMColor*>(bmp.getPixels()); |
| 320 | *pixel = 0; |
| 321 | |
| 322 | sk_sp<SkImage> bmpImage = SkImage::MakeFromBitmap(bmp); |
| 323 | |
| 324 | // Make sure we scale so we don't optimize out the use of mips. |
| 325 | surface->getCanvas()->scale(0.5f, 0.5f); |
| 326 | |
| 327 | SkPaint paint; |
| 328 | // This should upload the image to a non mipped GrTextureProxy. |
| 329 | surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint); |
| 330 | surface->flush(); |
| 331 | |
| 332 | // Now set the filter quality to high so we use mip maps. We should find the non mipped texture |
| 333 | // in the cache for the SkImage. Since the texture is 1x1 we should just use that texture |
| 334 | // instead of trying to do a copy to a mipped texture. |
| 335 | paint.setFilterQuality(kHigh_SkFilterQuality); |
| 336 | surface->getCanvas()->drawImage(bmpImage, 0, 0, &paint); |
| 337 | surface->flush(); |
| 338 | } |
| 339 | |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 340 | // Create a new render target and draw 'mipmapProxy' into it using the provided 'filter'. |
Brian Salomon | bf6b979 | 2019-08-21 09:38:10 -0400 | [diff] [blame] | 341 | static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target( |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 342 | GrRecordingContext* context, GrProxyProvider* proxyProvider, GrColorType colorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 343 | SkAlphaType alphaType, sk_sp<GrTextureProxy> mipmapProxy, GrSamplerState::Filter filter) { |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 344 | GrSurfaceDesc desc; |
| 345 | desc.fWidth = 1; |
| 346 | desc.fHeight = 1; |
| 347 | desc.fConfig = mipmapProxy->config(); |
| 348 | sk_sp<GrSurfaceProxy> renderTarget = proxyProvider->createProxy( |
| 349 | mipmapProxy->backendFormat(), desc, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin, |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 350 | GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes, GrProtected::kNo); |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 351 | |
| 352 | auto rtc = GrRenderTargetContext::Make( |
| 353 | context, colorType, nullptr, std::move(renderTarget), kTopLeft_GrSurfaceOrigin, |
| 354 | nullptr); |
| 355 | |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 356 | rtc->drawTexture(GrNoClip(), mipmapProxy, colorType, alphaType, filter, SkBlendMode::kSrcOver, |
Greg Daniel | c594e62 | 2019-10-15 14:01:49 -0400 | [diff] [blame] | 357 | {1,1,1,1}, SkRect::MakeWH(4, 4), SkRect::MakeWH(1,1), GrAA::kYes, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 358 | GrQuadAAFlags::kAll, SkCanvas::kFast_SrcRectConstraint, SkMatrix::I(), |
| 359 | nullptr); |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 360 | return rtc; |
| 361 | } |
| 362 | |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 363 | // Test that two opsTasks using the same mipmaps both depend on the same GrTextureResolveRenderTask. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 364 | DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) { |
| 365 | using CanClearFullscreen = GrRenderTargetContext::CanClearFullscreen; |
| 366 | using Enable = GrContextOptions::Enable; |
| 367 | using Filter = GrSamplerState::Filter; |
| 368 | |
| 369 | for (auto enableSortingAndReduction : {Enable::kYes, Enable::kNo}) { |
| 370 | GrMockOptions mockOptions; |
| 371 | mockOptions.fMipMapSupport = true; |
| 372 | GrContextOptions ctxOptions; |
Greg Daniel | 9313874 | 2019-08-22 17:15:39 -0400 | [diff] [blame] | 373 | ctxOptions.fReduceOpsTaskSplitting = enableSortingAndReduction; |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 374 | sk_sp<GrContext> context = GrContext::MakeMock(&mockOptions, ctxOptions); |
| 375 | if (!context) { |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 376 | ERRORF(reporter, "could not create mock context with fReduceOpsTaskSplitting %s.", |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 377 | (Enable::kYes == enableSortingAndReduction) ? "enabled" : "disabled"); |
| 378 | continue; |
| 379 | } |
| 380 | |
| 381 | SkASSERT(context->priv().caps()->mipMapSupport()); |
| 382 | |
| 383 | GrBackendFormat format = context->defaultBackendFormat( |
| 384 | kRGBA_8888_SkColorType, GrRenderable::kYes); |
| 385 | GrPixelConfig config = kRGBA_8888_GrPixelConfig; |
| 386 | GrColorType colorType = GrColorType::kRGBA_8888; |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 387 | SkAlphaType alphaType = kPremul_SkAlphaType; |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 388 | |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 389 | GrProxyProvider* proxyProvider = context->priv().proxyProvider(); |
| 390 | |
| 391 | // Create a mipmapped render target. |
| 392 | GrSurfaceDesc desc; |
| 393 | desc.fWidth = 4; |
| 394 | desc.fHeight = 4; |
| 395 | desc.fConfig = config; |
Brian Salomon | beb7f52 | 2019-08-30 16:19:42 -0400 | [diff] [blame] | 396 | sk_sp<GrTextureProxy> mipmapProxy = proxyProvider->createProxy( |
| 397 | format, desc, GrRenderable::kYes, 1, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, |
| 398 | SkBackingFit::kExact, SkBudgeted::kYes, GrProtected::kNo); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 399 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 400 | // Mark the mipmaps clean to ensure things still work properly when they won't be marked |
| 401 | // dirty again until GrRenderTask::makeClosed(). |
| 402 | mipmapProxy->markMipMapsClean(); |
| 403 | |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 404 | auto mipmapRTC = GrRenderTargetContext::Make( |
| 405 | context.get(), colorType, nullptr, mipmapProxy, kTopLeft_GrSurfaceOrigin, nullptr); |
| 406 | |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 407 | mipmapRTC->clear(nullptr, {.1f,.2f,.3f,.4f}, CanClearFullscreen::kYes); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 408 | REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask()); |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 409 | // mipmapProxy's last render task should now just be the opsTask containing the clear. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 410 | REPORTER_ASSERT(reporter, |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 411 | mipmapRTC->testingOnly_PeekLastOpsTask() == mipmapProxy->getLastRenderTask()); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 412 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 413 | // Mipmaps don't get marked dirty until makeClosed(). |
| 414 | REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty()); |
| 415 | |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 416 | // Draw the dirty mipmap texture into a render target. |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 417 | auto rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 418 | alphaType, mipmapProxy, Filter::kMipMap); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 419 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 420 | // Mipmaps should have gotten marked dirty during makeClosed, then marked clean again as |
| 421 | // soon as a GrTextureResolveRenderTask was inserted. The way we know they were resolved is |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 422 | // if mipmapProxy->getLastRenderTask() has switched from the opsTask that drew to it, to the |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 423 | // task that resolved its mips. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 424 | GrRenderTask* initialMipmapRegenTask = mipmapProxy->getLastRenderTask(); |
| 425 | REPORTER_ASSERT(reporter, initialMipmapRegenTask); |
| 426 | REPORTER_ASSERT(reporter, |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 427 | initialMipmapRegenTask != mipmapRTC->testingOnly_PeekLastOpsTask()); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 428 | REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty()); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 429 | |
| 430 | // Draw the now-clean mipmap texture into a second target. |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 431 | auto rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 432 | alphaType, mipmapProxy, Filter::kMipMap); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 433 | |
| 434 | // Make sure the mipmap texture still has the same regen task. |
| 435 | REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask() == initialMipmapRegenTask); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 436 | SkASSERT(!mipmapProxy->mipMapsAreDirty()); |
| 437 | |
| 438 | // Reset everything so we can go again, this time with the first draw not mipmapped. |
| 439 | context->flush(); |
| 440 | |
Chris Dalton | e2a903e | 2019-09-18 13:41:50 -0600 | [diff] [blame] | 441 | // Mip regen tasks don't get added as dependencies until makeClosed(). |
| 442 | REPORTER_ASSERT(reporter, |
| 443 | rtc1->testingOnly_PeekLastOpsTask()->dependsOn(initialMipmapRegenTask)); |
| 444 | REPORTER_ASSERT(reporter, |
| 445 | rtc2->testingOnly_PeekLastOpsTask()->dependsOn(initialMipmapRegenTask)); |
| 446 | |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 447 | // Render something to dirty the mips. |
| 448 | mipmapRTC->clear(nullptr, {.1f,.2f,.3f,.4f}, CanClearFullscreen::kYes); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 449 | REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask()); |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 450 | // mipmapProxy's last render task should now just be the opsTask containing the clear. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 451 | REPORTER_ASSERT(reporter, |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 452 | mipmapRTC->testingOnly_PeekLastOpsTask() == mipmapProxy->getLastRenderTask()); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 453 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 454 | // Mipmaps don't get marked dirty until makeClosed(). |
| 455 | REPORTER_ASSERT(reporter, !mipmapProxy->mipMapsAreDirty()); |
| 456 | |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 457 | // Draw the dirty mipmap texture into a render target, but don't do mipmap filtering. |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 458 | rtc1 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 459 | alphaType, mipmapProxy, Filter::kBilerp); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 460 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 461 | // Mipmaps should have gotten marked dirty during makeClosed() when adding the dependency. |
| 462 | // Since the last draw did not use mips, they will not have been regenerated and should |
| 463 | // therefore still be dirty. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 464 | REPORTER_ASSERT(reporter, mipmapProxy->mipMapsAreDirty()); |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 465 | |
| 466 | // Since mips weren't regenerated, the last render task shouldn't have changed. |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 467 | REPORTER_ASSERT(reporter, |
Greg Daniel | f41b2bd | 2019-08-22 16:19:24 -0400 | [diff] [blame] | 468 | mipmapRTC->testingOnly_PeekLastOpsTask() == mipmapProxy->getLastRenderTask()); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 469 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 470 | // Draw the stil-dirty mipmap texture into a second target with mipmap filtering. |
Greg Daniel | ba0ff78 | 2020-01-07 15:42:57 -0500 | [diff] [blame] | 471 | rtc2 = draw_mipmap_into_new_render_target(context.get(), proxyProvider, colorType, |
Brian Salomon | fc11844 | 2019-11-22 19:09:27 -0500 | [diff] [blame] | 472 | alphaType, mipmapProxy, Filter::kMipMap); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 473 | |
Chris Dalton | aa3cbb8 | 2019-08-21 00:01:21 -0600 | [diff] [blame] | 474 | // Make sure the mipmap texture now has a new last render task that regenerates the mips, |
| 475 | // and that the mipmaps are now clean. |
Chris Dalton | e2a903e | 2019-09-18 13:41:50 -0600 | [diff] [blame] | 476 | auto mipRegenTask2 = mipmapProxy->getLastRenderTask(); |
| 477 | REPORTER_ASSERT(reporter, mipRegenTask2); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 478 | REPORTER_ASSERT(reporter, |
Chris Dalton | e2a903e | 2019-09-18 13:41:50 -0600 | [diff] [blame] | 479 | mipmapRTC->testingOnly_PeekLastOpsTask() != mipRegenTask2); |
Chris Dalton | 30eea6c | 2019-08-21 10:22:50 -0600 | [diff] [blame] | 480 | SkASSERT(!mipmapProxy->mipMapsAreDirty()); |
Chris Dalton | e2a903e | 2019-09-18 13:41:50 -0600 | [diff] [blame] | 481 | |
| 482 | // Mip regen tasks don't get added as dependencies until makeClosed(). |
| 483 | context->flush(); |
| 484 | REPORTER_ASSERT(reporter, rtc2->testingOnly_PeekLastOpsTask()->dependsOn(mipRegenTask2)); |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 485 | } |
Chris Dalton | 3d77027 | 2019-08-14 09:24:37 -0600 | [diff] [blame] | 486 | } |