Nebula
Loading...
Searching...
No Matches
frameop.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
10//------------------------------------------------------------------------------
11#include "core/refcounted.h"
12#include "util/stringatom.h"
13#include "util/tupleutility.h"
14#include "coregraphics/config.h"
16#include "coregraphics/event.h"
20#include "coregraphics/pass.h"
21
22namespace Frame
23{
24
26{
27 Read, // reading means we must wait if we are writing
28 Write // writing always means we must wait for previous writes and reads to finish
29};
30
32{
33public:
34
36 FrameOp();
38 virtual ~FrameOp();
39
41 virtual void Discard();
42
44 void SetName(const Util::StringAtom& name);
46 const Util::StringAtom& GetName() const;
47
49 void SetEnabled(bool b);
51 const bool GetEnabled() const;
52
54 void AddChild(FrameOp* op);
57
59 virtual void OnWindowResized();
60
63
64 // TODO: Use these for the textureDeps and bufferDeps
71
78
83
84protected:
85 friend class FrameScriptLoader;
86 friend class FrameScript;
87 friend class FramePass;
88 friend class FrameSubpass;
89 friend class FrameSubmission;
90 friend class FrameSubgraph;
91
92 // inherit this class to implement the compiled runtime for the frame operation
93 struct Compiled
94 {
96 {
97 }
98
100 virtual void Run(const CoreGraphics::CmdBufferId cmdBuf, const IndexT frameIndex, const IndexT bufferIndex) = 0;
102 virtual void Discard();
103
105 virtual void SetupConstants(const IndexT bufferIndex);
106
108 virtual void QueuePreSync(const CoreGraphics::CmdBufferId cmdBuf);
109
112 };
113
121
129
131 struct FrameOp::Compiled* op,
133 const Util::StringAtom& textureName,
134 DependencyIntent readOrWrite,
138 CoreGraphics::QueueType fromQueue,
142 Util::Array<FrameOp::TextureDependency>& renderTextureDependencies);
143
145 struct FrameOp::Compiled* op,
147 const Util::StringAtom& bufferName,
148 DependencyIntent readOrWrite,
152 CoreGraphics::QueueType fromQueue,
156 Util::Array<FrameOp::BufferDependency>& bufferDependencies);
157
160
172
174 virtual void Build(const BuildContext& ctx);
175
183
190};
191
192//------------------------------------------------------------------------------
195inline void
197{
198 this->name = name;
199}
200
201//------------------------------------------------------------------------------
204inline const Util::StringAtom&
206{
207 return this->name;
208}
209
210//------------------------------------------------------------------------------
213inline void
215{
216 this->enabled = b;
217}
218
219//------------------------------------------------------------------------------
222inline const bool
224{
225 return this->enabled;
226}
227
228//------------------------------------------------------------------------------
231inline void
233{
234 this->children.Append(op);
235 this->childrenByName.Add(op->GetName(), op);
236}
237
238//------------------------------------------------------------------------------
241inline const Util::Array<Frame::FrameOp*>&
243{
244 return this->children;
245}
246
247} // namespace Frame2
Definition frameop.h:32
Compiled * compiled
Definition frameop.h:186
const bool GetEnabled() const
get if operation is enabled
Definition frameop.h:223
virtual void Discard()
discard operation
Definition frameop.cc:35
const Util::Array< Frame::FrameOp * > & GetChildren()
get children
Definition frameop.h:242
void SetEnabled(bool b)
set if operation should be enabled
Definition frameop.h:214
Util::StringAtom name
Definition frameop.h:187
virtual void Build(const BuildContext &ctx)
build operation
Definition frameop.cc:53
Util::Dictionary< CoreGraphics::BufferId, Util::Tuple< Util::StringAtom, CoreGraphics::PipelineStage, CoreGraphics::BufferSubresourceInfo > > bufferDeps
Definition frameop.h:80
void SetupSynchronization(Memory::ArenaAllocator< BIG_CHUNK > &allocator, Util::Array< CoreGraphics::EventId > &events, Util::Array< CoreGraphics::BarrierId > &barriers, Util::Dictionary< CoreGraphics::BufferId, Util::Array< BufferDependency > > &buffers, Util::Dictionary< CoreGraphics::TextureId, Util::Array< TextureDependency > > &textures)
setup synchronization
Definition frameop.cc:300
Util::Dictionary< const CoreGraphics::BufferId *, Util::Tuple< Util::StringAtom, CoreGraphics::PipelineStage, CoreGraphics::BufferSubresourceInfo > > bufferDepRefs
Definition frameop.h:82
virtual ~FrameOp()
destructor
Definition frameop.cc:26
virtual Compiled * AllocCompiled(Memory::ArenaAllocator< BIG_CHUNK > &allocator)=0
allocate instance of compiled
Util::Dictionary< const CoreGraphics::TextureId *, Util::Tuple< Util::StringAtom, CoreGraphics::PipelineStage, CoreGraphics::TextureSubresourceInfo > > textureDepRefs
Definition frameop.h:81
Util::Array< FrameOp * > children
Definition frameop.h:184
static void AnalyzeAndSetupBufferBarriers(struct FrameOp::Compiled *op, CoreGraphics::BufferId buf, const Util::StringAtom &bufferName, DependencyIntent readOrWrite, CoreGraphics::PipelineStage stage, CoreGraphics::BarrierDomain domain, const CoreGraphics::BufferSubresourceInfo &subres, CoreGraphics::QueueType fromQueue, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, CoreGraphics::BarrierCreateInfo > &barriers, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, CoreGraphics::EventCreateInfo > &waitEvents, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, struct FrameOp::Compiled * > &signalEvents, Util::Array< FrameOp::BufferDependency > &bufferDependencies)
Definition frameop.cc:198
void AddChild(FrameOp *op)
add child operation
Definition frameop.h:232
IndexT index
Definition frameop.h:188
Util::Dictionary< Util::StringAtom, FrameOp * > childrenByName
Definition frameop.h:185
CoreGraphics::BarrierDomain domain
Definition frameop.h:61
CoreGraphics::QueueType queue
Definition frameop.h:62
FrameOp()
constructor
Definition frameop.cc:15
Util::Dictionary< CoreGraphics::TextureId, Util::Tuple< Util::StringAtom, CoreGraphics::PipelineStage, CoreGraphics::TextureSubresourceInfo > > textureDeps
Definition frameop.h:79
static void AnalyzeAndSetupTextureBarriers(struct FrameOp::Compiled *op, CoreGraphics::TextureId tex, const Util::StringAtom &textureName, DependencyIntent readOrWrite, CoreGraphics::PipelineStage stage, CoreGraphics::BarrierDomain domain, const CoreGraphics::TextureSubresourceInfo &subres, CoreGraphics::QueueType fromQueue, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, CoreGraphics::BarrierCreateInfo > &barriers, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, CoreGraphics::EventCreateInfo > &waitEvents, Util::Dictionary< Util::Tuple< CoreGraphics::PipelineStage, CoreGraphics::PipelineStage >, struct FrameOp::Compiled * > &signalEvents, Util::Array< FrameOp::TextureDependency > &renderTextureDependencies)
Analyze and setup barriers if needed.
Definition frameop.cc:71
bool enabled
Definition frameop.h:189
void SetName(const Util::StringAtom &name)
set name
Definition frameop.h:196
const Util::StringAtom & GetName() const
get name
Definition frameop.h:205
virtual void OnWindowResized()
handle display resizing
Definition frameop.cc:43
Definition framepass.h:22
A FrameScript describes render operations being done to produce a single frame.
Definition framescript.h:41
Definition framescriptloader.h:22
Definition framesubgraph.h:15
Definition framesubmission.h:17
Definition framesubpass.h:18
Allocates memory in chunks.
Definition arenaallocator.h:36
Nebula's dynamic array class.
Definition array.h:60
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
A StringAtom.
Definition stringatom.h:22
QueueType
Definition config.h:40
BarrierDomain
Definition config.h:185
PipelineStage
Definition config.h:191
ImGUI debug interface for inspecting frame scripts.
Definition shaderserverbase.h:52
DependencyIntent
Definition frameop.h:26
std::tuple< T... > Tuple
Wrap std::tuple.
Definition tupleutility.h:19
Compile time configuration options for the CoreGraphics subsystem.
A semaphore is an inter-GPU queue synchronization primitive.
Definition barrier.h:227
Definition buffer.h:23
Definition commandbuffer.h:155
Definition event.h:27
Definition pass.h:28
texture type
Definition texture.h:25
Definition frameop.h:123
CoreGraphics::PipelineStage stage
Definition frameop.h:124
CoreGraphics::QueueType queue
Definition frameop.h:127
CoreGraphics::BufferSubresourceInfo subres
Definition frameop.h:126
DependencyIntent intent
Definition frameop.h:125
Util::StringAtom name
Definition frameop.h:67
CoreGraphics::PipelineStage stage
Definition frameop.h:68
CoreGraphics::BufferSubresourceInfo subres
Definition frameop.h:69
Definition frameop.h:162
Util::Array< CoreGraphics::EventId > & events
Definition frameop.h:167
Util::Array< CoreGraphics::BarrierId > & barriers
Definition frameop.h:168
Util::Array< FrameOp::Compiled * > & compiledOps
Definition frameop.h:166
Memory::ArenaAllocator< BIG_CHUNK > & allocator
Definition frameop.h:165
uint subpass
Definition frameop.h:164
Util::Dictionary< CoreGraphics::TextureId, Util::Array< TextureDependency > > & textures
Definition frameop.h:170
CoreGraphics::PassId currentPass
Definition frameop.h:163
Util::Dictionary< CoreGraphics::BufferId, Util::Array< BufferDependency > > & buffers
Definition frameop.h:169
Definition frameop.h:94
virtual void SetupConstants(const IndexT bufferIndex)
Setup constants.
Definition frameop.cc:465
Compiled()
Definition frameop.h:95
virtual void Discard()
Discard operation.
Definition frameop.cc:454
CoreGraphics::QueueType queue
Definition frameop.h:111
Util::Array< CoreGraphics::BarrierId > barriers
Definition frameop.h:110
virtual void QueuePreSync(const CoreGraphics::CmdBufferId cmdBuf)
Perform synchronization prior to execution of operation.
Definition frameop.cc:474
virtual void Run(const CoreGraphics::CmdBufferId cmdBuf, const IndexT frameIndex, const IndexT bufferIndex)=0
Run operation on a specific command buffer.
Definition frameop.cc:445
Definition frameop.h:115
CoreGraphics::TextureSubresourceInfo subres
Definition frameop.h:118
DependencyIntent intent
Definition frameop.h:117
CoreGraphics::PipelineStage stage
Definition frameop.h:116
CoreGraphics::QueueType queue
Definition frameop.h:119
Util::StringAtom name
Definition frameop.h:74
CoreGraphics::PipelineStage stage
Definition frameop.h:75
CoreGraphics::TextureSubresourceInfo subres
Definition frameop.h:76
unsigned int uint
Definition types.h:31
int IndexT
Definition types.h:48