Loading...
Searching...
No Matches
OutputNode.hpp
1#pragma once
2#include <Gfx/Graph/Node.hpp>
3#include <Gfx/Graph/NodeRenderer.hpp>
4#include <Gfx/Graph/RenderState.hpp>
5#include <Gfx/Graph/Uniforms.hpp>
6
7#include <score_plugin_gfx_export.h>
8
9#include <memory>
10
11namespace score::gfx
12{
13class GpuResourceRegistry;
15{
16 GraphicsApi graphicsApi{};
17 std::function<void()> onReady;
18 std::function<void()> onResize;
19
32 std::function<void()> onReleaseRenderList;
33};
34
35class SCORE_PLUGIN_GFX_EXPORT OutputNodeRenderer : public score::gfx::NodeRenderer
36{
37public:
38 using score::gfx::NodeRenderer::NodeRenderer;
39 virtual ~OutputNodeRenderer();
40 virtual void
41 finishFrame(RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res);
42
43 // Sinks have no output edges, so there is nothing to release per-edge.
44 // Concrete sinks may still override, e.g. to drop per-input bookkeeping
45 // routed through addOutputPass.
46 void removeOutputPass(RenderList&, Edge&) override { }
47};
48
49class Window;
53class SCORE_PLUGIN_GFX_EXPORT OutputNode : public score::gfx::Node
54{
55public:
56 virtual ~OutputNode();
57
58 virtual void setRenderer(std::shared_ptr<RenderList>) = 0;
59 virtual RenderList* renderer() const = 0;
60
61 OutputNodeRenderer* createRenderer(RenderList& r) const noexcept override = 0;
62
63 virtual void startRendering() = 0;
64 virtual void render() = 0;
65 virtual void stopRendering() = 0;
66 virtual bool canRender() const = 0;
67 virtual void onRendererChange() = 0;
68
75 virtual void setVSyncCallback(std::function<void()>);
76
77 virtual void createOutput(OutputConfiguration conf) = 0;
78
79 virtual void updateGraphicsAPI(GraphicsApi);
80 virtual void destroyOutput() = 0;
81 virtual std::shared_ptr<RenderState> renderState() const = 0;
82
84 {
85 // If set, the host is responsible for calling render() at this
86 // rate (given in milliseconds)
87 std::optional<double> manualRenderingRate;
88 bool outputNeedsRenderPass{};
89 bool supportsVSync{};
90 OutputNode* parent{};
91 };
92
93 virtual Configuration configuration() const noexcept = 0;
94
113 virtual TextureRenderTarget currentRenderTarget() const noexcept { return {}; }
114
133 GpuResourceRegistry& acquireRegistry();
134
139 GpuResourceRegistry* registry() const noexcept { return m_registry.get(); }
140
153 void releaseRegistry();
154
155protected:
156 explicit OutputNode();
157
166 void releaseOwnedRenderList();
167
168 // Set by concrete createOutput() implementations from
169 // OutputConfiguration::onReleaseRenderList.
170 std::function<void()> m_onReleaseRenderList;
171
172 // Persistent across RenderList rebuilds. See acquireRegistry() docs.
173 // unique_ptr is opaque-typed in this header (forward-declared above);
174 // its destructor needs the full type, hence the out-of-line ~OutputNode
175 // implementation in OutputNode.cpp.
176 std::unique_ptr<GpuResourceRegistry> m_registry;
177};
178}
Per-RenderList arena store for GPU-resident scene data.
Definition GpuResourceRegistry.hpp:44
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:74
Renderer for a given node.
Definition NodeRenderer.hpp:11
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:54
OutputNodeRenderer * createRenderer(RenderList &r) const noexcept override=0
Create a renderer in a given context for this node.
GpuResourceRegistry * registry() const noexcept
Non-owning accessor. Returns null if no registry has been acquired yet (e.g. queried before the first...
Definition OutputNode.hpp:139
Definition OutputNode.hpp:36
void removeOutputPass(RenderList &, Edge &) override
Definition OutputNode.hpp:46
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
GraphicsApi
Available graphics APIs to use.
Definition RenderState.hpp:22
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103
Definition OutputNode.hpp:15
std::function< void()> onReleaseRenderList
Ask the owning Graph to release + deregister the RenderList that was built against this output's QRhi...
Definition OutputNode.hpp:32
Definition OutputNode.hpp:84
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:152