Skip to main content

RenderPassFactory Class

Factory for constructing `RenderPass` objects from scene snapshots. More...

Declaration

class helios::rendering::RenderPassFactory { ... }

Public Member Functions Index

RenderPassbuildRenderPass (const helios::scene::Snapshot &snapshot) const

Builds a `RenderPass` from a given `Snapshot`. More...

voidpopulateRenderQueue (const helios::scene::Snapshot &snapshot, helios::rendering::RenderQueue &renderQueue) const

Populates an existing `RenderQueue` with render commands based on a `Snapshot`. More...

voidmakeRenderCommand (const helios::scene::SnapshotItem &snapshotItem, helios::rendering::RenderQueue &renderQueue) const noexcept

Emits render commands from a `SnapshotItem` to the render queue. More...

Public Static Functions Index

static RenderPassFactory &getInstance ()

Returns the singleton instance of `RenderPassFactory`. More...

Protected Static Attributes Index

static const helios::util::log::Logger &logger_ = ...

Shared logger instance for all RenderPassFactory objects. More...

Description

Factory for constructing `RenderPass` objects from scene snapshots.

`RenderPassFactory` transforms high-level scene data (`Snapshot` and `SnapshotItem`) into low-level rendering commands suitable for the rendering device. It creates `RenderPass` objects with populated `RenderQueue`s and configured frame uniforms.

## Responsibilities

  • Build `RenderPass` objects from `Snapshot` data.
  • Populate `RenderQueue` with `MeshRenderCommand` and `TextRenderCommand` objects.
  • Configure frame-level uniforms (view/projection matrices).

## Usage

```cpp auto& factory = RenderPassFactory::getInstance(); auto snapshot = sceneGraph.createSnapshot(viewport); auto renderPass = factory.buildRenderPass(snapshot);

device.beginRenderPass(renderPass); device.doRender(renderPass); device.endRenderPass(renderPass); ```

info

This class implements a singleton pattern. In the future, the conversion of high-level scene data into lower-level rendering commands might be realized with strategies and/or separate factories.

See Also

RenderPass

See Also

Snapshot

See Also

SnapshotItem

See Also

RenderQueue

Definition at line 61 of file RenderPassFactory.ixx.

Public Member Functions

buildRenderPass()

RenderPass helios::rendering::RenderPassFactory::buildRenderPass (const helios::scene::Snapshot & snapshot)
inline nodiscard

Builds a `RenderPass` from a given `Snapshot`.

This method orchestrates the creation of a `RenderQueue` and populates it with render commands derived from the `SnapshotItem`s within the snapshot. It also sets up frame-specific uniform values (view and projection matrices) for the `RenderPass`.

Parameters
snapshot

A const reference to the snapshot containing the scene data for which the `RenderPass` is to be built.

Returns

A fully constructed `RenderPass` object containing the render queue and frame-specific uniforms.

See Also

populateRenderQueue()

Definition at line 99 of file RenderPassFactory.ixx.

99 [[nodiscard]] RenderPass buildRenderPass(const helios::scene::Snapshot& snapshot) const {
100
101 auto renderQueue = RenderQueue();
102
103 populateRenderQueue(snapshot, renderQueue);
104
105 const auto& projectionMatrix = snapshot.projectionMatrix();
106 const auto& viewMatrix = snapshot.viewMatrix();
107
108 auto frameUniformValues = helios::rendering::shader::UniformValueMap();
109 frameUniformValues.set(helios::rendering::shader::UniformSemantics::ProjectionMatrix, projectionMatrix);
110 frameUniformValues.set(helios::rendering::shader::UniformSemantics::ViewMatrix, viewMatrix);
111
112 return RenderPass(
113 &snapshot.viewport(),
114 std::move(renderQueue),
115 frameUniformValues
116 );
117 }

References populateRenderQueue, helios::rendering::shader::ProjectionMatrix, helios::scene::Snapshot::projectionMatrix, helios::rendering::shader::ViewMatrix, helios::scene::Snapshot::viewMatrix and helios::scene::Snapshot::viewport.

Referenced by helios::engine::modules::scene::systems::SceneRenderingSystem::update.

makeRenderCommand()

void helios::rendering::RenderPassFactory::makeRenderCommand (const helios::scene::SnapshotItem & snapshotItem, helios::rendering::RenderQueue & renderQueue)
inline noexcept

Emits render commands from a `SnapshotItem` to the render queue.

This method extracts necessary data from the `SnapshotItem`, sets up the object uniform values (e.g., model matrix), and delegates to the `Renderable` to emit its render commands to the queue.

Parameters
snapshotItem

A const reference to the `SnapshotItem` from which to create render commands.

renderQueue

A reference to the `RenderQueue` to emit commands to.

info

If the `Renderable` pointer in the `SnapshotItem` is `nullptr`, a warning is logged and no commands are emitted.

Definition at line 158 of file RenderPassFactory.ixx.

159 const helios::scene::SnapshotItem& snapshotItem,
160 helios::rendering::RenderQueue& renderQueue) const noexcept {
161
162 const auto* renderable = snapshotItem.renderable();
163
164 if (renderable == nullptr) {
165 logger_.warn("Renderable no longer available");
166 return;
167 }
168
169 auto objectUniformValues = helios::rendering::shader::UniformValueMap();
170 auto materialUniformValues = helios::rendering::shader::UniformValueMap();
171 objectUniformValues.set(
173 snapshotItem.worldMatrix()
174 );
175
176 renderable->emit(
177 renderQueue,
178 objectUniformValues,
179 materialUniformValues
180 );
181
182 }

References logger_ and helios::rendering::shader::ModelMatrix.

Referenced by populateRenderQueue.

populateRenderQueue()

void helios::rendering::RenderPassFactory::populateRenderQueue (const helios::scene::Snapshot & snapshot, helios::rendering::RenderQueue & renderQueue)
inline

Populates an existing `RenderQueue` with render commands based on a `Snapshot`.

This method clears the specified `RenderQueue` before adding new commands. Each `SnapshotItem` in the snapshot is processed via `makeRenderCommand()`.

Parameters
snapshot

A const reference to the `Snapshot` providing scene data.

renderQueue

A reference to the `RenderQueue` to be filled. This queue will be cleared before new commands are added.

See Also

makeRenderCommand()

Definition at line 131 of file RenderPassFactory.ixx.

132 const helios::scene::Snapshot& snapshot, helios::rendering::RenderQueue& renderQueue) const {
133
134 // clear the queue
135 renderQueue.clear();
136
137 auto snapshotItems = snapshot.snapshotItems();
138
139 for (const auto& item : snapshotItems) {
140 makeRenderCommand(item, renderQueue);
141 }
142 }

References helios::rendering::RenderQueue::clear, makeRenderCommand and helios::scene::Snapshot::snapshotItems.

Referenced by buildRenderPass.

Public Static Functions

getInstance()

RenderPassFactory & helios::rendering::RenderPassFactory::getInstance ()
inline static

Returns the singleton instance of `RenderPassFactory`.

Returns

A reference to the single `RenderPassFactory` instance.

Definition at line 77 of file RenderPassFactory.ixx.

78 static RenderPassFactory instance;
79
80 return instance;
81 }

Referenced by helios::engine::modules::scene::systems::SceneRenderingSystem::update.

Protected Static Attributes

logger_

const helios::util::log::Logger& helios::rendering::RenderPassFactory::logger_
protected static

Shared logger instance for all RenderPassFactory objects.

Initialiser

Definition at line 67 of file RenderPassFactory.ixx.

Referenced by makeRenderCommand.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.