-VK_NULL_DEFINE_DEVICE_OBJ(Fence);
-VK_NULL_DEFINE_DEVICE_OBJ(Image);
-VK_NULL_DEFINE_DEVICE_OBJ(Semaphore);
-VK_NULL_DEFINE_DEVICE_OBJ(Event);
-VK_NULL_DEFINE_DEVICE_OBJ(QueryPool);
-VK_NULL_DEFINE_DEVICE_OBJ(BufferView);
-VK_NULL_DEFINE_DEVICE_OBJ(ImageView);
-VK_NULL_DEFINE_DEVICE_OBJ(ShaderModule);
-VK_NULL_DEFINE_DEVICE_OBJ(PipelineCache);
-VK_NULL_DEFINE_DEVICE_OBJ(PipelineLayout);
-VK_NULL_DEFINE_DEVICE_OBJ(RenderPass);
-VK_NULL_DEFINE_DEVICE_OBJ(DescriptorSetLayout);
-VK_NULL_DEFINE_DEVICE_OBJ(Sampler);
-VK_NULL_DEFINE_DEVICE_OBJ(Framebuffer);
-VK_NULL_DEFINE_DEVICE_OBJ(CommandPool);
-VK_NULL_DEFINE_DEVICE_OBJ(DescriptorPool);
+class DescriptorSet
+{
+public:
+ DescriptorSet (VkDevice, VkDescriptorPool, VkDescriptorSetLayout) {}
+};
+
+class DescriptorPool
+{
+public:
+ DescriptorPool (VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo)
+ : m_device (device)
+ , m_flags (pCreateInfo->flags)
+ {}
+ ~DescriptorPool (void)
+ {
+ reset();
+ }
+
+ VkDescriptorSet allocate (VkDescriptorSetLayout setLayout);
+ void free (VkDescriptorSet set);
+
+ void reset (void);
+
+private:
+ const VkDevice m_device;
+ const VkDescriptorPoolCreateFlags m_flags;
+
+ vector<DescriptorSet*> m_managedSets;
+};
+
+VkDescriptorSet DescriptorPool::allocate (VkDescriptorSetLayout setLayout)
+{
+ DescriptorSet* const impl = new DescriptorSet(m_device, VkDescriptorPool(reinterpret_cast<deUintptr>(this)), setLayout);
+
+ try
+ {
+ m_managedSets.push_back(impl);
+ }
+ catch (...)
+ {
+ delete impl;
+ throw;
+ }
+
+ return VkDescriptorSet(reinterpret_cast<deUintptr>(impl));
+}
+
+void DescriptorPool::free (VkDescriptorSet set)
+{
+ DescriptorSet* const impl = reinterpret_cast<DescriptorSet*>((deUintptr)set.getInternal());
+
+ DE_ASSERT(m_flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT);
+
+ delete impl;
+
+ for (size_t ndx = 0; ndx < m_managedSets.size(); ++ndx)
+ {
+ if (m_managedSets[ndx] == impl)
+ {
+ std::swap(m_managedSets[ndx], m_managedSets.back());
+ m_managedSets.pop_back();
+ return;
+ }
+ }
+
+ DE_FATAL("VkDescriptorSet not owned by VkDescriptorPool");
+}
+
+void DescriptorPool::reset (void)
+{
+ for (size_t ndx = 0; ndx < m_managedSets.size(); ++ndx)
+ delete m_managedSets[ndx];
+ m_managedSets.clear();
+}