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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 for (int i = 0; i < fTextures.count(); ++i) { | 401 for (int i = 0; i < fTextures.count(); ++i) { |
402 commandBuffer.addResource(fTextures[i]); | 402 commandBuffer.addResource(fTextures[i]); |
403 } | 403 } |
404 } | 404 } |
405 | 405 |
406 //////////////////////////////////////////////////////////////////////////////// | 406 //////////////////////////////////////////////////////////////////////////////// |
407 | 407 |
408 void GrVkPipelineState::DescriptorPoolManager::getNewPool(GrVkGpu* gpu) { | 408 void GrVkPipelineState::DescriptorPoolManager::getNewPool(GrVkGpu* gpu) { |
409 if (fPool) { | 409 if (fPool) { |
410 fPool->unref(gpu); | 410 fPool->unref(gpu); |
411 SkASSERT(fMaxDescriptorSets < (SK_MaxU32 >> 1)); | 411 if (fMaxDescriptors < kMaxDescLimit >> 1) { |
412 if (fMaxDescriptorSets < kMaxDescSetLimit >> 1) { | 412 fMaxDescriptors = fMaxDescriptors << 1; |
413 fMaxDescriptorSets = fMaxDescriptorSets << 1; | |
414 } else { | 413 } else { |
415 fMaxDescriptorSets = kMaxDescSetLimit; | 414 fMaxDescriptors = kMaxDescLimit; |
416 } | 415 } |
417 | 416 |
418 } | 417 } |
419 if (fMaxDescriptorSets) { | 418 if (fMaxDescriptors) { |
420 fPool = gpu->resourceProvider().findOrCreateCompatibleDescriptorPool(fDe
scType, | 419 fPool = gpu->resourceProvider().findOrCreateCompatibleDescriptorPool(fDe
scType, |
421 fMa
xDescriptorSets); | 420 fMa
xDescriptors); |
422 } | 421 } |
423 SkASSERT(fPool || !fMaxDescriptorSets); | 422 SkASSERT(fPool || !fMaxDescriptors); |
424 } | 423 } |
425 | 424 |
426 void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu,
VkDescriptorSet* ds) { | 425 void GrVkPipelineState::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu,
VkDescriptorSet* ds) { |
427 if (!fMaxDescriptorSets) { | 426 if (!fMaxDescriptors) { |
428 return; | 427 return; |
429 } | 428 } |
430 if (fCurrentDescriptorSet == fMaxDescriptorSets) { | 429 if (fCurrentDescriptorCount == fMaxDescriptors) { |
431 this->getNewPool(gpu); | 430 this->getNewPool(gpu); |
432 fCurrentDescriptorSet = 0; | 431 fCurrentDescriptorCount = 0; |
433 } | 432 } |
434 fCurrentDescriptorSet++; | 433 fCurrentDescriptorCount += fDescCountPerSet; |
435 | 434 |
436 VkDescriptorSetAllocateInfo dsAllocateInfo; | 435 VkDescriptorSetAllocateInfo dsAllocateInfo; |
437 memset(&dsAllocateInfo, 0, sizeof(VkDescriptorSetAllocateInfo)); | 436 memset(&dsAllocateInfo, 0, sizeof(VkDescriptorSetAllocateInfo)); |
438 dsAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; | 437 dsAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
439 dsAllocateInfo.pNext = nullptr; | 438 dsAllocateInfo.pNext = nullptr; |
440 dsAllocateInfo.descriptorPool = fPool->descPool(); | 439 dsAllocateInfo.descriptorPool = fPool->descPool(); |
441 dsAllocateInfo.descriptorSetCount = 1; | 440 dsAllocateInfo.descriptorSetCount = 1; |
442 dsAllocateInfo.pSetLayouts = &fDescLayout; | 441 dsAllocateInfo.pSetLayouts = &fDescLayout; |
443 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device()
, | 442 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device()
, |
444 &dsAllocateIn
fo, | 443 &dsAllocateIn
fo, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 | 500 |
502 b.add32(get_blend_info_key(pipeline)); | 501 b.add32(get_blend_info_key(pipeline)); |
503 | 502 |
504 b.add32(primitiveType); | 503 b.add32(primitiveType); |
505 | 504 |
506 // Set key length | 505 // Set key length |
507 int keyLength = key->count(); | 506 int keyLength = key->count(); |
508 SkASSERT(0 == (keyLength % 4)); | 507 SkASSERT(0 == (keyLength % 4)); |
509 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); | 508 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); |
510 } | 509 } |
OLD | NEW |