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 "GrVkDescriptorPool.h" | 8 #include "GrVkDescriptorPool.h" |
9 | 9 |
10 #include "GrVkGpu.h" | 10 #include "GrVkGpu.h" |
11 #include "SkTemplates.h" | 11 #include "SkTemplates.h" |
12 | 12 |
13 | 13 |
14 GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, const DescriptorTypeC ounts& typeCounts) | 14 GrVkDescriptorPool::GrVkDescriptorPool(const GrVkGpu* gpu, const DescriptorTypeC ounts& typeCounts) |
15 : INHERITED() | 15 : INHERITED() |
16 , fTypeCounts(typeCounts) { | 16 , fTypeCounts(typeCounts) { |
17 uint32_t numPools = fTypeCounts.numPoolSizes(); | 17 int numPools = fTypeCounts.numPoolSizes(); |
18 SkAutoTDeleteArray<VkDescriptorPoolSize> poolSizes(new VkDescriptorPoolSize[ numPools]); | 18 SkAutoTDeleteArray<VkDescriptorPoolSize> poolSizes(new VkDescriptorPoolSize[ numPools]); |
19 int currentPool = 0; | 19 int currentPool = 0; |
20 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { | 20 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { |
21 if (fTypeCounts.fDescriptorTypeCount[i]) { | 21 if (fTypeCounts.fDescriptorTypeCount[i]) { |
22 VkDescriptorPoolSize& poolSize = poolSizes.get()[currentPool++]; | 22 VkDescriptorPoolSize& poolSize = poolSizes.get()[currentPool++]; |
23 poolSize.type = (VkDescriptorType)i; | 23 poolSize.type = (VkDescriptorType)i; |
24 poolSize.descriptorCount = fTypeCounts.fDescriptorTypeCount[i]; | 24 poolSize.descriptorCount = fTypeCounts.fDescriptorTypeCount[i]; |
25 } | 25 } |
26 } | 26 } |
27 SkASSERT(currentPool == numPools); | 27 SkASSERT(currentPool == numPools); |
bsalomon
2016/02/22 19:50:32
this assert barfs on linux currently.
| |
28 | 28 |
29 VkDescriptorPoolCreateInfo createInfo; | 29 VkDescriptorPoolCreateInfo createInfo; |
30 memset(&createInfo, 0, sizeof(VkDescriptorPoolCreateInfo)); | 30 memset(&createInfo, 0, sizeof(VkDescriptorPoolCreateInfo)); |
31 createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; | 31 createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
32 createInfo.pNext = nullptr; | 32 createInfo.pNext = nullptr; |
33 createInfo.flags = 0; | 33 createInfo.flags = 0; |
34 createInfo.maxSets = 2; // Currently we allow one set for samplers and one set for uniforms | 34 createInfo.maxSets = 2; // Currently we allow one set for samplers and one set for uniforms |
35 createInfo.poolSizeCount = numPools; | 35 createInfo.poolSizeCount = numPools; |
36 createInfo.pPoolSizes = poolSizes.get(); | 36 createInfo.pPoolSizes = poolSizes.get(); |
37 | 37 |
(...skipping 12 matching lines...) Expand all Loading... | |
50 } | 50 } |
51 | 51 |
52 void GrVkDescriptorPool::freeGPUData(const GrVkGpu* gpu) const { | 52 void GrVkDescriptorPool::freeGPUData(const GrVkGpu* gpu) const { |
53 // Destroying the VkDescriptorPool will automatically free and delete any Vk DescriptorSets | 53 // Destroying the VkDescriptorPool will automatically free and delete any Vk DescriptorSets |
54 // allocated from the pool. | 54 // allocated from the pool. |
55 GR_VK_CALL(gpu->vkInterface(), DestroyDescriptorPool(gpu->device(), fDescPoo l, nullptr)); | 55 GR_VK_CALL(gpu->vkInterface(), DestroyDescriptorPool(gpu->device(), fDescPoo l, nullptr)); |
56 } | 56 } |
57 | 57 |
58 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
59 | 59 |
60 uint32_t GrVkDescriptorPool::DescriptorTypeCounts::numPoolSizes() const { | 60 int GrVkDescriptorPool::DescriptorTypeCounts::numPoolSizes() const { |
61 uint32_t count = 0; | 61 int count = 0; |
62 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { | 62 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { |
63 count += fDescriptorTypeCount[i] ? 1 : 0; | 63 count += fDescriptorTypeCount[i] ? 1 : 0; |
64 } | 64 } |
65 return count; | 65 return count; |
66 } | 66 } |
67 | 67 |
68 bool GrVkDescriptorPool::DescriptorTypeCounts::isSuperSet(const DescriptorTypeCo unts& that) const { | 68 bool GrVkDescriptorPool::DescriptorTypeCounts::isSuperSet(const DescriptorTypeCo unts& that) const { |
69 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { | 69 for (int i = VK_DESCRIPTOR_TYPE_BEGIN_RANGE; i < VK_DESCRIPTOR_TYPE_END_RANG E; ++i) { |
70 if (that.fDescriptorTypeCount[i] > fDescriptorTypeCount[i]) { | 70 if (that.fDescriptorTypeCount[i] > fDescriptorTypeCount[i]) { |
71 return false; | 71 return false; |
72 } | 72 } |
73 } | 73 } |
74 return true; | 74 return true; |
75 } | 75 } |
76 | 76 |
77 void GrVkDescriptorPool::DescriptorTypeCounts::setTypeCount(VkDescriptorType typ e, uint8_t count) { | 77 void GrVkDescriptorPool::DescriptorTypeCounts::setTypeCount(VkDescriptorType typ e, uint8_t count) { |
78 fDescriptorTypeCount[type] = count; | 78 fDescriptorTypeCount[type] = count; |
79 } | 79 } |
OLD | NEW |