wren
Vulkan-based game engine
Loading...
Searching...
No Matches
graph.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6#include <vulkan/vulkan.hpp>
8#include <wren/vk/image.hpp>
9
10#include "render_pass.hpp"
11
12namespace wren {
13
14struct Node {
15 std::string name;
16 std::shared_ptr<RenderPass> render_pass;
17};
18
19using node_t = std::shared_ptr<Node>;
20using edge_t = std::pair<node_t, node_t>;
21
22struct Graph {
23 auto begin() { return nodes.begin(); }
24 auto end() { return nodes.end(); }
25
26 [[nodiscard]] auto node_by_name(const std::string &name) const -> node_t {
27 const auto node = std::ranges::find_if(
28 nodes, [name](const node_t &node) { return name == node->name; });
29 if (node != nodes.end()) return *node;
30
31 return nullptr;
32 }
33
34 std::vector<node_t> nodes;
35 std::vector<edge_t> edges;
36};
37
39 public:
40 explicit GraphBuilder(const std::shared_ptr<Context> &ctx) : ctx_(ctx) {}
41
42 [[nodiscard]] auto compile() const -> expected<Graph>;
43
44 auto add_pass(const std::string &name, const PassResources &resources,
45 const RenderPass::execute_fn_t &fn) -> GraphBuilder &;
46
47 private:
48 [[nodiscard]] auto create_target() const
49 -> expected<std::shared_ptr<RenderTarget>>;
50
51 std::shared_ptr<Context> ctx_;
52 std::vector<std::tuple<std::string, PassResources, RenderPass::execute_fn_t>>
54};
55
56} // namespace wren
Definition graph.hpp:38
std::vector< std::tuple< std::string, PassResources, RenderPass::execute_fn_t > > passes_
Definition graph.hpp:53
auto create_target() const -> expected< std::shared_ptr< RenderTarget > >
auto add_pass(const std::string &name, const PassResources &resources, const RenderPass::execute_fn_t &fn) -> GraphBuilder &
Definition graph.cpp:11
auto compile() const -> expected< Graph >
Definition graph.cpp:19
GraphBuilder(const std::shared_ptr< Context > &ctx)
Definition graph.hpp:40
std::shared_ptr< Context > ctx_
Definition graph.hpp:51
Definition render_pass.hpp:23
Definition render_pass.hpp:59
Definition render_target.hpp:14
Definition editor_scene.hpp:5
std::pair< node_t, node_t > edge_t
Definition graph.hpp:20
std::shared_ptr< Node > node_t
Definition graph.hpp:19
std::expected< T, Err > expected
Definition result.hpp:49
Definition context.hpp:13
Definition graph.hpp:22
std::vector< edge_t > edges
Definition graph.hpp:35
auto node_by_name(const std::string &name) const -> node_t
Definition graph.hpp:26
std::vector< node_t > nodes
Definition graph.hpp:34
auto end()
Definition graph.hpp:24
auto begin()
Definition graph.hpp:23
Definition graph.hpp:14
std::shared_ptr< RenderPass > render_pass
Definition graph.hpp:16
std::string name
Definition graph.hpp:15