Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [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/vk/GrVkRenderTarget.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 9 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 10 | #include "include/gpu/GrBackendSurface.h" |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 11 | #include "include/gpu/GrDirectContext.h" |
| 12 | #include "src/gpu/GrBackendSurfaceMutableStateImpl.h" |
Adlai Holler | a069304 | 2020-10-14 11:23:11 -0400 | [diff] [blame] | 13 | #include "src/gpu/GrDirectContextPriv.h" |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 14 | #include "src/gpu/GrResourceProvider.h" |
| 15 | #include "src/gpu/vk/GrVkAttachment.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/gpu/vk/GrVkCommandBuffer.h" |
Greg Daniel | 37fd658 | 2020-09-14 12:36:09 -0400 | [diff] [blame] | 17 | #include "src/gpu/vk/GrVkDescriptorSet.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 18 | #include "src/gpu/vk/GrVkFramebuffer.h" |
| 19 | #include "src/gpu/vk/GrVkGpu.h" |
| 20 | #include "src/gpu/vk/GrVkImageView.h" |
| 21 | #include "src/gpu/vk/GrVkResourceProvider.h" |
| 22 | #include "src/gpu/vk/GrVkUtil.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 23 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 24 | #include "include/gpu/vk/GrVkTypes.h" |
jvanverth | fd359ca | 2016-03-18 11:57:24 -0700 | [diff] [blame] | 25 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 26 | #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) |
| 27 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 28 | static int renderpass_features_to_index(bool hasResolve, bool hasStencil, |
| 29 | GrVkRenderPass::SelfDependencyFlags selfDepFlags, |
| 30 | GrVkRenderPass::LoadFromResolve loadFromReslove) { |
| 31 | int index = 0; |
| 32 | if (hasResolve) { |
| 33 | index += 1; |
| 34 | } |
| 35 | if (hasStencil) { |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 36 | index += 2; |
| 37 | } |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 38 | if (selfDepFlags & GrVkRenderPass::SelfDependencyFlags::kForInputAttachment) { |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 39 | index += 4; |
| 40 | } |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 41 | if (selfDepFlags & GrVkRenderPass::SelfDependencyFlags::kForNonCoherentAdvBlend) { |
| 42 | index += 8; |
| 43 | } |
| 44 | if (loadFromReslove == GrVkRenderPass::LoadFromResolve::kLoad) { |
| 45 | index += 16; |
| 46 | } |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 47 | return index; |
| 48 | } |
| 49 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 50 | // We're virtually derived from GrSurface (via GrRenderTarget) so its |
| 51 | // constructor must be explicitly called. |
| 52 | GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu, |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 53 | SkISize dimensions, |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 54 | sk_sp<GrVkAttachment> colorAttachment, |
| 55 | sk_sp<GrVkAttachment> resolveAttachment, |
| 56 | CreateType createType) |
| 57 | : GrSurface(gpu, dimensions, |
| 58 | colorAttachment->isProtected() ? GrProtected::kYes : GrProtected::kNo) |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 59 | // for the moment we only support 1:1 color to stencil |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 60 | , GrRenderTarget(gpu, dimensions, colorAttachment->numSamples(), |
| 61 | colorAttachment->isProtected() ? GrProtected::kYes : GrProtected::kNo) |
| 62 | , fColorAttachment(std::move(colorAttachment)) |
| 63 | , fResolveAttachment(std::move(resolveAttachment)) |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 64 | , fCachedFramebuffers() |
| 65 | , fCachedRenderPasses() { |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 66 | SkASSERT(fColorAttachment); |
| 67 | SkASSERT(!resolveAttachment || |
| 68 | (fResolveAttachment->isProtected() == fColorAttachment->isProtected())); |
| 69 | SkASSERT(SkToBool(fColorAttachment->vkUsageFlags() & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)); |
| 70 | this->setFlags(); |
| 71 | if (createType == CreateType::kDirectlyWrapped) { |
| 72 | this->registerWithCacheWrapped(GrWrapCacheable::kNo); |
| 73 | } |
Greg Daniel | 7b62dca | 2020-08-21 11:26:12 -0400 | [diff] [blame] | 74 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 75 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 76 | GrVkRenderTarget::GrVkRenderTarget(GrVkGpu* gpu, |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 77 | SkISize dimensions, |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 78 | sk_sp<GrVkAttachment> colorAttachment, |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 79 | const GrVkRenderPass* renderPass, |
Greg Daniel | 8daf3b7 | 2019-07-30 09:57:26 -0400 | [diff] [blame] | 80 | VkCommandBuffer secondaryCommandBuffer) |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 81 | : GrSurface(gpu, dimensions, |
| 82 | colorAttachment->isProtected() ? GrProtected::kYes : GrProtected::kNo) |
| 83 | , GrRenderTarget(gpu, dimensions, 1, |
| 84 | colorAttachment->isProtected() ? GrProtected::kYes : GrProtected::kNo) |
| 85 | , fColorAttachment(std::move(colorAttachment)) |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 86 | , fCachedFramebuffers() |
| 87 | , fCachedRenderPasses() |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 88 | , fSecondaryCommandBuffer(secondaryCommandBuffer) { |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 89 | SkASSERT(fColorAttachment->numSamples() == 1); |
Greg Daniel | 8daf3b7 | 2019-07-30 09:57:26 -0400 | [diff] [blame] | 90 | SkASSERT(fSecondaryCommandBuffer != VK_NULL_HANDLE); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 91 | SkASSERT(SkToBool(fColorAttachment->vkUsageFlags() & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)); |
| 92 | SkASSERT(!SkToBool(fColorAttachment->vkUsageFlags() & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)); |
| 93 | this->setFlags(); |
Brian Salomon | aa6ca0a | 2019-01-24 16:03:07 -0500 | [diff] [blame] | 94 | this->registerWithCacheWrapped(GrWrapCacheable::kNo); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 95 | // We use the cached renderpass with no stencil and no extra dependencies to hold the external |
| 96 | // render pass. |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 97 | int exteralRPIndex = renderpass_features_to_index(false, false, SelfDependencyFlags::kNone, |
| 98 | LoadFromResolve::kNo); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 99 | fCachedRenderPasses[exteralRPIndex] = renderPass; |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 100 | } |
| 101 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 102 | void GrVkRenderTarget::setFlags() { |
| 103 | GrVkAttachment* nonMSAAAttachment = this->nonMSAAAttachment(); |
| 104 | if (nonMSAAAttachment && nonMSAAAttachment->supportsInputAttachmentUsage()) { |
Greg Daniel | 638b2e8 | 2020-08-27 14:29:00 -0400 | [diff] [blame] | 105 | this->setVkRTSupportsInputAttachment(); |
| 106 | } |
| 107 | } |
| 108 | |
Greg Daniel | 6c6caf4 | 2020-05-29 12:11:05 -0400 | [diff] [blame] | 109 | sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeWrappedRenderTarget( |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 110 | GrVkGpu* gpu, |
| 111 | SkISize dimensions, |
| 112 | int sampleCnt, |
| 113 | const GrVkImageInfo& info, |
Greg Daniel | 6c6caf4 | 2020-05-29 12:11:05 -0400 | [diff] [blame] | 114 | sk_sp<GrBackendSurfaceMutableStateImpl> mutableState) { |
Greg Daniel | 001c67f | 2018-06-26 13:51:57 -0400 | [diff] [blame] | 115 | SkASSERT(VK_NULL_HANDLE != info.fImage); |
egdaniel | 50ead53 | 2016-07-13 14:23:26 -0700 | [diff] [blame] | 116 | SkASSERT(1 == info.fLevelCount); |
Brian Salomon | 72c7b98 | 2020-10-06 10:07:38 -0400 | [diff] [blame] | 117 | SkASSERT(sampleCnt >= 1 && info.fSampleCount >= 1); |
| 118 | |
| 119 | int wrappedImageSampleCnt = static_cast<int>(info.fSampleCount); |
| 120 | if (sampleCnt != wrappedImageSampleCnt && wrappedImageSampleCnt != 1) { |
| 121 | return nullptr; |
| 122 | } |
| 123 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 124 | sk_sp<GrVkAttachment> wrappedAttachment = |
| 125 | GrVkAttachment::MakeWrapped(gpu, dimensions, info, std::move(mutableState), |
| 126 | GrAttachment::UsageFlags::kColorAttachment, |
| 127 | kBorrow_GrWrapOwnership, GrWrapCacheable::kNo); |
| 128 | if (!wrappedAttachment) { |
egdaniel | b2df0c2 | 2016-05-13 11:30:37 -0700 | [diff] [blame] | 129 | return nullptr; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 130 | } |
| 131 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 132 | sk_sp<GrVkAttachment> colorAttachment; |
| 133 | colorAttachment = std::move(wrappedAttachment); |
| 134 | |
| 135 | if (!colorAttachment) { |
| 136 | return nullptr; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 137 | } |
| 138 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 139 | GrVkRenderTarget* vkRT = new GrVkRenderTarget(gpu, dimensions, std::move(colorAttachment), |
| 140 | nullptr, CreateType::kDirectlyWrapped); |
Greg Daniel | 001c67f | 2018-06-26 13:51:57 -0400 | [diff] [blame] | 141 | return sk_sp<GrVkRenderTarget>(vkRT); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 142 | } |
| 143 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 144 | sk_sp<GrVkRenderTarget> GrVkRenderTarget::MakeSecondaryCBRenderTarget( |
Brian Salomon | a56a746 | 2020-02-07 14:17:25 -0500 | [diff] [blame] | 145 | GrVkGpu* gpu, SkISize dimensions, const GrVkDrawableInfo& vkInfo) { |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 146 | const GrVkRenderPass* rp = gpu->resourceProvider().findCompatibleExternalRenderPass( |
| 147 | vkInfo.fCompatibleRenderPass, vkInfo.fColorAttachmentIndex); |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 148 | if (!rp) { |
| 149 | return nullptr; |
| 150 | } |
| 151 | |
Greg Daniel | 8daf3b7 | 2019-07-30 09:57:26 -0400 | [diff] [blame] | 152 | if (vkInfo.fSecondaryCommandBuffer == VK_NULL_HANDLE) { |
Greg Daniel | 070cbaf | 2019-01-03 17:35:54 -0500 | [diff] [blame] | 153 | return nullptr; |
| 154 | } |
| 155 | |
Greg Daniel | 7f3408b | 2020-06-03 13:31:00 -0400 | [diff] [blame] | 156 | // We only set the few properties of the GrVkImageInfo that we know like layout and format. The |
| 157 | // others we keep at the default "null" values. |
| 158 | GrVkImageInfo info; |
| 159 | info.fImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 160 | info.fFormat = vkInfo.fFormat; |
Greg Daniel | 7b62dca | 2020-08-21 11:26:12 -0400 | [diff] [blame] | 161 | info.fImageUsageFlags = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | |
| 162 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Greg Daniel | 7f3408b | 2020-06-03 13:31:00 -0400 | [diff] [blame] | 163 | |
| 164 | sk_sp<GrBackendSurfaceMutableStateImpl> mutableState(new GrBackendSurfaceMutableStateImpl( |
| 165 | VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_QUEUE_FAMILY_IGNORED)); |
| 166 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 167 | sk_sp<GrVkAttachment> scbAttachment = |
| 168 | GrVkAttachment::MakeWrapped(gpu, dimensions, info, std::move(mutableState), |
| 169 | GrAttachment::UsageFlags::kColorAttachment, |
| 170 | kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, true); |
| 171 | |
| 172 | GrVkRenderTarget* vkRT = new GrVkRenderTarget(gpu, dimensions, std::move(scbAttachment), |
Greg Daniel | 6c6caf4 | 2020-05-29 12:11:05 -0400 | [diff] [blame] | 173 | rp, vkInfo.fSecondaryCommandBuffer); |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 174 | |
| 175 | return sk_sp<GrVkRenderTarget>(vkRT); |
| 176 | } |
| 177 | |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 178 | GrVkAttachment* GrVkRenderTarget::nonMSAAAttachment() const { |
| 179 | if (fColorAttachment->numSamples() == 1) { |
| 180 | return fColorAttachment.get(); |
| 181 | } else { |
| 182 | return fResolveAttachment.get(); |
| 183 | } |
| 184 | } |
| 185 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 186 | bool GrVkRenderTarget::completeStencilAttachment() { |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 187 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 188 | return true; |
| 189 | } |
| 190 | |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 191 | const GrVkRenderPass* GrVkRenderTarget::externalRenderPass() const { |
| 192 | SkASSERT(this->wrapsSecondaryCommandBuffer()); |
| 193 | // We use the cached render pass with no attachments or self dependencies to hold the |
| 194 | // external render pass. |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 195 | int exteralRPIndex = renderpass_features_to_index(false, false, SelfDependencyFlags::kNone, |
| 196 | LoadFromResolve::kNo); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 197 | return fCachedRenderPasses[exteralRPIndex]; |
| 198 | } |
| 199 | |
| 200 | GrVkResourceProvider::CompatibleRPHandle GrVkRenderTarget::compatibleRenderPassHandle( |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 201 | bool withResolve, |
| 202 | bool withStencil, |
| 203 | SelfDependencyFlags selfDepFlags, |
| 204 | LoadFromResolve loadFromResolve) { |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 205 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
| 206 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 207 | int cacheIndex = |
| 208 | renderpass_features_to_index(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 209 | SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedRenderPasses); |
| 210 | |
| 211 | GrVkResourceProvider::CompatibleRPHandle* pRPHandle; |
| 212 | pRPHandle = &fCompatibleRPHandles[cacheIndex]; |
| 213 | |
| 214 | if (!pRPHandle->isValid()) { |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 215 | this->createSimpleRenderPass(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 216 | } |
| 217 | |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 218 | #ifdef SK_DEBUG |
| 219 | const GrVkRenderPass* rp = fCachedRenderPasses[cacheIndex]; |
| 220 | SkASSERT(pRPHandle->isValid() == SkToBool(rp)); |
| 221 | if (rp) { |
| 222 | SkASSERT(selfDepFlags == rp->selfDependencyFlags()); |
| 223 | } |
| 224 | #endif |
| 225 | |
| 226 | return *pRPHandle; |
| 227 | } |
| 228 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 229 | const GrVkRenderPass* GrVkRenderTarget::getSimpleRenderPass(bool withResolve, |
| 230 | bool withStencil, |
| 231 | SelfDependencyFlags selfDepFlags, |
| 232 | LoadFromResolve loadFromResolve) { |
| 233 | int cacheIndex = renderpass_features_to_index(withResolve, withStencil, selfDepFlags, |
| 234 | loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 235 | SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedRenderPasses); |
| 236 | if (const GrVkRenderPass* rp = fCachedRenderPasses[cacheIndex]) { |
| 237 | return rp; |
| 238 | } |
| 239 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 240 | return this->createSimpleRenderPass(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 241 | } |
| 242 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 243 | const GrVkRenderPass* GrVkRenderTarget::createSimpleRenderPass(bool withResolve, |
| 244 | bool withStencil, |
| 245 | SelfDependencyFlags selfDepFlags, |
| 246 | LoadFromResolve loadFromResolve) { |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 247 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
| 248 | |
| 249 | GrVkResourceProvider& rp = this->getVkGpu()->resourceProvider(); |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 250 | int cacheIndex = renderpass_features_to_index(withResolve, withStencil, selfDepFlags, |
| 251 | loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 252 | SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedRenderPasses); |
| 253 | SkASSERT(!fCachedRenderPasses[cacheIndex]); |
| 254 | fCachedRenderPasses[cacheIndex] = rp.findCompatibleRenderPass( |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 255 | *this, &fCompatibleRPHandles[cacheIndex], withResolve, withStencil, selfDepFlags, |
| 256 | loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 257 | return fCachedRenderPasses[cacheIndex]; |
Greg Daniel | fa3adf7 | 2019-11-07 09:53:41 -0500 | [diff] [blame] | 258 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 259 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 260 | const GrVkFramebuffer* GrVkRenderTarget::getFramebuffer(bool withResolve, |
| 261 | bool withStencil, |
| 262 | SelfDependencyFlags selfDepFlags, |
| 263 | LoadFromResolve loadFromResolve) { |
| 264 | int cacheIndex = |
| 265 | renderpass_features_to_index(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 266 | SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedRenderPasses); |
| 267 | if (auto fb = fCachedFramebuffers[cacheIndex]) { |
| 268 | return fb; |
Greg Daniel | fa3adf7 | 2019-11-07 09:53:41 -0500 | [diff] [blame] | 269 | } |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 270 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 271 | return this->createFramebuffer(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Greg Daniel | fa3adf7 | 2019-11-07 09:53:41 -0500 | [diff] [blame] | 272 | } |
| 273 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 274 | const GrVkFramebuffer* GrVkRenderTarget::createFramebuffer(bool withResolve, |
| 275 | bool withStencil, |
| 276 | SelfDependencyFlags selfDepFlags, |
| 277 | LoadFromResolve loadFromResolve) { |
Greg Daniel | fa3adf7 | 2019-11-07 09:53:41 -0500 | [diff] [blame] | 278 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | fa3adf7 | 2019-11-07 09:53:41 -0500 | [diff] [blame] | 279 | GrVkGpu* gpu = this->getVkGpu(); |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 280 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 281 | const GrVkRenderPass* renderPass = |
| 282 | this->getSimpleRenderPass(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Greg Daniel | ed98476 | 2019-11-07 17:15:45 -0500 | [diff] [blame] | 283 | if (!renderPass) { |
| 284 | return nullptr; |
| 285 | } |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 286 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 287 | int cacheIndex = |
| 288 | renderpass_features_to_index(withResolve, withStencil, selfDepFlags, loadFromResolve); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 289 | SkASSERT(cacheIndex < GrVkRenderTarget::kNumCachedRenderPasses); |
| 290 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 291 | const GrVkImageView* resolveView = withResolve ? this->resolveAttachmentView() : nullptr; |
| 292 | |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 293 | // Stencil attachment view is stored in the base RT stencil attachment |
| 294 | const GrVkImageView* stencilView = withStencil ? this->stencilAttachmentView() : nullptr; |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 295 | fCachedFramebuffers[cacheIndex] = |
| 296 | GrVkFramebuffer::Create(gpu, this->width(), this->height(), renderPass, |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 297 | this->colorAttachmentView(), resolveView, stencilView); |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 298 | |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 299 | return fCachedFramebuffers[cacheIndex]; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 300 | } |
| 301 | |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 302 | void GrVkRenderTarget::getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc, |
| 303 | GrVkRenderPass::AttachmentFlags* attachmentFlags, |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 304 | bool withResolve, |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 305 | bool withStencil) const { |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 306 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 307 | desc->fColor.fFormat = fColorAttachment->imageFormat(); |
| 308 | desc->fColor.fSamples = fColorAttachment->numSamples(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 309 | *attachmentFlags = GrVkRenderPass::kColor_AttachmentFlag; |
| 310 | uint32_t attachmentCount = 1; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 311 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 312 | if (withResolve) { |
| 313 | desc->fResolve.fFormat = desc->fColor.fFormat; |
| 314 | desc->fResolve.fSamples = 1; |
| 315 | *attachmentFlags |= GrVkRenderPass::kResolve_AttachmentFlag; |
| 316 | ++attachmentCount; |
| 317 | } |
| 318 | |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 319 | if (withStencil) { |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 320 | const GrAttachment* stencil = this->getStencilAttachment(); |
Robert Phillips | 96f2237 | 2020-05-20 12:31:18 -0400 | [diff] [blame] | 321 | SkASSERT(stencil); |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 322 | const GrVkAttachment* vkStencil = static_cast<const GrVkAttachment*>(stencil); |
Jim Van Verth | bb60408 | 2020-04-13 13:05:07 -0400 | [diff] [blame] | 323 | desc->fStencil.fFormat = vkStencil->imageFormat(); |
Brian Salomon | bdecacf | 2018-02-02 20:32:49 -0500 | [diff] [blame] | 324 | desc->fStencil.fSamples = vkStencil->numSamples(); |
Chris Dalton | 6006105 | 2019-11-11 16:37:24 -0700 | [diff] [blame] | 325 | #ifdef SK_DEBUG |
| 326 | if (this->getVkGpu()->caps()->mixedSamplesSupport()) { |
| 327 | SkASSERT(desc->fStencil.fSamples >= desc->fColor.fSamples); |
| 328 | } else { |
| 329 | SkASSERT(desc->fStencil.fSamples == desc->fColor.fSamples); |
| 330 | } |
| 331 | #endif |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 332 | *attachmentFlags |= GrVkRenderPass::kStencil_AttachmentFlag; |
| 333 | ++attachmentCount; |
| 334 | } |
| 335 | desc->fAttachmentCount = attachmentCount; |
| 336 | } |
| 337 | |
Robert Phillips | 24e2f6e | 2020-06-26 08:30:07 -0400 | [diff] [blame] | 338 | void GrVkRenderTarget::ReconstructAttachmentsDescriptor(const GrVkCaps& vkCaps, |
| 339 | const GrProgramInfo& programInfo, |
| 340 | GrVkRenderPass::AttachmentsDescriptor* desc, |
| 341 | GrVkRenderPass::AttachmentFlags* flags) { |
| 342 | VkFormat format; |
| 343 | SkAssertResult(programInfo.backendFormat().asVkFormat(&format)); |
| 344 | |
| 345 | desc->fColor.fFormat = format; |
| 346 | desc->fColor.fSamples = programInfo.numSamples(); |
| 347 | *flags = GrVkRenderPass::kColor_AttachmentFlag; |
| 348 | uint32_t attachmentCount = 1; |
| 349 | |
Greg Daniel | a1b5d7e | 2020-12-17 10:36:58 -0500 | [diff] [blame] | 350 | if (programInfo.targetSupportsVkResolveLoad() && vkCaps.preferDiscardableMSAAAttachment()) { |
| 351 | desc->fResolve.fFormat = desc->fColor.fFormat; |
| 352 | desc->fResolve.fSamples = 1; |
| 353 | *flags |= GrVkRenderPass::kResolve_AttachmentFlag; |
| 354 | ++attachmentCount; |
| 355 | } |
| 356 | |
Robert Phillips | 24e2f6e | 2020-06-26 08:30:07 -0400 | [diff] [blame] | 357 | SkASSERT(!programInfo.isStencilEnabled() || programInfo.numStencilSamples()); |
| 358 | if (programInfo.numStencilSamples()) { |
Greg Daniel | 8ade5e8 | 2020-10-07 13:09:48 -0400 | [diff] [blame] | 359 | VkFormat stencilFormat = vkCaps.preferredStencilFormat(); |
| 360 | desc->fStencil.fFormat = stencilFormat; |
Robert Phillips | 24e2f6e | 2020-06-26 08:30:07 -0400 | [diff] [blame] | 361 | desc->fStencil.fSamples = programInfo.numStencilSamples(); |
| 362 | #ifdef SK_DEBUG |
| 363 | if (vkCaps.mixedSamplesSupport()) { |
| 364 | SkASSERT(desc->fStencil.fSamples >= desc->fColor.fSamples); |
| 365 | } else { |
| 366 | SkASSERT(desc->fStencil.fSamples == desc->fColor.fSamples); |
| 367 | } |
| 368 | #endif |
| 369 | *flags |= GrVkRenderPass::kStencil_AttachmentFlag; |
| 370 | ++attachmentCount; |
| 371 | } |
| 372 | desc->fAttachmentCount = attachmentCount; |
| 373 | } |
| 374 | |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 375 | const GrVkDescriptorSet* GrVkRenderTarget::inputDescSet(GrVkGpu* gpu, bool forResolve) { |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 376 | SkASSERT((forResolve && fResolveAttachment->supportsInputAttachmentUsage()) || |
| 377 | (!forResolve && fColorAttachment->supportsInputAttachmentUsage())); |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 378 | SkASSERT(this->numSamples() <= 1 || forResolve); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 379 | |
Greg Daniel | 37fd658 | 2020-09-14 12:36:09 -0400 | [diff] [blame] | 380 | if (fCachedInputDescriptorSet) { |
| 381 | return fCachedInputDescriptorSet; |
| 382 | } |
| 383 | fCachedInputDescriptorSet = gpu->resourceProvider().getInputDescriptorSet(); |
| 384 | |
| 385 | if (!fCachedInputDescriptorSet) { |
| 386 | return nullptr; |
| 387 | } |
| 388 | |
| 389 | VkDescriptorImageInfo imageInfo; |
| 390 | memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); |
| 391 | imageInfo.sampler = VK_NULL_HANDLE; |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 392 | imageInfo.imageView = forResolve ? this->resolveAttachmentView()->imageView() |
| 393 | : this->colorAttachmentView()->imageView(); |
| 394 | imageInfo.imageLayout = forResolve ? VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL |
| 395 | : VK_IMAGE_LAYOUT_GENERAL; |
Greg Daniel | 37fd658 | 2020-09-14 12:36:09 -0400 | [diff] [blame] | 396 | |
| 397 | VkWriteDescriptorSet writeInfo; |
| 398 | memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet)); |
| 399 | writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 400 | writeInfo.pNext = nullptr; |
| 401 | writeInfo.dstSet = *fCachedInputDescriptorSet->descriptorSet(); |
| 402 | writeInfo.dstBinding = GrVkUniformHandler::kInputBinding; |
| 403 | writeInfo.dstArrayElement = 0; |
| 404 | writeInfo.descriptorCount = 1; |
| 405 | writeInfo.descriptorType = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 406 | writeInfo.pImageInfo = &imageInfo; |
| 407 | writeInfo.pBufferInfo = nullptr; |
| 408 | writeInfo.pTexelBufferView = nullptr; |
| 409 | |
| 410 | GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), 1, &writeInfo, 0, nullptr)); |
| 411 | |
| 412 | return fCachedInputDescriptorSet; |
| 413 | } |
| 414 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 415 | GrVkRenderTarget::~GrVkRenderTarget() { |
| 416 | // either release or abandon should have been called by the owner of this object. |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 417 | SkASSERT(!fColorAttachment); |
| 418 | SkASSERT(!fResolveAttachment); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 419 | |
| 420 | for (int i = 0; i < kNumCachedRenderPasses; ++i) { |
| 421 | SkASSERT(!fCachedFramebuffers[i]); |
| 422 | SkASSERT(!fCachedRenderPasses[i]); |
| 423 | } |
Greg Daniel | 37fd658 | 2020-09-14 12:36:09 -0400 | [diff] [blame] | 424 | |
| 425 | SkASSERT(!fCachedInputDescriptorSet); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 426 | } |
| 427 | |
Greg Daniel | e2893f2 | 2020-10-13 10:20:06 -0400 | [diff] [blame] | 428 | void GrVkRenderTarget::addResources(GrVkCommandBuffer& commandBuffer, |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 429 | const GrVkRenderPass& renderPass) { |
Greg Daniel | 609e1a9 | 2020-12-11 14:18:19 -0500 | [diff] [blame] | 430 | commandBuffer.addGrSurface(sk_ref_sp<const GrSurface>(this)); |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 431 | commandBuffer.addResource(this->getFramebuffer(renderPass)); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 432 | commandBuffer.addResource(this->colorAttachmentView()); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 433 | commandBuffer.addResource(fColorAttachment->resource()); |
| 434 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 435 | if (this->stencilImageResource()) { |
| 436 | commandBuffer.addResource(this->stencilImageResource()); |
| 437 | commandBuffer.addResource(this->stencilAttachmentView()); |
| 438 | } |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 439 | if (renderPass.hasResolveAttachment()) { |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 440 | SkASSERT(fResolveAttachment); |
| 441 | commandBuffer.addResource(fResolveAttachment->resource()); |
Greg Daniel | 7acddf5 | 2020-12-16 15:15:51 -0500 | [diff] [blame] | 442 | commandBuffer.addResource(this->resolveAttachmentView()); |
| 443 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | void GrVkRenderTarget::releaseInternalObjects() { |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 447 | fColorAttachment.reset(); |
| 448 | fResolveAttachment.reset(); |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 449 | |
| 450 | for (int i = 0; i < kNumCachedRenderPasses; ++i) { |
| 451 | if (fCachedFramebuffers[i]) { |
| 452 | fCachedFramebuffers[i]->unref(); |
| 453 | fCachedFramebuffers[i] = nullptr; |
| 454 | } |
| 455 | if (fCachedRenderPasses[i]) { |
| 456 | fCachedRenderPasses[i]->unref(); |
| 457 | fCachedRenderPasses[i] = nullptr; |
| 458 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 459 | } |
Greg Daniel | 2177436 | 2020-09-14 10:36:43 -0400 | [diff] [blame] | 460 | |
Greg Daniel | 37fd658 | 2020-09-14 12:36:09 -0400 | [diff] [blame] | 461 | if (fCachedInputDescriptorSet) { |
| 462 | fCachedInputDescriptorSet->recycle(); |
| 463 | fCachedInputDescriptorSet = nullptr; |
| 464 | } |
| 465 | |
Greg Daniel | 32d6c8d | 2019-11-25 16:23:50 -0500 | [diff] [blame] | 466 | for (int i = 0; i < fGrSecondaryCommandBuffers.count(); ++i) { |
| 467 | SkASSERT(fGrSecondaryCommandBuffers[i]); |
Jim Van Verth | 5082df1 | 2020-03-11 16:14:51 -0400 | [diff] [blame] | 468 | fGrSecondaryCommandBuffers[i]->releaseResources(); |
Greg Daniel | 32d6c8d | 2019-11-25 16:23:50 -0500 | [diff] [blame] | 469 | } |
| 470 | fGrSecondaryCommandBuffers.reset(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 471 | } |
| 472 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 473 | void GrVkRenderTarget::onRelease() { |
| 474 | this->releaseInternalObjects(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 475 | GrRenderTarget::onRelease(); |
| 476 | } |
| 477 | |
| 478 | void GrVkRenderTarget::onAbandon() { |
Greg Daniel | f0e04f0 | 2019-12-04 15:17:54 -0500 | [diff] [blame] | 479 | this->releaseInternalObjects(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 480 | GrRenderTarget::onAbandon(); |
| 481 | } |
| 482 | |
Robert Phillips | b67821d | 2017-12-13 15:00:45 -0500 | [diff] [blame] | 483 | GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget() const { |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 484 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | 80ef70e | 2021-03-10 16:17:21 -0500 | [diff] [blame^] | 485 | // This should only get called with a non-released GrVkRenderTargets. |
| 486 | SkASSERT(!this->wasDestroyed()); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 487 | // If we have a resolve attachment that is what we return for the backend render target |
| 488 | const GrVkAttachment* beAttachment = this->externalAttachment(); |
| 489 | return GrBackendRenderTarget(beAttachment->width(), beAttachment->height(), |
| 490 | beAttachment->vkImageInfo(), beAttachment->getMutableState()); |
Brian Salomon | 72c7b98 | 2020-10-06 10:07:38 -0400 | [diff] [blame] | 491 | } |
| 492 | |
Jim Van Verth | 3e19216 | 2020-03-10 16:23:16 -0400 | [diff] [blame] | 493 | const GrManagedResource* GrVkRenderTarget::stencilImageResource() const { |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 494 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 495 | const GrAttachment* stencil = this->getStencilAttachment(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 496 | if (stencil) { |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 497 | const GrVkAttachment* vkStencil = static_cast<const GrVkAttachment*>(stencil); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 498 | return vkStencil->imageResource(); |
| 499 | } |
| 500 | |
| 501 | return nullptr; |
| 502 | } |
| 503 | |
| 504 | const GrVkImageView* GrVkRenderTarget::stencilAttachmentView() const { |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 505 | SkASSERT(!this->wrapsSecondaryCommandBuffer()); |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 506 | const GrAttachment* stencil = this->getStencilAttachment(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 507 | if (stencil) { |
Greg Daniel | c0d6915 | 2020-10-08 14:59:00 -0400 | [diff] [blame] | 508 | const GrVkAttachment* vkStencil = static_cast<const GrVkAttachment*>(stencil); |
Greg Daniel | 00d6cf4 | 2021-03-05 22:50:08 +0000 | [diff] [blame] | 509 | return vkStencil->framebufferView(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | return nullptr; |
| 513 | } |
| 514 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 515 | GrVkGpu* GrVkRenderTarget::getVkGpu() const { |
| 516 | SkASSERT(!this->wasDestroyed()); |
| 517 | return static_cast<GrVkGpu*>(this->getGpu()); |
| 518 | } |