3#include "spark/render/CommandBuffer.h"
4#include "spark/render/Export.h"
5#include "spark/render/Image.h"
7#include "spark/math/Vector2.h"
11namespace spark::render
28 [[nodiscard]]
virtual unsigned int bufferIndex() const noexcept = 0;
34 [[nodiscard]] virtual spark::math::Vector2<
unsigned> size() const noexcept = 0;
40 [[nodiscard]] std::vector<std::shared_ptr<const
ICommandBuffer>> commandBuffers() const noexcept {
return genericCommandBuffers(); }
49 [[nodiscard]] std::shared_ptr<const ICommandBuffer>
commandBuffer(
unsigned int index)
const {
return genericCommandBuffer(index); }
55 [[nodiscard]] std::vector<const IImage*>
images() const noexcept {
return genericImages(); }
62 [[nodiscard]]
const IImage&
image(
unsigned int location)
const {
return genericImage(location); }
78 [[nodiscard]]
virtual std::vector<std::shared_ptr<const ICommandBuffer>> genericCommandBuffers() const noexcept = 0;
79 [[nodiscard]] virtual std::shared_ptr<const
ICommandBuffer> genericCommandBuffer(
unsigned int index) const = 0;
80 [[nodiscard]] virtual std::vector<const
IImage*> genericImages() const noexcept = 0;
81 [[nodiscard]] virtual const
IImage& genericImage(
unsigned int location) const = 0;
89 template <typename CommandBufferType>
93 using command_buffer_type = CommandBufferType;
94 using image_type =
typename command_buffer_type::image_type;
98 [[nodiscard]]
virtual std::vector<std::shared_ptr<const command_buffer_type>>
commandBuffers() const noexcept = 0;
101 [[nodiscard]] virtual std::shared_ptr<const command_buffer_type> commandBuffer(
unsigned index) const = 0;
104 [[nodiscard]] virtual std::vector<const image_type*> images() const noexcept = 0;
107 [[nodiscard]] virtual const image_type& image(
unsigned location) const = 0;
110 [[nodiscard]] std::vector<std::shared_ptr<const
ICommandBuffer>> genericCommandBuffers() const noexcept final
112 auto tmp = commandBuffers();
113 std::vector<std::shared_ptr<const ICommandBuffer>> command_buffers_vector;
114 command_buffers_vector.reserve(tmp.size());
115 std::ranges::transform(tmp,
116 std::back_inserter(command_buffers_vector),
117 [](
const auto& command_buffer) {
return static_cast<std::shared_ptr<const ICommandBuffer>
>(command_buffer); });
118 return command_buffers_vector;
121 [[nodiscard]] std::shared_ptr<const ICommandBuffer> genericCommandBuffer(
unsigned index)
const final {
return commandBuffer(index); }
123 [[nodiscard]] std::vector<const IImage*> genericImages() const noexcept final
126 std::vector<const IImage*> images_vector;
127 images_vector.reserve(tmp.size());
128 std::ranges::transform(tmp, std::back_inserter(images_vector), [](
const auto& image) {
return static_cast<const IImage*
>(image); });
129 return images_vector;
132 [[nodiscard]]
const IImage& genericImage(
unsigned location)
const final {
return image(location); }
A vector with two components.
Definition Vector2.h:13
Stores the images for the output attachments for a back buffer of a IRenderPass>, as well as a Comman...
Definition FrameBuffer.h:91
virtual std::vector< std::shared_ptr< const command_buffer_type > > commandBuffers() const noexcept=0
Gets all command buffers of the frame buffer.
Interface for a command buffer.
Definition CommandBuffer.h:24
Interface for a frame buffer.
Definition FrameBuffer.h:17
std::vector< const IImage * > images() const noexcept
Gets all images storing the output attachments for the render targets of the IRenderPass.
Definition FrameBuffer.h:55
std::shared_ptr< const ICommandBuffer > commandBuffer(unsigned int index) const
Gets the command buffer that records draw commands for the frame buffer.
Definition FrameBuffer.h:49
virtual unsigned int bufferIndex() const noexcept=0
Gets the index of the frame buffer within the IRenderPass.
virtual void resize(const spark::math::Vector2< unsigned > &render_area)=0
Invalidate and resize the frame buffer with given render_area.
const IImage & image(unsigned int location) const
Gets the image storing the output attachment for the render target mapped at given location.
Definition FrameBuffer.h:62