]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/destroyqueue.h
Initial implementation of Vulkan backend
[libs/gl.git] / source / backends / vulkan / destroyqueue.h
1 #ifndef MSP_GL_VULKAN_DESTROYQUEUE_H_
2 #define MSP_GL_VULKAN_DESTROYQUEUE_H_
3
4 #include <deque>
5 #include "handles.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Device;
11 class VulkanFunctions;
12
13 class DestroyQueue
14 {
15 private:
16         struct Entry
17         {
18                 void *handle = 0;
19                 void (*destroy_func)(const VulkanFunctions &, void *) = 0;
20                 unsigned memory_id = 0;
21                 unsigned on_frame = 0;
22         };
23
24         Device &device;
25         std::deque<Entry> queue;
26         unsigned current_frame = 0;
27
28 public:
29         DestroyQueue(Device &);
30         ~DestroyQueue();
31
32         void destroy(VkBuffer, unsigned);
33         void destroy(VkFence);
34         void destroy(VkFramebuffer);
35         void destroy(VkImageView);
36         void destroy(VkSemaphore);
37
38 private:
39         template<typename T, void (VulkanFunctions::*)(T) const>
40         void destroy(T, unsigned = 0);
41
42 public:
43         void tick();
44 };
45
46 } // namespace GL
47 } // namespace Msp
48
49 #endif