reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 1 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 2 | * Copyright 2010 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. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 8 | |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 9 | #include "GrGpu.h" |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 10 | |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 11 | #include "GrBackendSemaphore.h" |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 12 | #include "GrBackendSurface.h" |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 13 | #include "GrBuffer.h" |
bsalomon | eb1cb5c | 2015-05-22 08:01:09 -0700 | [diff] [blame] | 14 | #include "GrCaps.h" |
bsalomon@google.com | 558a75b | 2011-08-08 17:01:14 +0000 | [diff] [blame] | 15 | #include "GrContext.h" |
bsalomon | 3582d3e | 2015-02-13 14:20:05 -0800 | [diff] [blame] | 16 | #include "GrGpuResourcePriv.h" |
egdaniel | 0e1853c | 2016-03-17 11:35:45 -0700 | [diff] [blame] | 17 | #include "GrMesh.h" |
kkinnunen | cabe20c | 2015-06-01 01:37:26 -0700 | [diff] [blame] | 18 | #include "GrPathRendering.h" |
bsalomon | cb02b38 | 2015-08-12 11:14:50 -0700 | [diff] [blame] | 19 | #include "GrPipeline.h" |
Robert Phillips | fbcef6e | 2017-06-15 12:07:18 -0400 | [diff] [blame] | 20 | #include "GrRenderTargetPriv.h" |
bsalomon | 0ea80f4 | 2015-02-11 10:49:59 -0800 | [diff] [blame] | 21 | #include "GrResourceCache.h" |
egdaniel | ec00d94 | 2015-09-14 12:56:10 -0700 | [diff] [blame] | 22 | #include "GrResourceProvider.h" |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 23 | #include "GrSemaphore.h" |
egdaniel | 8dc7c3a | 2015-04-16 11:22:42 -0700 | [diff] [blame] | 24 | #include "GrStencilAttachment.h" |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 25 | #include "GrStencilSettings.h" |
egdaniel | 6d901da | 2015-07-30 12:02:15 -0700 | [diff] [blame] | 26 | #include "GrSurfacePriv.h" |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 27 | #include "GrTexturePriv.h" |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 28 | #include "GrTracing.h" |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 29 | #include "SkJSONWriter.h" |
halcanary | 4dbbd04 | 2016-06-07 17:21:10 -0700 | [diff] [blame] | 30 | #include "SkMathPriv.h" |
bsalomon | cb8979d | 2015-05-05 09:51:38 -0700 | [diff] [blame] | 31 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 32 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 33 | |
bsalomon@google.com | 6e4e650 | 2013-02-25 20:12:45 +0000 | [diff] [blame] | 34 | GrGpu::GrGpu(GrContext* context) |
joshualitt | 3322fa4 | 2014-11-07 08:48:51 -0800 | [diff] [blame] | 35 | : fResetTimestamp(kExpiredTimestamp+1) |
bsalomon@google.com | 0a208a1 | 2013-06-28 18:57:35 +0000 | [diff] [blame] | 36 | , fResetBits(kAll_GrBackendState) |
joshualitt | 3322fa4 | 2014-11-07 08:48:51 -0800 | [diff] [blame] | 37 | , fContext(context) { |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 38 | fMultisampleSpecs.emplace_back(0, 0, nullptr); // Index 0 is an invalid unique id. |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 39 | } |
| 40 | |
bsalomon | ed0bcad | 2015-05-04 10:36:42 -0700 | [diff] [blame] | 41 | GrGpu::~GrGpu() {} |
bsalomon | 1d89ddc | 2014-08-19 14:20:58 -0700 | [diff] [blame] | 42 | |
bsalomon | 6e2aad4 | 2016-04-01 11:54:31 -0700 | [diff] [blame] | 43 | void GrGpu::disconnect(DisconnectType) {} |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 44 | |
bsalomon@google.com | d302f14 | 2011-03-03 13:54:13 +0000 | [diff] [blame] | 45 | //////////////////////////////////////////////////////////////////////////////// |
reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 46 | |
Robert Phillips | 81444fb | 2017-03-21 09:14:35 -0400 | [diff] [blame] | 47 | bool GrGpu::isACopyNeededForTextureParams(int width, int height, |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 48 | const GrSamplerState& textureParams, |
Robert Phillips | 81444fb | 2017-03-21 09:14:35 -0400 | [diff] [blame] | 49 | GrTextureProducer::CopyParams* copyParams, |
| 50 | SkScalar scaleAdjust[2]) const { |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 51 | const GrCaps& caps = *this->caps(); |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 52 | if (textureParams.isRepeated() && !caps.npotTextureTileSupport() && |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 53 | (!SkIsPow2(width) || !SkIsPow2(height))) { |
Robert Phillips | 67c18d6 | 2017-01-20 12:44:06 -0500 | [diff] [blame] | 54 | SkASSERT(scaleAdjust); |
bsalomon | 100b8f8 | 2015-10-28 08:37:44 -0700 | [diff] [blame] | 55 | copyParams->fWidth = GrNextPow2(width); |
| 56 | copyParams->fHeight = GrNextPow2(height); |
Robert Phillips | 67c18d6 | 2017-01-20 12:44:06 -0500 | [diff] [blame] | 57 | scaleAdjust[0] = ((SkScalar) copyParams->fWidth) / width; |
| 58 | scaleAdjust[1] = ((SkScalar) copyParams->fHeight) / height; |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 59 | switch (textureParams.filter()) { |
| 60 | case GrSamplerState::Filter::kNearest: |
| 61 | copyParams->fFilter = GrSamplerState::Filter::kNearest; |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 62 | break; |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 63 | case GrSamplerState::Filter::kBilerp: |
| 64 | case GrSamplerState::Filter::kMipMap: |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 65 | // We are only ever scaling up so no reason to ever indicate kMipMap. |
Brian Salomon | 2bbdcc4 | 2017-09-07 12:36:34 -0400 | [diff] [blame] | 66 | copyParams->fFilter = GrSamplerState::Filter::kBilerp; |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 67 | break; |
| 68 | } |
bsalomon | 100b8f8 | 2015-10-28 08:37:44 -0700 | [diff] [blame] | 69 | return true; |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 70 | } |
bsalomon | 100b8f8 | 2015-10-28 08:37:44 -0700 | [diff] [blame] | 71 | return false; |
bsalomon | 045802d | 2015-10-20 07:58:01 -0700 | [diff] [blame] | 72 | } |
| 73 | |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 74 | /** |
| 75 | * Prior to creating a texture, make sure the type of texture being created is |
| 76 | * supported by calling check_texture_creation_params. |
| 77 | * |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 78 | * @param caps The capabilities of the GL device. |
| 79 | * @param desc The descriptor of the texture to create. |
| 80 | * @param isRT Indicates if the texture can be a render target. |
| 81 | * @param texels The texel data for the mipmap levels |
| 82 | * @param mipLevelCount The number of GrMipLevels in 'texels' |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 83 | */ |
| 84 | static bool check_texture_creation_params(const GrCaps& caps, const GrSurfaceDesc& desc, |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 85 | bool* isRT, |
| 86 | const GrMipLevel texels[], int mipLevelCount) { |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 87 | if (!caps.isConfigTexturable(desc.fConfig)) { |
| 88 | return false; |
robertphillips@google.com | d3eb336 | 2012-10-31 13:56:35 +0000 | [diff] [blame] | 89 | } |
krajcevski | 9c0e629 | 2014-06-02 07:38:14 -0700 | [diff] [blame] | 90 | |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 91 | if (GrPixelConfigIsSint(desc.fConfig) && mipLevelCount > 1) { |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 92 | return false; |
| 93 | } |
| 94 | |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 95 | *isRT = SkToBool(desc.fFlags & kRenderTarget_GrSurfaceFlag); |
| 96 | if (*isRT && !caps.isConfigRenderable(desc.fConfig, desc.fSampleCnt > 0)) { |
| 97 | return false; |
commit-bot@chromium.org | 6b7938f | 2013-10-15 14:18:16 +0000 | [diff] [blame] | 98 | } |
robertphillips@google.com | d3eb336 | 2012-10-31 13:56:35 +0000 | [diff] [blame] | 99 | |
robertphillips | 6e83ac7 | 2015-08-13 05:19:14 -0700 | [diff] [blame] | 100 | // We currently do not support multisampled textures |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 101 | if (!*isRT && desc.fSampleCnt > 0) { |
| 102 | return false; |
| 103 | } |
| 104 | |
| 105 | if (*isRT) { |
| 106 | int maxRTSize = caps.maxRenderTargetSize(); |
| 107 | if (desc.fWidth > maxRTSize || desc.fHeight > maxRTSize) { |
| 108 | return false; |
| 109 | } |
| 110 | } else { |
| 111 | int maxSize = caps.maxTextureSize(); |
| 112 | if (desc.fWidth > maxSize || desc.fHeight > maxSize) { |
| 113 | return false; |
| 114 | } |
| 115 | } |
bsalomon | e699d0c | 2016-03-09 06:25:15 -0800 | [diff] [blame] | 116 | |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 117 | return true; |
| 118 | } |
| 119 | |
Robert Phillips | 67d52cf | 2017-06-05 13:38:13 -0400 | [diff] [blame] | 120 | sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& origDesc, SkBudgeted budgeted, |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 121 | const GrMipLevel texels[], int mipLevelCount) { |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 122 | GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "createTexture", fContext); |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 123 | GrSurfaceDesc desc = origDesc; |
| 124 | |
| 125 | const GrCaps* caps = this->caps(); |
| 126 | bool isRT = false; |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 127 | bool textureCreationParamsValid = check_texture_creation_params(*caps, desc, &isRT, |
| 128 | texels, mipLevelCount); |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 129 | if (!textureCreationParamsValid) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 130 | return nullptr; |
egdaniel | 8c9b6f1 | 2015-05-12 13:36:30 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Greg Daniel | 81e7bf8 | 2017-07-19 14:47:42 -0400 | [diff] [blame] | 133 | desc.fSampleCnt = caps->getSampleCount(desc.fSampleCnt, desc.fConfig); |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 134 | // Attempt to catch un- or wrongly initialized sample counts. |
egdaniel | b0e1be2 | 2015-04-22 13:27:39 -0700 | [diff] [blame] | 135 | SkASSERT(desc.fSampleCnt >= 0 && desc.fSampleCnt <= 64); |
egdaniel | b0e1be2 | 2015-04-22 13:27:39 -0700 | [diff] [blame] | 136 | |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 137 | if (mipLevelCount && (desc.fFlags & kPerformInitialClear_GrSurfaceFlag)) { |
Brian Salomon | d17b4a6 | 2017-05-23 16:53:47 -0400 | [diff] [blame] | 138 | return nullptr; |
| 139 | } |
| 140 | |
Robert Phillips | 92de631 | 2017-05-23 07:43:48 -0400 | [diff] [blame] | 141 | this->handleDirtyContext(); |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 142 | sk_sp<GrTexture> tex = this->onCreateTexture(desc, budgeted, texels, mipLevelCount); |
bsalomon | b12ea41 | 2015-02-02 21:19:50 -0800 | [diff] [blame] | 143 | if (tex) { |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 144 | if (!caps->reuseScratchTextures() && !isRT) { |
| 145 | tex->resourcePriv().removeScratchKey(); |
| 146 | } |
bsalomon | b12ea41 | 2015-02-02 21:19:50 -0800 | [diff] [blame] | 147 | fStats.incTextureCreates(); |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 148 | if (mipLevelCount) { |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 149 | if (texels[0].fPixels) { |
| 150 | fStats.incTextureUploads(); |
| 151 | } |
bsalomon | b12ea41 | 2015-02-02 21:19:50 -0800 | [diff] [blame] | 152 | } |
| 153 | } |
bsalomon@google.com | 81c3f8d | 2011-08-03 15:18:33 +0000 | [diff] [blame] | 154 | return tex; |
| 155 | } |
| 156 | |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 157 | sk_sp<GrTexture> GrGpu::createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted) { |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 158 | return this->createTexture(desc, budgeted, nullptr, 0); |
Robert Phillips | 646e429 | 2017-06-13 12:44:56 -0400 | [diff] [blame] | 159 | } |
| 160 | |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 161 | sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex, |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 162 | GrWrapOwnership ownership) { |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 163 | this->handleDirtyContext(); |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 164 | if (!this->caps()->isConfigTexturable(backendTex.config())) { |
bsalomon | 5b30c6f | 2015-12-17 14:17:34 -0800 | [diff] [blame] | 165 | return nullptr; |
| 166 | } |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 167 | if (backendTex.width() > this->caps()->maxTextureSize() || |
| 168 | backendTex.height() > this->caps()->maxTextureSize()) { |
bsalomon | 5b30c6f | 2015-12-17 14:17:34 -0800 | [diff] [blame] | 169 | return nullptr; |
| 170 | } |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 171 | sk_sp<GrTexture> tex = this->onWrapBackendTexture(backendTex, ownership); |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 172 | if (!tex) { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 173 | return nullptr; |
bsalomon@google.com | a14dd6d | 2012-01-03 21:08:12 +0000 | [diff] [blame] | 174 | } |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 175 | return tex; |
| 176 | } |
Eric Karl | 5c77975 | 2017-05-08 12:02:07 -0700 | [diff] [blame] | 177 | |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 178 | sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex, |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 179 | int sampleCnt, GrWrapOwnership ownership) { |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 180 | this->handleDirtyContext(); |
| 181 | if (!this->caps()->isConfigTexturable(backendTex.config()) || |
| 182 | !this->caps()->isConfigRenderable(backendTex.config(), sampleCnt > 0)) { |
| 183 | return nullptr; |
| 184 | } |
| 185 | |
| 186 | if (backendTex.width() > this->caps()->maxRenderTargetSize() || |
| 187 | backendTex.height() > this->caps()->maxRenderTargetSize()) { |
| 188 | return nullptr; |
| 189 | } |
Robert Phillips | c0192e3 | 2017-09-21 12:00:26 -0400 | [diff] [blame] | 190 | sk_sp<GrTexture> tex = this->onWrapRenderableBackendTexture(backendTex, sampleCnt, ownership); |
Brian Salomon | d17f658 | 2017-07-19 18:28:58 -0400 | [diff] [blame] | 191 | if (!tex) { |
| 192 | return nullptr; |
| 193 | } |
| 194 | SkASSERT(tex->asRenderTarget()); |
bungeman | 6bd5284 | 2016-10-27 09:30:08 -0700 | [diff] [blame] | 195 | return tex; |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 198 | sk_sp<GrRenderTarget> GrGpu::wrapBackendRenderTarget(const GrBackendRenderTarget& backendRT) { |
Greg Daniel | bcf612b | 2017-05-01 13:50:58 +0000 | [diff] [blame] | 199 | if (!this->caps()->isConfigRenderable(backendRT.config(), backendRT.sampleCnt() > 0)) { |
bsalomon | 5b30c6f | 2015-12-17 14:17:34 -0800 | [diff] [blame] | 200 | return nullptr; |
| 201 | } |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 202 | this->handleDirtyContext(); |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 203 | return this->onWrapBackendRenderTarget(backendRT); |
bsalomon@google.com | e269f21 | 2011-11-07 13:29:52 +0000 | [diff] [blame] | 204 | } |
| 205 | |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 206 | sk_sp<GrRenderTarget> GrGpu::wrapBackendTextureAsRenderTarget(const GrBackendTexture& tex, |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 207 | int sampleCnt) { |
ericrk | f7b8b8a | 2016-02-24 14:49:51 -0800 | [diff] [blame] | 208 | this->handleDirtyContext(); |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 209 | if (!this->caps()->isConfigRenderable(tex.config(), sampleCnt > 0)) { |
ericrk | f7b8b8a | 2016-02-24 14:49:51 -0800 | [diff] [blame] | 210 | return nullptr; |
| 211 | } |
| 212 | int maxSize = this->caps()->maxTextureSize(); |
Greg Daniel | 7ef28f3 | 2017-04-20 16:41:55 +0000 | [diff] [blame] | 213 | if (tex.width() > maxSize || tex.height() > maxSize) { |
ericrk | f7b8b8a | 2016-02-24 14:49:51 -0800 | [diff] [blame] | 214 | return nullptr; |
| 215 | } |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 216 | return this->onWrapBackendTextureAsRenderTarget(tex, sampleCnt); |
ericrk | f7b8b8a | 2016-02-24 14:49:51 -0800 | [diff] [blame] | 217 | } |
| 218 | |
cdalton | e2e71c2 | 2016-04-07 18:13:29 -0700 | [diff] [blame] | 219 | GrBuffer* GrGpu::createBuffer(size_t size, GrBufferType intendedType, |
cdalton | 1bf3e71 | 2016-04-19 10:00:02 -0700 | [diff] [blame] | 220 | GrAccessPattern accessPattern, const void* data) { |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 221 | this->handleDirtyContext(); |
cdalton | 1bf3e71 | 2016-04-19 10:00:02 -0700 | [diff] [blame] | 222 | GrBuffer* buffer = this->onCreateBuffer(size, intendedType, accessPattern, data); |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 223 | if (!this->caps()->reuseScratchBuffers()) { |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 224 | buffer->resourcePriv().removeScratchKey(); |
robertphillips | 1b8e1b5 | 2015-06-24 06:54:10 -0700 | [diff] [blame] | 225 | } |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 226 | return buffer; |
jvanverth | 73063dc | 2015-12-03 09:15:47 -0800 | [diff] [blame] | 227 | } |
| 228 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 229 | bool GrGpu::copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, |
| 230 | GrSurface* src, GrSurfaceOrigin srcOrigin, |
| 231 | const SkIRect& srcRect, const SkIPoint& dstPoint) { |
Brian Salomon | dcbb9d9 | 2017-07-19 10:53:20 -0400 | [diff] [blame] | 232 | GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "copySurface", fContext); |
joshualitt | 1cbdcde | 2015-08-21 11:53:29 -0700 | [diff] [blame] | 233 | SkASSERT(dst && src); |
| 234 | this->handleDirtyContext(); |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 235 | // We don't allow conversion between integer configs and float/fixed configs. |
| 236 | if (GrPixelConfigIsSint(dst->config()) != GrPixelConfigIsSint(src->config())) { |
| 237 | return false; |
| 238 | } |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 239 | return this->onCopySurface(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint); |
joshualitt | 1cbdcde | 2015-08-21 11:53:29 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 242 | bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, GrSurfaceOrigin srcOrigin, |
| 243 | int width, int height, size_t rowBytes, |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 244 | GrPixelConfig readConfig, DrawPreference* drawPreference, |
| 245 | ReadPixelTempDrawInfo* tempDrawInfo) { |
| 246 | SkASSERT(drawPreference); |
| 247 | SkASSERT(tempDrawInfo); |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 248 | SkASSERT(srcSurface); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 249 | SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
| 250 | |
egdaniel | 3fe0327 | 2016-08-15 10:59:17 -0700 | [diff] [blame] | 251 | // We currently do not support reading into the packed formats 565 or 4444 as they are not |
| 252 | // required to have read back support on all devices and backends. |
| 253 | if (kRGB_565_GrPixelConfig == readConfig || kRGBA_4444_GrPixelConfig == readConfig) { |
| 254 | return false; |
| 255 | } |
| 256 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 257 | if (!this->onGetReadPixelsInfo(srcSurface, srcOrigin, width, height, rowBytes, readConfig, |
| 258 | drawPreference, tempDrawInfo)) { |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 259 | return false; |
| 260 | } |
| 261 | |
| 262 | // Check to see if we're going to request that the caller draw when drawing is not possible. |
| 263 | if (!srcSurface->asTexture() || |
| 264 | !this->caps()->isConfigRenderable(tempDrawInfo->fTempSurfaceDesc.fConfig, false)) { |
| 265 | // If we don't have a fallback to a straight read then fail. |
| 266 | if (kRequireDraw_DrawPreference == *drawPreference) { |
| 267 | return false; |
| 268 | } |
| 269 | *drawPreference = kNoDraw_DrawPreference; |
| 270 | } |
| 271 | |
| 272 | return true; |
| 273 | } |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 274 | bool GrGpu::getWritePixelsInfo(GrSurface* dstSurface, GrSurfaceOrigin dstOrigin, |
| 275 | int width, int height, |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 276 | GrPixelConfig srcConfig, DrawPreference* drawPreference, |
| 277 | WritePixelTempDrawInfo* tempDrawInfo) { |
| 278 | SkASSERT(drawPreference); |
| 279 | SkASSERT(tempDrawInfo); |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 280 | SkASSERT(dstSurface); |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 281 | SkASSERT(kGpuPrefersDraw_DrawPreference != *drawPreference); |
| 282 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 283 | if (!this->onGetWritePixelsInfo(dstSurface, dstOrigin, width, height, srcConfig, drawPreference, |
bsalomon | f067451 | 2015-07-28 13:26:15 -0700 | [diff] [blame] | 284 | tempDrawInfo)) { |
| 285 | return false; |
| 286 | } |
| 287 | |
| 288 | // Check to see if we're going to request that the caller draw when drawing is not possible. |
| 289 | if (!dstSurface->asRenderTarget() || |
| 290 | !this->caps()->isConfigTexturable(tempDrawInfo->fTempSurfaceDesc.fConfig)) { |
| 291 | // If we don't have a fallback to a straight upload then fail. |
| 292 | if (kRequireDraw_DrawPreference == *drawPreference || |
| 293 | !this->caps()->isConfigTexturable(srcConfig)) { |
| 294 | return false; |
| 295 | } |
| 296 | *drawPreference = kNoDraw_DrawPreference; |
| 297 | } |
| 298 | return true; |
| 299 | } |
| 300 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 301 | bool GrGpu::readPixels(GrSurface* surface, GrSurfaceOrigin origin, |
bsalomon@google.com | 669fdc4 | 2011-04-05 17:08:27 +0000 | [diff] [blame] | 302 | int left, int top, int width, int height, |
bsalomon@google.com | c698097 | 2011-11-02 19:57:21 +0000 | [diff] [blame] | 303 | GrPixelConfig config, void* buffer, |
senorblanco@chromium.org | 3cb406b | 2013-02-05 19:50:46 +0000 | [diff] [blame] | 304 | size_t rowBytes) { |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 305 | SkASSERT(surface); |
| 306 | |
| 307 | // We don't allow conversion between integer configs and float/fixed configs. |
| 308 | if (GrPixelConfigIsSint(surface->config()) != GrPixelConfigIsSint(config)) { |
| 309 | return false; |
| 310 | } |
egdaniel | 6d901da | 2015-07-30 12:02:15 -0700 | [diff] [blame] | 311 | |
egdaniel | 6d901da | 2015-07-30 12:02:15 -0700 | [diff] [blame] | 312 | size_t bpp = GrBytesPerPixel(config); |
| 313 | if (!GrSurfacePriv::AdjustReadPixelParams(surface->width(), surface->height(), bpp, |
| 314 | &left, &top, &width, &height, |
| 315 | &buffer, |
| 316 | &rowBytes)) { |
| 317 | return false; |
| 318 | } |
| 319 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 320 | this->handleDirtyContext(); |
| 321 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 322 | return this->onReadPixels(surface, origin, |
egdaniel | 6d901da | 2015-07-30 12:02:15 -0700 | [diff] [blame] | 323 | left, top, width, height, |
| 324 | config, buffer, |
| 325 | rowBytes); |
bsalomon@google.com | a7f84e1 | 2011-03-10 14:13:19 +0000 | [diff] [blame] | 326 | } |
| 327 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 328 | bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, |
bsalomon | 6cb3cbe | 2015-07-30 07:34:27 -0700 | [diff] [blame] | 329 | int left, int top, int width, int height, |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 330 | GrPixelConfig config, const GrMipLevel texels[], int mipLevelCount) { |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 331 | SkASSERT(surface); |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 332 | if (1 == mipLevelCount) { |
Greg Daniel | 660cc99 | 2017-06-26 14:55:05 -0400 | [diff] [blame] | 333 | // We require that if we are not mipped, then the write region is contained in the surface |
| 334 | SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height); |
| 335 | SkIRect bounds = SkIRect::MakeWH(surface->width(), surface->height()); |
| 336 | if (!bounds.contains(subRect)) { |
| 337 | return false; |
| 338 | } |
| 339 | } else if (0 != left || 0 != top || width != surface->width() || height != surface->height()) { |
| 340 | // We require that if the texels are mipped, than the write region is the entire surface |
| 341 | return false; |
| 342 | } |
Robert Phillips | b7b7e5f | 2017-05-22 13:23:19 -0400 | [diff] [blame] | 343 | |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 344 | for (int currentMipLevel = 0; currentMipLevel < mipLevelCount; currentMipLevel++) { |
bsalomon | e699d0c | 2016-03-09 06:25:15 -0800 | [diff] [blame] | 345 | if (!texels[currentMipLevel].fPixels ) { |
| 346 | return false; |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 347 | } |
| 348 | } |
jvanverth | 2dc2994 | 2015-09-01 07:16:46 -0700 | [diff] [blame] | 349 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 350 | // We don't allow conversion between integer configs and float/fixed configs. |
| 351 | if (GrPixelConfigIsSint(surface->config()) != GrPixelConfigIsSint(config)) { |
| 352 | return false; |
| 353 | } |
| 354 | |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 355 | this->handleDirtyContext(); |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 356 | if (this->onWritePixels(surface, origin, left, top, width, height, config, |
| 357 | texels, mipLevelCount)) { |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 358 | SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 359 | this->didWriteToSurface(surface, &rect, mipLevelCount); |
bsalomon | b12ea41 | 2015-02-02 21:19:50 -0800 | [diff] [blame] | 360 | fStats.incTextureUploads(); |
| 361 | return true; |
| 362 | } |
| 363 | return false; |
bsalomon@google.com | 6f37951 | 2011-11-16 20:36:03 +0000 | [diff] [blame] | 364 | } |
| 365 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 366 | bool GrGpu::writePixels(GrSurface* surface, GrSurfaceOrigin origin, |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 367 | int left, int top, int width, int height, |
| 368 | GrPixelConfig config, const void* buffer, |
| 369 | size_t rowBytes) { |
Robert Phillips | 590533f | 2017-07-11 14:22:35 -0400 | [diff] [blame] | 370 | GrMipLevel mipLevel = { buffer, rowBytes }; |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 371 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 372 | return this->writePixels(surface, origin, left, top, width, height, config, &mipLevel, 1); |
cblume | 55f2d2d | 2016-02-26 13:20:48 -0800 | [diff] [blame] | 373 | } |
| 374 | |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 375 | bool GrGpu::transferPixels(GrTexture* texture, |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 376 | int left, int top, int width, int height, |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 377 | GrPixelConfig config, GrBuffer* transferBuffer, |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 378 | size_t offset, size_t rowBytes) { |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 379 | SkASSERT(transferBuffer); |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 380 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 381 | // We don't allow conversion between integer configs and float/fixed configs. |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 382 | if (GrPixelConfigIsSint(texture->config()) != GrPixelConfigIsSint(config)) { |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 383 | return false; |
| 384 | } |
| 385 | |
Greg Daniel | 660cc99 | 2017-06-26 14:55:05 -0400 | [diff] [blame] | 386 | // We require that the write region is contained in the texture |
| 387 | SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height); |
| 388 | SkIRect bounds = SkIRect::MakeWH(texture->width(), texture->height()); |
| 389 | if (!bounds.contains(subRect)) { |
| 390 | return false; |
| 391 | } |
| 392 | |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 393 | this->handleDirtyContext(); |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 394 | if (this->onTransferPixels(texture, left, top, width, height, config, |
cdalton | 397536c | 2016-03-25 12:15:03 -0700 | [diff] [blame] | 395 | transferBuffer, offset, rowBytes)) { |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 396 | SkIRect rect = SkIRect::MakeXYWH(left, top, width, height); |
Jim Van Verth | 2e5eaf0 | 2017-06-21 15:55:46 -0400 | [diff] [blame] | 397 | this->didWriteToSurface(texture, &rect); |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 398 | fStats.incTransfersToTexture(); |
jvanverth | 84741b3 | 2016-09-30 08:39:02 -0700 | [diff] [blame] | 399 | |
jvanverth | 17aa047 | 2016-01-05 10:41:27 -0800 | [diff] [blame] | 400 | return true; |
| 401 | } |
| 402 | return false; |
| 403 | } |
| 404 | |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 405 | void GrGpu::resolveRenderTarget(GrRenderTarget* target, GrSurfaceOrigin origin) { |
tfarina@chromium.org | f6de475 | 2013-08-17 00:02:59 +0000 | [diff] [blame] | 406 | SkASSERT(target); |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 407 | this->handleDirtyContext(); |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 408 | this->onResolveRenderTarget(target, origin); |
bsalomon@google.com | 75f9f25 | 2012-01-31 13:35:56 +0000 | [diff] [blame] | 409 | } |
| 410 | |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 411 | void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t mipLevels) const { |
| 412 | SkASSERT(surface); |
| 413 | // Mark any MIP chain and resolve buffer as dirty if and only if there is a non-empty bounds. |
| 414 | if (nullptr == bounds || !bounds->isEmpty()) { |
| 415 | if (GrRenderTarget* target = surface->asRenderTarget()) { |
| 416 | target->flagAsNeedingResolve(bounds); |
| 417 | } |
| 418 | GrTexture* texture = surface->asTexture(); |
| 419 | if (texture && 1 == mipLevels) { |
Greg Daniel | 0fc4d2d | 2017-10-12 11:23:36 -0400 | [diff] [blame] | 420 | texture->texturePriv().markMipMapsDirty(); |
jvanverth | 900bd4a | 2016-04-29 13:53:12 -0700 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 425 | const GrGpu::MultisampleSpecs& GrGpu::queryMultisampleSpecs(const GrPipeline& pipeline) { |
Robert Phillips | 2890fbf | 2017-07-26 15:48:41 -0400 | [diff] [blame] | 426 | GrRenderTarget* rt = pipeline.renderTarget(); |
Brian Salomon | 154ce91 | 2017-05-17 10:40:02 -0400 | [diff] [blame] | 427 | SkASSERT(rt->numStencilSamples() > 1); |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 428 | |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 429 | GrStencilSettings stencil; |
| 430 | if (pipeline.isStencilEnabled()) { |
| 431 | // TODO: attach stencil and create settings during render target flush. |
| 432 | SkASSERT(rt->renderTargetPriv().getStencilAttachment()); |
| 433 | stencil.reset(*pipeline.getUserStencil(), pipeline.hasStencilClip(), |
| 434 | rt->renderTargetPriv().numStencilBits()); |
| 435 | } |
| 436 | |
cdalton | 28f45b9 | 2016-03-07 13:58:26 -0800 | [diff] [blame] | 437 | int effectiveSampleCnt; |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 438 | SkSTArray<16, SkPoint, true> pattern; |
Robert Phillips | b0e93a2 | 2017-08-29 08:26:54 -0400 | [diff] [blame] | 439 | this->onQueryMultisampleSpecs(rt, pipeline.proxy()->origin(), stencil, |
| 440 | &effectiveSampleCnt, &pattern); |
Brian Salomon | 154ce91 | 2017-05-17 10:40:02 -0400 | [diff] [blame] | 441 | SkASSERT(effectiveSampleCnt >= rt->numStencilSamples()); |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 442 | |
| 443 | uint8_t id; |
| 444 | if (this->caps()->sampleLocationsSupport()) { |
| 445 | SkASSERT(pattern.count() == effectiveSampleCnt); |
| 446 | const auto& insertResult = fMultisampleSpecsIdMap.insert( |
| 447 | MultisampleSpecsIdMap::value_type(pattern, SkTMin(fMultisampleSpecs.count(), 255))); |
| 448 | id = insertResult.first->second; |
| 449 | if (insertResult.second) { |
| 450 | // This means the insert did not find the pattern in the map already, and therefore an |
| 451 | // actual insertion took place. (We don't expect to see many unique sample patterns.) |
| 452 | const SkPoint* sampleLocations = insertResult.first->first.begin(); |
| 453 | SkASSERT(id == fMultisampleSpecs.count()); |
| 454 | fMultisampleSpecs.emplace_back(id, effectiveSampleCnt, sampleLocations); |
| 455 | } |
| 456 | } else { |
| 457 | id = effectiveSampleCnt; |
| 458 | for (int i = fMultisampleSpecs.count(); i <= id; ++i) { |
| 459 | fMultisampleSpecs.emplace_back(i, i, nullptr); |
| 460 | } |
cdalton | 28f45b9 | 2016-03-07 13:58:26 -0800 | [diff] [blame] | 461 | } |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 462 | SkASSERT(id > 0); |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 463 | |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 464 | return fMultisampleSpecs[id]; |
cdalton | 28f45b9 | 2016-03-07 13:58:26 -0800 | [diff] [blame] | 465 | } |
| 466 | |
csmartdalton | 0d28e57 | 2016-07-06 09:59:43 -0700 | [diff] [blame] | 467 | bool GrGpu::SamplePatternComparator::operator()(const SamplePattern& a, |
| 468 | const SamplePattern& b) const { |
| 469 | if (a.count() != b.count()) { |
| 470 | return a.count() < b.count(); |
| 471 | } |
| 472 | for (int i = 0; i < a.count(); ++i) { |
| 473 | // This doesn't have geometric meaning. We just need to define an ordering for std::map. |
| 474 | if (a[i].x() != b[i].x()) { |
| 475 | return a[i].x() < b[i].x(); |
| 476 | } |
| 477 | if (a[i].y() != b[i].y()) { |
| 478 | return a[i].y() < b[i].y(); |
| 479 | } |
| 480 | } |
| 481 | return false; // Equal. |
| 482 | } |
Greg Daniel | 5131678 | 2017-08-02 15:10:09 +0000 | [diff] [blame] | 483 | |
| 484 | GrSemaphoresSubmitted GrGpu::finishFlush(int numSemaphores, |
| 485 | GrBackendSemaphore backendSemaphores[]) { |
| 486 | if (this->caps()->fenceSyncSupport()) { |
| 487 | for (int i = 0; i < numSemaphores; ++i) { |
| 488 | sk_sp<GrSemaphore> semaphore; |
| 489 | if (backendSemaphores[i].isInitialized()) { |
| 490 | semaphore = fContext->resourceProvider()->wrapBackendSemaphore( |
| 491 | backendSemaphores[i], kBorrow_GrWrapOwnership); |
| 492 | } else { |
| 493 | semaphore = fContext->resourceProvider()->makeSemaphore(false); |
| 494 | } |
| 495 | this->insertSemaphore(semaphore, false); |
| 496 | |
| 497 | if (!backendSemaphores[i].isInitialized()) { |
| 498 | semaphore->setBackendSemaphore(&backendSemaphores[i]); |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | this->onFinishFlush((numSemaphores > 0 && this->caps()->fenceSyncSupport())); |
| 503 | return this->caps()->fenceSyncSupport() ? GrSemaphoresSubmitted::kYes |
| 504 | : GrSemaphoresSubmitted::kNo; |
| 505 | } |
Brian Osman | 71a1889 | 2017-08-10 10:23:25 -0400 | [diff] [blame] | 506 | |
| 507 | void GrGpu::dumpJSON(SkJSONWriter* writer) const { |
| 508 | writer->beginObject(); |
| 509 | |
| 510 | // TODO: Is there anything useful in the base class to dump here? |
| 511 | |
| 512 | this->onDumpJSON(writer); |
| 513 | |
| 514 | writer->endObject(); |
| 515 | } |