Loading...
Searching...
No Matches
score-plugin-gfx/Gfx/Graph/Graph.hpp
1#pragma once
2#include <Process/Dataflow/CableData.hpp>
3
4#include <Gfx/Graph/Node.hpp>
5#include <Gfx/Graph/RenderList.hpp>
6
7#include <ossia/detail/algorithms.hpp>
8#include <ossia/detail/hash_map.hpp>
9
10#include <string>
11
12#include <score_plugin_gfx_export.h>
13namespace Gfx
14{
15class AssetTable;
16}
17namespace score::gfx
18{
19class OutputNode;
20class Window;
24struct SCORE_PLUGIN_GFX_EXPORT Graph
25{
29 explicit Graph();
30
31 ~Graph();
32
36 void addNode(score::gfx::Node* n);
37
41 void removeNode(score::gfx::Node* n);
42
46 void addEdge(Port* source, Port* sink, Process::CableType t);
47
51 void removeEdge(Port* source, Port* sink);
52
54 Edge* findEdge(Port* source, Port* sink);
55
57 void removeNodeFromRenderLists(Node* node);
58
62 void removeNodeAndEdges(Node* node);
63
73 void
74 onEdgeRemoved(Edge& edge, const ossia::hash_set<const Port*>* preserveSinks = nullptr);
75
78 void updateSinkSampler(Edge& edge);
79
81 void createAllMissingPasses();
82 void updateAllSinkSamplers();
83
86 void createPassForEdgeIfMissing(Edge& edge);
87
91 void reconcileAllRenderLists();
92
96 void clearEdges();
97
101 void createAllRenderLists(GraphicsApi graphicsApi);
102
106 void createSingleRenderList(score::gfx::OutputNode& node, GraphicsApi graphicsApi);
107
111 void destroyOutputRenderList(score::gfx::OutputNode& node);
112
121 void releaseOutputRenderList(score::gfx::OutputNode& node);
122
126 void relinkGraph();
127
131 bool canDoVSync() const noexcept;
132
142 void createMissingRenderLists();
143
144 const std::vector<std::shared_ptr<RenderList>>& renderLists() const noexcept
145 {
146 return m_renderers;
147 }
148
149 std::span<OutputNode* const> outputs() const noexcept
150 {
151 return m_outputs;
152 }
153
165 void setAssetTable(Gfx::AssetTable* a) noexcept { m_assetTable = a; }
166 Gfx::AssetTable* assetTable() const noexcept { return m_assetTable; }
167
168private:
170 void retopologicalSort(RenderList& rl);
171
172 void initializeOutput(OutputNode* output, GraphicsApi graphicsApi);
173 void createOutputRenderList(OutputNode& output);
174 void recreateOutputRenderList(OutputNode& output);
175 std::shared_ptr<RenderList>
176 createRenderList(OutputNode*, std::shared_ptr<RenderState> state);
177
178 std::vector<std::shared_ptr<RenderList>> m_renderers;
179 std::vector<std::shared_ptr<Window>> m_unused_windows;
180
181 std::vector<score::gfx::Node*> m_nodes;
182 std::vector<Edge*> m_edges;
183
184 std::vector<OutputNode*> m_outputs;
185
186 // Session-wide decode cache. Non-owning; GfxContext owns the
187 // actual AssetTable. May be null in tests or during teardown.
188 Gfx::AssetTable* m_assetTable{};
189
190 ossia::hash_set<std::string> m_warnedCycles;
191};
192}
Cross-RenderList content-hash dedup for decoded asset bytes.
Definition AssetTable.hpp:71
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:115
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:56
Binds the rendering pipeline to ossia processes.
Definition AssetTable.cpp:7
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
GraphicsApi
Available graphics APIs to use.
Definition RenderState.hpp:25
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:236
Represents a graph of renderers.
Definition score-plugin-gfx/Gfx/Graph/Graph.hpp:25
void setAssetTable(Gfx::AssetTable *a) noexcept
Inject the session-wide AssetTable.
Definition score-plugin-gfx/Gfx/Graph/Graph.hpp:165
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:215