SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
CommandBuffer.h
1#pragma once
2
3#include "spark/render/Buffer.h"
4#include "spark/render/DescriptorSet.h"
5#include "spark/render/Export.h"
6#include "spark/render/Image.h"
7#include "spark/render/IndexBuffer.h"
8#include "spark/render/Pipeline.h"
9#include "spark/render/Scissor.h"
10#include "spark/render/VertexBuffer.h"
11#include "spark/render/Viewport.h"
12
13#include "spark/math/Vector4.h"
14
15#include <memory>
16#include <span>
17
18namespace spark::render
19{
23 class SPARK_RENDER_EXPORT ICommandBuffer
24 {
25 public:
26 virtual ~ICommandBuffer() noexcept = default;
27
34 virtual void begin() const = 0;
35
40 virtual void end() const = 0;
41
46 [[nodiscard]] virtual bool isRecording() const noexcept = 0;
47
52 [[nodiscard]] virtual bool isSecondary() const noexcept = 0;
53
64 void transfer(IBuffer& source, IBuffer& target, unsigned int source_element = 0, unsigned int target_element = 0, unsigned int elements = 1) const
65 {
66 genericTransfer(source, target, source_element, target_element, elements);
67 }
68
79 void transfer(std::shared_ptr<IBuffer> source, IBuffer& target, unsigned int source_element = 0, unsigned int target_element = 0, unsigned int elements = 1) const
80 {
81 genericTransfer(source, target, source_element, target_element, elements);
82 }
83
100 void transfer(IBuffer& source, IImage& target, unsigned int source_element = 0, unsigned int first_subresource = 0, unsigned int elements = 1) const
101 {
102 genericTransfer(source, target, source_element, first_subresource, elements);
103 }
104
121 void transfer(std::shared_ptr<IBuffer> source, IImage& target, unsigned int source_element = 0, unsigned int first_subresource = 0, unsigned int elements = 1) const
122 {
123 genericTransfer(source, target, source_element, first_subresource, elements);
124 }
125
137 void transfer(IImage& source, IImage& target, unsigned int source_subresource = 0, unsigned int target_subresource = 0, unsigned int subresources = 1) const
138 {
139 genericTransfer(source, target, source_subresource, target_subresource, subresources);
140 }
141
153 void transfer(std::shared_ptr<IImage> source, IImage& target, unsigned int source_subresource = 0, unsigned int target_subresource = 0, unsigned int subresources = 1) const
154 {
155 genericTransfer(source, target, source_subresource, target_subresource, subresources);
156 }
157
179 void transfer(IImage& source, IBuffer& target, unsigned int first_subresource = 0, unsigned int target_element = 0, unsigned int subresources = 1) const
180 {
181 genericTransfer(source, target, first_subresource, target_element, subresources);
182 }
183
205 void transfer(std::shared_ptr<IImage> source, IBuffer& target, unsigned int first_subresource = 0, unsigned int target_element = 0, unsigned int subresources = 1) const
206 {
207 genericTransfer(source, target, first_subresource, target_element, subresources);
208 }
209
214 void use(const IPipeline& pipeline) const noexcept { genericUse(pipeline); }
215
222 void bind(const IDescriptorSet& descriptor_set) const { genericBind(descriptor_set); }
223
229 void bind(const IDescriptorSet& descriptor_set, const IPipeline& pipeline) const noexcept { genericBind(descriptor_set, pipeline); }
230
237 void bind(const IVertexBuffer& vertex_buffer) const noexcept { genericBind(vertex_buffer); }
238
245 void bind(const IIndexBuffer& index_buffer) const noexcept { genericBind(index_buffer); }
246
254 void draw(unsigned int vertices, unsigned int instances = 1, unsigned int first_vertex = 0, unsigned int first_instance = 0) const noexcept
255 {
256 genericDraw(vertices, instances, first_vertex, first_instance);
257 }
258
266 void draw(const IVertexBuffer& vertex_buffer, unsigned int instances = 1, unsigned int first_vertex = 0, unsigned int first_instance = 0) const noexcept
267 {
268 genericDraw(vertex_buffer, instances, first_vertex, first_instance);
269 }
270
279 void drawIndexed(unsigned int indices, unsigned int instances = 1, unsigned int first_index = 0, int vertex_offset = 0, unsigned int first_instance = 0) const noexcept
280 {
281 genericDrawIndexed(indices, instances, first_index, vertex_offset, first_instance);
282 }
283
294 void drawIndexed(const IIndexBuffer& index_buffer,
295 unsigned int instances = 1,
296 unsigned int first_index = 0,
297 int vertex_offset = 0,
298 unsigned int first_instance = 0) const noexcept { genericDrawIndexed(index_buffer, instances, first_index, vertex_offset, first_instance); }
299
309 void drawIndexed(const IVertexBuffer& vertex_buffer,
310 const IIndexBuffer& index_buffer,
311 unsigned int instances = 1,
312 unsigned int first_index = 0,
313 int vertex_offset = 0,
314 unsigned int first_instance = 0) const noexcept { genericDrawIndexed(vertex_buffer, index_buffer, instances, first_index, vertex_offset, first_instance); }
315
319 virtual void dispatch() const noexcept = 0;
320
325 void execute(std::shared_ptr<const ICommandBuffer> command_buffer) const { genericExecute(command_buffer); }
326
331 void execute(const std::vector<std::shared_ptr<const ICommandBuffer>>& command_buffers) const { genericExecute(command_buffers); }
332
338 void pushConstants(const IPushConstantsLayout& layout, const void* const memory) const noexcept { genericPushConstants(layout, memory); }
339
344 virtual void setViewport(const IViewport* viewport) const noexcept = 0;
345
350 virtual void setViewports(std::span<const IViewport*> viewports) const noexcept = 0;
351
356 virtual void setScissor(const IScissor* scissor) const noexcept = 0;
357
362 virtual void setScissors(std::span<const IScissor*> scissors) const noexcept = 0;
363
370 virtual void setBlendFactors(const math::Vector4<float>& blend_factors) const noexcept = 0;
371
376 virtual void setStencilRef(unsigned int stencil_ref) const noexcept = 0;
377
381 virtual void releaseSharedState() const = 0;
382
383 private:
386 virtual void genericTransfer(IBuffer& source,
387 IBuffer& target,
388 unsigned int source_element = 0,
389 unsigned int target_element = 0,
390 unsigned int elements = 1) const noexcept = 0;
391 virtual void genericTransfer(std::shared_ptr<IBuffer> source,
392 IBuffer& target,
393 unsigned int source_element = 0,
394 unsigned int target_element = 0,
395 unsigned int elements = 1) const = 0;
396 virtual void genericTransfer(IBuffer& source,
397 IImage& target,
398 unsigned int source_element = 0,
399 unsigned int first_subresource = 0,
400 unsigned int elements = 1) const noexcept = 0;
401 virtual void genericTransfer(std::shared_ptr<IBuffer> source,
402 IImage& target,
403 unsigned int source_element = 0,
404 unsigned int first_subresource = 0,
405 unsigned int elements = 1) const noexcept = 0;
406 virtual void genericTransfer(IImage& source,
407 IImage& target,
408 unsigned int source_subresource = 0,
409 unsigned int target_subresource = 0,
410 unsigned int subresources = 1) const noexcept = 0;
411 virtual void genericTransfer(std::shared_ptr<IImage> source,
412 IImage& target,
413 unsigned int source_subresource = 0,
414 unsigned int target_subresource = 0,
415 unsigned int subresources = 1) const noexcept = 0;
416 virtual void genericTransfer(IImage& source, IBuffer& target, unsigned int first_subresource = 0, unsigned int target_element = 0, unsigned int subresources = 1) const = 0;
417 virtual void genericTransfer(std::shared_ptr<IImage> source,
418 IBuffer& target,
419 unsigned int first_subresource = 0,
420 unsigned int target_element = 0,
421 unsigned int subresources = 1) const noexcept = 0;
422 virtual void genericUse(const IPipeline& pipeline) const noexcept = 0;
423 virtual void genericBind(const IDescriptorSet& descriptor_set) const = 0;
424 virtual void genericBind(const IDescriptorSet& descriptor_set, const IPipeline& pipeline) const noexcept = 0;
425 virtual void genericBind(const IIndexBuffer& index_buffer) const noexcept = 0;
426 virtual void genericBind(const IVertexBuffer& vertex_buffer) const noexcept = 0;
427 virtual void genericDraw(unsigned int vertices, unsigned int instances = 1, unsigned int first_vertex = 0, unsigned int first_instance = 0) const noexcept = 0;
428 virtual void genericDraw(const IVertexBuffer& vertex_buffer, unsigned int instances = 1, unsigned int first_vertex = 0, unsigned int first_instance = 0) const noexcept = 0;
429 virtual void genericDrawIndexed(unsigned int indices,
430 unsigned int instances = 1,
431 unsigned int first_index = 0,
432 int vertex_offset = 0,
433 unsigned int first_instance = 0) const noexcept = 0;
434 virtual void genericDrawIndexed(const IIndexBuffer& index_buffer,
435 unsigned int instances = 1,
436 unsigned int first_index = 0,
437 int vertex_offset = 0,
438 unsigned int first_instance = 0) const noexcept = 0;
439 virtual void genericDrawIndexed(const IVertexBuffer& vertex_buffer,
440 const IIndexBuffer& index_buffer,
441 unsigned int instances = 1,
442 unsigned int first_index = 0,
443 int vertex_offset = 0,
444 unsigned int first_instance = 0) const noexcept = 0;
445 virtual void genericExecute(std::shared_ptr<const ICommandBuffer> command_buffer) const = 0;
446 virtual void genericExecute(const std::vector<std::shared_ptr<const ICommandBuffer>>& command_buffers) const = 0;
447 virtual void genericPushConstants(const IPushConstantsLayout& layout, const void* const memory) const noexcept = 0;
449 };
450
460 template <typename CommandBufferType, typename BufferType, typename VertexBufferType, typename IndexBufferType, typename ImageType, typename PipelineType>
462 {
463 public:
464 using command_buffer_type = CommandBufferType;
465 using buffer_type = BufferType;
466 using vertex_buffer_type = VertexBufferType;
467 using index_buffer_type = IndexBufferType;
468 using image_type = ImageType;
469 using pipeline_type = PipelineType;
470 using pipeline_layout_type = typename pipeline_type::pipeline_layout_type;
471 using descriptor_set_layout_type = typename pipeline_layout_type::descriptor_set_layout_type;
472 using push_constants_layout_type = typename pipeline_layout_type::push_constants_layout_type;
473 using descriptor_set_type = typename descriptor_set_layout_type::descriptor_set_type;
474
475 public:
477 virtual void transfer(buffer_type& source, buffer_type& target, unsigned source_element, unsigned target_element, unsigned elements) const = 0;
478
480 virtual void transfer(image_type& source, buffer_type& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const = 0;
481
483 virtual void transfer(buffer_type& source, image_type& target, unsigned source_element, unsigned first_subresource, unsigned elements) const = 0;
484
486 virtual void transfer(image_type& source, image_type& target, unsigned source_subresource, unsigned target_subresource, unsigned subresources) const = 0;
487
489 virtual void transfer(std::shared_ptr<buffer_type> source, buffer_type& target, unsigned source_element, unsigned target_element, unsigned elements) const = 0;
490
492 virtual void transfer(std::shared_ptr<buffer_type> source, image_type& target, unsigned source_element, unsigned first_subresource, unsigned elements) const = 0;
493
495 virtual void transfer(std::shared_ptr<image_type> source, image_type& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const = 0;
496
498 virtual void transfer(std::shared_ptr<image_type> source,
499 buffer_type& target,
500 unsigned int first_subresource,
501 unsigned int target_element,
502 unsigned int subresources) const = 0;
503
505 virtual void use(const pipeline_type& pipeline) const noexcept = 0;
506
508 virtual void bind(const descriptor_set_type& descriptor_set) const = 0;
509
511 virtual void bind(const descriptor_set_type& descriptor_set, const pipeline_type& pipeline) const noexcept = 0;
512
514 virtual void bind(const index_buffer_type& index_buffer) const noexcept = 0;
515
517 virtual void bind(const vertex_buffer_type& vertex_buffer) const noexcept = 0;
518
520 virtual void draw(unsigned vertices, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept = 0;
521
523 virtual void draw(const vertex_buffer_type& vertex_buffer, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept = 0;
524
526 virtual void drawIndexed(unsigned indices, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept = 0;
527
529 virtual void drawIndexed(const index_buffer_type& index_buffer, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept = 0;
530
532 virtual void drawIndexed(const vertex_buffer_type& vertex_buffer,
533 const index_buffer_type& index_buffer,
534 unsigned instances,
535 unsigned first_index,
536 int vertex_offset,
537 unsigned first_instance) const noexcept = 0;
538
540 virtual void execute(std::shared_ptr<const command_buffer_type> command_buffer) const = 0;
541
543 virtual void execute(const std::vector<std::shared_ptr<const command_buffer_type>>& command_buffers) const = 0;
544
546 virtual void pushConstants(const push_constants_layout_type& layout, const void* const memory) const noexcept = 0;
547
548 private:
549 void genericTransfer(IBuffer& source, IBuffer& target, unsigned source_element, unsigned target_element, unsigned elements) const noexcept final
550 {
551 transfer(dynamic_cast<buffer_type&>(source), dynamic_cast<buffer_type&>(target), source_element, target_element, elements);
552 }
553
554 void genericTransfer(std::shared_ptr<IBuffer> source, IBuffer& target, unsigned source_element, unsigned target_element, unsigned elements) const final
555 {
556 transfer(std::dynamic_pointer_cast<buffer_type>(source), dynamic_cast<buffer_type&>(target), source_element, target_element, elements);
557 }
558
559 void genericTransfer(IBuffer& source, IImage& target, unsigned source_element, unsigned first_subresource, unsigned elements) const noexcept final
560 {
561 transfer(dynamic_cast<buffer_type&>(source), dynamic_cast<image_type&>(target), source_element, first_subresource, elements);
562 }
563
564 void genericTransfer(std::shared_ptr<IBuffer> source, IImage& target, unsigned source_element, unsigned first_subresource, unsigned elements) const noexcept final
565 {
566 transfer(std::dynamic_pointer_cast<buffer_type>(source), dynamic_cast<image_type&>(target), source_element, first_subresource, elements);
567 }
568
569 void genericTransfer(IImage& source, IImage& target, unsigned source_subresource, unsigned target_subresource, unsigned subresources) const noexcept final
570 {
571 transfer(dynamic_cast<image_type&>(source), dynamic_cast<image_type&>(target), source_subresource, target_subresource, subresources);
572 }
573
574 void genericTransfer(std::shared_ptr<IImage> source, IImage& target, unsigned source_subresource, unsigned target_subresource, unsigned subresources) const noexcept final
575 {
576 transfer(std::static_pointer_cast<image_type>(source), dynamic_cast<image_type&>(target), source_subresource, target_subresource, subresources);
577 }
578
579 void genericTransfer(IImage& source, IBuffer& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const noexcept final
580 {
581 transfer(dynamic_cast<image_type&>(source), dynamic_cast<buffer_type&>(target), first_subresource, target_element, subresources);
582 }
583
584 void genericTransfer(std::shared_ptr<IImage> source, IBuffer& target, unsigned first_subresource, unsigned target_element, unsigned subresources) const noexcept final
585 {
586 transfer(std::static_pointer_cast<image_type>(source), dynamic_cast<buffer_type&>(target), first_subresource, target_element, subresources);
587 }
588
589 void genericUse(const IPipeline& pipeline) const noexcept final { use(dynamic_cast<const pipeline_type&>(pipeline)); }
590 void genericBind(const IDescriptorSet& descriptor_set) const final { bind(dynamic_cast<const descriptor_set_type&>(descriptor_set)); }
591
592 void genericBind(const IDescriptorSet& descriptor_set, const IPipeline& pipeline) const noexcept final
593 {
594 bind(dynamic_cast<const descriptor_set_type&>(descriptor_set), dynamic_cast<const pipeline_type&>(pipeline));
595 }
596
597 void genericBind(const IIndexBuffer& index_buffer) const noexcept final { bind(dynamic_cast<const index_buffer_type&>(index_buffer)); }
598 void genericBind(const IVertexBuffer& vertex_buffer) const noexcept final { bind(dynamic_cast<const vertex_buffer_type&>(vertex_buffer)); }
599
600 void genericDraw(unsigned vertices, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept final
601 {
602 draw(vertices, instances, first_vertex, first_instance);
603 }
604
605 void genericDraw(const IVertexBuffer& vertex_buffer, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept final
606 {
607 draw(dynamic_cast<const vertex_buffer_type&>(vertex_buffer), instances, first_vertex, first_instance);
608 }
609
610 void genericDrawIndexed(unsigned indices, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept final
611 {
612 drawIndexed(indices, instances, first_index, vertex_offset, first_instance);
613 }
614
615 void genericDrawIndexed(const IIndexBuffer& index_buffer, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept final
616 {
617 drawIndexed(dynamic_cast<const index_buffer_type&>(index_buffer), instances, first_index, vertex_offset, first_instance);
618 }
619
620 void genericDrawIndexed(const IVertexBuffer& vertex_buffer,
621 const IIndexBuffer& index_buffer,
622 unsigned instances,
623 unsigned first_index,
624 int vertex_offset,
625 unsigned first_instance) const noexcept final
626 {
627 drawIndexed(dynamic_cast<const vertex_buffer_type&>(vertex_buffer),
628 dynamic_cast<const index_buffer_type&>(index_buffer),
629 instances,
630 first_index,
631 vertex_offset,
632 first_instance);
633 }
634
635 void genericExecute(std::shared_ptr<const ICommandBuffer> command_buffer) const final { execute(std::static_pointer_cast<const command_buffer_type>(command_buffer)); }
636
637 void genericExecute(const std::vector<std::shared_ptr<const ICommandBuffer>>& command_buffers) const final
638 {
639 std::vector<std::shared_ptr<const command_buffer_type>> command_buffer_types;
640 command_buffer_types.reserve(command_buffers.size());
641 std::ranges::transform(command_buffers,
642 std::back_inserter(command_buffer_types),
643 [](const std::shared_ptr<const ICommandBuffer>& command_buffer) { return std::static_pointer_cast<const command_buffer_type>(command_buffer); });
644 execute(command_buffer_types);
645 }
646
647 void genericPushConstants(const IPushConstantsLayout& layout, const void* const memory) const noexcept final
648 {
649 pushConstants(dynamic_cast<const push_constants_layout_type&>(layout), memory);
650 }
651 };
652}
A vector with four components.
Definition Vector4.h:13
Definition CommandBuffer.h:462
virtual void execute(const std::vector< std::shared_ptr< const command_buffer_type > > &command_buffers) const =0
Executes a secondary command buffer.
virtual void bind(const vertex_buffer_type &vertex_buffer) const noexcept=0
Binds the descriptor_set to the last pipeline used by the command buffer.
virtual void transfer(image_type &source, image_type &target, unsigned source_subresource, unsigned target_subresource, unsigned subresources) const =0
Performs a buffer to buffer transfer from source to target.
virtual void draw(unsigned vertices, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept=0
Draw a number of vertices from the currently bound vertex buffer.
virtual void transfer(buffer_type &source, image_type &target, unsigned source_element, unsigned first_subresource, unsigned elements) const =0
Performs a buffer to buffer transfer from source to target.
virtual void transfer(buffer_type &source, buffer_type &target, unsigned source_element, unsigned target_element, unsigned elements) const =0
Performs a buffer to buffer transfer from source to target.
virtual void bind(const descriptor_set_type &descriptor_set) const =0
Binds the descriptor_set to the last pipeline used by the command buffer.
virtual void use(const pipeline_type &pipeline) const noexcept=0
Sets the pipeline to be used for subsequent draw calls.
virtual void draw(const vertex_buffer_type &vertex_buffer, unsigned instances, unsigned first_vertex, unsigned first_instance) const noexcept=0
Draw a number of vertices from the currently bound vertex buffer.
virtual void drawIndexed(const vertex_buffer_type &vertex_buffer, const index_buffer_type &index_buffer, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept=0
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
virtual void drawIndexed(unsigned indices, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept=0
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
virtual void bind(const index_buffer_type &index_buffer) const noexcept=0
Binds the descriptor_set to the last pipeline used by the command buffer.
virtual void drawIndexed(const index_buffer_type &index_buffer, unsigned instances, unsigned first_index, int vertex_offset, unsigned first_instance) const noexcept=0
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
virtual void bind(const descriptor_set_type &descriptor_set, const pipeline_type &pipeline) const noexcept=0
Binds the descriptor_set to the last pipeline used by the command buffer.
virtual void pushConstants(const push_constants_layout_type &layout, const void *const memory) const noexcept=0
Pushes a block of memory into the push constants backing memory.
virtual void transfer(image_type &source, buffer_type &target, unsigned first_subresource, unsigned target_element, unsigned subresources) const =0
Performs a buffer to buffer transfer from source to target.
virtual void transfer(std::shared_ptr< buffer_type > source, image_type &target, unsigned source_element, unsigned first_subresource, unsigned elements) const =0
Performs a buffer to buffer transfer from source to target.
virtual void transfer(std::shared_ptr< buffer_type > source, buffer_type &target, unsigned source_element, unsigned target_element, unsigned elements) const =0
Performs a buffer to buffer transfer from source to target.
virtual void transfer(std::shared_ptr< image_type > source, image_type &target, unsigned first_subresource, unsigned target_element, unsigned subresources) const =0
Performs a buffer to buffer transfer from source to target.
virtual void execute(std::shared_ptr< const command_buffer_type > command_buffer) const =0
Executes a secondary command buffer.
virtual void transfer(std::shared_ptr< image_type > source, buffer_type &target, unsigned int first_subresource, unsigned int target_element, unsigned int subresources) const =0
Performs a buffer to buffer transfer from source to target.
Base interface for all buffers.
Definition Buffer.h:151
Interface for a command buffer.
Definition CommandBuffer.h:24
void transfer(std::shared_ptr< IBuffer > source, IBuffer &target, unsigned int source_element=0, unsigned int target_element=0, unsigned int elements=1) const
Performs a buffer to buffer transfer from source to target.
Definition CommandBuffer.h:79
virtual void end() const =0
Ends the recording of the command buffer.
virtual void setBlendFactors(const math::Vector4< float > &blend_factors) const noexcept=0
Sets the blend factors to use for subsequent draw calls.
void transfer(IBuffer &source, IImage &target, unsigned int source_element=0, unsigned int first_subresource=0, unsigned int elements=1) const
Performs a buffer to image transfer from source to target.
Definition CommandBuffer.h:100
virtual void setScissor(const IScissor *scissor) const noexcept=0
Sets the scissor to use for subsequent draw calls.
void drawIndexed(const IVertexBuffer &vertex_buffer, const IIndexBuffer &index_buffer, unsigned int instances=1, unsigned int first_index=0, int vertex_offset=0, unsigned int first_instance=0) const noexcept
Draws the currently bound IVertexBuffer using the provided IIndexBuffer in index_buffer.
Definition CommandBuffer.h:309
void bind(const IDescriptorSet &descriptor_set) const
Binds the descriptor_set to the last pipeline used by the command buffer.
Definition CommandBuffer.h:222
void draw(unsigned int vertices, unsigned int instances=1, unsigned int first_vertex=0, unsigned int first_instance=0) const noexcept
Draw a number of vertices from the currently bound vertex buffer.
Definition CommandBuffer.h:254
void bind(const IDescriptorSet &descriptor_set, const IPipeline &pipeline) const noexcept
Binds the descriptor_set to the pipeline.
Definition CommandBuffer.h:229
void bind(const IVertexBuffer &vertex_buffer) const noexcept
Binds the vertex_buffer to the pipeline.
Definition CommandBuffer.h:237
void draw(const IVertexBuffer &vertex_buffer, unsigned int instances=1, unsigned int first_vertex=0, unsigned int first_instance=0) const noexcept
Draw all vertices from the provided IVertexBuffer in vertex_buffer.
Definition CommandBuffer.h:266
void transfer(std::shared_ptr< IImage > source, IBuffer &target, unsigned int first_subresource=0, unsigned int target_element=0, unsigned int subresources=1) const
Performs an image to buffer transfer from source to target.
Definition CommandBuffer.h:205
virtual void setScissors(std::span< const IScissor * > scissors) const noexcept=0
Sets the scissors to use for subsequent draw calls.
void pushConstants(const IPushConstantsLayout &layout, const void *const memory) const noexcept
Pushes a block of memory into the push constants backing memory.
Definition CommandBuffer.h:338
virtual void setViewports(std::span< const IViewport * > viewports) const noexcept=0
Sets the viewports to use for subsequent draw calls.
virtual void begin() const =0
Sets the command buffer to recording state, allowing it to receive commands that should be transmitte...
void drawIndexed(const IIndexBuffer &index_buffer, unsigned int instances=1, unsigned int first_index=0, int vertex_offset=0, unsigned int first_instance=0) const noexcept
Draws the currently bound IVertexBuffer using the provided IIndexBuffer in index_buffer.
Definition CommandBuffer.h:294
virtual void setViewport(const IViewport *viewport) const noexcept=0
Sets the viewport to use for subsequent draw calls.
void transfer(IImage &source, IImage &target, unsigned int source_subresource=0, unsigned int target_subresource=0, unsigned int subresources=1) const
Performs an image to buffer transfer from source to target.
Definition CommandBuffer.h:137
virtual void dispatch() const noexcept=0
Executes a compute shader.
void transfer(std::shared_ptr< IImage > source, IImage &target, unsigned int source_subresource=0, unsigned int target_subresource=0, unsigned int subresources=1) const
Performs an image to buffer transfer from source to target.
Definition CommandBuffer.h:153
virtual bool isRecording() const noexcept=0
Checks if the command buffer is recording.
void bind(const IIndexBuffer &index_buffer) const noexcept
Binds the index_buffer to the pipeline.
Definition CommandBuffer.h:245
void use(const IPipeline &pipeline) const noexcept
Sets the pipeline to be used for subsequent draw calls.
Definition CommandBuffer.h:214
virtual void setStencilRef(unsigned int stencil_ref) const noexcept=0
Sets the stencil reference value to use for subsequent draw calls.
void execute(const std::vector< std::shared_ptr< const ICommandBuffer > > &command_buffers) const
Executes a series of secondary command buffers/bundles.
Definition CommandBuffer.h:331
virtual void releaseSharedState() const =0
Called by the parent command queue to signal that the command buffer should release it's shared state...
void transfer(IImage &source, IBuffer &target, unsigned int first_subresource=0, unsigned int target_element=0, unsigned int subresources=1) const
Performs an image to buffer transfer from source to target.
Definition CommandBuffer.h:179
void transfer(std::shared_ptr< IBuffer > source, IImage &target, unsigned int source_element=0, unsigned int first_subresource=0, unsigned int elements=1) const
Performs a buffer to image transfer from source to target.
Definition CommandBuffer.h:121
void drawIndexed(unsigned int indices, unsigned int instances=1, unsigned int first_index=0, int vertex_offset=0, unsigned int first_instance=0) const noexcept
Draws the currently bound vertex buffer with a set of indices from the currently bound index buffer.
Definition CommandBuffer.h:279
Interface for a descriptor set.
Definition DescriptorSet.h:103
Definition Image.h:131
Describes an index buffer.
Definition IndexBuffer.h:39
Interface representing a pipeline.
Definition Pipeline.h:82
Interface for a push constants layout.
Definition PushConstantsLayout.h:15
Interface representing a scissor.
Definition Scissor.h:15
Represents a vertex buffer.
Definition VertexBuffer.h:35
Interface representing a viewport.
Definition Viewport.h:15