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
65 bool maybeRebuild(bool force = false);
66
72 TextureRenderTarget renderTargetForOutput(const Edge& edge) const noexcept;
73
79 QImage adaptImage(const QImage& in);
80
85
90
91 using Buffers = std::pair<const Mesh* const, MeshBuffers>;
92 Buffers acquireMesh(
93 const ossia::geometry_spec&, QRhiResourceUpdateBatch& res, const Mesh* current,
94 MeshBuffers currentbufs) noexcept;
95
99 std::vector<score::gfx::Node*> nodes;
100
104 std::vector<score::gfx::NodeRenderer*> renderers;
105
107 void clearRenderers();
108
112 QRhiTexture& emptyTexture() const noexcept { return *m_emptyTexture; }
113
120 QRhiBuffer& outputUBO() const noexcept { return *m_outputUBO; }
121
125 const score::gfx::Mesh& defaultQuad() const noexcept;
126
130 const score::gfx::Mesh& defaultTriangle() const noexcept;
131
137 bool requiresDepth() const noexcept { return m_requiresDepth; }
138
139 int samples() const noexcept { return m_samples; }
140
141 bool canRender() const noexcept { return m_ready; }
142
143 QSize renderSize(const Edge* e) const noexcept;
144
145 int64_t frame = 0;
146
147private:
148 OutputUBO m_outputUBOData;
149
150 QRhiResourceUpdateBatch* m_initialBatch{};
151
152 // Material
153 QRhiBuffer* m_outputUBO{};
154 QRhiTexture* m_emptyTexture{};
155
159 ossia::flat_map<Mesh*, MeshBuffers> m_vertexBuffers;
160
161 ossia::flat_map<ossia::geometry_spec, Mesh*> m_customMeshCache;
162
166 QSize m_lastSize{};
167
168 int m_minTexSize{};
169 int m_maxTexSize{};
170 int m_samples{1};
171
172 bool m_requiresDepth{};
173 bool m_ready{};
174 bool m_built{};
175};
176}
Base class for sink nodes (QWindow, spout, syphon, NDI output, ...)
Definition OutputNode.hpp:24
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:120
std::vector< score::gfx::NodeRenderer * > renderers
Renderers - one per node.
Definition RenderList.hpp:104
std::vector< score::gfx::Node * > nodes
Nodes present in this RenderList, in order.
Definition RenderList.hpp:99
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:89
QRhiTexture & emptyTexture() const noexcept
Texture to use when a texture is missing.
Definition RenderList.hpp:112
OutputNode & output
Output node to which this RenderList is rendering to.
Definition RenderList.hpp:84
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
Base toolkit upon which the software is built.
Definition Application.cpp:97
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
Global state associated to a rendering context.
Definition RenderState.hpp:32
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:111