1#ifndef LIBSBX_GRAPHICS_RENDERER_HPP_
2#define LIBSBX_GRAPHICS_RENDERER_HPP_
8#include <libsbx/utility/noncopyable.hpp>
9#include <libsbx/utility/concepts.hpp>
14#include <libsbx/graphics/commands/command_buffer.hpp>
16#include <libsbx/graphics/pipeline/pipeline.hpp>
18#include <libsbx/graphics/task.hpp>
19#include <libsbx/graphics/subrenderer.hpp>
20#include <libsbx/graphics/render_stage.hpp>
21#include <libsbx/graphics/render_graph.hpp>
23namespace sbx::graphics {
33 virtual auto initialize() ->
void = 0;
36 for (
const auto& [
render_stage, index] : _subrenderer_stages) {
44 for (
const auto&
task : _tasks) {
49 auto add_render_stage(std::vector<attachment>&& attachments, std::vector<subpass_binding>&& subpass_bindings,
const viewport&
viewport =
graphics::viewport{}) ->
void {
50 _render_stages.push_back(std::make_unique<graphics::render_stage>(std::move(attachments), std::move(subpass_bindings),
viewport));
53 auto render_stages()
const noexcept ->
const std::vector<std::unique_ptr<graphics::render_stage>>& {
54 return _render_stages;
58 return *_render_stages.at(stage.renderpass);
64 template<
typename Type,
typename... Args>
65 requires (std::is_constructible_v<Type,
const std::filesystem::path&,
const pipeline::stage&, Args...>)
66 auto add_subrenderer(
const std::filesystem::path& path,
const pipeline::stage& stage, Args&&... args) -> Type& {
67 _subrenderer_stages.insert({stage, _subrenderers.size()});
69 _subrenderers.push_back(std::make_unique<Type>(path, stage, std::forward<Args>(args)...));
71 return *
static_cast<Type*
>(_subrenderers.back().get());
74 template<
typename Type,
typename... Args>
75 requires (std::is_constructible_v<Type, std::filesystem::path, Args...>)
76 auto add_task(
const std::filesystem::path& path, Args&&... args) -> Type& {
77 _tasks.push_back(std::make_unique<Type>(path, std::forward<Args>(args)...));
79 return *
static_cast<Type*
>(_tasks.back().get());
84 std::vector<std::unique_ptr<graphics::task>> _tasks;
86 std::vector<std::unique_ptr<graphics::render_stage>> _render_stages;
88 std::vector<std::unique_ptr<subrenderer>> _subrenderers;
89 std::multimap<pipeline::stage, std::size_t> _subrenderer_stages;
Definition: command_buffer.hpp:14
Definition: render_graph.hpp:43
Definition: render_stage.hpp:216
Definition: renderer.hpp:25
Definition: render_stage.hpp:125
Definition: pipeline.hpp:22
Definition: noncopyable.hpp:6