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" |
11 #include "GrVkCommandBuffer.h" | 11 #include "GrVkCommandBuffer.h" |
12 #include "GrVkPipeline.h" | 12 #include "GrVkPipeline.h" |
| 13 #include "GrVkRenderTarget.h" |
13 #include "GrVkSampler.h" | 14 #include "GrVkSampler.h" |
14 #include "GrVkUtil.h" | 15 #include "GrVkUtil.h" |
15 | 16 |
16 #ifdef SK_TRACE_VK_RESOURCES | 17 #ifdef SK_TRACE_VK_RESOURCES |
17 SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace; | 18 SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace; |
18 SkRandom GrVkResource::fRandom; | 19 SkRandom GrVkResource::fRandom; |
19 #endif | 20 #endif |
20 | 21 |
21 GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) | 22 GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) |
22 : fGpu(gpu) | 23 : fGpu(gpu) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 renderPass->ref(); | 133 renderPass->ref(); |
133 return renderPass; | 134 return renderPass; |
134 } | 135 } |
135 | 136 |
136 const GrVkRenderPass* GrVkResourceProvider::findRenderPass( | 137 const GrVkRenderPass* GrVkResourceProvider::findRenderPass( |
137 const GrVkRenderTarget& tar
get, | 138 const GrVkRenderTarget& tar
get, |
138 const GrVkRenderPass::LoadS
toreOps& colorOps, | 139 const GrVkRenderPass::LoadS
toreOps& colorOps, |
139 const GrVkRenderPass::LoadS
toreOps& resolveOps, | 140 const GrVkRenderPass::LoadS
toreOps& resolveOps, |
140 const GrVkRenderPass::LoadS
toreOps& stencilOps, | 141 const GrVkRenderPass::LoadS
toreOps& stencilOps, |
141 CompatibleRPHandle* compati
bleHandle) { | 142 CompatibleRPHandle* compati
bleHandle) { |
| 143 GrVkResourceProvider::CompatibleRPHandle tempRPHandle; |
| 144 GrVkResourceProvider::CompatibleRPHandle* pRPHandle = compatibleHandle ? com
patibleHandle |
| 145 : &te
mpRPHandle; |
| 146 *pRPHandle = target.compatibleRenderPassHandle(); |
| 147 |
142 // This will get us the handle to (and possible create) the compatible set f
or the specific | 148 // This will get us the handle to (and possible create) the compatible set f
or the specific |
143 // GrVkRenderPass we are looking for. | 149 // GrVkRenderPass we are looking for. |
144 this->findCompatibleRenderPass(target, compatibleHandle); | 150 this->findCompatibleRenderPass(target, compatibleHandle); |
145 return this->findRenderPass(*compatibleHandle, colorOps, resolveOps, stencil
Ops); | 151 return this->findRenderPass(*pRPHandle, colorOps, resolveOps, stencilOps); |
146 } | 152 } |
147 | 153 |
148 const GrVkRenderPass* | 154 const GrVkRenderPass* |
149 GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, | 155 GrVkResourceProvider::findRenderPass(const CompatibleRPHandle& compatibleHandle, |
150 const GrVkRenderPass::LoadStoreOps& colorOp
s, | 156 const GrVkRenderPass::LoadStoreOps& colorOp
s, |
151 const GrVkRenderPass::LoadStoreOps& resolve
Ops, | 157 const GrVkRenderPass::LoadStoreOps& resolve
Ops, |
152 const GrVkRenderPass::LoadStoreOps& stencil
Ops) { | 158 const GrVkRenderPass::LoadStoreOps& stencil
Ops) { |
153 SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderP
assArray.count()); | 159 SkASSERT(compatibleHandle.isValid() && compatibleHandle.toIndex() < fRenderP
assArray.count()); |
154 CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.t
oIndex()]; | 160 CompatibleRenderPassSet& compatibleSet = fRenderPassArray[compatibleHandle.t
oIndex()]; |
155 const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, | 161 const GrVkRenderPass* renderPass = compatibleSet.getRenderPass(fGpu, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 355 } |
350 | 356 |
351 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { | 357 void GrVkResourceProvider::CompatibleRenderPassSet::abandonResources() { |
352 for (int i = 0; i < fRenderPasses.count(); ++i) { | 358 for (int i = 0; i < fRenderPasses.count(); ++i) { |
353 if (fRenderPasses[i]) { | 359 if (fRenderPasses[i]) { |
354 fRenderPasses[i]->unrefAndAbandon(); | 360 fRenderPasses[i]->unrefAndAbandon(); |
355 fRenderPasses[i] = nullptr; | 361 fRenderPasses[i] = nullptr; |
356 } | 362 } |
357 } | 363 } |
358 } | 364 } |
OLD | NEW |