2#include <Gfx/Graph/Node.hpp>
27 virtual QRhiTexture* textureForOutput(
const Port& output);
33 virtual void updateInputTexture(
const Port& input, QRhiTexture* tex, QRhiTexture* depthTex =
nullptr);
37 virtual void updateInputSamplerFilter(
43 inputAboutToFinish(
RenderList& renderer,
const Port& p, QRhiResourceUpdateBatch*&);
45 virtual void init(
RenderList& renderer, QRhiResourceUpdateBatch& res) = 0;
46 virtual void update(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge* edge)
49 virtual void runInitialPasses(
50 RenderList&, QRhiCommandBuffer& commands, QRhiResourceUpdateBatch*& res,
53 virtual void runRenderPass(
RenderList&, QRhiCommandBuffer& commands,
Edge& edge);
73 virtual void initState(
RenderList& renderer, QRhiResourceUpdateBatch& res);
77 virtual void releaseState(
RenderList& renderer);
80 virtual void addOutputPass(
92 addInputEdge(
RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res);
98 virtual bool hasOutputPassForEdge(
Edge& edge)
const;
108 virtual void seedInitialOutputs(
RenderList& renderer);
112 void checkForChanges()
117 materialChanged |= node.hasMaterialChanged(materialChangedIndex);
118 renderTargetSpecsChanged |= node.hasRenderTargetChanged(renderTargetSpecsChangedIndex);
126 node.hasRenderTargetChanged(renderTargetSpecsChangedIndex);
127 renderTargetSpecsChanged =
false;
130 void process(int32_t port,
const ossia::geometry_spec& v);
131 void process(int32_t port,
const ossia::scene_spec& v);
132 virtual void process(int32_t port,
const ossia::transform3d& v);
140 void process(int32_t port,
const ossia::geometry_spec& v,
const void* source_key);
141 void process(int32_t port,
const ossia::scene_spec& v,
const void* source_key);
148 for(
const auto& [k, v] : m_portGeometries)
160 template <
typename F>
163 for(
const auto& [k, v] : m_portScenes)
164 if(k.first == port && v.state)
171 void rebuildMergedScene();
195 ossia::small_flat_map<PortSourceKey, ossia::geometry_spec, 4> m_portGeometries;
207 ossia::small_flat_map<PortSourceKey, ossia::scene_spec, 4>
m_portScenes;
218 ossia::small_vector<MergeCacheKey, 4> m_mergeCacheInputs;
219 ossia::scene_spec m_mergeCacheOutput;
225 ossia::small_flat_map<
226 PortSourceKey, std::pair<ossia::geometry_spec, ossia::scene_spec>, 4>
230 bool materialChanged{
false};
231 bool geometryChanged{
false};
232 bool sceneChanged{
false};
233 bool renderTargetSpecsChanged{
false};
237 bool m_initialized{
false};
240 int64_t materialChangedIndex{-1};
241 int64_t renderTargetSpecsChangedIndex{-1};
254 : renderTarget{std::move(rt)}, p{pi}, processUBO{ubo} {}
263 QRhiBuffer* processUBO{};
278 processUBO->deleteLater();
279 processUBO =
nullptr;
281 fallback_bindings.clear();
286using PassMap = ossia::small_vector<std::pair<Edge*, Pass>, 2>;
287SCORE_PLUGIN_GFX_EXPORT
288void defaultPassesInit(
289 PassMap& passes,
const std::vector<Edge*>& edges,
RenderList& renderer,
290 const Mesh& mesh,
const QShader& v,
const QShader& f, QRhiBuffer* processUBO,
291 QRhiBuffer* matUBO, std::span<const Sampler> samplers,
292 std::span<QRhiShaderResourceBinding> additionalBindings = {});
294SCORE_PLUGIN_GFX_EXPORT
295void defaultRenderPass(
296 RenderList& renderer,
const Mesh& mesh,
const MeshBuffers& bufs,
297 QRhiCommandBuffer& cb, Edge& edge, PassMap& passes);
299SCORE_PLUGIN_GFX_EXPORT
301 RenderList& renderer,
const MeshBuffers& bufs, QRhiCommandBuffer& cb, Edge& edge,
323 ossia::small_vector<Sampler, 8> m_samplers;
345 std::pair<QVector<quint32>, QRhiGraphicsPipeline*>, 2>
350 QRhiBuffer* m_processUBO{};
358 defaultMeshInit(
RenderList& renderer,
const Mesh& mesh, QRhiResourceUpdateBatch& res);
361 void defaultPassesInit(
362 RenderList& renderer,
const Mesh& mesh,
const QShader& v,
const QShader& f,
363 std::span<QRhiShaderResourceBinding> additionalBindings = {});
365 void init(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
367 void initState(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
368 void releaseState(
RenderList& renderer)
override;
370 RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res)
override;
372 bool hasOutputPassForEdge(
Edge& edge)
const override;
374 void defaultUBOUpdate(
RenderList& renderer, QRhiResourceUpdateBatch& res);
375 void defaultMeshUpdate(
RenderList& renderer, QRhiResourceUpdateBatch& res);
376 void update(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge* edge)
override;
381 void defaultRenderPass(
384 void defaultRenderPass(
388 void runRenderPass(
RenderList&, QRhiCommandBuffer& commands,
Edge& edge)
override;
390 void updateInputTexture(
const Port& input, QRhiTexture* tex, QRhiTexture* depthTex =
nullptr)
override;
Generic renderer.
Definition NodeRenderer.hpp:311
Root data model for visual nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:74
Common base class for most single-pass, simple nodes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:215
Renderer for a given node.
Definition NodeRenderer.hpp:11
virtual void removeOutputPass(RenderList &renderer, Edge &edge)=0
std::pair< const ossia::scene_state *, int64_t > MergeCacheKey
Definition NodeRenderer.hpp:217
ossia::small_flat_map< PortSourceKey, ossia::scene_spec, 4 > m_portScenes
Per-(port, source) scene storage. See m_portGeometries comment.
Definition NodeRenderer.hpp:207
ossia::scene_spec scene
The scene to use (when receiving scene_spec data).
Definition NodeRenderer.hpp:204
ossia::geometry_spec geometry
The geometry to use.
Definition NodeRenderer.hpp:187
std::pair< int32_t, const void * > PortSourceKey
Definition NodeRenderer.hpp:194
ossia::small_flat_map< PortSourceKey, std::pair< ossia::geometry_spec, ossia::scene_spec >, 4 > m_wrapCache
Definition NodeRenderer.hpp:227
void syncRenderTargetIndex()
Definition NodeRenderer.hpp:124
void forEachSceneOnPort(int32_t port, F &&fn) const
Definition NodeRenderer.hpp:161
const ossia::geometry_spec * findGeometryByPort(int32_t port) const
Definition NodeRenderer.hpp:146
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Utility to represent a shader material following score conventions.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:673
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103
Definition VertexFallbackPlan.hpp:27
Data model for meshes.
Definition Mesh.hpp:179
Definition NodeRenderer.hpp:245
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:132
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:82
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:56
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:152