]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/synchronizer.h
Check the flat qualifier from the correct member
[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 VulkanCommandRecorder;
12
13 class Synchronizer
14 {
15 private:
16         struct ImageAccess
17         {
18                 VkImage image = 0;
19                 unsigned aspect;
20                 int level = -1;
21                 unsigned current_layout;
22                 unsigned pending_layout;
23         };
24
25         struct BufferAccess
26         {
27                 VkBuffer buffer = 0;
28                 std::size_t offset = 0;
29                 std::size_t size = 0;
30                 bool was_written = false;
31                 bool pending_write = false;
32         };
33
34         Device &device;
35         std::vector<BufferAccess> buffer_accesses;
36         std::vector<ImageAccess> image_accesses;
37
38 public:
39         Synchronizer(Device &);
40
41         void write_buffer(VkBuffer, std::size_t, std::size_t, bool = false);
42         void split_image_mipmap(VkImage, unsigned, unsigned);
43         void change_image_layout(VkImage, unsigned, int, unsigned, bool);
44         void reset();
45         void barrier(const VulkanCommandRecorder &);
46
47 private:
48         bool is_write_layout(unsigned);
49 };
50
51 } // namespace GL
52 } // namespace Msp
53
54 #endif