Foundation
Loading...
Searching...
No Matches
RenderPass.hpp
Go to the documentation of this file.
1#pragma once
2#include <RHICore/Command.hpp>
4#include <RHICore/Device.hpp>
8{
9 using namespace RHI;
10 class Renderer;
11 using PassHandle = size_t; // Index in the pass definitions vector
12 using ResourceHandle = size_t; // Index in the resource definitions vector
17 {
18 public:
23 RenderPass() = default;
31 virtual void Setup(PassHandle self, Renderer* r) = 0;
41 virtual void Record(PassHandle self, Renderer* r, RHI::RHICommandList* cmd) = 0;
52 virtual bool IsSkipped(PassHandle self, Renderer* r) const { return false; }
53 };
58 {
59 void operator()(PassHandle, Renderer*) const { /* nop */ }
60 };
65 {
66 void operator()(PassHandle, Renderer*, RHI::RHICommandList*) const { /* nop */ }
67 };
72 {
73 bool operator()(PassHandle, Renderer*) const { return false; }
74 };
80 template <typename FSetup, typename FRecord, typename FSkip>
81 struct LambdaPass : public RenderPass
82 {
91 void Setup(PassHandle self, Renderer* r) override { mSetup(self, r); }
92 void Record(PassHandle self, Renderer* r, RHICommandList* cmd) override { mRecord(self, r, cmd); }
93 bool IsSkipped(PassHandle self, Renderer* r) const override { return mSkip(self, r); }
94 };
99 {
101 PassHandle handle; // Index to tracked passes
102 int priority{0}; // Higher priority passes are scheduled earlier
103 // The queue to run this pass on
105 bool used{false}; // Culled?
106 // Writes to the swapchain backbuffer
107 // Ignores other RTVs if true
108 bool writeBackbuffer{false};
110 // Uses compute shader? (not necessarily in a compute queue)
111 // Should be mutually exclusive with write_backbuffer and other graphics states
112 bool isComputePass{false};
113 // Local size for compute/mesh shaders
115 size_t depth{}; // Depth in RG
116 size_t ord{}; // Execution order
117 /* -- Resources -- */
120 textureUsages; // Referenced texture sub resources
122 RHIPipelineStage>> bufferUsages; // Referenced buffers
123 // Unique referenced resources (tex/buf)
125 // Unique texture views
127 /* -- Pipeline -- */
128 // Shader [path, entry point, stage]
130 // Explicit descriptor bindings [binding index,set index, binding point]
131 // These are otherwise derived from shader reflection
133 // Bind points [view(tex) or buffer(buf), desc type, binding point]
135 // External Bind Sets [Ptr, Layout Ptr, binding point]
137 // Samplers
139 // Push Constants by [stage, offset, size]
141 // (Graphics Only) Render Target View[s], Blending Op
143 // (Graphics Only) Depth Stencil View
145 // (Graphics Only) Vertex Input assembly
148 /* --- */
152 /* -- States -- */
153 int groupIndex{}; // executionGroup index
154 // All stages used in this pass
156 // Pipeline states for the entire pass
158 // PSO Creation parameters
161 // Layouts created by ourselves
163 // Pointers. Can also contain external sets
165 // Sets created by ourselves
167 // Pointers. Can also contain external sets
169 // [Set Index, Set, Layout]
171 };
172}
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Definition Command.hpp:34
Base class for all RHI objects.
Definition Details.hpp:16
Interface for a render pass.
Definition RenderPass.hpp:17
virtual void Setup(PassHandle self, Renderer *r)=0
Perform any setup required for this pass. This may include creating resources, declaring resource acc...
RenderPass()=default
Constructor. You may also create resources here for early setup. However, access declaration must be ...
virtual bool IsSkipped(PassHandle self, Renderer *r) const
Determine whether this pass should be skipped during Record time.
Definition RenderPass.hpp:52
virtual void Record(PassHandle self, Renderer *r, RHI::RHICommandList *cmd)=0
Record the commands of this pass into the given command list.
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:78
std::vector< T, StlAllocator< T > > Vector
std::vector with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:159
std::basic_string< char > String
Alias for std::basic_string<char>, without an explicit allocator constructor.
Definition Container.hpp:141
std::tuple< Args... > Tuple
Alias for std::tuple
Definition Container.hpp:36
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:53
std::unique_ptr< T, StlDeleter< T > > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:161
RHITextureLayout
Definition Common.hpp:99
static constexpr Handle kInvalidHandle
Definition Details.hpp:10
RHIDeviceQueueType
Definition Common.hpp:69
Core functionalities for rendering, including the Frame Graph implementation.
Definition Renderer.hpp:12
size_t ResourceHandle
Definition RenderPass.hpp:12
size_t PassHandle
Definition RenderPass.hpp:11
Definition Filesystem.hpp:36
Default "no-op" functor for Record()
Definition RenderPass.hpp:65
void operator()(PassHandle, Renderer *, RHI::RHICommandList *) const
Definition RenderPass.hpp:66
Default "no-op" functor for Setup()
Definition RenderPass.hpp:58
void operator()(PassHandle, Renderer *) const
Definition RenderPass.hpp:59
Default "not skipped" functor for IsSkipped()
Definition RenderPass.hpp:72
bool operator()(PassHandle, Renderer *) const
Definition RenderPass.hpp:73
Functional wrapper for a render pass.
Definition RenderPass.hpp:82
FRecord mRecord
Definition RenderPass.hpp:84
void Setup(PassHandle self, Renderer *r) override
Perform any setup required for this pass. This may include creating resources, declaring resource acc...
Definition RenderPass.hpp:91
bool IsSkipped(PassHandle self, Renderer *r) const override
Determine whether this pass should be skipped during Record time.
Definition RenderPass.hpp:93
FSkip mSkip
Definition RenderPass.hpp:85
FSetup mSetup
Definition RenderPass.hpp:83
LambdaPass(FSetup &&setup, FRecord &&record, FSkip &&skip={})
Definition RenderPass.hpp:86
void Record(PassHandle self, Renderer *r, RHICommandList *cmd) override
Record the commands of this pass into the given command list.
Definition RenderPass.hpp:92
Internal tracking information for a render pass in the frame graph.
Definition RenderPass.hpp:99
int priority
Definition RenderPass.hpp:102
bool writeBackbuffer
Definition RenderPass.hpp:108
RHIPipelineState::PipelineStateDesc::DepthStencil psoDepthStencil
Definition RenderPass.hpp:160
ResourceHandle dsv
Definition RenderPass.hpp:144
Vector< RHIPipelineState::PipelineStateDesc::VertexInput::Binding > vertexInputBindings
Definition RenderPass.hpp:146
Vector< Tuple< RHIDeviceDescriptorSet *, RHIDeviceDescriptorSetLayout *, String > > externalBindings
Definition RenderPass.hpp:136
Vector< RHIDeviceDescriptorSetLayout * > pDescriptorLayouts
Definition RenderPass.hpp:164
RHIPipelineStageBits piplineStages
Definition RenderPass.hpp:155
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage, RHITextureSubresourceRange, RHITextureLayout > > textureUsages
Definition RenderPass.hpp:120
UniquePtr< RenderPass > pass
Definition RenderPass.hpp:149
Vector< RHIDeviceDescriptorSet * > pDescriptorSets
Definition RenderPass.hpp:168
RHIDeviceScopedObjectHandle< RHIPipelineState > pso
Definition RenderPass.hpp:157
RHIDeviceQueueType queue
Definition RenderPass.hpp:104
Vector< RHIDeviceScopedObjectHandle< RHIDeviceDescriptorSetLayout > > descriptorLayouts
Definition RenderPass.hpp:162
RHIPipelineState::PipelineStateDesc::Rasterizer psoRasterizer
Definition RenderPass.hpp:159
int groupIndex
Definition RenderPass.hpp:153
size_t ord
Definition RenderPass.hpp:116
Vector< Tuple< uint32_t, uint32_t, String > > explictDescriptorBindings
Definition RenderPass.hpp:132
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > textureBindings
Definition RenderPass.hpp:134
Vector< Pair< ResourceHandle, String > > samplers
Definition RenderPass.hpp:138
Vector< RHIPipelineState::PipelineStateDesc::PushConstant > pushConstants
Definition RenderPass.hpp:140
Vector< Tuple< Native::Path, String, RHIShaderStage > > shaders
Definition RenderPass.hpp:129
RHIPipelineState::PipelineStateDesc::Attachment::Blending writeBackbufferBlending
Definition RenderPass.hpp:109
bool used
Definition RenderPass.hpp:105
Vector< RHIVertexAttribute > vertexInputAttributes
Definition RenderPass.hpp:147
Vector< Tuple< size_t, RHIDeviceDescriptorSet *, RHIDeviceDescriptorSetLayout * > > pExternalDescriptorSets
Definition RenderPass.hpp:170
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > bufferBindings
Definition RenderPass.hpp:134
Vector< RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > > descriptorSets
Definition RenderPass.hpp:166
PassHandle handle
Definition RenderPass.hpp:101
Tuple< uint32_t, uint32_t, uint32_t > groupLocalSize
Definition RenderPass.hpp:114
Vector< ResourceHandle > texviews
Definition RenderPass.hpp:126
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > bufferUsages
Definition RenderPass.hpp:122
size_t depth
Definition RenderPass.hpp:115
Vector< Pair< ResourceHandle, RHIPipelineState::PipelineStateDesc::Attachment::Blending > > rtvs
Definition RenderPass.hpp:142
bool isComputePass
Definition RenderPass.hpp:112
Vector< ResourceHandle > resources
Definition RenderPass.hpp:124
String name
Definition RenderPass.hpp:100