Hymn to Beauty
C++ 3D Engine
CommandBuffer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <glm/glm.hpp>
4#include "Types.hpp"
5#include "ShaderProgram.hpp"
6#include "RenderPass.hpp"
7#include <initializer_list>
8#include <utility>
9
10namespace Video {
11
12class VertexDescription;
13class GeometryBinding;
14class Texture;
15class Sampler;
16class Buffer;
17class GraphicsPipeline;
18class ComputePipeline;
19
21
25 public:
28
30 virtual ~CommandBuffer() {}
31
33
37 virtual void BeginRenderPass(RenderPass* renderPass, const std::string& name = "Untitled render pass") = 0;
38
40
47 virtual void BeginRenderPass(Texture* colorAttachment, RenderPass::LoadOperation colorLoadOperation = RenderPass::LoadOperation::CLEAR, Texture* depthAttachment = nullptr, RenderPass::LoadOperation depthLoadOperation = RenderPass::LoadOperation::CLEAR, const std::string& name = "Untitled render pass") = 0;
48
50
55 virtual void BeginAttachmentlessRenderPass(const glm::uvec2& size, uint32_t msaaSamples = 1, const std::string& name = "Untitled render pass") = 0;
56
58 virtual void EndRenderPass() = 0;
59
61
64 virtual void BindGraphicsPipeline(GraphicsPipeline* graphicsPipeline) = 0;
65
67
71 virtual void SetViewport(const glm::uvec2& origin, const glm::uvec2& size) = 0;
72
74
78 virtual void SetScissor(const glm::uvec2& origin, const glm::uvec2& size) = 0;
79
81
85 void SetViewportAndScissor(const glm::uvec2& origin, const glm::uvec2& size) {
86 SetViewport(origin, size);
87 SetScissor(origin, size);
88 }
89
91
94 virtual void SetLineWidth(float width) = 0;
95
97
100 virtual void BindGeometry(GeometryBinding* geometryBinding) = 0;
101
103
107 virtual void BindUniformBuffer(ShaderProgram::BindingType bindingType, Buffer* uniformBuffer) = 0;
108
110
113 virtual void BindStorageBuffers(std::initializer_list<Buffer*> buffers) = 0;
114
116
119 virtual void BindMaterial(std::initializer_list<std::pair<Texture*, const Sampler*>> textures) = 0;
120
122
125 virtual void PushConstants(const void* data) = 0;
126
128
132 virtual void Draw(unsigned int vertexCount, unsigned int firstVertex = 0) = 0;
133
135
140 virtual void DrawIndexed(unsigned int indexCount, unsigned int firstIndex = 0, unsigned int baseVertex = 0) = 0;
141
143
149 virtual void DrawIndexedInstanced(unsigned int indexCount, unsigned int instanceCount = 1, unsigned int firstIndex = 0, unsigned int baseVertex = 0) = 0;
150
152
155 virtual void BlitToSwapChain(Texture* texture) = 0;
156
158
161 virtual void BindComputePipeline(ComputePipeline* computePipeline) = 0;
162
164
168 virtual void Dispatch(const glm::uvec3& numGroups, const std::string& name = "Untitled dispatch") = 0;
169
171
174 virtual void ClearBuffer(Buffer* buffer) = 0;
175
176 private:
177 CommandBuffer(const CommandBuffer& other) = delete;
178};
179
180}
A buffer containing GPU accessible data.
Definition: Buffer.hpp:8
A buffer into which rendering commands are recorded.
Definition: CommandBuffer.hpp:24
virtual void EndRenderPass()=0
End render pass.
virtual void DrawIndexed(unsigned int indexCount, unsigned int firstIndex=0, unsigned int baseVertex=0)=0
Draw indexed geometry.
virtual ~CommandBuffer()
Destructor.
Definition: CommandBuffer.hpp:30
virtual void BindComputePipeline(ComputePipeline *computePipeline)=0
Bind compute pipeline.
virtual void BlitToSwapChain(Texture *texture)=0
Blit a texture to the current swap chain image.
virtual void SetScissor(const glm::uvec2 &origin, const glm::uvec2 &size)=0
Set the scissor box.
virtual void BindGeometry(GeometryBinding *geometryBinding)=0
Bind geometry to be used in upcoming draw calls.
virtual void SetLineWidth(float width)=0
Set width of lines.
void SetViewportAndScissor(const glm::uvec2 &origin, const glm::uvec2 &size)
Set both viewport and scissor.
Definition: CommandBuffer.hpp:85
virtual void Draw(unsigned int vertexCount, unsigned int firstVertex=0)=0
Draw geometry.
CommandBuffer()
Create a new command buffer.
Definition: CommandBuffer.hpp:27
virtual void SetViewport(const glm::uvec2 &origin, const glm::uvec2 &size)=0
Set the viewport to render to.
virtual void DrawIndexedInstanced(unsigned int indexCount, unsigned int instanceCount=1, unsigned int firstIndex=0, unsigned int baseVertex=0)=0
Draw indexed instanced geometry.
virtual void PushConstants(const void *data)=0
Update push constants.
virtual void Dispatch(const glm::uvec3 &numGroups, const std::string &name="Untitled dispatch")=0
Dispatch compute shader.
virtual void BindUniformBuffer(ShaderProgram::BindingType bindingType, Buffer *uniformBuffer)=0
Bind uniform buffer for use in a shader.
virtual void ClearBuffer(Buffer *buffer)=0
Clear a buffer (fill with 0).
virtual void BeginRenderPass(Texture *colorAttachment, RenderPass::LoadOperation colorLoadOperation=RenderPass::LoadOperation::CLEAR, Texture *depthAttachment=nullptr, RenderPass::LoadOperation depthLoadOperation=RenderPass::LoadOperation::CLEAR, const std::string &name="Untitled render pass")=0
Begin render pass.
virtual void BindGraphicsPipeline(GraphicsPipeline *graphicsPipeline)=0
Bind graphics pipeline.
virtual void BeginAttachmentlessRenderPass(const glm::uvec2 &size, uint32_t msaaSamples=1, const std::string &name="Untitled render pass")=0
Begin attachmentless render pass.
virtual void BindStorageBuffers(std::initializer_list< Buffer * > buffers)=0
Bind storage buffers.
virtual void BeginRenderPass(RenderPass *renderPass, const std::string &name="Untitled render pass")=0
Begin render pass.
virtual void BindMaterial(std::initializer_list< std::pair< Texture *, const Sampler * > > textures)=0
Bind a material.
A compute pipeline.
Definition: ComputePipeline.hpp:11
Binds together a vertex description with buffers.
Definition: GeometryBinding.hpp:8
A graphics pipeline.
Definition: GraphicsPipeline.hpp:11
A render pass.
Definition: RenderPass.hpp:11
LoadOperation
What to do with an image being rendered to before rendering to it.
Definition: RenderPass.hpp:14
@ CLEAR
Clear the image contents.
BindingType
A type of bound resource.
Definition: ShaderProgram.hpp:14
A texture.
Definition: Texture.hpp:8
Definition: Editor.hpp:18