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