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 "GrVkPipelineState.h" | 8 #include "GrVkPipelineState.h" |
9 | 9 |
10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
(...skipping 276 matching lines...) Loading... |
287 | 287 |
288 void GrVkPipelineState::writeSamplers(GrVkGpu* gpu, | 288 void GrVkPipelineState::writeSamplers(GrVkGpu* gpu, |
289 const SkTArray<const GrTextureAccess*>& te
xtureBindings, | 289 const SkTArray<const GrTextureAccess*>& te
xtureBindings, |
290 bool allowSRGBInputs) { | 290 bool allowSRGBInputs) { |
291 SkASSERT(fNumSamplers == textureBindings.count()); | 291 SkASSERT(fNumSamplers == textureBindings.count()); |
292 | 292 |
293 for (int i = 0; i < textureBindings.count(); ++i) { | 293 for (int i = 0; i < textureBindings.count(); ++i) { |
294 const GrTextureParams& params = textureBindings[i]->getParams(); | 294 const GrTextureParams& params = textureBindings[i]->getParams(); |
295 | 295 |
296 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); | 296 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); |
297 if (GrTextureParams::kMipMap_FilterMode == params.filterMode()) { | |
298 if (texture->texturePriv().mipMapsAreDirty()) { | |
299 gpu->generateMipmap(texture); | |
300 texture->texturePriv().dirtyMipMaps(false); | |
301 } | |
302 } | |
303 | 297 |
304 fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(par
ams, | 298 fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(par
ams, |
305 texture->texturePriv()
.maxMipMapLevel())); | 299 texture->texturePriv()
.maxMipMapLevel())); |
306 | 300 |
307 const GrVkResource* textureResource = texture->resource(); | 301 const GrVkResource* textureResource = texture->resource(); |
308 textureResource->ref(); | 302 textureResource->ref(); |
309 fTextures.push(textureResource); | 303 fTextures.push(textureResource); |
310 | 304 |
311 const GrVkImageView* textureView = texture->textureView(allowSRGBInputs)
; | 305 const GrVkImageView* textureView = texture->textureView(allowSRGBInputs)
; |
312 textureView->ref(); | 306 textureView->ref(); |
313 fTextureViews.push(textureView); | 307 fTextureViews.push(textureView); |
314 | 308 |
315 // Change texture layout so it can be read in shader | |
316 texture->setImageLayout(gpu, | |
317 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, | |
318 VK_ACCESS_SHADER_READ_BIT, | |
319 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, | |
320 false); | |
321 | |
322 VkDescriptorImageInfo imageInfo; | 309 VkDescriptorImageInfo imageInfo; |
323 memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); | 310 memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); |
324 imageInfo.sampler = fSamplers[i]->sampler(); | 311 imageInfo.sampler = fSamplers[i]->sampler(); |
325 imageInfo.imageView = textureView->imageView(); | 312 imageInfo.imageView = textureView->imageView(); |
326 imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | 313 imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
327 | 314 |
328 VkWriteDescriptorSet writeInfo; | 315 VkWriteDescriptorSet writeInfo; |
329 memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet)); | 316 memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet)); |
330 writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | 317 writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
331 writeInfo.pNext = nullptr; | 318 writeInfo.pNext = nullptr; |
(...skipping 172 matching lines...) Loading... |
504 | 491 |
505 b.add32(get_blend_info_key(pipeline)); | 492 b.add32(get_blend_info_key(pipeline)); |
506 | 493 |
507 b.add32(primitiveType); | 494 b.add32(primitiveType); |
508 | 495 |
509 // Set key length | 496 // Set key length |
510 int keyLength = key->count(); | 497 int keyLength = key->count(); |
511 SkASSERT(0 == (keyLength % 4)); | 498 SkASSERT(0 == (keyLength % 4)); |
512 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); | 499 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); |
513 } | 500 } |
OLD | NEW |