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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 const GrVkRenderPass* | 124 const GrVkRenderPass* |
125 GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, | 125 GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, |
126 const GrVkRenderPass::LoadStoreOps& colorOp
s, | 126 const GrVkRenderPass::LoadStoreOps& colorOp
s, |
127 const GrVkRenderPass::LoadStoreOps& resolve
Ops, | 127 const GrVkRenderPass::LoadStoreOps& resolve
Ops, |
128 const GrVkRenderPass::LoadStoreOps& stencil
Ops) { | 128 const GrVkRenderPass::LoadStoreOps& stencil
Ops) { |
129 SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderP
assArray.count()); | 129 SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderP
assArray.count()); |
130 CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.t
oIndex()]; | 130 CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.t
oIndex()]; |
131 const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, | 131 const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, |
132 colorOps, | 132 colorOps, |
133 resolveOps, | |
134 stencilOps); | 133 stencilOps); |
135 renderPass->ref(); | 134 renderPass->ref(); |
136 return renderPass; | 135 return renderPass; |
137 } | 136 } |
138 | 137 |
139 GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( | 138 GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( |
140 VkDescriptorType typ
e, uint32_t count) { | 139 VkDescriptorType typ
e, uint32_t count) { |
141 return new GrVkDescriptorPool(fGpu, type, count); | 140 return new GrVkDescriptorPool(fGpu, type, count); |
142 } | 141 } |
143 | 142 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 const GrVkRenderTar
get& target) const { | 393 const GrVkRenderTar
get& target) const { |
395 // The first GrVkRenderpass should always exists since we create the basic l
oad store | 394 // The first GrVkRenderpass should always exists since we create the basic l
oad store |
396 // render pass on create | 395 // render pass on create |
397 SkASSERT(fRenderPasses[0]); | 396 SkASSERT(fRenderPasses[0]); |
398 return fRenderPasses[0]->isCompatible(target); | 397 return fRenderPasses[0]->isCompatible(target); |
399 } | 398 } |
400 | 399 |
401 GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass( | 400 GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass( |
402 const GrVkGpu* gpu, | 401 const GrVkGpu* gpu, |
403 const GrVkRenderPass::LoadSto
reOps& colorOps, | 402 const GrVkRenderPass::LoadSto
reOps& colorOps, |
404 const GrVkRenderPass::LoadSto
reOps& resolveOps, | |
405 const GrVkRenderPass::LoadSto
reOps& stencilOps) { | 403 const GrVkRenderPass::LoadSto
reOps& stencilOps) { |
406 for (int i = 0; i < fRenderPasses.count(); ++i) { | 404 for (int i = 0; i < fRenderPasses.count(); ++i) { |
407 int idx = (i + fLastReturnedIndex) % fRenderPasses.count(); | 405 int idx = (i + fLastReturnedIndex) % fRenderPasses.count(); |
408 if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, resolveOps, stencilO
ps)) { | 406 if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, stencilOps)) { |
409 fLastReturnedIndex = idx; | 407 fLastReturnedIndex = idx; |
410 return fRenderPasses[idx]; | 408 return fRenderPasses[idx]; |
411 } | 409 } |
412 } | 410 } |
413 GrVkRenderPass* renderPass = fRenderPasses.emplace_back(new GrVkRenderPass()
); | 411 GrVkRenderPass* renderPass = fRenderPasses.emplace_back(new GrVkRenderPass()
); |
414 renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, resolveOps
, stencilOps); | 412 renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, stencilOps
); |
415 fLastReturnedIndex = fRenderPasses.count() - 1; | 413 fLastReturnedIndex = fRenderPasses.count() - 1; |
416 return renderPass; | 414 return renderPass; |
417 } | 415 } |
418 | 416 |
419 void GrVkResourceProvider::CompatibleRenderPassSet::releaseResources(const GrVkG
pu* gpu) { | 417 void GrVkResourceProvider::CompatibleRenderPassSet::releaseResources(const GrVkG
pu* gpu) { |
420 for (int i = 0; i < fRenderPasses.count(); ++i) { | 418 for (int i = 0; i < fRenderPasses.count(); ++i) { |
421 if (fRenderPasses[i]) { | 419 if (fRenderPasses[i]) { |
422 fRenderPasses[i]->unref(gpu); | 420 fRenderPasses[i]->unref(gpu); |
423 fRenderPasses[i] = nullptr; | 421 fRenderPasses[i] = nullptr; |
424 } | 422 } |
425 } | 423 } |
426 } | 424 } |
427 | 425 |
428 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { | 426 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { |
429 for (int i = 0; i < fRenderPasses.count(); ++i) { | 427 for (int i = 0; i < fRenderPasses.count(); ++i) { |
430 if (fRenderPasses[i]) { | 428 if (fRenderPasses[i]) { |
431 fRenderPasses[i]->unrefAndAbandon(); | 429 fRenderPasses[i]->unrefAndAbandon(); |
432 fRenderPasses[i] = nullptr; | 430 fRenderPasses[i] = nullptr; |
433 } | 431 } |
434 } | 432 } |
435 } | 433 } |
OLD | NEW |