Skip to main content

Pass Class

Abstract base class for game loop passes. More...

Declaration

class helios::engine::runtime::gameloop::Pass { ... }

Derived Classes

classTypedPass<StateType>

State-filtered pass that only executes in specific states. More...

Public Constructors Index

Pass (GameWorld &gameWorld)

Constructs a pass bound to a specific GameWorld. More...

Public Destructor Index

~Pass ()=default

Public Member Functions Index

voidupdate (helios::engine::runtime::world::UpdateContext &updateContext)=0

Updates all systems in this pass. More...

voidinit (helios::engine::runtime::world::GameWorld &gameWorld)=0

Initializes all systems in this pass. More...

Phase &endPass ()=0

Ends this pass. More...

boolshouldRun (helios::engine::runtime::world::UpdateContext &updateContext) const noexcept=0

Determines if this pass should execute. More...

template <typename T, typename... Args>
Pass &addSystem (Args &&... args)

Adds a system of type T to this pass. More...

template <typename ... TSystem>
Pass &addParallelSystems ()

Adds TypedSystem-like systems that should be executed parallel. More...

template <typename ... TSystem>
Pass &addParallelSystems (TSystem &&... system)

Adds two or more TypedSystemSpec-wrapped systems that may execute in parallel. More...

template <typename TSystem>
Pass &addSystem (TSystem &&system)

Adds a system of type TSystem to this pass. More...

template <typename ... TSystem>
Pass &addParallelSystems (TSystem &&... system)

Adds multiple systems to this pass, allowing for parallel execution. More...

template <typename... T>
Pass &flush ()

Registers the Managers this pass should flush. More...

template <typename TManager>
Pass &flushParallel ()

Register the Manager this pass should flush in parallel. More...

std::span< const ManagerTypeId >managerTypeIds () noexcept

Returns a span of the ManagerTypeIds this pass is flushing. More...

std::span< const ManagerTypeId >parallelManagerTypeIds () noexcept

Returns a span of the ManagerTypeIds this pass is flushing in parallel. More...

Protected Member Functions Index

template <typename T>
voidregisterManagerFlush ()

Registers the ManagerTypeIds for the Managers this pass should flush. More...

template <typename T>
voidregisterManagerParallelFlush ()

Registers the ManagerTypeIds for the Managers this pass should flush in parallel. More...

template <typename TSystem>
Pass &registerCallableSystem (TSystem &&system, const bool isParallel=false)

Registers a callable system for this pass. More...

template <typename T, typename... Args>
Pass &registerParallelTypedSystem (Args &&... args)
template <typename T, typename... Args>
Pass &registerTypedSystem (Args &&... args)

Registers a TypedSystem-like system with this pass. More...

template <typename T>
Pass &registerTypedSystemSpec (T &&spec)

Registers a system described by a TypedSystemSpec with this pass. More...

Protected Member Attributes Index

helios::engine::runtime::world::SystemRegistrysystemRegistry_ {}

Registry holding all systems for this pass. More...

std::vector< std::vector< SystemTypeId > >systemTypeIdQueue_

Queue of system type IDs for execution order. More...

GameWorld &gameWorld_

Reference to the owning GameWorld. More...

std::vector< ManagerTypeId >managerTypeIds_

List of ManagerTypeIds. More...

std::vector< ManagerTypeId >parallelManagerTypeIds_

List of ManagerTypeIds for parallel execution. More...

Description

Abstract base class for game loop passes.

A Pass represents a logical grouping of systems executed sequentially within a Phase. Concrete implementations (TypedPass) add state-based filtering via shouldRun().

Definition at line 55 of file Pass.ixx.

Public Constructors

Pass()

helios::engine::runtime::gameloop::Pass::Pass (GameWorld & gameWorld)
inline explicit

Constructs a pass bound to a specific GameWorld.

Parameters
gameWorld

GameWorld used for system initialization and command buffer lookup.

Definition at line 238 of file Pass.ixx.

238 explicit Pass(GameWorld& gameWorld) : gameWorld_(gameWorld) {};

Public Destructor

~Pass()

virtual helios::engine::runtime::gameloop::Pass::~Pass ()
virtual default

Definition at line 230 of file Pass.ixx.

Public Member Functions

addParallelSystems()

template <typename ... TSystem>
Pass & helios::engine::runtime::gameloop::Pass::addParallelSystems ()
inline

Adds TypedSystem-like systems that should be executed parallel.

Template Parameters
TSystem

The types of the systems to add.

Returns

Reference to this Pass for method chaining.

Definition at line 306 of file Pass.ixx.

307
309
310 auto& group = systemTypeIdQueue_.emplace_back();
311 group.reserve(sizeof...(TSystem));
312 (group.push_back({SystemTypeId::template id<TSystem>()}), ...);
313
314 return *this;
315 }

