1#ifndef LIBSBX_GRAPHICS_RENDERER_HPP_
2#define LIBSBX_GRAPHICS_RENDERER_HPP_
8#include <easy/profiler.h>
10#include <libsbx/utility/noncopyable.hpp>
11#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 const auto stage_name = fmt::format(
"Render Stage: {}.{}", stage.renderpass, stage.subpass);
37 EASY_BLOCK(stage_name.c_str(), profiler::colors::LightBlue);
38 for (
const auto& [
render_stage, index] : _subrenderer_stages) {
47 for (
const auto&
task : _tasks) {
52 auto add_render_stage(std::vector<attachment>&& attachments, std::vector<subpass_binding>&& subpass_bindings,
const viewport&
viewport = graphics::viewport::window()) ->
void {
53 _render_stages.push_back(std::make_unique<graphics::render_stage>(std::move(attachments), std::move(subpass_bindings),
viewport));
56 auto render_stages()
const noexcept ->
const std::vector<std::unique_ptr<graphics::render_stage>>& {
57 return _render_stages;
61 return *_render_stages.at(stage.renderpass);
67 template<
typename Type,
typename... Args>
68 requires (std::is_constructible_v<Type,
const std::filesystem::path&,
const pipeline::stage&, Args...>)
69 auto add_subrenderer(
const std::filesystem::path& path,
const pipeline::stage& stage, Args&&... args) -> Type& {
70 _subrenderer_stages.insert({stage, _subrenderers.size()});
72 _subrenderers.push_back(std::make_unique<Type>(path, stage, std::forward<Args>(args)...));
74 return *
static_cast<Type*
>(_subrenderers.back().get());
77 template<
typename Type,
typename... Args>
78 requires (std::is_constructible_v<Type, std::filesystem::path, Args...>)
79 auto add_task(
const std::filesystem::path& path, Args&&... args) -> Type& {
80 _tasks.push_back(std::make_unique<Type>(path, std::forward<Args>(args)...));
82 return *
static_cast<Type*
>(_tasks.back().get());
87 std::vector<std::unique_ptr<graphics::task>> _tasks;
89 std::vector<std::unique_ptr<graphics::render_stage>> _render_stages;
91 std::vector<std::unique_ptr<subrenderer>> _subrenderers;
92 std::multimap<pipeline::stage, std::size_t> _subrenderer_stages;
Definition: command_buffer.hpp:14
Definition: render_graph.hpp:43
Definition: render_stage.hpp:251
Definition: renderer.hpp:25
Definition: render_stage.hpp:123
Definition: pipeline.hpp:22
Definition: noncopyable.hpp:6