1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #ifndef VK_DESCRIPTOR_POOL_HPP_
16 #define VK_DESCRIPTOR_POOL_HPP_
18 #include "VkObject.hpp"
23 class DescriptorPool : public Object<DescriptorPool, VkDescriptorPool>
26 DescriptorPool(const VkDescriptorPoolCreateInfo* pCreateInfo, void* mem);
27 ~DescriptorPool() = delete;
28 void destroy(const VkAllocationCallbacks* pAllocator);
30 static size_t ComputeRequiredAllocationSize(const VkDescriptorPoolCreateInfo* pCreateInfo);
32 VkResult allocateSets(uint32_t descriptorSetCount, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets);
33 void freeSets(uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets);
37 VkResult allocateSets(size_t* sizes, uint32_t numAllocs, VkDescriptorSet* pDescriptorSets);
38 VkDescriptorSet findAvailableMemory(size_t size);
39 void freeSet(const VkDescriptorSet descriptorSet);
40 size_t computeTotalFreeSize() const;
44 Node(VkDescriptorSet set, size_t size) : set(set), size(size) {}
45 bool operator<(const Node& node) const { return this->set < node.set; }
46 bool operator==(VkDescriptorSet set) const { return this->set == set; }
53 VkDescriptorSet pool = nullptr;
57 static inline DescriptorPool* Cast(VkDescriptorPool object)
59 return reinterpret_cast<DescriptorPool*>(object);
64 #endif // VK_DESCRIPTOR_POOL_HPP_