References helios::engine::runtime::registerComponents and systemTypeIdQueue_.

addParallelSystems()

template <typename ... TSystem>
Pass & helios::engine::runtime::gameloop::Pass::addParallelSystems (TSystem &&... system)
inline

Adds two or more TypedSystemSpec-wrapped systems that may execute in parallel.

Each spec is unpacked via registerTypedSystemSpec() and all resulting system type IDs are placed in a single execution group, signalling to the scheduler that the systems are independent and can run concurrently.

Template Parameters
TSystem

TypedSystemSpec specialisations whose System_type satisfies IsTypedSystemLike. At least two types are required.

Parameters
system

Spec instances forwarded to registerTypedSystemSpec().

Returns

Reference to this pass for method chaining.

Definition at line 341 of file Pass.ixx.

342
343 (registerParallelTypedSystemSpec<TSystem>(std::forward<TSystem>(system)), ...);
344
345 auto& group = systemTypeIdQueue_.emplace_back();
346 group.reserve(sizeof...(TSystem));
347 (group.push_back({SystemTypeId::template id<typename std::remove_cvref_t<TSystem>::System_type>()}), ...);
348
349 return *this;
350 }

References helios::engine::runtime::registerComponents and systemTypeIdQueue_.

addParallelSystems()

template <typename ... TSystem>
Pass & helios::engine::runtime::gameloop::Pass::addParallelSystems (TSystem &&... system)
inline

Adds multiple systems to this pass, allowing for parallel execution.

Template Parameters
TSystem

The types of the systems to add.

Parameters
system

The system instances to add.

Returns

Reference to this pass.

Definition at line 383 of file Pass.ixx.

384
385 (registerCallableSystem(std::forward<TSystem>(system), true), ...);
386
387 auto& group = systemTypeIdQueue_.emplace_back();
388 group.reserve(sizeof...(TSystem));
389 (group.push_back({SystemTypeId::template id<std::remove_cvref_t<TSystem>>()}), ...);
390
391 return *this;
392 }

References registerCallableSystem, helios::engine::runtime::registerComponents and systemTypeIdQueue_.

addSystem()

template <typename T, typename... Args>
Pass & helios::engine::runtime::gameloop::Pass::addSystem (Args &&... args)
inline

Adds a system of type T to this pass.

Template Parameters
T

The system type to add.

Args

Constructor argument types for the system.

Parameters
args

Arguments forwarded to the system constructor.

If T defines CommandBuffer_type, the buffer is resolved from the bound GameWorld and injected into the wrapped helios::engine::runtime::world::System.

Returns

Reference to this Pass for method chaining.

Definition at line 287 of file Pass.ixx.

287 Pass& addSystem(Args&&... args) {
288
289 registerTypedSystem<T>(std::forward<Args>(args)...);
290
291 systemTypeIdQueue_.push_back({SystemTypeId::template id<T>()});
292
293 return *this;
294 }

References helios::engine::runtime::registerComponents and systemTypeIdQueue_.

addSystem()

template <typename TSystem>
Pass & helios::engine::runtime::gameloop::Pass::addSystem (TSystem && system)
inline

Adds a system of type TSystem to this pass.

Template Parameters
TSystem

The system type to add.

Parameters
system

System forwarded to the system constructor.

If TSystem defines CommandBuffer_type, the buffer is resolved from the bound GameWorld and injected into the wrapped helios::engine::runtime::world::System.

Returns

Reference to this Pass for method chaining.

Definition at line 367 of file Pass.ixx.

368 registerCallableSystem(std::forward<TSystem>(system));
369 systemTypeIdQueue_.push_back({SystemTypeId::template id<TSystem>()});
370 return *this;
371 }

References registerCallableSystem, helios::engine::runtime::registerComponents and systemTypeIdQueue_.

endPass()

virtual Phase & helios::engine::runtime::gameloop::Pass::endPass ()

Ends this pass.

Returns

Reference to the owning phase.

Definition at line 259 of file Pass.ixx.

flush()

template <typename... T>
Pass & helios::engine::runtime::gameloop::Pass::flush ()
inline

Registers the Managers this pass should flush.

Template Parameters
T

The types of the Managers to flush.

Returns

Reference to this Pass for method chaining.

Definition at line 402 of file Pass.ixx.

403
405
406 return *this;
407 }

Reference helios::engine::runtime::registerComponents.

flushParallel()

template <typename TManager>
Pass & helios::engine::runtime::gameloop::Pass::flushParallel ()
inline

Register the Manager this pass should flush in parallel.

Template Parameters
TManager

The type of the Manager to flush in parallel.

