Loading...
Searching...
No Matches
NodeRenderer.hpp
1#pragma once
2#include <Gfx/Graph/Node.hpp>
3
4namespace score::gfx
5{
6
10class SCORE_PLUGIN_GFX_EXPORT NodeRenderer
11{
12public:
13 int32_t id{-1};
14 explicit NodeRenderer() noexcept;
15 virtual ~NodeRenderer();
16
17 virtual TextureRenderTarget renderTargetForInput(const Port& input) = 0;
18
21 virtual void
22 inputAboutToFinish(RenderList& renderer, const Port& p, QRhiResourceUpdateBatch*&);
23
24 virtual void init(RenderList& renderer, QRhiResourceUpdateBatch& res) = 0;
25 virtual void update(RenderList& renderer, QRhiResourceUpdateBatch& res) = 0;
26
27 virtual void runInitialPasses(
28 RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res,
29 Edge& edge);
30
31 virtual void runRenderPass(RenderList&, QRhiCommandBuffer& commands, Edge& edge);
32
33 virtual void release(RenderList&) = 0;
34};
35
36using PassMap = ossia::small_vector<std::pair<Edge*, Pipeline>, 2>;
37SCORE_PLUGIN_GFX_EXPORT
38void defaultPassesInit(
39 PassMap& passes, const std::vector<Edge*>& edges, RenderList& renderer,
40 const Mesh& mesh, const QShader& v, const QShader& f, QRhiBuffer* processUBO,
41 QRhiBuffer* matUBO, const std::vector<Sampler>& samplers,
42 std::span<QRhiShaderResourceBinding> additionalBindings = {});
43
44SCORE_PLUGIN_GFX_EXPORT
45void defaultRenderPass(
46 RenderList& renderer, const Mesh& mesh, const MeshBuffers& bufs,
47 QRhiCommandBuffer& cb, Edge& edge, PassMap& passes);
48
49SCORE_PLUGIN_GFX_EXPORT
50void quadRenderPass(
51 RenderList& renderer, const MeshBuffers& bufs, QRhiCommandBuffer& cb, Edge& edge,
52 PassMap& passes);
53
60class SCORE_PLUGIN_GFX_EXPORT GenericNodeRenderer : public score::gfx::NodeRenderer
61{
62public:
63 GenericNodeRenderer(const NodeModel& node) noexcept
64 : NodeRenderer{}
65 , node{node}
66 {
67 }
68
69 TextureRenderTarget renderTargetForInput(const Port& p) override;
70 virtual ~GenericNodeRenderer() { }
71
72 const NodeModel& node;
73 std::vector<Sampler> m_samplers;
74
75 QShader m_vertexS;
76 QShader m_fragmentS;
77
78 // Pipeline
79 PassMap m_p;
80
81 MeshBuffers m_meshbufs;
82
83 QRhiBuffer* m_processUBO{};
84
85 DefaultShaderMaterial m_material;
86 int64_t materialChangedIndex{-1};
87 int64_t geometryChangedIndex{-1};
88
89 const score::gfx::Mesh* m_mesh{};
90
91 // Render loop
92 void
93 defaultMeshInit(RenderList& renderer, const Mesh& mesh, QRhiResourceUpdateBatch& res);
94 void processUBOInit(RenderList& renderer);
95 void defaultPassesInit(RenderList& renderer, const Mesh& mesh);
96 void defaultPassesInit(
97 RenderList& renderer, const Mesh& mesh, const QShader& v, const QShader& f,
98 std::span<QRhiShaderResourceBinding> additionalBindings = {});
99
100 void init(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
101
102 void defaultUBOUpdate(RenderList& renderer, QRhiResourceUpdateBatch& res);
103 void defaultMeshUpdate(RenderList& renderer, QRhiResourceUpdateBatch& res);
104 void update(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
105
106 void defaultRelease(RenderList&);
107 void release(RenderList&) override;
108
109 void defaultRenderPass(
110 RenderList&, const Mesh& mesh, QRhiCommandBuffer& commands, Edge& edge);
111
112 void defaultRenderPass(
113 RenderList&, const Mesh& mesh, QRhiCommandBuffer& commands, Edge& edge,
114 PassMap& passes);
115
116 void runRenderPass(RenderList&, QRhiCommandBuffer& commands, Edge& edge) override;
117};
118
119}
Generic renderer.
Definition NodeRenderer.hpp:61
Common base class for most single-pass, simple nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:181
Renderer for a given node.
Definition NodeRenderer.hpp:11
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
Utility to represent a shader material following score conventions.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:247
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:66
Definition Mesh.hpp:15
Data model for meshes.
Definition Mesh.hpp:23
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:48
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:111