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