]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/commands_backend.h
f96a441c434c5375cc8d0af4df25232ee39a128f
[libs/gl.git] / source / backends / vulkan / commands_backend.h
1 #ifndef MSP_GL_COMMANDS_BACKEND_H_
2 #define MSP_GL_COMMANDS_BACKEND_H_
3
4 #include <vector>
5 #include "fence.h"
6 #include "handles.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Batch;
12 union ClearValue;
13 class Device;
14 class Framebuffer;
15 class PipelineState;
16 class QueryPool;
17 struct Rect;
18 class Semaphore;
19 class SwapChain;
20
21 class VulkanCommands
22 {
23 protected:
24         struct CommandBuffers
25         {
26                 std::vector<VkCommandBuffer> buffers;
27                 unsigned next_buffer = 0;
28         };
29
30         struct CommandPool
31         {
32                 Device &device;
33                 VkCommandPool pool = 0;
34                 CommandBuffers primary;
35                 CommandBuffers secondary;
36                 Fence fence;
37                 bool in_use = false;
38                 
39                 CommandPool(Device &);
40                 CommandPool(CommandPool &&);
41                 ~CommandPool();
42         };
43
44         Device &device;
45         std::vector<CommandPool> command_pools;
46         CommandPool *current_pool = 0;
47         VkCommandBuffer primary_buffer = 0;
48         VkCommandBuffer pass_buffer = 0;
49         const PipelineState *pipeline_state = 0;
50         const Framebuffer *framebuffer = 0;
51         const Rect *viewport = 0;
52         bool fb_is_swapchain = false;
53         std::vector<char> pass_begin_info;
54
55         VulkanCommands();
56         ~VulkanCommands();
57
58         void begin_buffer(VkRenderPass);
59         void begin_render_pass(bool, const ClearValue *);
60         void end_render_pass();
61
62         void begin_frame(unsigned);
63         void submit_frame();
64         void submit_frame(Semaphore *, Semaphore *);
65
66         void use_pipeline(const PipelineState *);
67         void clear(const ClearValue *);
68         void draw(const Batch &);
69         void draw_instanced(const Batch &, unsigned);
70         void resolve_multisample(Framebuffer &);
71
72         void begin_query(const QueryPool &, unsigned);
73         void end_query(const QueryPool &, unsigned);
74 };
75
76 using CommandsBackend = VulkanCommands;
77
78 } // namespace GL
79 } // namespace Msp
80
81 #endif
82