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 "GrVkProgram.h" | 8 #include "GrVkProgram.h" |
9 | 9 |
10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 SkTArray<const GrTextureAccess*>* textureBin
dings) { | 156 SkTArray<const GrTextureAccess*>* textureBin
dings) { |
157 if (int numTextures = processor.numTextures()) { | 157 if (int numTextures = processor.numTextures()) { |
158 const GrTextureAccess** bindings = textureBindings->push_back_n(numTextu
res); | 158 const GrTextureAccess** bindings = textureBindings->push_back_n(numTextu
res); |
159 int i = 0; | 159 int i = 0; |
160 do { | 160 do { |
161 bindings[i] = &processor.textureAccess(i); | 161 bindings[i] = &processor.textureAccess(i); |
162 } while (++i < numTextures); | 162 } while (++i < numTextures); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 void GrVkProgram::setData(const GrVkGpu* gpu, | 166 void GrVkProgram::setData(GrVkGpu* gpu, |
167 const GrPrimitiveProcessor& primProc, | 167 const GrPrimitiveProcessor& primProc, |
168 const GrPipeline& pipeline) { | 168 const GrPipeline& pipeline) { |
169 // This is here to protect against someone calling setData multiple times in
a row without | 169 // This is here to protect against someone calling setData multiple times in
a row without |
170 // freeing the tempData between calls. | 170 // freeing the tempData between calls. |
171 this->freeTempResources(gpu); | 171 this->freeTempResources(gpu); |
172 | 172 |
173 this->setRenderTargetState(pipeline); | 173 this->setRenderTargetState(pipeline); |
174 | 174 |
175 SkSTArray<8, const GrTextureAccess*> textureBindings; | 175 SkSTArray<8, const GrTextureAccess*> textureBindings; |
176 | 176 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 } | 248 } |
249 | 249 |
250 if (uniformBindingUpdateCount) { | 250 if (uniformBindingUpdateCount) { |
251 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), | 251 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), |
252 uniformBindingUpdate
Count, | 252 uniformBindingUpdate
Count, |
253 &descriptorWrites[fi
rstUniformWrite], | 253 &descriptorWrites[fi
rstUniformWrite], |
254 0, nullptr)); | 254 0, nullptr)); |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 void GrVkProgram::writeSamplers(const GrVkGpu* gpu, | 258 void GrVkProgram::writeSamplers(GrVkGpu* gpu, |
259 const SkTArray<const GrTextureAccess*>& textureB
indings) { | 259 const SkTArray<const GrTextureAccess*>& textureB
indings) { |
260 SkASSERT(fNumSamplers == textureBindings.count()); | 260 SkASSERT(fNumSamplers == textureBindings.count()); |
261 | 261 |
262 for (int i = 0; i < textureBindings.count(); ++i) { | 262 for (int i = 0; i < textureBindings.count(); ++i) { |
263 fSamplers.push(GrVkSampler::Create(gpu, *textureBindings[i])); | 263 const GrTextureParams& params = textureBindings[i]->getParams(); |
| 264 fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(par
ams)); |
264 | 265 |
265 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); | 266 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); |
266 | 267 |
267 const GrVkImage::Resource* textureResource = texture->resource(); | 268 const GrVkImage::Resource* textureResource = texture->resource(); |
268 textureResource->ref(); | 269 textureResource->ref(); |
269 fTextures.push(textureResource); | 270 fTextures.push(textureResource); |
270 | 271 |
271 const GrVkImageView* textureView = texture->textureView(); | 272 const GrVkImageView* textureView = texture->textureView(); |
272 textureView->ref(); | 273 textureView->ref(); |
273 fTextureViews.push(textureView); | 274 fTextureViews.push(textureView); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 for (int i = 0; i < fTextureViews.count(); ++i) { | 360 for (int i = 0; i < fTextureViews.count(); ++i) { |
360 commandBuffer.addResource(fTextureViews[i]); | 361 commandBuffer.addResource(fTextureViews[i]); |
361 } | 362 } |
362 | 363 |
363 for (int i = 0; i < fTextures.count(); ++i) { | 364 for (int i = 0; i < fTextures.count(); ++i) { |
364 commandBuffer.addResource(fTextures[i]); | 365 commandBuffer.addResource(fTextures[i]); |
365 } | 366 } |
366 #endif | 367 #endif |
367 } | 368 } |
OLD | NEW |