Index: src/gpu/vk/GrVkResourceProvider.cpp |
diff --git a/src/gpu/vk/GrVkResourceProvider.cpp b/src/gpu/vk/GrVkResourceProvider.cpp |
index fdc9e90686b972391c4290ad2296588c6ab1d44a..cd3ba47bcaf586e71adac8f5aee421544ca427ef 100644 |
--- a/src/gpu/vk/GrVkResourceProvider.cpp |
+++ b/src/gpu/vk/GrVkResourceProvider.cpp |
@@ -10,7 +10,6 @@ |
#include "GrTextureParams.h" |
#include "GrVkCommandBuffer.h" |
#include "GrVkPipeline.h" |
-#include "GrVkRenderPass.h" |
#include "GrVkSampler.h" |
#include "GrVkUtil.h" |
@@ -134,6 +133,33 @@ GrVkResourceProvider::findCompatibleRenderPass(const CompatibleRPHandle& compati |
return renderPass; |
} |
+const GrVkRenderPass* GrVkResourceProvider::findRenderPass( |
+ const GrVkRenderTarget& target, |
+ const GrVkRenderPass::LoadStoreOps& colorOps, |
+ const GrVkRenderPass::LoadStoreOps& resolveOps, |
+ const GrVkRenderPass::LoadStoreOps& stencilOps, |
+ CompatibleRPHandle* compatibleHandle) { |
+ // This will get us the handle to (and possible create) the compatible set for the specific |
+ // GrVkRenderPass we are looking for. |
+ this->findCompatibleRenderPass(target, compatibleHandle); |
+ return this->findRenderPass(*compatibleHandle, colorOps, resolveOps, stencilOps); |
+} |
+ |
+const GrVkRenderPass* |
+GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, |
+ const GrVkRenderPass::LoadStoreOps& colorOps, |
+ const GrVkRenderPass::LoadStoreOps& resolveOps, |
+ const GrVkRenderPass::LoadStoreOps& stencilOps) { |
+ SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderPassArray.count()); |
+ CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.toIndex()]; |
+ const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, |
+ colorOps, |
+ resolveOps, |
+ stencilOps); |
+ renderPass->ref(); |
+ return renderPass; |
+} |
+ |
GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( |
VkDescriptorType type, uint32_t count) { |
return new GrVkDescriptorPool(fGpu, type, count); |
@@ -295,6 +321,24 @@ bool GrVkResourceProvider::CompatibleRenderPassSet::isCompatible( |
return fRenderPasses[0]->isCompatible(target); |
} |
+GrVkRenderPass* GrVkResourceProvider::CompatibleRenderPassSet::getRenderPass( |
+ const GrVkGpu* gpu, |
+ const GrVkRenderPass::LoadStoreOps& colorOps, |
+ const GrVkRenderPass::LoadStoreOps& resolveOps, |
+ const GrVkRenderPass::LoadStoreOps& stencilOps) { |
+ for (int i = 0; i < fRenderPasses.count(); ++i) { |
+ int idx = (i + fLastReturnedIndex) % fRenderPasses.count(); |
+ if (fRenderPasses[idx]->equalLoadStoreOps(colorOps, resolveOps, stencilOps)) { |
+ fLastReturnedIndex = idx; |
+ return fRenderPasses[idx]; |
+ } |
+ } |
+ GrVkRenderPass* renderPass = fRenderPasses.push_back(); |
+ renderPass->init(gpu, *this->getCompatibleRenderPass(), colorOps, resolveOps, stencilOps); |
+ fLastReturnedIndex = fRenderPasses.count() - 1; |
+ return renderPass; |
+} |
+ |
void GrVkResourceProvider::CompatibleRenderPassSet::releaseResources(const GrVkGpu* gpu) { |
for (int i = 0; i < fRenderPasses.count(); ++i) { |
if (fRenderPasses[i]) { |