]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/synchronizer.h
Add a synchronization helper class to the Vulkan backend
[libs/gl.git] / source / backends / vulkan / synchronizer.h
1 #ifndef MSP_GL_VULKAN_SYNCHRONIZER_H_
2 #define MSP_GL_VULKAN_SYNCHRONIZER_H_
3
4 #include <cstdint>
5 #include <vector>
6 #include "handles.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Synchronizer
12 {
13 private:
14         struct BufferAccess
15         {
16                 VkBuffer buffer = 0;
17                 std::size_t offset = 0;
18                 std::size_t size = 0;
19                 bool was_written = false;
20                 bool pending_write = false;
21         };
22
23         Device &device;
24         std::vector<BufferAccess> buffer_accesses;
25
26 public:
27         Synchronizer(Device &);
28
29         void access(VkBuffer, std::size_t, std::size_t);
30         void reset();
31         void barrier(VkCommandBuffer);
32 };
33
34 } // namespace GL
35 } // namespace Msp
36
37 #endif