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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 fSimpleRenderPasses.push_back(renderPass); | 78 fSimpleRenderPasses.push_back(renderPass); |
79 renderPass->ref(); | 79 renderPass->ref(); |
80 return renderPass; | 80 return renderPass; |
81 } | 81 } |
82 | 82 |
83 GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( | 83 GrVkDescriptorPool* GrVkResourceProvider::findOrCreateCompatibleDescriptorPool( |
84 VkDescriptorType typ
e, uint32_t count) { | 84 VkDescriptorType typ
e, uint32_t count) { |
85 return new GrVkDescriptorPool(fGpu, type, count); | 85 return new GrVkDescriptorPool(fGpu, type, count); |
86 } | 86 } |
87 | 87 |
88 GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(const GrTexture
Params& params) { | 88 GrVkSampler* GrVkResourceProvider::findOrCreateCompatibleSampler(const GrTexture
Params& params, |
89 GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params)); | 89 uint32_t mipLev
els) { |
| 90 GrVkSampler* sampler = fSamplers.find(GrVkSampler::GenerateKey(params, mipLe
vels)); |
90 if (!sampler) { | 91 if (!sampler) { |
91 sampler = GrVkSampler::Create(fGpu, params); | 92 sampler = GrVkSampler::Create(fGpu, params, mipLevels); |
92 fSamplers.add(sampler); | 93 fSamplers.add(sampler); |
93 } | 94 } |
94 SkASSERT(sampler); | 95 SkASSERT(sampler); |
95 sampler->ref(); | 96 sampler->ref(); |
96 return sampler; | 97 return sampler; |
97 } | 98 } |
98 | 99 |
99 sk_sp<GrVkPipelineState> GrVkResourceProvider::findOrCreateCompatiblePipelineSta
te( | 100 sk_sp<GrVkPipelineState> GrVkResourceProvider::findOrCreateCompatiblePipelineSta
te( |
100 const GrPipelin
e& pipeline, | 101 const GrPipelin
e& pipeline, |
101 const GrPrimiti
veProcessor& proc, | 102 const GrPrimiti
veProcessor& proc, |
(...skipping 27 matching lines...) Expand all Loading... |
129 } | 130 } |
130 fActiveCommandBuffers.reset(); | 131 fActiveCommandBuffers.reset(); |
131 | 132 |
132 // loop over all render passes to make sure we destroy all the internal VkRe
nderPasses | 133 // loop over all render passes to make sure we destroy all the internal VkRe
nderPasses |
133 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { | 134 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { |
134 fSimpleRenderPasses[i]->unref(fGpu); | 135 fSimpleRenderPasses[i]->unref(fGpu); |
135 } | 136 } |
136 fSimpleRenderPasses.reset(); | 137 fSimpleRenderPasses.reset(); |
137 | 138 |
138 // Iterate through all store GrVkSamplers and unref them before resetting th
e hash. | 139 // Iterate through all store GrVkSamplers and unref them before resetting th
e hash. |
139 SkTDynamicHash<GrVkSampler, uint8_t>::Iter iter(&fSamplers); | 140 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); |
140 for (; !iter.done(); ++iter) { | 141 for (; !iter.done(); ++iter) { |
141 (*iter).unref(fGpu); | 142 (*iter).unref(fGpu); |
142 } | 143 } |
143 fSamplers.reset(); | 144 fSamplers.reset(); |
144 | 145 |
145 fPipelineStateCache->release(); | 146 fPipelineStateCache->release(); |
146 | 147 |
147 #ifdef SK_TRACE_VK_RESOURCES | 148 #ifdef SK_TRACE_VK_RESOURCES |
148 SkASSERT(0 == GrVkResource::fTrace.count()); | 149 SkASSERT(0 == GrVkResource::fTrace.count()); |
149 #endif | 150 #endif |
150 | 151 |
151 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipeli
neCache, nullptr)); | 152 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipeli
neCache, nullptr)); |
152 fPipelineCache = VK_NULL_HANDLE; | 153 fPipelineCache = VK_NULL_HANDLE; |
153 } | 154 } |
154 | 155 |
155 void GrVkResourceProvider::abandonResources() { | 156 void GrVkResourceProvider::abandonResources() { |
156 // release our current command buffers | 157 // release our current command buffers |
157 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { | 158 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { |
158 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); | 159 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); |
159 fActiveCommandBuffers[i]->unrefAndAbandon(); | 160 fActiveCommandBuffers[i]->unrefAndAbandon(); |
160 } | 161 } |
161 fActiveCommandBuffers.reset(); | 162 fActiveCommandBuffers.reset(); |
162 | 163 |
163 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { | 164 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { |
164 fSimpleRenderPasses[i]->unrefAndAbandon(); | 165 fSimpleRenderPasses[i]->unrefAndAbandon(); |
165 } | 166 } |
166 fSimpleRenderPasses.reset(); | 167 fSimpleRenderPasses.reset(); |
167 | 168 |
168 // Iterate through all store GrVkSamplers and unrefAndAbandon them before re
setting the hash. | 169 // Iterate through all store GrVkSamplers and unrefAndAbandon them before re
setting the hash. |
169 SkTDynamicHash<GrVkSampler, uint8_t>::Iter iter(&fSamplers); | 170 SkTDynamicHash<GrVkSampler, uint16_t>::Iter iter(&fSamplers); |
170 for (; !iter.done(); ++iter) { | 171 for (; !iter.done(); ++iter) { |
171 (*iter).unrefAndAbandon(); | 172 (*iter).unrefAndAbandon(); |
172 } | 173 } |
173 fSamplers.reset(); | 174 fSamplers.reset(); |
174 | 175 |
175 fPipelineStateCache->abandon(); | 176 fPipelineStateCache->abandon(); |
176 | 177 |
177 #ifdef SK_TRACE_VK_RESOURCES | 178 #ifdef SK_TRACE_VK_RESOURCES |
178 SkASSERT(0 == GrVkResource::fTrace.count()); | 179 SkASSERT(0 == GrVkResource::fTrace.count()); |
179 #endif | 180 #endif |
180 fPipelineCache = VK_NULL_HANDLE; | 181 fPipelineCache = VK_NULL_HANDLE; |
181 } | 182 } |
OLD | NEW |