Loading...
Searching...
No Matches
score::gfx::GenericNodeRenderer Class Reference

Generic renderer. More...

Inheritance diagram for score::gfx::GenericNodeRenderer:
score::gfx::NodeRenderer score::gfx::GaussianSplatRenderer score::gfx::ImagesNode::PreloadedRenderer score::gfx::TexgenNode::Rendered score::gfx::TextNode::Renderer score::gfx::TouchHistoryRenderer

Detailed Description

Generic renderer.

Used for the common case of a single pass node with a vertex & fragment shader, samplers, and a single render target.

Public Member Functions

 GenericNodeRenderer (const NodeModel &node) noexcept
 
score::gfx::Port * imageOutlet () const noexcept
 The node's first Image outlet, or nullptr. Not always output[0].
 
virtual std::span< const Sampler > samplersForOutputEdge (const Edge &edge) const noexcept
 
const Mesh * currentMesh () const noexcept override
 
void defaultMeshInit (RenderList &renderer, const Mesh &mesh, QRhiResourceUpdateBatch &res)
 
void processUBOInit (RenderList &renderer)
 
void defaultPassesInit (RenderList &renderer, const Mesh &mesh)
 
void defaultPassesInit (RenderList &renderer, const Mesh &mesh, const QShader &v, const QShader &f, std::span< QRhiShaderResourceBinding > additionalBindings={})
 
void init (RenderList &renderer, QRhiResourceUpdateBatch &res) override
 
void initState (RenderList &renderer, QRhiResourceUpdateBatch &res) override
 
void releaseState (RenderList &renderer) override
 
void addOutputPass (RenderList &renderer, Edge &edge, QRhiResourceUpdateBatch &res) override
 Create a pass for a new output edge (pipeline, SRB, processUBO).
 
void removeOutputPass (RenderList &renderer, Edge &edge) override
 
bool hasOutputPassForEdge (Edge &edge) const override
 Check if this renderer already has an output pass for the given edge.
 
void defaultUBOUpdate (RenderList &renderer, QRhiResourceUpdateBatch &res)
 
void defaultMeshUpdate (RenderList &renderer, QRhiResourceUpdateBatch &res)
 
void update (RenderList &renderer, QRhiResourceUpdateBatch &res, Edge *edge) override
 
void defaultRelease (RenderList &)
 
void release (RenderList &) override
 
void defaultRenderPass (RenderList &, const Mesh &mesh, QRhiCommandBuffer &commands, Edge &edge)
 
void defaultRenderPass (RenderList &, const Mesh &mesh, QRhiCommandBuffer &commands, Edge &edge, PassMap &passes)
 
void runRenderPass (RenderList &, QRhiCommandBuffer &commands, Edge &edge) override
 
void updateInputTexture (const Port &input, QRhiTexture *tex, QRhiTexture *depthTex=nullptr) override
 
- Public Member Functions inherited from score::gfx::NodeRenderer
 NodeRenderer (const Node &node)
 
virtual TextureRenderTarget renderTargetForInput (const Port &input)
 
virtual BufferView bufferForInput (const Port &input)
 
virtual BufferView bufferForOutput (const Port &output)
 
virtual QRhiTexture * textureForOutput (const Port &output)
 
virtual void updateInputSamplerFilter (const Port &input, const RenderTargetSpecs &spec)
 
virtual void inputAboutToFinish (RenderList &renderer, const Port &p, QRhiResourceUpdateBatch *&)
 
virtual void runInitialPasses (RenderList &, QRhiCommandBuffer &commands, QRhiResourceUpdateBatch *&res, Edge &edge)
 
virtual QRhiGraphicsPipeline::CompareOp depthCompare () const noexcept
 The depth compare this renderer's pipeline was built with.
 
void checkForChanges ()
 
void syncRenderTargetIndex ()
 
void process (int32_t port, const ossia::geometry_spec &v)
 
void process (int32_t port, const ossia::scene_spec &v)
 
virtual void process (int32_t port, const ossia::transform3d &v)
 
void process (int32_t port, const ossia::geometry_spec &v, const void *source_key)
 
void process (int32_t port, const ossia::scene_spec &v, const void *source_key)
 
const ossia::geometry_spec * findGeometryByPort (int32_t port) const
 
template<typename F >
void forEachSceneOnPort (int32_t port, F &&fn) const
 
virtual void addInputEdge (RenderList &renderer, Edge &edge, QRhiResourceUpdateBatch &res)
 
virtual void removeInputEdge (RenderList &renderer, Edge &edge)
 Notify the renderer that an input edge was disconnected.
 
virtual void seedInitialOutputs (RenderList &renderer)
 
virtual bool followsRenderSize () const noexcept
 

Public Attributes

ossia::small_vector< Sampler, 8 > m_samplers
 
QShader m_vertexS
 
QShader m_fragmentS
 
bool m_outputPremultiplied {false}
 
PassMap m_p
 
ossia::small_vector< std::pair< QVector< quint32 >, QRhiGraphicsPipeline * >, 2 > m_pipelineCache
 
FallbackBindingPlan m_pipelinePlan
 
MeshBuffers m_meshbufs
 
QRhiBuffer * m_processUBO {}
 
DefaultShaderMaterial m_material
 
const score::gfx::Mesh * m_mesh {}
 
const score::gfx::Mesh * m_initMesh {}
 What defaultMeshInit set up: drawn again once the geometry input goes.
 
- Public Attributes inherited from score::gfx::NodeRenderer
const Node & node
 
