3#include "../Interface/CommandBuffer.hpp"
11class OpenGLRenderPassAllocator;
12class OpenGLShaderProgram;
44 void SetViewport(const glm::uvec2& origin, const glm::uvec2& size) final;
45 void SetScissor(const glm::uvec2& origin, const glm::uvec2& size) final;
52 void Draw(
unsigned int vertexCount,
unsigned int firstVertex) final;
53 void DrawIndexed(
unsigned int indexCount,
unsigned int firstIndex,
unsigned int baseVertex) final;
54 void DrawIndexedInstanced(
unsigned int indexCount,
unsigned int instanceCount,
unsigned int firstIndex,
unsigned int baseVertex) final;
57 void Dispatch(const glm::uvec3& numGroups, const std::
string& name) final;
72 struct BeginRenderPassCommand {
75 unsigned int timingIndex;
78 struct BindGraphicsPipelineCommand {
84 GLenum blendingSourceFactor;
85 GLenum blendingDestinationFactor;
86 bool depthTestEnabled;
87 GLboolean depthMaskEnabled;
89 bool depthClampEnabled;
90 bool conservativeRasterizationEnabled;
93 struct SetViewportCommand {
94 unsigned int origin[2];
98 struct SetScissorCommand {
99 unsigned int origin[2];
100 unsigned int size[2];
103 struct SetLineWidthCommand {
107 struct BindGeometryCommand {
111 struct SetUniformIntegerCommand {
112 unsigned int location;
116 struct SetUniformUnsignedIntegerCommand {
117 unsigned int location;
121 struct SetUniformFloatCommand {
122 unsigned int location;
126 struct SetUniformVector2Command {
127 unsigned int location;
131 struct SetUniformIVector2Command {
132 unsigned int location;
136 struct SetUniformUVector2Command {
137 unsigned int location;
141 struct SetUniformVector3Command {
142 unsigned int location;
146 struct SetUniformIVector3Command {
147 unsigned int location;
151 struct SetUniformUVector3Command {
152 unsigned int location;
156 struct SetUniformVector4Command {
157 unsigned int location;
161 struct SetUniformIVector4Command {
162 unsigned int location;
166 struct SetUniformUVector4Command {
167 unsigned int location;
171 struct SetUniformMatrix3Command {
172 unsigned int location;
176 struct SetUniformMatrix4Command {
177 unsigned int location;
181 struct BindTextureCommand {
187 struct BindUniformBufferCommand {
189 GLuint uniformBuffer;
194 struct BindStorageBufferCommand {
196 GLuint storageBuffer;
207 struct DrawIndexedCommand {
215 struct DrawIndexedInstancedCommand {
220 GLsizei instanceCount;
224 struct BlitToSwapChainCommand {
228 struct BindComputePipelineCommand {
232 struct DispatchCommand {
236 unsigned int timingIndex;
239 struct ClearBufferCommand {
248 BeginRenderPassCommand beginRenderPassCommand;
249 BindGraphicsPipelineCommand bindGraphicsPipelineCommand;
250 SetViewportCommand setViewportCommand;
251 SetScissorCommand setScissorCommand;
252 SetLineWidthCommand setLineWidthCommand;
253 BindGeometryCommand bindGeometryCommand;
254 SetUniformIntegerCommand setUniformIntegerCommand;
255 SetUniformUnsignedIntegerCommand setUniformUnsignedIntegerCommand;
256 SetUniformFloatCommand setUniformFloatCommand;
257 SetUniformVector2Command setUniformVector2Command;
258 SetUniformIVector2Command setUniformIVector2Command;
259 SetUniformUVector2Command setUniformUVector2Command;
260 SetUniformVector3Command setUniformVector3Command;
261 SetUniformIVector3Command setUniformIVector3Command;
262 SetUniformUVector3Command setUniformUVector3Command;
263 SetUniformVector4Command setUniformVector4Command;
264 SetUniformIVector4Command setUniformIVector4Command;
265 SetUniformUVector4Command setUniformUVector4Command;
266 SetUniformMatrix3Command setUniformMatrix3Command;
267 SetUniformMatrix4Command setUniformMatrix4Command;
268 BindTextureCommand bindTextureCommand;
269 BindUniformBufferCommand bindUniformBufferCommand;
270 BindStorageBufferCommand bindStorageBufferCommand;
271 DrawCommand drawCommand;
272 DrawIndexedCommand drawIndexedCommand;
273 DrawIndexedInstancedCommand drawIndexedInstancedCommand;
274 BlitToSwapChainCommand blitToSwapChainCommand;
275 BindComputePipelineCommand bindComputePipelineCommand;
276 DispatchCommand dispatchCommand;
277 ClearBufferCommand clearBufferCommand;
283 BIND_GRAPHICS_PIPELINE,
289 SET_UNIFORM_UNSIGNED_INTEGER,
292 SET_UNIFORM_IVECTOR2,
293 SET_UNIFORM_UVECTOR2,
295 SET_UNIFORM_IVECTOR3,
296 SET_UNIFORM_UVECTOR3,
298 SET_UNIFORM_IVECTOR4,
299 SET_UNIFORM_UVECTOR4,
307 DRAW_INDEXED_INSTANCED,
309 BIND_COMPUTE_PIPELINE,
316 void SetUniformInteger(
unsigned int location, int32_t value);
317 void SetUniformUnsignedInteger(
unsigned int location, uint32_t value);
318 void SetUniformFloat(
unsigned int location,
float value);
319 void SetUniformVector2(
unsigned int location,
const glm::vec2& value);
320 void SetUniformIVector2(
unsigned int location,
const glm::ivec2& value);
321 void SetUniformUVector2(
unsigned int location,
const glm::uvec2& value);
322 void SetUniformVector3(
unsigned int location,
const glm::vec3& value);
323 void SetUniformIVector3(
unsigned int location,
const glm::ivec3& value);
324 void SetUniformUVector3(
unsigned int location,
const glm::uvec3& value);
325 void SetUniformVector4(
unsigned int location,
const glm::vec4& value);
326 void SetUniformIVector4(
unsigned int location,
const glm::ivec4& value);
327 void SetUniformUVector4(
unsigned int location,
const glm::uvec4& value);
328 void SetUniformMatrix3(
unsigned int location,
const glm::mat3& value);
329 void SetUniformMatrix4(
unsigned int location,
const glm::mat4& value);
331 void AddCommand(
const Command& command);
332 void SubmitCommand(
const Command& command);
334 OpenGLRenderer& openGLRenderer;
335 OpenGLRenderPassAllocator& renderPassAllocator;
337 std::vector<Command> commands;
338 GLenum primitiveType;
341 uint32_t frameBufferHeight;
342 uintptr_t indexBufferOffset;
344 bool inRenderPass =
false;
346 const OpenGLShaderProgram* currentShaderProgram =
nullptr;
348 const OpenGLShaderProgram* blitShaderProgram;
351 bool writesStorageBuffer =
false;
353 std::vector<Timing> timings;
354 unsigned int timingIndex;
A buffer containing GPU accessible data.
Definition: Buffer.hpp:8
A buffer into which rendering commands are recorded.
Definition: CommandBuffer.hpp:24
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
OpenGL implementation of CommandBuffer.
Definition: OpenGLCommandBuffer.hpp:15
void BindGeometry(GeometryBinding *geometryBinding) final
Bind geometry to be used in upcoming draw calls.
Definition: OpenGLCommandBuffer.cpp:230
void DrawIndexedInstanced(unsigned int indexCount, unsigned int instanceCount, unsigned int firstIndex, unsigned int baseVertex) final
Draw indexed instanced geometry.
Definition: OpenGLCommandBuffer.cpp:403
void SetScissor(const glm::uvec2 &origin, const glm::uvec2 &size) final
Set the scissor box.
Definition: OpenGLCommandBuffer.cpp:206
void EndRenderPass() final
End render pass.
Definition: OpenGLCommandBuffer.cpp:65
void BindComputePipeline(ComputePipeline *computePipeline) final
Bind compute pipeline.
Definition: OpenGLCommandBuffer.cpp:431
void BindUniformBuffer(ShaderProgram::BindingType bindingType, Buffer *uniformBuffer) final
Bind uniform buffer for use in a shader.
Definition: OpenGLCommandBuffer.cpp:256
void ClearBuffer(Buffer *buffer) final
Clear a buffer (fill with 0).
Definition: OpenGLCommandBuffer.cpp:473
void Draw(unsigned int vertexCount, unsigned int firstVertex) final
Draw geometry.
Definition: OpenGLCommandBuffer.cpp:375
void BlitToSwapChain(Texture *texture) final
Blit a texture to the current swap chain image.
Definition: OpenGLCommandBuffer.cpp:419
void DrawIndexed(unsigned int indexCount, unsigned int firstIndex, unsigned int baseVertex) final
Draw indexed geometry.
Definition: OpenGLCommandBuffer.cpp:388
void SetViewport(const glm::uvec2 &origin, const glm::uvec2 &size) final
Set the viewport to render to.
Definition: OpenGLCommandBuffer.cpp:193
void BeginAttachmentlessRenderPass(const glm::uvec2 &size, uint32_t msaaSamples, const std::string &name) final
Begin attachmentless render pass.
Definition: OpenGLCommandBuffer.cpp:60
void Dispatch(const glm::uvec3 &numGroups, const std::string &name) final
Dispatch compute shader.
Definition: OpenGLCommandBuffer.cpp:446
OpenGLCommandBuffer(OpenGLRenderer &openGLRenderer, OpenGLRenderPassAllocator &renderPassAllocator)
Create new OpenGL command buffer.
Definition: OpenGLCommandBuffer.cpp:21
void BeginRenderPass(RenderPass *renderPass, const std::string &name) final
Begin render pass.
Definition: OpenGLCommandBuffer.cpp:28
void Submit()
Submit the commands in the command buffer to the GPU.
Definition: OpenGLCommandBuffer.cpp:490
void BindGraphicsPipeline(GraphicsPipeline *graphicsPipeline) final
Bind graphics pipeline.
Definition: OpenGLCommandBuffer.cpp:83
const std::vector< Timing > & GetTimings() const
Get the all timings in the command buffer.
Definition: OpenGLCommandBuffer.cpp:499
void PushConstants(const void *data) final
Update push constants.
Definition: OpenGLCommandBuffer.cpp:321
void SetLineWidth(float width) final
Set width of lines.
Definition: OpenGLCommandBuffer.cpp:219
~OpenGLCommandBuffer() final
Destructor.
Definition: OpenGLCommandBuffer.cpp:26
void BindStorageBuffers(std::initializer_list< Buffer * > buffers) final
Bind storage buffers.
Definition: OpenGLCommandBuffer.cpp:282
void BindMaterial(std::initializer_list< std::pair< Texture *, const Sampler * > > textures) final
Bind a material.
Definition: OpenGLCommandBuffer.cpp:302
OpenGL implementation of RenderPassAllocator.
Definition: OpenGLRenderPassAllocator.hpp:8
Low-level renderer implementing OpenGL.
Definition: OpenGLRenderer.hpp:23
A render pass.
Definition: RenderPass.hpp:11
Determines how a texture should be sampled.
Definition: Sampler.hpp:6
A shader program.
Definition: ShaderProgram.hpp:11
A texture.
Definition: Texture.hpp:8
Definition: Editor.hpp:18
Timing for a block of work.
Definition: OpenGLCommandBuffer.hpp:18
GLuint endQuery
The timestamp for ending the block of work.
Definition: OpenGLCommandBuffer.hpp:26
GLuint startQuery
The timestamp for starting the block of work.
Definition: OpenGLCommandBuffer.hpp:23
std::string name
The name of the block of work.
Definition: OpenGLCommandBuffer.hpp:20