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);
56 virtual QRhiGraphicsPipeline::CompareOp
depthCompare() const noexcept
58 return QRhiGraphicsPipeline::Greater;
79 virtual void initState(
RenderList& renderer, QRhiResourceUpdateBatch& res);
83 virtual void releaseState(
RenderList& renderer);
86 virtual void addOutputPass(
98 addInputEdge(
RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res);
104 virtual bool hasOutputPassForEdge(
Edge& edge)
const;
114 virtual void seedInitialOutputs(
RenderList& renderer);
118 void checkForChanges()
123 materialChanged |= node.hasMaterialChanged(materialChangedIndex);
124 renderTargetSpecsChanged |= node.hasRenderTargetChanged(renderTargetSpecsChangedIndex);
132 node.hasRenderTargetChanged(renderTargetSpecsChangedIndex);
133 renderTargetSpecsChanged =
false;
136 void process(int32_t port,
const ossia::geometry_spec& v);
137 void process(int32_t port,
const ossia::scene_spec& v);
138 virtual void process(int32_t port,
const ossia::transform3d& v);
146 void process(int32_t port,
const ossia::geometry_spec& v,
const void* source_key);
147 void process(int32_t port,
const ossia::scene_spec& v,
const void* source_key);
154 for(
const auto& [k, v] : m_portGeometries)
166 template <
typename F>
169 for(
const auto& [k, v] : m_portScenes)
170 if(k.first == port && v.state)
177 void rebuildMergedScene();
201 ossia::small_flat_map<PortSourceKey, ossia::geometry_spec, 4> m_portGeometries;
213 ossia::small_flat_map<PortSourceKey, ossia::scene_spec, 4>
m_portScenes;
224 ossia::small_vector<MergeCacheKey, 4> m_mergeCacheInputs;
225 ossia::scene_spec m_mergeCacheOutput;
231 ossia::small_flat_map<
232 PortSourceKey, std::pair<ossia::geometry_spec, ossia::scene_spec>, 4>
236 bool materialChanged{
false};
237 bool geometryChanged{
false};
238 bool sceneChanged{
false};
239 bool renderTargetSpecsChanged{
false};
243 bool m_initialized{
false};
246 int64_t materialChangedIndex{-1};
247 int64_t renderTargetSpecsChangedIndex{-1};
260 : renderTarget{std::move(rt)}, p{pi}, processUBO{ubo} {}
269 QRhiBuffer* processUBO{};
284 processUBO->deleteLater();
285 processUBO =
nullptr;
287 fallback_bindings.clear();
292using PassMap = ossia::small_vector<std::pair<Edge*, Pass>, 2>;
293SCORE_PLUGIN_GFX_EXPORT
294void defaultPassesInit(
295 PassMap& passes,
const std::vector<Edge*>& edges,
RenderList& renderer,
296 const Mesh& mesh,
const QShader& v,
const QShader& f, QRhiBuffer* processUBO,
297 QRhiBuffer* matUBO, std::span<const Sampler> samplers,
298 std::span<QRhiShaderResourceBinding> additionalBindings = {});
300SCORE_PLUGIN_GFX_EXPORT
301void defaultRenderPass(
302 RenderList& renderer,
const Mesh& mesh,
const MeshBuffers& bufs,
303 QRhiCommandBuffer& cb, Edge& edge, PassMap& passes);
305SCORE_PLUGIN_GFX_EXPORT
307 RenderList& renderer,
const MeshBuffers& bufs, QRhiCommandBuffer& cb, Edge& edge,
329 ossia::small_vector<Sampler, 8> m_samplers;
351 std::pair<QVector<quint32>, QRhiGraphicsPipeline*>, 2>
356 QRhiBuffer* m_processUBO{};
364 defaultMeshInit(
RenderList& renderer,
const Mesh& mesh, QRhiResourceUpdateBatch& res);
367 void defaultPassesInit(
368 RenderList& renderer,
const Mesh& mesh,
const QShader& v,
const QShader& f,
369 std::span<QRhiShaderResourceBinding> additionalBindings = {});
371 void init(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
373 void initState(
RenderList& renderer, QRhiResourceUpdateBatch& res)
override;
374 void releaseState(
RenderList& renderer)
override;
376 RenderList& renderer,
Edge& edge, QRhiResourceUpdateBatch& res)
override;
378 bool hasOutputPassForEdge(
Edge& edge)
const override;
380 void defaultUBOUpdate(
RenderList& renderer, QRhiResourceUpdateBatch& res);
381 void defaultMeshUpdate(
RenderList& renderer, QRhiResourceUpdateBatch& res);
382 void update(
RenderList& renderer, QRhiResourceUpdateBatch& res,
Edge* edge)
override;
387 void defaultRenderPass(
390 void defaultRenderPass(
394 void runRenderPass(
RenderList&, QRhiCommandBuffer& commands,
Edge& edge)
override;
396 void updateInputTexture(
const Port& input, QRhiTexture* tex, QRhiTexture* depthTex =
nullptr)
override;
Generic renderer.
Definition NodeRenderer.hpp:317
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:228
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:223
ossia::small_flat_map< PortSourceKey, ossia::scene_spec, 4 > m_portScenes
Per-(port, source) scene storage. See m_portGeometries comment.
Definition NodeRenderer.hpp:213
ossia::scene_spec scene
The scene to use (when receiving scene_spec data).
Definition NodeRenderer.hpp:210
ossia::geometry_spec geometry
The geometry to use.
Definition NodeRenderer.hpp:193
std::pair< int32_t, const void * > PortSourceKey
Definition NodeRenderer.hpp:200
ossia::small_flat_map< PortSourceKey, std::pair< ossia::geometry_spec, ossia::scene_spec >, 4 > m_wrapCache
Definition NodeRenderer.hpp:233
void syncRenderTargetIndex()
Definition NodeRenderer.hpp:130
virtual QRhiGraphicsPipeline::CompareOp depthCompare() const noexcept
The depth compare this renderer's pipeline was built with.
Definition NodeRenderer.hpp:56
void forEachSceneOnPort(int32_t port, F &&fn) const
Definition NodeRenderer.hpp:167
const ossia::geometry_spec * findGeometryByPort(int32_t port) const
Definition NodeRenderer.hpp:152
List of nodes to be rendered to an output.
Definition RenderList.hpp:33
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:776
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:198
Definition VertexFallbackPlan.hpp:27
Data model for meshes.
Definition Mesh.hpp:179
Definition NodeRenderer.hpp:251
Useful abstraction for storing a graphics pipeline and associated resource bindings.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:227
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:177
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:247