| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrVkResourceProvider.h" | 8 #include "GrVkResourceProvider.h" |
| 9 | 9 |
| 10 #include "GrTextureParams.h" | 10 #include "GrTextureParams.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 // Iterate through all store GrVkSamplers and unref them before resetting th
e hash. | 255 // Iterate through all store GrVkSamplers and unref them before resetting th
e hash. |
| 256 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); | 256 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); |
| 257 for (; !iter.done(); ++iter) { | 257 for (; !iter.done(); ++iter) { |
| 258 (*iter).unref(fGpu); | 258 (*iter).unref(fGpu); |
| 259 } | 259 } |
| 260 fSamplers.reset(); | 260 fSamplers.reset(); |
| 261 | 261 |
| 262 fPipelineStateCache->release(); | 262 fPipelineStateCache->release(); |
| 263 | 263 |
| 264 #ifdef SK_TRACE_VK_RESOURCES | |
| 265 SkASSERT(0 == GrVkResource::fTrace.count()); | |
| 266 #endif | |
| 267 | |
| 268 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipeli
neCache, nullptr)); | 264 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipeli
neCache, nullptr)); |
| 269 fPipelineCache = VK_NULL_HANDLE; | 265 fPipelineCache = VK_NULL_HANDLE; |
| 270 | 266 |
| 271 if (fUniformDescLayout) { | 267 if (fUniformDescLayout) { |
| 272 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), | 268 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), |
| 273 fUniformDescL
ayout, | 269 fUniformDescL
ayout, |
| 274 nullptr)); | 270 nullptr)); |
| 275 fUniformDescLayout = VK_NULL_HANDLE; | 271 fUniformDescLayout = VK_NULL_HANDLE; |
| 276 } | 272 } |
| 277 fUniformDescPool->unref(fGpu); | 273 fUniformDescPool->unref(fGpu); |
| 274 |
| 275 #ifdef SK_TRACE_VK_RESOURCES |
| 276 SkASSERT(0 == GrVkResource::fTrace.count()); |
| 277 #endif |
| 278 } | 278 } |
| 279 | 279 |
| 280 void GrVkResourceProvider::abandonResources() { | 280 void GrVkResourceProvider::abandonResources() { |
| 281 // release our current command buffers | 281 // release our current command buffers |
| 282 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { | 282 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { |
| 283 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); | 283 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); |
| 284 fActiveCommandBuffers[i]->unrefAndAbandon(); | 284 fActiveCommandBuffers[i]->unrefAndAbandon(); |
| 285 } | 285 } |
| 286 fActiveCommandBuffers.reset(); | 286 fActiveCommandBuffers.reset(); |
| 287 | 287 |
| 288 // loop over all render pass sets to make sure we destroy all the internal V
kRenderPasses | 288 // loop over all render pass sets to make sure we destroy all the internal V
kRenderPasses |
| 289 for (int i = 0; i < fRenderPassArray.count(); ++i) { | 289 for (int i = 0; i < fRenderPassArray.count(); ++i) { |
| 290 fRenderPassArray[i].abandonResources(); | 290 fRenderPassArray[i].abandonResources(); |
| 291 } | 291 } |
| 292 fRenderPassArray.reset(); | 292 fRenderPassArray.reset(); |
| 293 | 293 |
| 294 // Iterate through all store GrVkSamplers and unrefAndAbandon them before re
setting the hash. | 294 // Iterate through all store GrVkSamplers and unrefAndAbandon them before re
setting the hash. |
| 295 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); | 295 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); |
| 296 for (; !iter.done(); ++iter) { | 296 for (; !iter.done(); ++iter) { |
| 297 (*iter).unrefAndAbandon(); | 297 (*iter).unrefAndAbandon(); |
| 298 } | 298 } |
| 299 fSamplers.reset(); | 299 fSamplers.reset(); |
| 300 | 300 |
| 301 fPipelineStateCache->abandon(); | 301 fPipelineStateCache->abandon(); |
| 302 | 302 |
| 303 fPipelineCache = VK_NULL_HANDLE; |
| 304 |
| 305 fUniformDescLayout = VK_NULL_HANDLE; |
| 306 fUniformDescPool->unrefAndAbandon(); |
| 307 |
| 303 #ifdef SK_TRACE_VK_RESOURCES | 308 #ifdef SK_TRACE_VK_RESOURCES |
| 304 SkASSERT(0 == GrVkResource::fTrace.count()); | 309 SkASSERT(0 == GrVkResource::fTrace.count()); |
| 305 #endif | 310 #endif |
| 306 fPipelineCache = VK_NULL_HANDLE; | |
| 307 | |
| 308 fUniformDescLayout = VK_NULL_HANDLE; | |
| 309 fUniformDescPool->unrefAndAbandon(); | |
| 310 } | 311 } |
| 311 | 312 |
| 312 //////////////////////////////////////////////////////////////////////////////// | 313 //////////////////////////////////////////////////////////////////////////////// |
| 313 | 314 |
| 314 GrVkResourceProvider::CompatibleRenderPassSet::CompatibleRenderPassSet( | 315 GrVkResourceProvider::CompatibleRenderPassSet::CompatibleRenderPassSet( |
| 315 const GrVkG
pu* gpu, | 316 const GrVkG
pu* gpu, |
| 316 const GrVkR
enderTarget& target) | 317 const GrVkR
enderTarget& target) |
| 317 : fLastReturnedIndex(0) { | 318 : fLastReturnedIndex(0) { |
| 318 fRenderPasses.emplace_back(new GrVkRenderPass()); | 319 fRenderPasses.emplace_back(new GrVkRenderPass()); |
| 319 fRenderPasses[0]->initSimple(gpu, target); | 320 fRenderPasses[0]->initSimple(gpu, target); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 356 } |
| 356 | 357 |
| 357 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { | 358 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { |
| 358 for (int i = 0; i < fRenderPasses.count(); ++i) { | 359 for (int i = 0; i < fRenderPasses.count(); ++i) { |
| 359 if (fRenderPasses[i]) { | 360 if (fRenderPasses[i]) { |
| 360 fRenderPasses[i]->unrefAndAbandon(); | 361 fRenderPasses[i]->unrefAndAbandon(); |
| 361 fRenderPasses[i] = nullptr; | 362 fRenderPasses[i] = nullptr; |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 } | 365 } |
| OLD | NEW |