egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [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 | |
| 8 | #include "GrVkDescriptorSetManager.h" |
| 9 | |
| 10 | #include "GrVkDescriptorPool.h" |
| 11 | #include "GrVkDescriptorSet.h" |
| 12 | #include "GrVkGpu.h" |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 13 | #include "GrVkUniformHandler.h" |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 14 | |
Ben Wagner | 6c30e74 | 2019-02-06 10:46:14 -0500 | [diff] [blame^] | 15 | #if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS) |
| 16 | #include <sanitizer/lsan_interface.h> |
| 17 | #endif |
| 18 | |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 19 | GrVkDescriptorSetManager* GrVkDescriptorSetManager::CreateUniformManager(GrVkGpu* gpu) { |
| 20 | SkSTArray<2, uint32_t> visibilities; |
| 21 | // We set the visibility of the first binding to all supported geometry processing shader |
| 22 | // stages (vertex, tesselation, geometry, etc.) and the second binding to the fragment |
| 23 | // shader. |
| 24 | uint32_t geomStages = kVertex_GrShaderFlag; |
| 25 | if (gpu->vkCaps().shaderCaps()->geometryShaderSupport()) { |
| 26 | geomStages |= kGeometry_GrShaderFlag; |
| 27 | } |
| 28 | visibilities.push_back(geomStages); |
| 29 | visibilities.push_back(kFragment_GrShaderFlag); |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 30 | |
| 31 | SkTArray<const GrVkSampler*> samplers; |
| 32 | return new GrVkDescriptorSetManager(gpu, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, visibilities, |
| 33 | samplers); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | GrVkDescriptorSetManager* GrVkDescriptorSetManager::CreateSamplerManager( |
| 37 | GrVkGpu* gpu, VkDescriptorType type, const GrVkUniformHandler& uniformHandler) { |
| 38 | SkSTArray<4, uint32_t> visibilities; |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 39 | SkSTArray<4, const GrVkSampler*> immutableSamplers; |
Brian Salomon | 662ea4b | 2018-07-12 14:53:49 -0400 | [diff] [blame] | 40 | SkASSERT(type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER); |
| 41 | for (int i = 0 ; i < uniformHandler.numSamplers(); ++i) { |
| 42 | visibilities.push_back(uniformHandler.samplerVisibility(i)); |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 43 | immutableSamplers.push_back(uniformHandler.immutableSampler(i)); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 44 | } |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 45 | return new GrVkDescriptorSetManager(gpu, type, visibilities, immutableSamplers); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | GrVkDescriptorSetManager* GrVkDescriptorSetManager::CreateSamplerManager( |
| 49 | GrVkGpu* gpu, VkDescriptorType type, const SkTArray<uint32_t>& visibilities) { |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 50 | SkSTArray<4, const GrVkSampler*> immutableSamplers; |
| 51 | SkASSERT(type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER); |
| 52 | for (int i = 0 ; i < visibilities.count(); ++i) { |
| 53 | immutableSamplers.push_back(nullptr); |
| 54 | } |
| 55 | return new GrVkDescriptorSetManager(gpu, type, visibilities, immutableSamplers); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 58 | GrVkDescriptorSetManager::GrVkDescriptorSetManager( |
| 59 | GrVkGpu* gpu, VkDescriptorType type, |
| 60 | const SkTArray<uint32_t>& visibilities, |
| 61 | const SkTArray<const GrVkSampler*>& immutableSamplers) |
| 62 | : fPoolManager(type, gpu, visibilities, immutableSamplers) { |
| 63 | #ifdef SK_DEBUG |
| 64 | if (type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) { |
| 65 | SkASSERT(visibilities.count() == immutableSamplers.count()); |
| 66 | } else { |
| 67 | SkASSERT(immutableSamplers.count() == 0); |
| 68 | } |
| 69 | #endif |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 70 | for (int i = 0; i < visibilities.count(); ++i) { |
| 71 | fBindingVisibilities.push_back(visibilities[i]); |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 72 | } |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 73 | for (int i = 0; i < immutableSamplers.count(); ++i) { |
| 74 | const GrVkSampler* sampler = immutableSamplers[i]; |
| 75 | if (sampler) { |
| 76 | sampler->ref(); |
| 77 | } |
| 78 | fImmutableSamplers.push_back(sampler); |
| 79 | } |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 80 | } |
| 81 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 82 | const GrVkDescriptorSet* GrVkDescriptorSetManager::getDescriptorSet(GrVkGpu* gpu, |
| 83 | const Handle& handle) { |
| 84 | const GrVkDescriptorSet* ds = nullptr; |
| 85 | int count = fFreeSets.count(); |
| 86 | if (count > 0) { |
| 87 | ds = fFreeSets[count - 1]; |
| 88 | fFreeSets.removeShuffle(count - 1); |
| 89 | } else { |
| 90 | VkDescriptorSet vkDS; |
| 91 | fPoolManager.getNewDescriptorSet(gpu, &vkDS); |
| 92 | |
| 93 | ds = new GrVkDescriptorSet(vkDS, fPoolManager.fPool, handle); |
| 94 | } |
| 95 | SkASSERT(ds); |
| 96 | return ds; |
| 97 | } |
| 98 | |
| 99 | void GrVkDescriptorSetManager::recycleDescriptorSet(const GrVkDescriptorSet* descSet) { |
| 100 | SkASSERT(descSet); |
| 101 | fFreeSets.push_back(descSet); |
| 102 | } |
| 103 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 104 | void GrVkDescriptorSetManager::release(GrVkGpu* gpu) { |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 105 | fPoolManager.freeGPUResources(gpu); |
| 106 | |
| 107 | for (int i = 0; i < fFreeSets.count(); ++i) { |
| 108 | fFreeSets[i]->unref(gpu); |
| 109 | } |
| 110 | fFreeSets.reset(); |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 111 | |
| 112 | for (int i = 0; i < fImmutableSamplers.count(); ++i) { |
| 113 | if (fImmutableSamplers[i]) { |
| 114 | fImmutableSamplers[i]->unref(gpu); |
| 115 | } |
| 116 | } |
| 117 | fImmutableSamplers.reset(); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | void GrVkDescriptorSetManager::abandon() { |
| 121 | fPoolManager.abandonGPUResources(); |
| 122 | |
| 123 | for (int i = 0; i < fFreeSets.count(); ++i) { |
| 124 | fFreeSets[i]->unrefAndAbandon(); |
| 125 | } |
| 126 | fFreeSets.reset(); |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 127 | |
| 128 | for (int i = 0; i < fImmutableSamplers.count(); ++i) { |
| 129 | if (fImmutableSamplers[i]) { |
| 130 | fImmutableSamplers[i]->unrefAndAbandon(); |
| 131 | } |
| 132 | } |
| 133 | fImmutableSamplers.reset(); |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 134 | } |
| 135 | |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 136 | bool GrVkDescriptorSetManager::isCompatible(VkDescriptorType type, |
| 137 | const GrVkUniformHandler* uniHandler) const { |
| 138 | SkASSERT(uniHandler); |
| 139 | if (type != fPoolManager.fDescType) { |
| 140 | return false; |
| 141 | } |
| 142 | |
Brian Salomon | 662ea4b | 2018-07-12 14:53:49 -0400 | [diff] [blame] | 143 | SkASSERT(type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER); |
| 144 | if (fBindingVisibilities.count() != uniHandler->numSamplers()) { |
| 145 | return false; |
| 146 | } |
| 147 | for (int i = 0; i < uniHandler->numSamplers(); ++i) { |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 148 | if (uniHandler->samplerVisibility(i) != fBindingVisibilities[i] || |
| 149 | uniHandler->immutableSampler(i) != fImmutableSamplers[i]) { |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 150 | return false; |
| 151 | } |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 152 | } |
| 153 | return true; |
| 154 | } |
| 155 | |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 156 | bool GrVkDescriptorSetManager::isCompatible(VkDescriptorType type, |
| 157 | const SkTArray<uint32_t>& visibilities) const { |
| 158 | if (type != fPoolManager.fDescType) { |
| 159 | return false; |
| 160 | } |
| 161 | |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 162 | if (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type || |
| 163 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER == type) { |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 164 | if (fBindingVisibilities.count() != visibilities.count()) { |
| 165 | return false; |
| 166 | } |
| 167 | for (int i = 0; i < visibilities.count(); ++i) { |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 168 | if (visibilities[i] != fBindingVisibilities[i] || fImmutableSamplers[i] != nullptr) { |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 169 | return false; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | return true; |
| 174 | } |
| 175 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 176 | //////////////////////////////////////////////////////////////////////////////// |
| 177 | |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 178 | VkShaderStageFlags visibility_to_vk_stage_flags(uint32_t visibility) { |
| 179 | VkShaderStageFlags flags = 0; |
| 180 | |
| 181 | if (visibility & kVertex_GrShaderFlag) { |
| 182 | flags |= VK_SHADER_STAGE_VERTEX_BIT; |
| 183 | } |
| 184 | if (visibility & kGeometry_GrShaderFlag) { |
| 185 | flags |= VK_SHADER_STAGE_GEOMETRY_BIT; |
| 186 | } |
| 187 | if (visibility & kFragment_GrShaderFlag) { |
| 188 | flags |= VK_SHADER_STAGE_FRAGMENT_BIT; |
| 189 | } |
| 190 | return flags; |
| 191 | } |
| 192 | |
| 193 | GrVkDescriptorSetManager::DescriptorPoolManager::DescriptorPoolManager( |
| 194 | VkDescriptorType type, |
| 195 | GrVkGpu* gpu, |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 196 | const SkTArray<uint32_t>& visibilities, |
| 197 | const SkTArray<const GrVkSampler*>& immutableSamplers) |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 198 | : fDescType(type) |
| 199 | , fCurrentDescriptorCount(0) |
| 200 | , fPool(nullptr) { |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 201 | |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 202 | |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 203 | if (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type || |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 204 | VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER == type) { |
| 205 | uint32_t numBindings = visibilities.count(); |
| 206 | std::unique_ptr<VkDescriptorSetLayoutBinding[]> dsSamplerBindings( |
| 207 | new VkDescriptorSetLayoutBinding[numBindings]); |
| 208 | for (uint32_t i = 0; i < numBindings; ++i) { |
| 209 | uint32_t visibility = visibilities[i]; |
| 210 | dsSamplerBindings[i].binding = i; |
| 211 | dsSamplerBindings[i].descriptorType = type; |
| 212 | dsSamplerBindings[i].descriptorCount = 1; |
| 213 | dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(visibility); |
Greg Daniel | 7a82edf | 2018-12-04 10:54:34 -0500 | [diff] [blame] | 214 | if (VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER == type) { |
| 215 | if (immutableSamplers[i]) { |
| 216 | dsSamplerBindings[i].pImmutableSamplers = immutableSamplers[i]->samplerPtr(); |
| 217 | } else { |
| 218 | dsSamplerBindings[i].pImmutableSamplers = nullptr; |
| 219 | } |
| 220 | } |
egdaniel | 4d866df | 2016-08-25 13:52:00 -0700 | [diff] [blame] | 221 | } |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 222 | |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 223 | VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; |
| 224 | memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo)); |
| 225 | dsSamplerLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 226 | dsSamplerLayoutCreateInfo.pNext = nullptr; |
| 227 | dsSamplerLayoutCreateInfo.flags = 0; |
| 228 | dsSamplerLayoutCreateInfo.bindingCount = numBindings; |
| 229 | // Setting to nullptr fixes an error in the param checker validation layer. Even though |
| 230 | // bindingCount is 0 (which is valid), it still tries to validate pBindings unless it is |
| 231 | // null. |
| 232 | dsSamplerLayoutCreateInfo.pBindings = numBindings ? dsSamplerBindings.get() : nullptr; |
| 233 | |
Ben Wagner | 6c30e74 | 2019-02-06 10:46:14 -0500 | [diff] [blame^] | 234 | #if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS) |
| 235 | // skia:8713 |
| 236 | __lsan::ScopedDisabler lsanDisabler; |
| 237 | #endif |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 238 | GR_VK_CALL_ERRCHECK(gpu->vkInterface(), |
| 239 | CreateDescriptorSetLayout(gpu->device(), |
| 240 | &dsSamplerLayoutCreateInfo, |
| 241 | nullptr, |
| 242 | &fDescLayout)); |
| 243 | fDescCountPerSet = visibilities.count(); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 244 | } else { |
Greg Daniel | a754378 | 2017-05-02 14:01:43 -0400 | [diff] [blame] | 245 | SkASSERT(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER == type); |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 246 | GR_STATIC_ASSERT(2 == kUniformDescPerSet); |
| 247 | SkASSERT(kUniformDescPerSet == visibilities.count()); |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 248 | // Create Uniform Buffer Descriptor |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 249 | static const uint32_t bindings[kUniformDescPerSet] = |
| 250 | { GrVkUniformHandler::kGeometryBinding, GrVkUniformHandler::kFragBinding }; |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 251 | VkDescriptorSetLayoutBinding dsUniBindings[kUniformDescPerSet]; |
Greg Daniel | 18f9602 | 2017-05-04 15:09:03 -0400 | [diff] [blame] | 252 | memset(&dsUniBindings, 0, kUniformDescPerSet * sizeof(VkDescriptorSetLayoutBinding)); |
| 253 | for (int i = 0; i < kUniformDescPerSet; ++i) { |
| 254 | dsUniBindings[i].binding = bindings[i]; |
| 255 | dsUniBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 256 | dsUniBindings[i].descriptorCount = 1; |
| 257 | dsUniBindings[i].stageFlags = visibility_to_vk_stage_flags(visibilities[i]); |
| 258 | dsUniBindings[i].pImmutableSamplers = nullptr; |
| 259 | } |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 260 | |
| 261 | VkDescriptorSetLayoutCreateInfo uniformLayoutCreateInfo; |
| 262 | memset(&uniformLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo)); |
| 263 | uniformLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 264 | uniformLayoutCreateInfo.pNext = nullptr; |
| 265 | uniformLayoutCreateInfo.flags = 0; |
| 266 | uniformLayoutCreateInfo.bindingCount = 2; |
| 267 | uniformLayoutCreateInfo.pBindings = dsUniBindings; |
| 268 | |
Ben Wagner | 6c30e74 | 2019-02-06 10:46:14 -0500 | [diff] [blame^] | 269 | #if defined(SK_ENABLE_SCOPED_LSAN_SUPPRESSIONS) |
| 270 | // skia:8713 |
| 271 | __lsan::ScopedDisabler lsanDisabler; |
| 272 | #endif |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 273 | GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateDescriptorSetLayout(gpu->device(), |
| 274 | &uniformLayoutCreateInfo, |
| 275 | nullptr, |
| 276 | &fDescLayout)); |
| 277 | fDescCountPerSet = kUniformDescPerSet; |
| 278 | } |
| 279 | |
| 280 | SkASSERT(fDescCountPerSet < kStartNumDescriptors); |
| 281 | fMaxDescriptors = kStartNumDescriptors; |
| 282 | SkASSERT(fMaxDescriptors > 0); |
| 283 | this->getNewPool(gpu); |
| 284 | } |
| 285 | |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 286 | void GrVkDescriptorSetManager::DescriptorPoolManager::getNewPool(GrVkGpu* gpu) { |
| 287 | if (fPool) { |
| 288 | fPool->unref(gpu); |
| 289 | uint32_t newPoolSize = fMaxDescriptors + ((fMaxDescriptors + 1) >> 1); |
| 290 | if (newPoolSize < kMaxDescriptors) { |
| 291 | fMaxDescriptors = newPoolSize; |
| 292 | } else { |
| 293 | fMaxDescriptors = kMaxDescriptors; |
| 294 | } |
| 295 | |
| 296 | } |
| 297 | fPool = gpu->resourceProvider().findOrCreateCompatibleDescriptorPool(fDescType, |
| 298 | fMaxDescriptors); |
| 299 | SkASSERT(fPool); |
| 300 | } |
| 301 | |
| 302 | void GrVkDescriptorSetManager::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu, |
| 303 | VkDescriptorSet* ds) { |
| 304 | if (!fMaxDescriptors) { |
| 305 | return; |
| 306 | } |
| 307 | fCurrentDescriptorCount += fDescCountPerSet; |
| 308 | if (fCurrentDescriptorCount > fMaxDescriptors) { |
| 309 | this->getNewPool(gpu); |
| 310 | fCurrentDescriptorCount = fDescCountPerSet; |
| 311 | } |
| 312 | |
| 313 | VkDescriptorSetAllocateInfo dsAllocateInfo; |
| 314 | memset(&dsAllocateInfo, 0, sizeof(VkDescriptorSetAllocateInfo)); |
| 315 | dsAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 316 | dsAllocateInfo.pNext = nullptr; |
| 317 | dsAllocateInfo.descriptorPool = fPool->descPool(); |
| 318 | dsAllocateInfo.descriptorSetCount = 1; |
| 319 | dsAllocateInfo.pSetLayouts = &fDescLayout; |
| 320 | GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device(), |
| 321 | &dsAllocateInfo, |
| 322 | ds)); |
| 323 | } |
| 324 | |
Ethan Nicholas | 8e265a7 | 2018-12-12 16:22:40 -0500 | [diff] [blame] | 325 | void GrVkDescriptorSetManager::DescriptorPoolManager::freeGPUResources(GrVkGpu* gpu) { |
egdaniel | 707bbd6 | 2016-07-26 07:19:47 -0700 | [diff] [blame] | 326 | if (fDescLayout) { |
| 327 | GR_VK_CALL(gpu->vkInterface(), DestroyDescriptorSetLayout(gpu->device(), fDescLayout, |
| 328 | nullptr)); |
| 329 | fDescLayout = VK_NULL_HANDLE; |
| 330 | } |
egdaniel | a95220d | 2016-07-21 11:50:37 -0700 | [diff] [blame] | 331 | |
| 332 | if (fPool) { |
| 333 | fPool->unref(gpu); |
| 334 | fPool = nullptr; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | void GrVkDescriptorSetManager::DescriptorPoolManager::abandonGPUResources() { |
| 339 | fDescLayout = VK_NULL_HANDLE; |
| 340 | if (fPool) { |
| 341 | fPool->unrefAndAbandon(); |
| 342 | fPool = nullptr; |
| 343 | } |
| 344 | } |