Loading...
Searching...
No Matches
RenderList.hpp
1#pragma once
2#include <Gfx/Graph/CommonUBOs.hpp>
3#include <Gfx/Graph/Node.hpp>
4
5namespace score::gfx
6{
7
8class OutputNode;
18class SCORE_PLUGIN_GFX_EXPORT RenderList
19{
20private:
21 std::shared_ptr<RenderState> m_state;
22
23public:
24 explicit RenderList(OutputNode& output, const std::shared_ptr<RenderState>& state);
26
30 void init();
31
37 [[nodiscard]] QRhiResourceUpdateBatch* initialBatch() const noexcept;
38
45 MeshBuffers initMeshBuffer(const Mesh& mesh, QRhiResourceUpdateBatch& res);
46
50 void update(QRhiResourceUpdateBatch& res);
51
55 void render(QRhiCommandBuffer& commands, bool force = false);
56
60 void release();
61
62 void releaseBuffer(QRhiBuffer* buf);
63
67 bool maybeRebuild(bool force = false);
68
74 TextureRenderTarget renderTargetForOutput(const Edge& edge) const noexcept;
75
82 TextureRenderTarget renderTargetForInputPort(const Port& p) const noexcept;
83
84 BufferView bufferForInput(const Edge& edge) const noexcept;
85 BufferView bufferForOutput(const Edge& edge) const noexcept;
86
92 QImage adaptImage(const QImage& in);
93
98
103
104 using Buffers = std::pair<const Mesh* const, MeshBuffers>;
105 Buffers acquireMesh(
106 const ossia::geometry_spec&, QRhiResourceUpdateBatch& res, const Mesh* current,
107 MeshBuffers currentbufs) noexcept;
108
112 std::vector<score::gfx::Node*> nodes;
113
117 std::vector<score::gfx::NodeRenderer*> renderers;
118
120 void clearRenderers();
121
125 QRhiTexture& emptyTexture() const noexcept { return *m_emptyTexture; }
126
133 QRhiBuffer& outputUBO() const noexcept { return *m_outputUBO; }
134
138 const score::gfx::Mesh& defaultQuad() const noexcept;
139
143 const score::gfx::Mesh& defaultTriangle() const noexcept;
144
150 bool requiresDepth(score::gfx::Port& p) const noexcept;
151 bool anyNodeRequiresDepth() const noexcept { return m_requiresDepth; }
152
153 int samples() const noexcept { return m_samples; }
154
155 bool canRender() const noexcept { return m_ready; }
156
157 QSize renderSize(const Edge* e) const noexcept;
158
159 int64_t frame = 0;
160
161 void createAllInputRenderTargets();
162
163private:
164 OutputUBO m_outputUBOData;
165
166 QRhiResourceUpdateBatch* m_initialBatch{};
167
168 // Material
169 QRhiBuffer* m_outputUBO{};
170 QRhiTexture* m_emptyTexture{};
171
175 ossia::flat_map<Mesh*, MeshBuffers> m_vertexBuffers;
176
177 ossia::flat_map<ossia::geometry_spec, Mesh*> m_customMeshCache;
178
185 ossia::small_flat_map<const Port*, TextureRenderTarget, 8> m_inputRenderTargets;
186
190 QSize m_lastSize{};
191
192 int m_minTexSize{};
193 int m_maxTexSize{};
194 int m_samples{1};
195
196 bool m_requiresDepth{};
197 bool m_ready{};
198 bool m_built{};
199};
200}
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:31
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
QRhiBuffer & outputUBO() const noexcept
UBO corresponding to the output parameters:
Definition RenderList.hpp:133
std::vector< score::gfx::NodeRenderer * > renderers
Renderers - one per node.
Definition RenderList.hpp:117
std::vector< score::gfx::Node * > nodes
Nodes present in this RenderList, in order.
Definition RenderList.hpp:112
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:102
QRhiTexture & emptyTexture() const noexcept
Texture to use when a texture is missing.
Definition RenderList.hpp:125
OutputNode & output
Output node to which this RenderList is rendering to.
Definition RenderList.hpp:97
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
Base toolkit upon which the software is built.
Definition Application.cpp:113
Definition Mesh.hpp:15
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:75
Definition Mesh.hpp:33
Data model for meshes.
Definition Mesh.hpp:46
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:54
Global state associated to a rendering context.
Definition RenderState.hpp:37
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:122