| Index: src/gpu/vk/GrVkDescriptorPool.cpp
|
| diff --git a/src/gpu/vk/GrVkDescriptorPool.cpp b/src/gpu/vk/GrVkDescriptorPool.cpp
|
| index 48880b64db2c32c9951113eda11baa1746055c11..43ffe951e2131fd87af2e79be37886259f5b5543 100644
|
| --- a/src/gpu/vk/GrVkDescriptorPool.cpp
|
| +++ b/src/gpu/vk/GrVkDescriptorPool.cpp
|
| @@ -11,29 +11,24 @@
|
| #include "SkTemplates.h"
|
|
|
|
|
| -GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, const DescriptorTypeCounts& typeCounts)
|
| +GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, VkDescriptorType type, uint32_t count)
|
| : INHERITED()
|
| - , fTypeCounts(typeCounts) {
|
| - int numPools = fTypeCounts.numPoolSizes();
|
| - SkAutoTDeleteArray<VkDescriptorPoolSize> poolSizes(new VkDescriptorPoolSize[numPools]);
|
| - int currentPool = 0;
|
| - for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANGE; ++i) {
|
| - if (fTypeCounts.fDescriptorTypeCount[i]) {
|
| - VkDescriptorPoolSize& poolSize = poolSizes.get()[currentPool++];
|
| - poolSize.type = (VkDescriptorType)i;
|
| - poolSize.descriptorCount = fTypeCounts.fDescriptorTypeCount[i];
|
| - }
|
| - }
|
| - SkASSERT(currentPool == numPools);
|
| + , fType (type)
|
| + , fCount(count) {
|
| + VkDescriptorPoolSize poolSize;
|
| + memset(&poolSize, 0, sizeof(VkDescriptorPoolSize));
|
| + poolSize.descriptorCount = count;
|
| + poolSize.type = type;
|
|
|
| VkDescriptorPoolCreateInfo createInfo;
|
| memset(&createInfo, 0, sizeof(VkDescriptorPoolCreateInfo));
|
| createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
| createInfo.pNext = nullptr;
|
| createInfo.flags = 0;
|
| - createInfo.maxSets = 2; // Currently we allow one set for samplers and one set for uniforms
|
| - createInfo.poolSizeCount = numPools;
|
| - createInfo.pPoolSizes = poolSizes.get();
|
| + // This is an over/conservative estimate since each set may contain more than count descriptors.
|
| + createInfo.maxSets = count;
|
| + createInfo.poolSizeCount = 1;
|
| + createInfo.pPoolSizes = &poolSize;
|
|
|
| GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateDescriptorPool(gpu->device(),
|
| &createInfo,
|
| @@ -41,8 +36,8 @@ GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, const DescriptorTypeC
|
| &fDescPool));
|
| }
|
|
|
| -bool GrVkDescriptorPool::isCompatible(const DescriptorTypeCounts& typeCounts) const {
|
| - return fTypeCounts.isSuperSet(typeCounts);
|
| +bool GrVkDescriptorPool::isCompatible(VkDescriptorType type, uint32_t count) const {
|
| + return fType == type && count <= fCount;
|
| }
|
|
|
| void GrVkDescriptorPool::reset(const GrVkGpu* gpu) {
|
| @@ -54,26 +49,3 @@ void GrVkDescriptorPool::freeGPUData(const GrVkGpu* gpu) const {
|
| // allocated from the pool.
|
| GR_VK_CALL(gpu->vkInterface(), DestroyDescriptorPool(gpu->device(), fDescPool, nullptr));
|
| }
|
| -
|
| -///////////////////////////////////////////////////////////////////////////////
|
| -
|
| -int GrVkDescriptorPool::DescriptorTypeCounts::numPoolSizes() const {
|
| - int count = 0;
|
| - for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANGE; ++i) {
|
| - count += fDescriptorTypeCount[i] ? 1 : 0;
|
| - }
|
| - return count;
|
| -}
|
| -
|
| -bool GrVkDescriptorPool::DescriptorTypeCounts::isSuperSet(const DescriptorTypeCounts& that) const {
|
| - for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANGE; ++i) {
|
| - if (that.fDescriptorTypeCount[i] > fDescriptorTypeCount[i]) {
|
| - return false;
|
| - }
|
| - }
|
| - return true;
|
| -}
|
| -
|
| -void GrVkDescriptorPool::DescriptorTypeCounts::setTypeCount(VkDescriptorType type, uint8_t count) {
|
| - fDescriptorTypeCount[type] = count;
|
| -}
|
|
|