ossia::geometry_spec geometry
 The geometry to use.
 
ossia::small_flat_map< PortSourceKey, ossia::geometry_spec, 4 > m_portGeometries
 
ossia::scene_spec scene
 The scene to use (when receiving scene_spec data).
 
ossia::small_flat_map< PortSourceKey, ossia::scene_spec, 4 > m_portScenes
 Per-(port, source) scene storage. See m_portGeometries comment.
 
ossia::small_vector< MergeCacheKey, 4 > m_mergeCacheInputs
 
ossia::scene_spec m_mergeCacheOutput
 
ossia::small_flat_map< PortSourceKey, std::pair< ossia::geometry_spec, ossia::scene_spec >, 4 > m_wrapCache
 
int32_t nodeId {-1}
 
bool materialChanged {false}
 
bool geometryChanged {false}
 
bool sceneChanged {false}
 
bool renderTargetSpecsChanged {false}
 
bool m_initialized {false}
 

Additional Inherited Members

- Public Types inherited from score::gfx::NodeRenderer
using PortSourceKey = std::pair< int32_t, const void * >
 
using MergeCacheKey = std::pair< const ossia::scene_state *, int64_t >
 

Member Function Documentation

◆ addOutputPass()

void score::gfx::GenericNodeRenderer::addOutputPass ( RenderList &  renderer,
Edge &  edge,
QRhiResourceUpdateBatch &  res 
)
overridevirtual

Create a pass for a new output edge (pipeline, SRB, processUBO).

Reimplemented from score::gfx::NodeRenderer.

◆ currentMesh()

const Mesh * score::gfx::GenericNodeRenderer::currentMesh ( ) const
inlineoverridevirtualnoexcept

The mesh this renderer draws when it came from RenderList::acquireMesh; the mesh cache keeps it alive while any renderer still points at it.

Reimplemented from score::gfx::NodeRenderer.

◆ hasOutputPassForEdge()

bool score::gfx::GenericNodeRenderer::hasOutputPassForEdge ( Edge &  edge) const
overridevirtual

Check if this renderer already has an output pass for the given edge.

Reimplemented from score::gfx::NodeRenderer.

◆ init()

void score::gfx::GenericNodeRenderer::init ( RenderList &  renderer,
QRhiResourceUpdateBatch &  res 
)
overridevirtual

◆ initState()

void score::gfx::GenericNodeRenderer::initState ( RenderList &  renderer,
QRhiResourceUpdateBatch &  res 
)
overridevirtual

Initialize edge-independent state: material UBO, samplers, mesh, shaders. Called once when the renderer enters a RenderList.

Reimplemented from score::gfx::NodeRenderer.

Reimplemented in score::gfx::TexgenNode::Rendered, and score::gfx::TouchHistoryRenderer.

◆ release()

void score::gfx::GenericNodeRenderer::release ( RenderList &  r)
overridevirtual

◆ releaseState()

void score::gfx::GenericNodeRenderer::releaseState ( RenderList &  renderer)
overridevirtual

Release edge-independent state. Called once when the renderer leaves a RenderList.

Reimplemented from score::gfx::NodeRenderer.

Reimplemented in score::gfx::TexgenNode::Rendered, and score::gfx::TouchHistoryRenderer.

◆ removeOutputPass()

void score::gfx::GenericNodeRenderer::removeOutputPass ( RenderList &  renderer,
Edge &  edge 
)
overridevirtual

Remove the pass for a removed output edge. Pure-virtual: every concrete renderer must explicitly handle edge removal. Sinks (OutputNodeRenderer) and data-only renderers that store no per-edge GPU state can override with an empty body.

Implements score::gfx::NodeRenderer.

◆ runRenderPass()

void score::gfx::GenericNodeRenderer::runRenderPass ( RenderList &  renderer,
QRhiCommandBuffer &  commands,
Edge &  edge 
)
overridevirtual

Reimplemented from score::gfx::NodeRenderer.

◆ samplersForOutputEdge()

virtual std::span< const Sampler > score::gfx::GenericNodeRenderer::samplersForOutputEdge ( const Edge &  edge) const
inlinevirtualnoexcept

Samplers bound by the pass that draws edge. Every sampler of the node by default. A renderer whose outlets each carry their own texture (avnd CPU texture outputs: one sampler per outlet) returns only the sampler of the outlet the edge leaves from; otherwise every outlet would draw whatever sits at binding 3, i.e. the first one.

◆ update()

void score::gfx::GenericNodeRenderer::update ( RenderList &  renderer,
QRhiResourceUpdateBatch &  res,
Edge *  edge 
)
overridevirtual

◆ updateInputTexture()

void score::gfx::GenericNodeRenderer::updateInputTexture ( const Port &  input,
QRhiTexture *  tex,
QRhiTexture *  depthTex = nullptr 
)
overridevirtual

Updates the sampler texture for an input port. Called when the upstream texture may have changed (edge add, RT recreation). If the port has SamplableDepth and depthTex is non-null, the depth sampler (immediately after the color sampler) is also updated.

Reimplemented from score::gfx::NodeRenderer.

Member Data Documentation

◆ m_outputPremultiplied

bool score::gfx::GenericNodeRenderer::m_outputPremultiplied {false}

What the fragment shader writes into the consumers' targets: straight colour (decoded images, video, CPU textures) is composited with the straight "over", premultiplied colour (a copy of a render target) with the premultiplied one.


The documentation for this class was generated from the following files: