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

List of nodes to be rendered to an output. More...

Detailed Description

List of nodes to be rendered to an output.

This references all the score::gfx::Node that have an effect on a given output, and manages all the matching renderers, as well as a few shared data, such as output-specific UBOs, shared textures and buffers, etc.

The score::gfx::Graph creates one RenderList per OutputNode in the graph.

Public Types

using Buffers = std::pair< const Mesh *const, MeshBuffers >
 

Public Member Functions

 RenderList (OutputNode &output, const std::shared_ptr< RenderState > &state)
 
void init ()
 Initialize data for this renderer.
 
QRhiResourceUpdateBatch * initialBatch () const noexcept
 Initial resource update batch.
 
void setInitialBatch (QRhiResourceUpdateBatch *batch) noexcept
 Store a resource update batch to be submitted on the next render frame.
 
void flushInitialBatch ()
 Submit the pending initial batch before destroying resources it may name.
 
MeshBuffers initMeshBuffer (const Mesh &mesh, QRhiResourceUpdateBatch &res)
 Create buffers for a mesh and mark them for upload.
 
void update (QRhiResourceUpdateBatch &res)
 Update / upload this RenderList's shared data.
 
void render (QRhiCommandBuffer &commands, bool force=false)
 Render every node in order.
 
QRhiCommandBuffer * currentCommandBuffer () const noexcept
 
void release ()
 Release GPU resources owned by this render list.
 
void releaseBuffer (QRhiBuffer *buf)
 
bool maybeRebuild (bool force=false)
 Check if the render size has changed in order to rebuild the pipelines.
 
bool resizeSwapchainSizedTargets (QSize newOutputSize, QSize newRenderSize)
 Fast-path for pure viewport resize.
 
TextureRenderTarget renderTargetForOutput (const Edge &edge) const noexcept
 Obtain the texture corresponding to an output port.
 
TextureRenderTarget renderTargetForInputPort (const Port &p) const noexcept
 Look up the render target for a given input port.
 
BufferView bufferForInput (const Edge &edge) const noexcept
 
BufferView bufferForOutput (const Edge &edge) const noexcept
 
QImage adaptImage (const QImage &in)
 Adapts an image to the GPU limits / format.
 
Buffers acquireMesh (const ossia::geometry_spec &, QRhiResourceUpdateBatch &res, const Mesh *current, MeshBuffers currentbufs) noexcept
 
void clearRenderers ()
 Clear the renderers so that they get reinitialized on the next frame.
 
QRhiTexture & emptyTexture () const noexcept
 Texture to use when a texture is missing (2D)
 
QRhiTexture & emptyTexture3D () const noexcept
 Texture to use when a 3D (sampler3D) texture is missing.
 
QRhiTexture & emptyTextureCube () const noexcept
 Texture to use when a cubemap (samplerCube) is missing.
 
QRhiTexture & emptyTextureArray () const noexcept
 Texture to use when a 2D array (sampler2DArray) is missing.
 
QRhiBuffer & outputUBO () const noexcept
 UBO corresponding to the output parameters:
 
GpuResourceRegistryregistry () noexcept
 Per-output GPU arena store for scene-graph source nodes.
 
const GpuResourceRegistryregistry () const noexcept
 
VertexFallbackPoolvertexFallbackPool () noexcept
 Per-RenderList pool of neutral fallback vertex buffers for "REQUIRED: false" VERTEX_INPUTS whose upstream geometry does not provide a matching attribute.
 
GpuTimingsgpuTimings () noexcept
 Per-RenderList GPU-timing collector.
 
const GpuTimingsgpuTimings () const noexcept
 
Gfx::AssetTableassetTable () const noexcept
 Session-wide asset decode cache.
 
void setAssetTable (Gfx::AssetTable *t) noexcept
 
const score::gfx::MeshdefaultQuad () const noexcept
 A quad mesh correct for this API.
 
const score::gfx::MeshdefaultTriangle () const noexcept
 A triangle mesh correct for this API.
 
bool requiresDepth (const score::gfx::Port &p) const noexcept
 Whether this list of rendering actions requires depth testing at all.
 
bool anyNodeRequiresDepth () const noexcept
 
int samples () const noexcept
 
bool canRender () const noexcept
 
QSize renderSize (const Edge *e) const noexcept
 
void createAllInputRenderTargets ()
 
void markBuilt () noexcept
 Mark this render list as fully built.
 
bool isBuilt () const noexcept
 Is this render list currently coherent with its output's GPU objects?
 
void markRequiresDepth (bool value) noexcept
 
void onEdgeRemoved (Edge &edge, const ossia::hash_set< const Port * > *preserveSinks=nullptr)
 
void removeInputRenderTarget (const Port *port)
 Remove the render target for a specific input port.
 
QSize resolveDownstreamSize (const Node *node, const ossia::small_flat_map< const Port *, RenderTargetSpecs, 16 > &resolvedSpecs) const noexcept
 Resolve the downstream render target size for a node.
 

Public Attributes

OutputNodeoutput
 Output node to which this RenderList is rendering to.
 
RenderStatestate
 RenderState corresponding to this RenderList.
 
std::vector< score::gfx::Node * > nodes
 Nodes present in this RenderList, in order.
 
std::vector< score::gfx::NodeRenderer * > renderers
 Renderers - one per node.
 
int64_t frame = 0
 
float currentDate [4] {}
 

Friends

struct Graph
 

Member Function Documentation

◆ adaptImage()

QImage score::gfx::RenderList::adaptImage ( const QImage &  in)

Adapts an image to the GPU limits / format.

e.g. Y direction, texture size limits...

◆ assetTable()

Gfx::AssetTable * score::gfx::RenderList::assetTable ( ) const
inlinenoexcept

Session-wide asset decode cache.

Set by Graph::createRenderList from GfxContext's AssetTable. May be null on test RenderLists or after teardown. Consumers must guard.

◆ currentCommandBuffer()

QRhiCommandBuffer * score::gfx::RenderList::currentCommandBuffer ( ) const
inlinenoexcept

The command buffer render() is currently recording into, or null outside a frame. Strategies that must record raw-API commands (the Vulkan host-import upload) need it at update() time, where only the resource batch is passed.

◆ flushInitialBatch()

void score::gfx::RenderList::flushInitialBatch ( )

Submit the pending initial batch before destroying resources it may name.

A QRhiResourceUpdateBatch stores raw QRhiBuffer / QRhiTexture pointers until it is committed, and QRhiResource::deleteLater() outside a frame deletes immediately. Graph mutations run between frames, so any path that tears down renderer resources while this batch is outstanding must call this first; otherwise the next render() submits updates naming freed resources.

◆ gpuTimings()

GpuTimings & score::gfx::RenderList::gpuTimings ( )
inlinenoexcept

Per-RenderList GPU-timing collector.

Renderers wrap their begin/endPass regions in ScopedGpuTimer to attribute the CB-wide lastCompletedGpuTime to the named pass. The result is one frame stale — see GpuTiming.hpp for details.

◆ initialBatch()

QRhiResourceUpdateBatch * score::gfx::RenderList::initialBatch ( ) const
noexcept

Initial resource update batch.

See QRhiResourceUpdateBatch::merge for documentation on this

◆ initMeshBuffer()

MeshBuffers score::gfx::RenderList::initMeshBuffer ( const Mesh mesh,
QRhiResourceUpdateBatch &  res 
)

Create buffers for a mesh and mark them for upload.

The meshes used by the nodes are cached (as most are just rendering on a full-screen triangle, which we can reuse).

◆ isBuilt()

bool score::gfx::RenderList::isBuilt ( ) const
inlinenoexcept

Is this render list currently coherent with its output's GPU objects?

False between the moment something invalidates the list (a fast-path viewport resize: resizeSwapchainSizedTargets) and the maybeRebuild() that runs on the next render frame. In that window the output node has ALREADY destroyed and replaced its QRhiTextureRenderTarget / QRhiRenderPassDescriptor while the renderers still hold the pre-resize snapshot, so nothing outside the rebuild may ask a renderer for a render target.

◆ markBuilt()

void score::gfx::RenderList::markBuilt ( )
inlinenoexcept

Mark this render list as fully built.

Prevents maybeRebuild() from unnecessarily tearing down and recreating all resources on the first render frame after createRenderList() has already fully initialized everything.

◆ markRequiresDepth()

void score::gfx::RenderList::markRequiresDepth ( bool  value)
inlinenoexcept

Set the "any node requires depth" flag computed from the node graph. Mirrors what maybeRebuild() recomputes; called from Graph::createRenderList so the freshly-built RL doesn't need a first-frame maybeRebuild to populate it.

◆ onEdgeRemoved()

void score::gfx::RenderList::onEdgeRemoved ( Edge edge,
const ossia::hash_set< const Port * > *  preserveSinks = nullptr 
)

Notify that an edge was removed. Notifies renderers, releases RT if unused.

Parameters
preserveSinksOptional set of sink Ports that should keep their input render target even if this edge was their only feed. Used by batched edge updates (see GfxContext::incrementalEdgeUpdate) so that inserting a filter between two nodes doesn't destroy and immediately re-allocate the same RT when the old and new edges share a sink port.

◆ outputUBO()

QRhiBuffer & score::gfx::RenderList::outputUBO ( ) const
inlinenoexcept

UBO corresponding to the output parameters:

  • Render size
  • Per-API adjustments and globals

◆ registry()

GpuResourceRegistry & score::gfx::RenderList::registry ( )
inlinenoexcept

Per-output GPU arena store for scene-graph source nodes.

Returns a reference to the registry that owns the Camera / Light / Material / PerDraw arena buffers. Source nodes (Camera, Light, PBRMesh, …) allocate a slot from this registry at construction and write their packed bytes into it at their own update().

Persist-across-rebuild contract: the registry is owned by the OutputNode (OutputNode::m_registry) and survives RenderList rebuilds — the same registry pointer is observed by both the pre- and post-rebuild RenderList for a given OutputNode. Consumers that cache the registry pointer (e.g. ScenePreprocessor's m_registry) can compare it against the new RL's registry on init() and skip the cache wipe when it is unchanged.

Valid between init() and release().

◆ renderTargetForInputPort()

TextureRenderTarget score::gfx::RenderList::renderTargetForInputPort ( const Port p) const
noexcept

Look up the render target for a given input port.

All input render targets are created centrally before any node init() so that they are available regardless of initialization order.

◆ renderTargetForOutput()

TextureRenderTarget score::gfx::RenderList::renderTargetForOutput ( const Edge edge) const
noexcept

Obtain the texture corresponding to an output port.

This is done by looking for the render target which corresponds to a given port.

◆ requiresDepth()

bool score::gfx::RenderList::requiresDepth ( const score::gfx::Port p) const
noexcept

Whether this list of rendering actions requires depth testing at all.

e.g. it's not needed if we're just doing some generative shaders.

◆ resizeSwapchainSizedTargets()

bool score::gfx::RenderList::resizeSwapchainSizedTargets ( QSize  newOutputSize,
QSize  newRenderSize 
)

Fast-path for pure viewport resize.

Update state.outputSize to newOutputSize and state.renderSize to newRenderSize, and mark every renderer's renderTargetSpecsChanged so the rt_changed block in renderInternal does the RT recreation and sampler rebinding on the next render frame.

The two sizes are distinct: the output node owns the render size (the /rendersize override, ScreenNode::setRenderSize), the platform owns the output size (the swapchain). Callers pass both from the RenderState the output node has already updated.

Skips the full recreateOutputRenderList teardown + rebuild (pipeline compiles, ScenePreprocessor rebuild, mesh slab uploads, texture array reallocation): the persistent registry and ScenePreprocessor caches make that work unnecessary for a pure size change. Cost is O(N renderers), with no GPU drain and no allocation until the next frame's rt_changed block recreates the RTs.

Returns true on success. Returns false, and the caller must fall back to recreateOutputRenderList, when:

  • either size is invalid
  • renderers vector is empty (RL not yet initialised)

◆ resolveDownstreamSize()

QSize score::gfx::RenderList::resolveDownstreamSize ( const Node node,
const ossia::small_flat_map< const Port *, RenderTargetSpecs, 16 > &  resolvedSpecs 
) const
noexcept

Resolve the downstream render target size for a node.

Returns the maximum size across all downstream render targets that this node renders to. Used as fallback when a node's input port has no explicit render target size.

◆ setInitialBatch()

void score::gfx::RenderList::setInitialBatch ( QRhiResourceUpdateBatch *  batch)
inlinenoexcept

Store a resource update batch to be submitted on the next render frame.

Used by incremental edge additions that happen after the first render frame (when the original m_initialBatch has already been consumed).

◆ vertexFallbackPool()

VertexFallbackPool & score::gfx::RenderList::vertexFallbackPool ( )
inlinenoexcept

Per-RenderList pool of neutral fallback vertex buffers for "REQUIRED: false" VERTEX_INPUTS whose upstream geometry does not provide a matching attribute.

Valid between init() and release(). See VertexFallbackPool.hpp.


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