SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
VulkanCommandBuffer.h
1#pragma once
2
3#include "spark/render/CommandBuffer.h"
4#include "spark/render/CommandQueue.h"
5#include "spark/render/Resource.h"
6#include "spark/render/vk/Export.h"
7#include "spark/render/vk/VulkanIndexBuffer.h"
8#include "spark/render/vk/VulkanPipeline.h"
9#include "spark/render/vk/VulkanPipelineLayout.h"
10#include "spark/render/vk/VulkanVertexBuffer.h"
11
12SPARK_FWD_DECLARE_VK_HANDLE(VkCommandBuffer)
13
14namespace spark::render::vk
15{
16 class VulkanQueue;
17 class VulkanRenderPass;
18 class IVulkanBuffer;
19 class IVulkanImage;
20 class VulkanDescriptorSet;
21 class VulkanPushConstantsLayout;
22
26 class SPARK_RENDER_VK_EXPORT VulkanCommandBuffer final : public CommandBuffer<
27 VulkanCommandBuffer, IVulkanBuffer, IVulkanVertexBuffer, IVulkanIndexBuffer, IVulkanImage, VulkanPipelineState>,
28 public Resource<VkCommandBuffer>
29 {
30 public:
31 explicit VulkanCommandBuffer(const VulkanQueue& queue, bool begin_recording = false, bool is_primary = true);
32 ~VulkanCommandBuffer() override;
33
34 VulkanCommandBuffer(const VulkanCommandBuffer& other) = delete;
35 VulkanCommandBuffer(VulkanCommandBuffer&& other) noexcept = delete;
36 VulkanCommandBuffer& operator=(const VulkanCommandBuffer& other) = delete;
37 VulkanCommandBuffer& operator=(VulkanCommandBuffer&& other) noexcept = delete;
38
40 void begin() const override;
41
46 void begin(const VulkanRenderPass& render_pass) const;
47
49 void end() const override;
50
52 [[nodiscard]] bool isRecording() const noexcept override;
53
55 [[nodiscard]] bool isSecondary() const noexcept override;
56
58 void transfer(IVulkanBuffer& source, IVulkanBuffer& target, unsigned source_element, unsigned target_element, unsigned elements) const override;
59
61 void transfer(IVulkanImage& source, IVulkanBuffer& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const override;
62
64 void transfer(IVulkanBuffer& source, IVulkanImage& target, unsigned source_element, unsigned first_subresource, unsigned elements) const override;
65
67 void transfer(IVulkanImage& source, IVulkanImage& target, unsigned source_subresource, unsigned target_subresource, unsigned subresources) const override;
68
70 void transfer(std::shared_ptr<IVulkanBuffer> source, IVulkanBuffer& target, unsigned source_element, unsigned target_element, unsigned elements) const override;
71
73 void transfer(std::shared_ptr<IVulkanBuffer> source, IVulkanImage& target, unsigned source_element, unsigned first_subresource, unsigned elements) const override;
74
76 void transfer(std::shared_ptr<IVulkanImage> source, IVulkanImage& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const override;
77
79 void transfer(std::shared_ptr<IVulkanImage> source, IVulkanBuffer& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const override;
80
82 void use(const VulkanPipelineState& pipeline) const noexcept override;
83
85 void bind(const VulkanDescriptorSet& descriptor_set) const override;
86
88 void bind(const VulkanDescriptorSet& descriptor_set, const VulkanPipelineState& pipeline) const noexcept override;
89
91 void bind(const IVulkanIndexBuffer& index_buffer) const noexcept override;
92
94 void bind(const IVulkanVertexBuffer& vertex_buffer) const noexcept override;
95
97 void draw(unsigned vertices, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept override;
98
100 void draw(const IVulkanVertexBuffer& vertex_buffer, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept override;
101
103 void drawIndexed(unsigned indices, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept override;
104
106 void drawIndexed(const IVulkanIndexBuffer& index_buffer, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept override;
107
109 void drawIndexed(const IVulkanVertexBuffer& vertex_buffer,
110 const IVulkanIndexBuffer& index_buffer,
111 unsigned instances,
112 unsigned first_index,
113 int vertex_offset,
114 unsigned first_instance) const noexcept override;
115
117 void dispatch() const noexcept override;
118
120 void execute(std::shared_ptr<const VulkanCommandBuffer> command_buffer) const override;
121
123 void execute(const std::vector<std::shared_ptr<const VulkanCommandBuffer>>& command_buffers) const override;
124
126 void pushConstants(const VulkanPushConstantsLayout& layout, const void* const memory) const noexcept override;
127
129 void setViewport(const IViewport* viewport) const noexcept override;
130
132 void setViewports(std::span<const IViewport*> viewports) const noexcept override;
133
135 void setScissor(const IScissor* scissor) const noexcept override;
136
138 void setScissors(std::span<const IScissor*> scissors) const noexcept override;
139
141 void setBlendFactors(const math::Vector4<float>& blend_factors) const noexcept override;
142
144 void setStencilRef(unsigned stencil_ref) const noexcept override;
145
147 void releaseSharedState() const override;
148
149 private:
150 struct Impl;
151 std::unique_ptr<Impl> m_impl;
152 };
153}
A vector with four components.
Definition Vector4.h:13
Definition CommandBuffer.h:462
Interface representing a scissor.
Definition Scissor.h:15
Interface representing a viewport.
Definition Viewport.h:15
Definition Resource.h:34
Vulkan interface for a IBuffer.
Definition VulkanBuffer.h:22
Represents a Vulkan image.
Definition VulkanImage.h:33
Vulkan interface for an IIndexBuffer.
Definition VulkanIndexBuffer.h:14
Vulkan interface for a IVertexBuffer.
Definition VulkanVertexBuffer.h:14
Vulkan implementation of ICommandBuffer.
Definition VulkanCommandBuffer.h:29
Vulkan implementation of IDescriptorSet.
Definition VulkanDescriptorSet.h:24
Vulkan implementation of IPipeline.
Definition VulkanPipeline.h:20
Vulkan implementation of IPushConstantsLayout.
Definition VulkanPushConstantsLayout.h:17
Vulkan implementation of ICommandQueue.
Definition VulkanQueue.h:23
Vulkan implementation of IRenderPass.
Definition VulkanRenderPass.h:27
Definition VulkanCommandBuffer.cpp:22