sandbox
Loading...
Searching...
No Matches
command_buffer.hpp
1#ifndef LIBSBX_GRAPHICS_COMMANDS_COMMAND_BUFFER_HPP_
2#define LIBSBX_GRAPHICS_COMMANDS_COMMAND_BUFFER_HPP_
3
4#include <memory>
5
6#include <vulkan/vulkan.hpp>
7
8#include <libsbx/graphics/devices/logical_device.hpp>
9
10#include <libsbx/graphics/commands/command_pool.hpp>
11
12namespace sbx::graphics {
13
15
16public:
17
18 struct wait_data {
19 VkSemaphore semaphore;
20 VkPipelineStageFlags stage;
21 }; // struct wait_data
22
23 command_buffer(bool should_begin = true, VkQueueFlagBits queue_type = VK_QUEUE_GRAPHICS_BIT, VkCommandBufferLevel buffer_level = VK_COMMAND_BUFFER_LEVEL_PRIMARY);
24
26
27 auto handle() const noexcept -> const VkCommandBuffer&;
28
29 operator const VkCommandBuffer&() const noexcept;
30
31 auto is_running() const noexcept -> bool;
32
33 auto begin(VkCommandBufferUsageFlags usage = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) -> void;
34
35 auto end() -> void;
36
37 auto submit_idle() -> void;
38
39 auto submit(const std::vector<wait_data>& wait_data = {}, const VkSemaphore &signal_semaphore = nullptr, const VkFence& fence = nullptr) -> void;
40
41 auto copy_buffer(const VkBuffer& source, const VkBuffer& destination, const VkBufferCopy& region) -> void;
42
43 auto set_viewport(const VkViewport& viewport) -> void;
44
45 auto set_scissor(const VkRect2D& scissor) -> void;
46
47 auto bind_vertex_buffer(std::uint32_t first_binding, const VkBuffer& buffer) -> void;
48
49 auto bind_index_buffer(const VkBuffer& buffer, VkDeviceSize offset, VkIndexType index_type) -> void;
50
51 auto draw(std::uint32_t vertex_count, std::uint32_t instance_count, std::uint32_t first_vertex, std::uint32_t first_instance) -> void;
52
53 auto draw_indexed(std::uint32_t index_count, std::uint32_t instance_count, std::uint32_t first_index, std::int32_t vertex_offset, std::uint32_t first_instance) -> void;
54
55 auto begin_render_pass(const VkRenderPassBeginInfo& renderpass_begin_info, VkSubpassContents subpass_contents) -> void;
56
57 auto end_render_pass() -> void;
58
59private:
60
61 auto _queue() const -> const graphics::queue&;
62
63 std::shared_ptr<command_pool> _command_pool{};
64
65 VkCommandBuffer _handle{};
66 VkQueueFlagBits _queue_type{};
67 bool _is_running{};
68
69}; // class command_buffer
70
71} // namespace sbx::graphics
72
73#endif // LIBSBX_GRAPHICS_COMMANDS_COMMAND_BUFFER_HPP_
Definition: command_buffer.hpp:14
Definition: command_pool.hpp:12
Definition: fence.hpp:10
Definition: logical_device.hpp:17
Definition: semaphore.hpp:8
Definition: render_stage.hpp:125
Definition: command_buffer.hpp:18