Nebula
Loading...
Searching...
No Matches
frameevent.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
9//------------------------------------------------------------------------------
10#include "game/processor.h"
12
13namespace Game
14{
15
16class FramePipeline;
17
23
29
30//------------------------------------------------------------------------------
34{
35public:
36 FrameEvent() = default;
38
39 class Batch;
41 void Run(World* world);
43 void AddProcessor(Processor* processor);
45 void RemoveProcessor(Processor* processor);
46
48 void Prefilter(World* world, bool force = false);
51
53 int order = 100;
54
56
57private:
59
62
65};
66
67
68//------------------------------------------------------------------------------
73{
74public:
75 Batch() = default;
76 ~Batch();
77
78 void Execute(World* world);
79
86 bool TryInsert(Processor* processor);
87
90 bool TryRemove(Processor* processor);
91
93 void Prefilter(World* world, bool force = false);
96
98 int order = 100;
99 bool async = false;
100
102
103private:
104 void ExecuteAsync(World* world);
105 void ExecuteSequential(World* world);
106
108};
109
110
111//------------------------------------------------------------------------------
115{
116public:
117 FramePipeline() = delete;
120
123
125 void Begin();
127 void End();
129 void Reset();
131 void RunThru(Util::StringAtom name);
133 void RunRemaining();
134
136 bool IsRunningAsync();
137
139 void Prefilter(bool force = false);
142
143 // get read copy of frame events. This is not thread safe to read from!
145
146private:
148
150 bool isRunning = false;
151 volatile bool inAsync = false;
154};
155
156} // namespace Game
A batch of frame callbacks.
Definition frameevent.h:73
void ExecuteAsync(World *world)
Definition frameevent.cc:303
Util::Array< Processor * > processors
Definition frameevent.h:107
int order
sorting order in frame event
Definition frameevent.h:98
void Execute(World *world)
Definition frameevent.cc:172
bool async
Definition frameevent.h:99
~Batch()
Definition frameevent.cc:160
void CacheTable(MemDb::TableId, MemDb::TableSignature const &)
add a table to the cache of any processors that accepts it, that is attached to this frame batch
Definition frameevent.cc:263
void Prefilter(World *world, bool force=false)
prefilter all processors. Should not be done per frame - instead use CacheTable if you need to do inc...
Definition frameevent.cc:245
void ExecuteSequential(World *world)
Definition frameevent.cc:385
bool TryInsert(Processor *processor)
Try to insert a processor into the batch.
Definition frameevent.cc:188
bool TryRemove(Processor *processor)
Tries to remove a processor from the batch, if it exists in the batch.
Definition frameevent.cc:227
Util::Array< Processor const * > GetProcessors() const
Definition frameevent.cc:288
void AddProcessor(Processor *processor)
Adds a processor to the frame event.
Definition frameevent.cc:70
Util::Array< Batch const * > const GetBatches() const
Definition frameevent.cc:146
int order
Definition frameevent.h:53
Util::Array< Batch * > batches
Batches that this event will execute.
Definition frameevent.h:64
FrameEvent()=default
FramePipeline * pipeline
Which pipeline is this event attached to.
Definition frameevent.h:61
void CacheTable(MemDb::TableId, MemDb::TableSignature const &)
add a table to the caches of any processors that accepts it, that is attached to this frame event
Definition frameevent.cc:134
void RemoveProcessor(Processor *processor)
Removes a processor for the frame event. Does not free the memory, you need to handle this yourself.
Definition frameevent.cc:105
void Run(World *world)
Runs the frame event.
Definition frameevent.cc:51
friend FramePipeline
Definition frameevent.h:58
void Prefilter(World *world, bool force=false)
prefilter all processors. Should not be done per frame - instead use CacheTable if you need to do inc...
Definition frameevent.cc:122
Util::StringAtom name
Definition frameevent.h:52
~FrameEvent()
Definition frameevent.cc:39
volatile bool inAsync
Definition frameevent.h:151
Util::Array< FrameEvent const * > const GetFrameEvents() const
Definition frameevent.cc:586
void RunRemaining()
Run until the pipeline ends.
Definition frameevent.cc:539
void Prefilter(bool force=false)
prefilter all processors. Should not be done per frame - instead use CacheTable if you need to do inc...
Definition frameevent.cc:562
void Reset()
Reset the pipeline to the start.
Definition frameevent.cc:511
void Begin()
Start running the pipeline.
Definition frameevent.cc:493
friend FrameEvent
Definition frameevent.h:147
IndexT currentIndex
Definition frameevent.h:152
bool isRunning
Definition frameevent.h:150
bool IsRunningAsync()
check if the pipeline is currently executing an async frame event batch
Definition frameevent.cc:553
World * world
Definition frameevent.h:149
Util::Array< FrameEvent * > frameEvents
Definition frameevent.h:153
void CacheTable(MemDb::TableId, MemDb::TableSignature const &)
add a table to the caches of any processors that accepts it, that is attached to this frame event
Definition frameevent.cc:574
FrameEvent * GetFrameEvent(Util::StringAtom name)
Definition frameevent.cc:477
void End()
Stop running the pipeline.
Definition frameevent.cc:504
void RunThru(Util::StringAtom name)
Run and execute until a certain event is executed (inclusive).
Definition frameevent.cc:520
~FramePipeline()
Definition frameevent.cc:432
FrameEvent * RegisterFrameEvent(int order, Util::StringAtom name)
Definition frameevent.cc:444
Definition processor.h:23
A container of entities, their components, and processors.
Definition world.h:81
Basically a bitfield with packed ComponentIds.
Definition tablesignature.h:26
Nebula's dynamic array class.
Definition array.h:61
A StringAtom.
Definition stringatom.h:22
Game::EditorState.
Definition graphicsmanager.h:67
This represents a "view" into an entity table.
Definition dataset.h:35
Definition frameevent.h:25
ProcessorJobInput * inputs
Definition frameevent.h:27
Game::World * world
Definition frameevent.h:26
Definition frameevent.h:19
Game::Dataset::View * view
Definition frameevent.h:20
Processor * processor
Definition frameevent.h:21
Table identifier.
Definition tableid.h:14
int IndexT
Definition types.h:41