]> git.tdb.fi Git - libs/gl.git/blob - source/backends/vulkan/commands_backend.h
Initial implementation of Vulkan backend
[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 class Semaphore;
18 class SwapChain;
19
20 class VulkanCommands
21 {
22 protected:
23         struct CommandPool
24         {
25                 Device &device;
26                 VkCommandPool pool = 0;
27                 Fence fence;
28                 bool in_use = false;
29                 
30                 CommandPool(Device &);
31                 CommandPool(CommandPool &&);
32                 ~CommandPool();
33         };
34
35         Device &device;
36         std::vector<CommandPool> command_pools;
37         CommandPool *current_pool = 0;
38         VkCommandBuffer current_buffer = 0;
39         const PipelineState *pipeline_state = 0;
40         VkRenderPass render_pass = 0;
41
42         VulkanCommands();
43         ~VulkanCommands();
44
45         void begin_buffer();
46         void begin_render_pass(const ClearValue *);
47         void end_render_pass();
48
49         void begin_frame(unsigned);
50         void submit_frame();
51         void submit_frame(Semaphore *, Semaphore *);
52
53         void use_pipeline(const PipelineState *);
54         void clear(const ClearValue *);
55         void draw(const Batch &);
56         void draw_instanced(const Batch &, unsigned);
57         void resolve_multisample(Framebuffer &);
58
59         void begin_query(const QueryPool &, unsigned);
60         void end_query(const QueryPool &, unsigned);
61 };
62
63 using CommandsBackend = VulkanCommands;
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif
69