3#include "spark/render/Export.h"
4#include "spark/render/FrameBuffer.h"
5#include "spark/render/InputAttachementMapping.h"
6#include "spark/render/RenderPipeilne.h"
7#include "spark/render/RenderTarget.h"
8#include "spark/render/StateResource.h"
12namespace spark::render
29 virtual void begin(
unsigned int buffer) = 0;
37 virtual void end()
const = 0;
51 [[nodiscard]] std::vector<const IFrameBuffer*>
frameBuffers() const noexcept {
return genericFrameBuffers(); }
63 [[nodiscard]] std::vector<const IRenderPipeline*>
pipelines() const noexcept {
return genericPipelines(); }
76 [[nodiscard]]
virtual std::span<const RenderTarget>
renderTargets() const noexcept = 0;
82 [[nodiscard]] virtual
bool hasPresentRenderTarget() const noexcept = 0;
88 [[nodiscard]] virtual MultiSamplingLevel multiSamplingLevel() const noexcept = 0;
94 void updateAttachments(const
IDescriptorSet& descriptor_set)
const { genericUpdateAttachments(descriptor_set); }
97 [[nodiscard]]
virtual const IFrameBuffer& genericActiveFrameBuffer()
const = 0;
98 [[nodiscard]]
virtual std::vector<const IFrameBuffer*> genericFrameBuffers() const noexcept = 0;
99 [[nodiscard]] virtual std::vector<const
IRenderPipeline*> genericPipelines() const noexcept = 0;
100 virtual
void genericUpdateAttachments(const
IDescriptorSet& descriptor_set) const = 0;
112 template <typename RenderPipelineType, typename FrameBufferType, typename InputAttachmentMappingType>
116 using frame_buffer_type = FrameBufferType;
117 using render_pipeline_type = RenderPipelineType;
118 using input_attachment_mapping_type = InputAttachmentMappingType;
119 using pipeline_layout_type =
typename render_pipeline_type::pipeline_layout_type;
120 using descriptor_set_layout_type =
typename pipeline_layout_type::descriptor_set_layout_type;
121 using descriptor_set_type =
typename descriptor_set_layout_type::descriptor_set_type;
128 [[nodiscard]]
virtual std::vector<const frame_buffer_type*>
frameBuffers() const noexcept = 0;
131 [[nodiscard]] virtual std::vector<const render_pipeline_type*> pipelines() const noexcept = 0;
137 [[nodiscard]] virtual std::span<const input_attachment_mapping_type> inputAttachments() const noexcept = 0;
140 virtual
void updateAttachments(const descriptor_set_type& descriptor_set) const = 0;
143 [[nodiscard]] const
IFrameBuffer& genericActiveFrameBuffer() const final {
return activeFrameBuffer(); }
145 [[nodiscard]] std::vector<const IFrameBuffer*> genericFrameBuffers() const noexcept final
147 auto tmp = frameBuffers();
148 std::vector<const IFrameBuffer*> frame_buffers_vector;
149 frame_buffers_vector.reserve(tmp.size());
150 std::ranges::transform(tmp, std::back_inserter(frame_buffers_vector), [](
const auto& frame_buffer) {
return static_cast<const IFrameBuffer*
>(frame_buffer); });
151 return frame_buffers_vector;
154 [[nodiscard]] std::vector<const IRenderPipeline*> genericPipelines() const noexcept final
156 auto tmp = pipelines();
157 std::vector<const IRenderPipeline*> pipelines_vector;
158 pipelines_vector.reserve(tmp.size());
159 std::ranges::transform(tmp, std::back_inserter(pipelines_vector), [](
const auto& pipeline) {
return static_cast<const IRenderPipeline*
>(pipeline); });
160 return pipelines_vector;
163 void genericUpdateAttachments(
const IDescriptorSet& descriptor_set)
const final { updateAttachments(
static_cast<const descriptor_set_type&
>(descriptor_set)); }
A vector with two components.
Definition Vector2.h:13
Interface for a descriptor set.
Definition DescriptorSet.h:103
Interface for a frame buffer.
Definition FrameBuffer.h:17
Interface for a render pass.
Definition RenderPass.h:18
virtual const RenderTarget & renderTarget(unsigned int location) const =0
Gets the render target at the specified location.
virtual void resizeFrameBuffers(const math::Vector2< unsigned int > &new_render_area)=0
Resets the frame buffers owned by the render pass.
virtual void begin(unsigned int buffer)=0
Begins the render pass.
virtual std::span< const RenderTarget > renderTargets() const noexcept=0
Gets all render targets the render pass is rendering to.
const IFrameBuffer & activeFrameBuffer() const
Gets the active frame buffer from the render pass.
Definition RenderPass.h:45
virtual void end() const =0
Ends the render pass.
std::vector< const IFrameBuffer * > frameBuffers() const noexcept
Gets all frame buffers owned by the render pass.
Definition RenderPass.h:51
std::vector< const IRenderPipeline * > pipelines() const noexcept
Gets all render pipelines owned by the render pass.
Definition RenderPass.h:63
Interface for a render pipeline.
Definition RenderPipeilne.h:16
Interface for a state resource.
Definition StateResource.h:14
Represents a render pass.
Definition RenderPass.h:114
virtual std::vector< const frame_buffer_type * > frameBuffers() const noexcept=0
Gets all frame buffers owned by the render pass.
virtual const frame_buffer_type & activeFrameBuffer() const =0
Gets the active frame buffer from the render pass.
Implements a IRenderTarget.
Definition RenderTarget.h:201
Base class for a resource that can be identified by a name in a DeviceState.
Definition StateResource.h:29