Returns

Reference to this Pass for method chaining.

Definition at line 417 of file Pass.ixx.

418
420
421 return *this;
422 }

Reference helios::engine::runtime::registerComponents.

init()

virtual void helios::engine::runtime::gameloop::Pass::init (helios::engine::runtime::world::GameWorld & gameWorld)

Initializes all systems in this pass.

Parameters
gameWorld

Reference to the game world.

Definition at line 252 of file Pass.ixx.

managerTypeIds()

std::span< const ManagerTypeId > helios::engine::runtime::gameloop::Pass::managerTypeIds ()
inline noexcept

Returns a span of the ManagerTypeIds this pass is flushing.

Returns

A span of ManagerTypeIds.

Definition at line 429 of file Pass.ixx.

429 [[nodiscard]] std::span<const ManagerTypeId> managerTypeIds() noexcept {
430 return managerTypeIds_;
431 }

Reference managerTypeIds_.

parallelManagerTypeIds()

std::span< const ManagerTypeId > helios::engine::runtime::gameloop::Pass::parallelManagerTypeIds ()
inline noexcept

Returns a span of the ManagerTypeIds this pass is flushing in parallel.

Returns

A span of ManagerTypeIds.

Definition at line 438 of file Pass.ixx.

438 [[nodiscard]] std::span<const ManagerTypeId> parallelManagerTypeIds() noexcept {
440 }

Reference parallelManagerTypeIds_.

shouldRun()

virtual bool helios::engine::runtime::gameloop::Pass::shouldRun (helios::engine::runtime::world::UpdateContext & updateContext)
noexcept

Determines if this pass should execute.

Parameters
updateContext

The current update context.

Returns

True if the pass should run.

Definition at line 269 of file Pass.ixx.

update()

virtual void helios::engine::runtime::gameloop::Pass::update (helios::engine::runtime::world::UpdateContext & updateContext)

Updates all systems in this pass.

Parameters
updateContext

The current update context.

Definition at line 245 of file Pass.ixx.

Protected Member Functions

registerCallableSystem()

template <typename TSystem>
Pass & helios::engine::runtime::gameloop::Pass::registerCallableSystem (TSystem && system, const bool isParallel=false)
inline protected

Registers a callable system for this pass.

Template Parameters
TSystem

The type of the system to register.

Parameters
system

The system instance to register.

isParallel
Returns

Reference to this pass.

Definition at line 123 of file Pass.ixx.

124
125 using SystemType = std::remove_cvref_t<TSystem>;
126
127 if (!isParallel) {
128 void* bufferPtr = nullptr;
129 if constexpr (requires { typename SystemType::CommandBuffer_type; }) {
130 using TCommandBuffer = typename TSystem::CommandBuffer_type;
132 assert(bufferPtr && "Command buffer not found for system's CommandBuffer_type");
133 }
134
136 System(std::forward<TSystem>(system), bufferPtr)
137 );
138
139 } else {
140 if constexpr (requires { typename SystemType::CommandBuffer_type; }) {
141 using TCommandBuffer = typename TSystem::CommandBuffer_type;
143 System(std::forward<TSystem>(system), TCommandBuffer{})
144 );
145 } else {
147 System(std::forward<TSystem>(system))
148 );
149 }
150
151 }
152
153 return *this;
154 }

References gameWorld_, helios::engine::runtime::registerComponents, systemRegistry_ and helios::engine::runtime::world::GameWorld::tryCommandBuffer.

Referenced by addParallelSystems and addSystem.

registerManagerFlush()

template <typename T>
void helios::engine::runtime::gameloop::Pass::registerManagerFlush ()
inline protected

Registers the ManagerTypeIds for the Managers this pass should flush.

Template Parameters
T

The type of the manager to register.

Definition at line 94 of file Pass.ixx.

95 T* manager = gameWorld_.tryManager<T>();
96 assert(manager && "Manager buffer not found for system's manager");
97 managerTypeIds_.push_back(ManagerTypeId::template id<T>());
98 }

References gameWorld_, managerTypeIds_, helios::engine::runtime::registerComponents and helios::engine::runtime::world::GameWorld::tryManager.

registerManagerParallelFlush()

template <typename T>
void helios::engine::runtime::gameloop::Pass::registerManagerParallelFlush ()
inline protected

Registers the ManagerTypeIds for the Managers this pass should flush in parallel.

Template Parameters
T

The type of the manager to register.

Definition at line 107 of file Pass.ixx.

108 T* manager = gameWorld_.tryManager<T>();
109 assert(manager && "Manager buffer not found for system's manager");
110 parallelManagerTypeIds_.push_back(ManagerTypeId::template id<T>());
111 }

