Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 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/GrVkResourceProvider.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/GrSamplerState.h" |
| 11 | #include "src/core/SkTaskGroup.h" |
| 12 | #include "src/gpu/GrContextPriv.h" |
| 13 | #include "src/gpu/vk/GrVkCommandBuffer.h" |
| 14 | #include "src/gpu/vk/GrVkCommandPool.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 15 | #include "src/gpu/vk/GrVkGpu.h" |
| 16 | #include "src/gpu/vk/GrVkPipeline.h" |
| 17 | #include "src/gpu/vk/GrVkRenderTarget.h" |
| 18 | #include "src/gpu/vk/GrVkUniformBuffer.h" |
| 19 | #include "src/gpu/vk/GrVkUtil.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 20 | |
| 21 | #ifdef SK_TRACE_VK_RESOURCES |
Mike Klein | 820e79b | 2018-12-04 09:31:31 -0500 | [diff] [blame] | 22 | std::atomic<uint32_t> GrVkResource::fKeyCounter{0}; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 23 | #endif |
| 24 | |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 25 | GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) |
| 26 | : fGpu(gpu) |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 27 | , fPipelineCache(VK_NULL_HANDLE) { |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 28 | fPipelineStateCache = new PipelineStateCache(gpu); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | GrVkResourceProvider::~GrVkResourceProvider() { |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 32 | SkASSERT(0 == fRenderPassArray.count()); |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 33 | SkASSERT(0 == fExternalRenderPasses.count()); |
jvanverth | 03509ea | 2016-03-02 13:19:47 -0800 | [diff] [blame] | 34 | SkASSERT(VK_NULL_HANDLE == fPipelineCache); |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 35 | delete fPipelineStateCache; |
jvanverth | 03509ea | 2016-03-02 13:19:47 -0800 | [diff] [blame] | 36 | } |
| 37 | |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 38 | VkPipelineCache GrVkResourceProvider::pipelineCache() { |
| 39 | if (fPipelineCache == VK_NULL_HANDLE) { |
| 40 | VkPipelineCacheCreateInfo createInfo; |
| 41 | memset(&createInfo, 0, sizeof(VkPipelineCacheCreateInfo)); |
| 42 | createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 43 | createInfo.pNext = nullptr; |
| 44 | createInfo.flags = 0; |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 45 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 46 | auto persistentCache = fGpu->getContext()->priv().getPersistentCache(); |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 47 | sk_sp<SkData> cached; |
| 48 | if (persistentCache) { |
| 49 | uint32_t key = GrVkGpu::kPipelineCache_PersistentCacheKeyType; |
| 50 | sk_sp<SkData> keyData = SkData::MakeWithoutCopy(&key, sizeof(uint32_t)); |
| 51 | cached = persistentCache->load(*keyData); |
| 52 | } |
| 53 | bool usedCached = false; |
| 54 | if (cached) { |
| 55 | uint32_t* cacheHeader = (uint32_t*)cached->data(); |
| 56 | if (cacheHeader[1] == VK_PIPELINE_CACHE_HEADER_VERSION_ONE) { |
| 57 | // For version one of the header, the total header size is 16 bytes plus |
| 58 | // VK_UUID_SIZE bytes. See Section 9.6 (Pipeline Cache) in the vulkan spec to see |
| 59 | // the breakdown of these bytes. |
| 60 | SkASSERT(cacheHeader[0] == 16 + VK_UUID_SIZE); |
| 61 | const VkPhysicalDeviceProperties& devProps = fGpu->physicalDeviceProperties(); |
| 62 | const uint8_t* supportedPipelineCacheUUID = devProps.pipelineCacheUUID; |
| 63 | if (cacheHeader[2] == devProps.vendorID && cacheHeader[3] == devProps.deviceID && |
| 64 | !memcmp(&cacheHeader[4], supportedPipelineCacheUUID, VK_UUID_SIZE)) { |
| 65 | createInfo.initialDataSize = cached->size(); |
| 66 | createInfo.pInitialData = cached->data(); |
| 67 | usedCached = true; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | if (!usedCached) { |
| 72 | createInfo.initialDataSize = 0; |
| 73 | createInfo.pInitialData = nullptr; |
| 74 | } |
| 75 | VkResult result = GR_VK_CALL(fGpu->vkInterface(), |
| 76 | CreatePipelineCache(fGpu->device(), &createInfo, nullptr, |
| 77 | &fPipelineCache)); |
| 78 | SkASSERT(VK_SUCCESS == result); |
| 79 | if (VK_SUCCESS != result) { |
| 80 | fPipelineCache = VK_NULL_HANDLE; |
| 81 | } |
| 82 | } |
| 83 | return fPipelineCache; |
| 84 | } |
| 85 | |
| 86 | void GrVkResourceProvider::init() { |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 87 | // Init uniform descriptor objects |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 88 | GrVkDescriptorSetManager* dsm = GrVkDescriptorSetManager::CreateUniformManager(fGpu); |
| 89 | fDescriptorSetManagers.emplace_back(dsm); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 90 | SkASSERT(1 == fDescriptorSetManagers.count()); |
| 91 | fUniformDSHandle = GrVkDescriptorSetManager::Handle(0); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 92 | } |
| 93 | |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 94 | GrVkPipeline* GrVkResourceProvider::createPipeline(int numColorSamples, |
| 95 | const GrPrimitiveProcessor& primProc, |
Brian Salomon | ff168d9 | 2018-06-23 15:17:27 -0400 | [diff] [blame] | 96 | const GrPipeline& pipeline, |
csmartdalton | c633abb | 2016-11-01 08:55:55 -0700 | [diff] [blame] | 97 | const GrStencilSettings& stencil, |
Chris Dalton | 71713f6 | 2019-04-18 12:41:03 -0600 | [diff] [blame] | 98 | GrSurfaceOrigin origin, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 99 | VkPipelineShaderStageCreateInfo* shaderStageInfo, |
| 100 | int shaderStageCount, |
| 101 | GrPrimitiveType primitiveType, |
Greg Daniel | 99b88e0 | 2018-10-03 15:31:20 -0400 | [diff] [blame] | 102 | VkRenderPass compatibleRenderPass, |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 103 | VkPipelineLayout layout) { |
Chris Dalton | 71713f6 | 2019-04-18 12:41:03 -0600 | [diff] [blame] | 104 | return GrVkPipeline::Create( |
| 105 | fGpu, numColorSamples, primProc, pipeline, stencil, origin, shaderStageInfo, |
| 106 | shaderStageCount, primitiveType, compatibleRenderPass, layout, this->pipelineCache()); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 107 | } |
| 108 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 109 | // To create framebuffers, we first need to create a simple RenderPass that is |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 110 | // only used for framebuffer creation. When we actually render we will create |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 111 | // RenderPasses as needed that are compatible with the framebuffer. |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 112 | const GrVkRenderPass* |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 113 | GrVkResourceProvider::findCompatibleRenderPass(const GrVkRenderTarget& target, |
| 114 | CompatibleRPHandle* compatibleHandle) { |
| 115 | for (int i = 0; i < fRenderPassArray.count(); ++i) { |
| 116 | if (fRenderPassArray[i].isCompatible(target)) { |
| 117 | const GrVkRenderPass* renderPass = fRenderPassArray[i].getCompatibleRenderPass(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 118 | renderPass->ref(); |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 119 | if (compatibleHandle) { |
| 120 | *compatibleHandle = CompatibleRPHandle(i); |
| 121 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 122 | return renderPass; |
| 123 | } |
| 124 | } |
| 125 | |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 126 | const GrVkRenderPass* renderPass = |
| 127 | fRenderPassArray.emplace_back(fGpu, target).getCompatibleRenderPass(); |
| 128 | renderPass->ref(); |
| 129 | |
| 130 | if (compatibleHandle) { |
| 131 | *compatibleHandle = CompatibleRPHandle(fRenderPassArray.count() - 1); |
| 132 | } |
| 133 | return renderPass; |
| 134 | } |
| 135 | |
| 136 | const GrVkRenderPass* |
| 137 | GrVkResourceProvider::findCompatibleRenderPass(const CompatibleRPHandle& compatibleHandle) { |
| 138 | SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderPassArray.count()); |
| 139 | int index = compatibleHandle.toIndex(); |
| 140 | const GrVkRenderPass* renderPass = fRenderPassArray[index].getCompatibleRenderPass(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 141 | renderPass->ref(); |
| 142 | return renderPass; |
| 143 | } |
| 144 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 145 | const GrVkRenderPass* GrVkResourceProvider::findCompatibleExternalRenderPass( |
| 146 | VkRenderPass renderPass, uint32_t colorAttachmentIndex) { |
| 147 | for (int i = 0; i < fExternalRenderPasses.count(); ++i) { |
| 148 | if (fExternalRenderPasses[i]->isCompatibleExternalRP(renderPass)) { |
| 149 | fExternalRenderPasses[i]->ref(); |
| 150 | #ifdef SK_DEBUG |
| 151 | uint32_t cachedColorIndex; |
| 152 | SkASSERT(fExternalRenderPasses[i]->colorAttachmentIndex(&cachedColorIndex)); |
| 153 | SkASSERT(cachedColorIndex == colorAttachmentIndex); |
| 154 | #endif |
| 155 | return fExternalRenderPasses[i]; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | const GrVkRenderPass* newRenderPass = new GrVkRenderPass(renderPass, colorAttachmentIndex); |
| 160 | fExternalRenderPasses.push_back(newRenderPass); |
| 161 | newRenderPass->ref(); |
| 162 | return newRenderPass; |
| 163 | } |
| 164 | |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 165 | const GrVkRenderPass* GrVkResourceProvider::findRenderPass( |
| 166 | const GrVkRenderTarget& target, |
| 167 | const GrVkRenderPass::LoadStoreOps& colorOps, |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 168 | const GrVkRenderPass::LoadStoreOps& stencilOps, |
| 169 | CompatibleRPHandle* compatibleHandle) { |
egdaniel | 066df7c | 2016-06-08 14:02:27 -0700 | [diff] [blame] | 170 | GrVkResourceProvider::CompatibleRPHandle tempRPHandle; |
| 171 | GrVkResourceProvider::CompatibleRPHandle* pRPHandle = compatibleHandle ? compatibleHandle |
| 172 | : &tempRPHandle; |
| 173 | *pRPHandle = target.compatibleRenderPassHandle(); |
| 174 | |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 175 | // This will get us the handle to (and possible create) the compatible set for the specific |
| 176 | // GrVkRenderPass we are looking for. |
| 177 | this->findCompatibleRenderPass(target, compatibleHandle); |
Greg Daniel | d368211 | 2016-10-03 15:06:07 -0400 | [diff] [blame] | 178 | return this->findRenderPass(*pRPHandle, colorOps, stencilOps); |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | const GrVkRenderPass* |
| 182 | GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, |
| 183 | const GrVkRenderPass::LoadStoreOps& colorOps, |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 184 | const GrVkRenderPass::LoadStoreOps& stencilOps) { |
| 185 | SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderPassArray.count()); |
| 186 | CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()]; |
| 187 | const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, |
| 188 | colorOps, |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 189 | stencilOps); |
| 190 | renderPass->ref(); |
| 191 | return renderPass; |
| 192 | } |
| 193 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 194 | GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( |
egdaniel | c2dc1b2 | 2016-03-18 13:18:23 -0700 | [diff] [blame] | 195 | VkDescriptorType type, uint32_t count) { |
| 196 | return new GrVkDescriptorPool(fGpu, type, count); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 197 | } |
| 198 | |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 199 | GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler( |
| 200 | const GrSamplerState& params, const GrVkYcbcrConversionInfo& ycbcrInfo) { |
| 201 | GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, ycbcrInfo)); |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 202 | if (!sampler) { |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 203 | sampler = GrVkSampler::Create(fGpu, params, ycbcrInfo); |
| 204 | if (!sampler) { |
| 205 | return nullptr; |
| 206 | } |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 207 | fSamplers.add(sampler); |
| 208 | } |
| 209 | SkASSERT(sampler); |
| 210 | sampler->ref(); |
| 211 | return sampler; |
| 212 | } |
| 213 | |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 214 | GrVkSamplerYcbcrConversion* GrVkResourceProvider::findOrCreateCompatibleSamplerYcbcrConversion( |
| 215 | const GrVkYcbcrConversionInfo& ycbcrInfo) { |
| 216 | GrVkSamplerYcbcrConversion* ycbcrConversion = |
| 217 | fYcbcrConversions.find(GrVkSamplerYcbcrConversion::GenerateKey(ycbcrInfo)); |
| 218 | if (!ycbcrConversion) { |
| 219 | ycbcrConversion = GrVkSamplerYcbcrConversion::Create(fGpu, ycbcrInfo); |
| 220 | if (!ycbcrConversion) { |
| 221 | return nullptr; |
| 222 | } |
| 223 | fYcbcrConversions.add(ycbcrConversion); |
| 224 | } |
| 225 | SkASSERT(ycbcrConversion); |
| 226 | ycbcrConversion->ref(); |
| 227 | return ycbcrConversion; |
| 228 | } |
| 229 | |
Greg Daniel | 09eeefb | 2017-10-16 15:15:02 -0400 | [diff] [blame] | 230 | GrVkPipelineState* GrVkResourceProvider::findOrCreateCompatiblePipelineState( |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 231 | GrRenderTarget* renderTarget, GrSurfaceOrigin origin, |
Greg Daniel | 9a51a86 | 2018-11-30 10:18:14 -0500 | [diff] [blame] | 232 | const GrPipeline& pipeline, const GrPrimitiveProcessor& proc, |
| 233 | const GrTextureProxy* const primProcProxies[], GrPrimitiveType primitiveType, |
Greg Daniel | 99b88e0 | 2018-10-03 15:31:20 -0400 | [diff] [blame] | 234 | VkRenderPass compatibleRenderPass) { |
Robert Phillips | d0fe875 | 2019-01-31 14:13:59 -0500 | [diff] [blame] | 235 | return fPipelineStateCache->refPipelineState(renderTarget, origin, proc, primProcProxies, |
| 236 | pipeline, primitiveType, compatibleRenderPass); |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 239 | void GrVkResourceProvider::getSamplerDescriptorSetHandle(VkDescriptorType type, |
| 240 | const GrVkUniformHandler& uniformHandler, |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 241 | GrVkDescriptorSetManager::Handle* handle) { |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 242 | SkASSERT(handle); |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 243 | SkASSERT(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type || |
| 244 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER == type); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 245 | for (int i = 0; i < fDescriptorSetManagers.count(); ++i) { |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 246 | if (fDescriptorSetManagers[i]->isCompatible(type, &uniformHandler)) { |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 247 | *handle = GrVkDescriptorSetManager::Handle(i); |
| 248 | return; |
| 249 | } |
| 250 | } |
| 251 | |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 252 | GrVkDescriptorSetManager* dsm = GrVkDescriptorSetManager::CreateSamplerManager(fGpu, type, |
| 253 | uniformHandler); |
| 254 | fDescriptorSetManagers.emplace_back(dsm); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 255 | *handle = GrVkDescriptorSetManager::Handle(fDescriptorSetManagers.count() - 1); |
| 256 | } |
| 257 | |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 258 | void GrVkResourceProvider::getSamplerDescriptorSetHandle(VkDescriptorType type, |
| 259 | const SkTArray<uint32_t>& visibilities, |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 260 | GrVkDescriptorSetManager::Handle* handle) { |
| 261 | SkASSERT(handle); |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 262 | SkASSERT(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type || |
| 263 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER == type); |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 264 | for (int i = 0; i < fDescriptorSetManagers.count(); ++i) { |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 265 | if (fDescriptorSetManagers[i]->isCompatible(type, visibilities)) { |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 266 | *handle = GrVkDescriptorSetManager::Handle(i); |
| 267 | return; |
| 268 | } |
| 269 | } |
| 270 | |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 271 | GrVkDescriptorSetManager* dsm = GrVkDescriptorSetManager::CreateSamplerManager(fGpu, type, |
| 272 | visibilities); |
| 273 | fDescriptorSetManagers.emplace_back(dsm); |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 274 | *handle = GrVkDescriptorSetManager::Handle(fDescriptorSetManagers.count() - 1); |
| 275 | } |
| 276 | |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 277 | VkDescriptorSetLayout GrVkResourceProvider::getUniformDSLayout() const { |
| 278 | SkASSERT(fUniformDSHandle.isValid()); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 279 | return fDescriptorSetManagers[fUniformDSHandle.toIndex()]->layout(); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | VkDescriptorSetLayout GrVkResourceProvider::getSamplerDSLayout( |
| 283 | const GrVkDescriptorSetManager::Handle& handle) const { |
| 284 | SkASSERT(handle.isValid()); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 285 | return fDescriptorSetManagers[handle.toIndex()]->layout(); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 286 | } |
| 287 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 288 | const GrVkDescriptorSet* GrVkResourceProvider::getUniformDescriptorSet() { |
| 289 | SkASSERT(fUniformDSHandle.isValid()); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 290 | return fDescriptorSetManagers[fUniformDSHandle.toIndex()]->getDescriptorSet(fGpu, |
| 291 | fUniformDSHandle); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 292 | } |
| 293 | |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 294 | const GrVkDescriptorSet* GrVkResourceProvider::getSamplerDescriptorSet( |
| 295 | const GrVkDescriptorSetManager::Handle& handle) { |
| 296 | SkASSERT(handle.isValid()); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 297 | return fDescriptorSetManagers[handle.toIndex()]->getDescriptorSet(fGpu, handle); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 298 | } |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 299 | |
| 300 | void GrVkResourceProvider::recycleDescriptorSet(const GrVkDescriptorSet* descSet, |
| 301 | const GrVkDescriptorSetManager::Handle& handle) { |
| 302 | SkASSERT(descSet); |
| 303 | SkASSERT(handle.isValid()); |
| 304 | int managerIdx = handle.toIndex(); |
| 305 | SkASSERT(managerIdx < fDescriptorSetManagers.count()); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 306 | fDescriptorSetManagers[managerIdx]->recycleDescriptorSet(descSet); |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 309 | GrVkCommandPool* GrVkResourceProvider::findOrCreateCommandPool() { |
| 310 | std::unique_lock<std::recursive_mutex> lock(fBackgroundMutex); |
| 311 | GrVkCommandPool* result; |
| 312 | if (fAvailableCommandPools.count()) { |
| 313 | result = fAvailableCommandPools.back(); |
| 314 | fAvailableCommandPools.pop_back(); |
jvanverth | 7ec9241 | 2016-07-06 09:24:57 -0700 | [diff] [blame] | 315 | } else { |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 316 | result = GrVkCommandPool::Create(fGpu); |
jvanverth | 7ec9241 | 2016-07-06 09:24:57 -0700 | [diff] [blame] | 317 | } |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 318 | SkASSERT(result->unique()); |
| 319 | SkDEBUGCODE( |
| 320 | for (const GrVkCommandPool* pool : fActiveCommandPools) { |
| 321 | SkASSERT(pool != result); |
| 322 | } |
| 323 | for (const GrVkCommandPool* pool : fAvailableCommandPools) { |
| 324 | SkASSERT(pool != result); |
| 325 | } |
Ben Wagner | 1c0cacf | 2019-01-14 12:57:36 -0500 | [diff] [blame] | 326 | ) |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 327 | fActiveCommandPools.push_back(result); |
| 328 | result->ref(); |
| 329 | return result; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | void GrVkResourceProvider::checkCommandBuffers() { |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 333 | for (int i = fActiveCommandPools.count() - 1; i >= 0; --i) { |
| 334 | GrVkCommandPool* pool = fActiveCommandPools[i]; |
| 335 | if (!pool->isOpen()) { |
| 336 | GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer(); |
| 337 | if (buffer->finished(fGpu)) { |
| 338 | fActiveCommandPools.removeShuffle(i); |
| 339 | this->backgroundReset(pool); |
| 340 | } |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
Greg Daniel | a3aa75a | 2019-04-12 14:24:55 -0400 | [diff] [blame] | 345 | void GrVkResourceProvider::addFinishedProcToActiveCommandBuffers( |
| 346 | GrGpuFinishedProc finishedProc, GrGpuFinishedContext finishedContext) { |
| 347 | sk_sp<GrRefCntedCallback> procRef(new GrRefCntedCallback(finishedProc, finishedContext)); |
| 348 | for (int i = 0; i < fActiveCommandPools.count(); ++i) { |
| 349 | GrVkCommandPool* pool = fActiveCommandPools[i]; |
| 350 | if (!pool->isOpen()) { |
| 351 | GrVkPrimaryCommandBuffer* buffer = pool->getPrimaryCommandBuffer(); |
| 352 | buffer->addFinishedProc(procRef); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
jvanverth | 4c6e47a | 2016-07-22 10:34:52 -0700 | [diff] [blame] | 357 | const GrVkResource* GrVkResourceProvider::findOrCreateStandardUniformBufferResource() { |
| 358 | const GrVkResource* resource = nullptr; |
| 359 | int count = fAvailableUniformBufferResources.count(); |
| 360 | if (count > 0) { |
| 361 | resource = fAvailableUniformBufferResources[count - 1]; |
| 362 | fAvailableUniformBufferResources.removeShuffle(count - 1); |
| 363 | } else { |
| 364 | resource = GrVkUniformBuffer::CreateResource(fGpu, GrVkUniformBuffer::kStandardSize); |
| 365 | } |
| 366 | return resource; |
| 367 | } |
| 368 | |
| 369 | void GrVkResourceProvider::recycleStandardUniformBufferResource(const GrVkResource* resource) { |
| 370 | fAvailableUniformBufferResources.push_back(resource); |
| 371 | } |
| 372 | |
Jim Van Verth | 09557d7 | 2016-11-07 11:10:21 -0500 | [diff] [blame] | 373 | void GrVkResourceProvider::destroyResources(bool deviceLost) { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 374 | SkTaskGroup* taskGroup = fGpu->getContext()->priv().getTaskGroup(); |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 375 | if (taskGroup) { |
| 376 | taskGroup->wait(); |
Ethan Nicholas | bff4e07 | 2018-12-12 18:17:24 +0000 | [diff] [blame] | 377 | } |
Ethan Nicholas | bff4e07 | 2018-12-12 18:17:24 +0000 | [diff] [blame] | 378 | |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 379 | // loop over all render pass sets to make sure we destroy all the internal VkRenderPasses |
| 380 | for (int i = 0; i < fRenderPassArray.count(); ++i) { |
| 381 | fRenderPassArray[i].releaseResources(fGpu); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 382 | } |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 383 | fRenderPassArray.reset(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 384 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 385 | for (int i = 0; i < fExternalRenderPasses.count(); ++i) { |
| 386 | fExternalRenderPasses[i]->unref(fGpu); |
| 387 | } |
| 388 | fExternalRenderPasses.reset(); |
| 389 | |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 390 | // Iterate through all store GrVkSamplers and unref them before resetting the hash. |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 391 | SkTDynamicHash<GrVkSampler, GrVkSampler::Key>::Iter iter(&fSamplers); |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 392 | for (; !iter.done(); ++iter) { |
| 393 | (*iter).unref(fGpu); |
| 394 | } |
| 395 | fSamplers.reset(); |
| 396 | |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 397 | fPipelineStateCache->release(); |
| 398 | |
jvanverth | 03509ea | 2016-03-02 13:19:47 -0800 | [diff] [blame] | 399 | GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipelineCache, nullptr)); |
| 400 | fPipelineCache = VK_NULL_HANDLE; |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 401 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 402 | for (GrVkCommandPool* pool : fActiveCommandPools) { |
| 403 | SkASSERT(pool->unique()); |
| 404 | pool->unref(fGpu); |
| 405 | } |
| 406 | fActiveCommandPools.reset(); |
| 407 | |
| 408 | for (GrVkCommandPool* pool : fAvailableCommandPools) { |
| 409 | SkASSERT(pool->unique()); |
| 410 | pool->unref(fGpu); |
| 411 | } |
| 412 | fAvailableCommandPools.reset(); |
| 413 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 414 | // We must release/destroy all command buffers and pipeline states before releasing the |
| 415 | // GrVkDescriptorSetManagers |
| 416 | for (int i = 0; i < fDescriptorSetManagers.count(); ++i) { |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 417 | fDescriptorSetManagers[i]->release(fGpu); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 418 | } |
| 419 | fDescriptorSetManagers.reset(); |
jvanverth | 4c6e47a | 2016-07-22 10:34:52 -0700 | [diff] [blame] | 420 | |
| 421 | // release our uniform buffers |
| 422 | for (int i = 0; i < fAvailableUniformBufferResources.count(); ++i) { |
| 423 | SkASSERT(fAvailableUniformBufferResources[i]->unique()); |
| 424 | fAvailableUniformBufferResources[i]->unref(fGpu); |
| 425 | } |
| 426 | fAvailableUniformBufferResources.reset(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | void GrVkResourceProvider::abandonResources() { |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 430 | SkTaskGroup* taskGroup = fGpu->getContext()->priv().getTaskGroup(); |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 431 | if (taskGroup) { |
| 432 | taskGroup->wait(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 433 | } |
Ethan Nicholas | bff4e07 | 2018-12-12 18:17:24 +0000 | [diff] [blame] | 434 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 435 | // Abandon all command pools |
| 436 | for (int i = 0; i < fActiveCommandPools.count(); ++i) { |
| 437 | SkASSERT(fActiveCommandPools[i]->unique()); |
| 438 | fActiveCommandPools[i]->unrefAndAbandon(); |
Ethan Nicholas | bff4e07 | 2018-12-12 18:17:24 +0000 | [diff] [blame] | 439 | } |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 440 | fActiveCommandPools.reset(); |
| 441 | for (int i = 0; i < fAvailableCommandPools.count(); ++i) { |
| 442 | SkASSERT(fAvailableCommandPools[i]->unique()); |
| 443 | fAvailableCommandPools[i]->unrefAndAbandon(); |
| 444 | } |
| 445 | fAvailableCommandPools.reset(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 446 | |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 447 | // loop over all render pass sets to make sure we destroy all the internal VkRenderPasses |
| 448 | for (int i = 0; i < fRenderPassArray.count(); ++i) { |
| 449 | fRenderPassArray[i].abandonResources(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 450 | } |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 451 | fRenderPassArray.reset(); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 452 | |
Greg Daniel | b46add8 | 2019-01-02 14:51:29 -0500 | [diff] [blame] | 453 | for (int i = 0; i < fExternalRenderPasses.count(); ++i) { |
| 454 | fExternalRenderPasses[i]->unrefAndAbandon(); |
| 455 | } |
| 456 | fExternalRenderPasses.reset(); |
| 457 | |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 458 | // Iterate through all store GrVkSamplers and unrefAndAbandon them before resetting the hash. |
Greg Daniel | 7e00022 | 2018-12-03 10:08:21 -0500 | [diff] [blame] | 459 | SkTDynamicHash<GrVkSampler, GrVkSampler::Key>::Iter iter(&fSamplers); |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 460 | for (; !iter.done(); ++iter) { |
| 461 | (*iter).unrefAndAbandon(); |
| 462 | } |
| 463 | fSamplers.reset(); |
| 464 | |
egdaniel | 22281c1 | 2016-03-23 13:49:40 -0700 | [diff] [blame] | 465 | fPipelineStateCache->abandon(); |
| 466 | |
jvanverth | 03509ea | 2016-03-02 13:19:47 -0800 | [diff] [blame] | 467 | fPipelineCache = VK_NULL_HANDLE; |
egdaniel | 778555c | 2016-05-02 06:50:36 -0700 | [diff] [blame] | 468 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 469 | // We must abandon all command buffers and pipeline states before abandoning the |
| 470 | // GrVkDescriptorSetManagers |
| 471 | for (int i = 0; i < fDescriptorSetManagers.count(); ++i) { |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 472 | fDescriptorSetManagers[i]->abandon(); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 473 | } |
| 474 | fDescriptorSetManagers.reset(); |
| 475 | |
jvanverth | 4c6e47a | 2016-07-22 10:34:52 -0700 | [diff] [blame] | 476 | // release our uniform buffers |
| 477 | for (int i = 0; i < fAvailableUniformBufferResources.count(); ++i) { |
| 478 | SkASSERT(fAvailableUniformBufferResources[i]->unique()); |
| 479 | fAvailableUniformBufferResources[i]->unrefAndAbandon(); |
| 480 | } |
| 481 | fAvailableUniformBufferResources.reset(); |
jvanverth | 03509ea | 2016-03-02 13:19:47 -0800 | [diff] [blame] | 482 | } |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 483 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 484 | void GrVkResourceProvider::backgroundReset(GrVkCommandPool* pool) { |
| 485 | SkASSERT(pool->unique()); |
| 486 | pool->releaseResources(fGpu); |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 487 | SkTaskGroup* taskGroup = fGpu->getContext()->priv().getTaskGroup(); |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 488 | if (taskGroup) { |
| 489 | taskGroup->add([this, pool]() { |
| 490 | this->reset(pool); |
| 491 | }); |
| 492 | } else { |
| 493 | this->reset(pool); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void GrVkResourceProvider::reset(GrVkCommandPool* pool) { |
| 498 | SkASSERT(pool->unique()); |
| 499 | pool->reset(fGpu); |
| 500 | std::unique_lock<std::recursive_mutex> providerLock(fBackgroundMutex); |
| 501 | fAvailableCommandPools.push_back(pool); |
| 502 | } |
| 503 | |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 504 | void GrVkResourceProvider::storePipelineCacheData() { |
| 505 | size_t dataSize = 0; |
| 506 | VkResult result = GR_VK_CALL(fGpu->vkInterface(), GetPipelineCacheData(fGpu->device(), |
| 507 | this->pipelineCache(), |
| 508 | &dataSize, nullptr)); |
| 509 | SkASSERT(result == VK_SUCCESS); |
| 510 | |
| 511 | std::unique_ptr<uint8_t[]> data(new uint8_t[dataSize]); |
| 512 | |
| 513 | result = GR_VK_CALL(fGpu->vkInterface(), GetPipelineCacheData(fGpu->device(), |
| 514 | this->pipelineCache(), |
| 515 | &dataSize, |
| 516 | (void*)data.get())); |
| 517 | SkASSERT(result == VK_SUCCESS); |
| 518 | |
| 519 | uint32_t key = GrVkGpu::kPipelineCache_PersistentCacheKeyType; |
| 520 | sk_sp<SkData> keyData = SkData::MakeWithoutCopy(&key, sizeof(uint32_t)); |
| 521 | |
Robert Phillips | 9da87e0 | 2019-02-04 13:26:26 -0500 | [diff] [blame] | 522 | fGpu->getContext()->priv().getPersistentCache()->store( |
Greg Daniel | a870b46 | 2019-01-08 15:49:46 -0500 | [diff] [blame] | 523 | *keyData, *SkData::MakeWithoutCopy(data.get(), dataSize)); |
| 524 | } |
| 525 | |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 526 | //////////////////////////////////////////////////////////////////////////////// |
| 527 | |
| 528 | GrVkResourceProvider::CompatibleRenderPassSet::CompatibleRenderPassSet( |
| 529 | const GrVkGpu* gpu, |
| 530 | const GrVkRenderTarget& target) |
| 531 | : fLastReturnedIndex(0) { |
| 532 | fRenderPasses.emplace_back(new GrVkRenderPass()); |
| 533 | fRenderPasses[0]->initSimple(gpu, target); |
| 534 | } |
| 535 | |
| 536 | bool GrVkResourceProvider::CompatibleRenderPassSet::isCompatible( |
| 537 | const GrVkRenderTarget& target) const { |
| 538 | // The first GrVkRenderpass should always exists since we create the basic load store |
| 539 | // render pass on create |
| 540 | SkASSERT(fRenderPasses[0]); |
| 541 | return fRenderPasses[0]->isCompatible(target); |
| 542 | } |
| 543 | |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 544 | GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass( |
| 545 | const GrVkGpu* gpu, |
| 546 | const GrVkRenderPass::LoadStoreOps& colorOps, |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 547 | const GrVkRenderPass::LoadStoreOps& stencilOps) { |
| 548 | for (int i = 0; i < fRenderPasses.count(); ++i) { |
| 549 | int idx = (i + fLastReturnedIndex) % fRenderPasses.count(); |
egdaniel | ce3bfb1 | 2016-08-26 11:05:13 -0700 | [diff] [blame] | 550 | if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, stencilOps)) { |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 551 | fLastReturnedIndex = idx; |
| 552 | return fRenderPasses[idx]; |
| 553 | } |
| 554 | } |
egdaniel | 9cb6340 | 2016-06-23 08:37:05 -0700 | [diff] [blame] | 555 | GrVkRenderPass* renderPass = fRenderPasses.emplace_back(new GrVkRenderPass()); |
egdaniel | ce3bfb1 | 2016-08-26 11:05:13 -0700 | [diff] [blame] | 556 | renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, stencilOps); |
egdaniel | 2feb093 | 2016-06-08 06:48:09 -0700 | [diff] [blame] | 557 | fLastReturnedIndex = fRenderPasses.count() - 1; |
| 558 | return renderPass; |
| 559 | } |
| 560 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 561 | void GrVkResourceProvider::CompatibleRenderPassSet::releaseResources(GrVkGpu* gpu) { |
egdaniel | d62e28b | 2016-06-07 08:43:30 -0700 | [diff] [blame] | 562 | for (int i = 0; i < fRenderPasses.count(); ++i) { |
| 563 | if (fRenderPasses[i]) { |
| 564 | fRenderPasses[i]->unref(gpu); |
| 565 | fRenderPasses[i] = nullptr; |
| 566 | } |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { |
| 571 | for (int i = 0; i < fRenderPasses.count(); ++i) { |
| 572 | if (fRenderPasses[i]) { |
| 573 | fRenderPasses[i]->unrefAndAbandon(); |
| 574 | fRenderPasses[i] = nullptr; |
| 575 | } |
| 576 | } |
| 577 | } |