References gameWorld_, parallelManagerTypeIds_, helios::engine::runtime::registerComponents and helios::engine::runtime::world::GameWorld::tryManager.

registerParallelTypedSystem()

template <typename T, typename... Args>
Pass & helios::engine::runtime::gameloop::Pass::registerParallelTypedSystem (Args &&... args)
inline protected

Definition at line 158 of file Pass.ixx.

159
160 T concreteSystem(std::forward<Args>(args)...);
161
162 if constexpr (requires { typename T::CommandBuffer_type; }) {
163 using TCommandBuffer = typename T::CommandBuffer_type;
164 systemRegistry_.template add<T>(
166 );
167 } else {
168 systemRegistry_.template add<T>(
169 System(std::move(concreteSystem))
170 );
171 }
172
173 return *this;
174 }

References helios::engine::runtime::registerComponents and systemRegistry_.

registerTypedSystem()

template <typename T, typename... Args>
Pass & helios::engine::runtime::gameloop::Pass::registerTypedSystem (Args &&... args)
inline protected

Registers a TypedSystem-like system with this pass.

Template Parameters
T

The concrete system type to register.

Args

The constructor arg types, if any.

Parameters
args

Concrete constructor args.

Returns

This pass.

Definition at line 187 of file Pass.ixx.

188
189 T concreteSystem(std::forward<Args>(args)...);
190
191 void* bufferPtr = nullptr;
192 if constexpr (requires { typename T::CommandBuffer_type; }) {
193 using TCommandBuffer = typename T::CommandBuffer_type;
195 assert(bufferPtr && "Command buffer not found for system's CommandBuffer_type");
196 }
197
198 systemRegistry_.template add<T>(
200 );
201
202 return *this;
203 }

References gameWorld_, helios::engine::runtime::registerComponents, systemRegistry_ and helios::engine::runtime::world::GameWorld::tryCommandBuffer.

registerTypedSystemSpec()

template <typename T>
Pass & helios::engine::runtime::gameloop::Pass::registerTypedSystemSpec (T && spec)
inline protected

Registers a system described by a TypedSystemSpec with this pass.

Unpacks the argument tuple stored in spec and delegates to registerTypedSystem<TSystem>(args...).

Template Parameters
T

A TypedSystemSpec specialisation whose System_type satisfies IsTypedSystemLike.

Parameters
spec

Spec instance carrying the system type and its construction arguments.

Returns

Reference to this pass.

Definition at line 217 of file Pass.ixx.

218
219 using Spec = std::remove_cvref_t<T>;
220 using TSystem = Spec::System_type;
221
222 std::apply([this](auto&... args) {
224 }, spec.args);
225
226 return *this;
227 }

Reference helios::engine::runtime::registerComponents.

Protected Member Attributes

gameWorld_

GameWorld& helios::engine::runtime::gameloop::Pass::gameWorld_
protected

Reference to the owning GameWorld.

Used to resolve optional command buffer dependencies for systems declaring CommandBuffer_type.

Definition at line 76 of file Pass.ixx.

Referenced by registerCallableSystem, registerManagerFlush, registerManagerParallelFlush and registerTypedSystem.

managerTypeIds_

std::vector<ManagerTypeId> helios::engine::runtime::gameloop::Pass::managerTypeIds_
protected

List of ManagerTypeIds.

Definition at line 81 of file Pass.ixx.

81 std::vector<ManagerTypeId> managerTypeIds_;

Referenced by managerTypeIds and registerManagerFlush.

parallelManagerTypeIds_

std::vector<ManagerTypeId> helios::engine::runtime::gameloop::Pass::parallelManagerTypeIds_
protected

List of ManagerTypeIds for parallel execution.

Definition at line 86 of file Pass.ixx.

86 std::vector<ManagerTypeId> parallelManagerTypeIds_;

Referenced by parallelManagerTypeIds and registerManagerParallelFlush.

systemRegistry_

helios::engine::runtime::world::SystemRegistry helios::engine::runtime::gameloop::Pass::systemRegistry_ {}
protected

Registry holding all systems for this pass.

Definition at line 61 of file Pass.ixx.

Referenced by registerCallableSystem, registerParallelTypedSystem and registerTypedSystem.

systemTypeIdQueue_

std::vector<std::vector<SystemTypeId> > helios::engine::runtime::gameloop::Pass::systemTypeIdQueue_
protected

Queue of system type IDs for execution order.

Each entry holds a group of one or more SystemType-ids, whereas multiple ids indicate systems that can be executed in parallel.

Definition at line 68 of file Pass.ixx.

68 std::vector<std::vector<SystemTypeId>> systemTypeIdQueue_;

Referenced by addParallelSystems, addParallelSystems, addSystem and addSystem.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.