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>
7{
8 using namespace RHI;
9 class Renderer;
10 using PassHandle = Handle; // Index in the pass definitions vector
11 using ResourceHandle = Handle; // Index in the resource definitions vector
15 class RenderPass : public RHIObject
16 {
17 public:
22 RenderPass() = default;
30 virtual void Setup(PassHandle self, Renderer* r) = 0;
41 };
46 {
47 void operator()(PassHandle, Renderer*) const { /* nop */ }
48 };
53 {
54 void operator()(PassHandle, Renderer*, RHICommandList*) const { /* nop */ }
55 };
61 template <typename FSetup, typename FRecord>
77 {
79 PassHandle handle; // Index to tracked passes
80 int priority{0}; // Higher priority passes are scheduled earlier
81 // The queue to run this pass on
83 bool used{false}; // Culled?
84 // Backbuffer specializations
86 Optional<int> backbufferUAV; // opt: set index
87 // Uses compute shader? (not necessarily in a compute queue)
88 // Should be mutually exclusive with write_backbuffer and other graphics states
89 bool isComputePass{false};
90 // Uses RayGen/RayHit/RayMiss at all?
91 // Should be compatible with most graphics states, and can be run on either queue
92 bool isRayTracingPass{false};
93 // Local size for compute/mesh shaders
95 size_t depth{}; // Depth in RG
96 size_t ord{}; // Execution order
97 size_t frameExec{}; // Last frame this pass is executed
98 /* -- Resources -- */
99 Vector<PassHandle> bindPasses; // Referenced, explicit pass execute-before.
102 textureUsages; // Referenced texture sub resources
104 RHIPipelineStage>> bufferUsages; // Referenced buffers
106 RHIPipelineStage>> asUsages; // Referenced Acceleration Structures
107 // Unique referenced resources (tex/buf/AS)
109 // Unique texture views
111 /* -- Pipeline -- */
112 // Shader [path, entry point, stage, specialization data, RT hit group, RT hit group type]
115 // Bind points [view(tex) or buffer(buf), desc type, binding point]
117 // External Bind Sets [binding point, layout ptr, set index (set when built)]
118 // Sorted lexicographically if the pipeline is built.
120 // Samplers
122 // Push Constant
124 // Specialization Constants by [stage, offset, value]
126 // (Graphics Only) Render Target View[s], Blending Op
128 // (Graphics Only) Depth Stencil View
130 // (Graphics Only) Vertex Input assembly
133 /* --- */
137 /* -- Pipeline states (built at PSO setup) -- */
138 int groupIndex{}; // executionGroup index
139 // All stages used in this pass
141 // Pipeline states for the entire pass
143 // PSO Creation parameters
148 // Layouts created by ourselves
150 // Pointers. Can also contain external sets
152 // Sets created by ourselves
154 // Pointers. Can also contain external sets
156 // [Set Index, Set, Layout], correspond to externalBindings
158
159
161 {
162 if (isComputePass) return RHIDevicePipelineType::Compute;
163 if (isRayTracingPass) return RHIDevicePipelineType::RayTracing;
164 return RHIDevicePipelineType::Graphics;
165 }
166 void ResetPipeline();
167 };
168}
General Purpose Allocator (GPA) interface.
Definition Allocator.hpp:24
Definition Command.hpp:42
Base class for all RHI objects.
Definition Details.hpp:16
Scoped move-only RAII handle wrapper for RHI Objects.
Definition Details.hpp:86
Interface for a render pass.
Definition RenderPass.hpp:16
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 void Record(PassHandle self, Renderer *r, 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:89
std::vector< T, StlAllocator< T > > Vector
std::vector with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:130
std::basic_string< char > String
Alias for std::basic_string<char>, without an explicit allocator constructor.
Definition Container.hpp:112
std::tuple< Args... > Tuple
Alias for std::tuple
Definition Container.hpp:38
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:55
std::unique_ptr< T, Deleter > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:170
T * Construct(Allocator *resource, Args &&...args)
Convenience placement new with object of type T using a Foundation::Core::Allocator.
Definition Allocator.hpp:153
std::optional< T > Optional
Alias for std::optional
Definition Container.hpp:26
RHITextureLayout
Definition Common.hpp:203
uintptr_t Handle
Definition Details.hpp:8
RHIDeviceQueueType
Definition Common.hpp:164
static constexpr Handle kInvalidHandle
Definition Details.hpp:9
Core functionalities for rendering, including the Frame Graph implementation.
Definition Bindless.cpp:2
Handle ResourceHandle
Definition RenderPass.hpp:11
Handle PassHandle
Definition RenderPass.hpp:10
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Topology TriangleList
RayTracingHitGroupType
Definition PipelineState.hpp:171
Default "no-op" functor for Record()
Definition RenderPass.hpp:53
void operator()(PassHandle, Renderer *, RHICommandList *) const
Definition RenderPass.hpp:54
Default "no-op" functor for Setup()
Definition RenderPass.hpp:46
void operator()(PassHandle, Renderer *) const
Definition RenderPass.hpp:47
Functional wrapper for a render pass.
Definition RenderPass.hpp:63
LambdaPass(FSetup &&setup, FRecord &&record)
Definition RenderPass.hpp:66
void Record(PassHandle self, Renderer *r, RHICommandList *cmd) override
Record the commands of this pass into the given command list.
Definition RenderPass.hpp:71
FRecord mRecord
Definition RenderPass.hpp:65
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:70
FSetup mSetup
Definition RenderPass.hpp:64
Internal tracking information for a render pass in the frame graph.
Definition RenderPass.hpp:77
size_t frameExec
Definition RenderPass.hpp:97
int priority
Definition RenderPass.hpp:80
RHIPipelineState::PipelineStateDesc::DepthStencil psoDepthStencil
Definition RenderPass.hpp:145
ResourceHandle dsv
Definition RenderPass.hpp:129
Vector< Tuple< String, String, RHIShaderStage, Vector< char >, uint32_t, RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType > > shaders
Definition RenderPass.hpp:114
Vector< RHIPipelineState::PipelineStateDesc::VertexInput::Binding > vertexInputBindings
Definition RenderPass.hpp:131
Vector< RHIDeviceDescriptorSetLayout * > pDescriptorLayouts
Definition RenderPass.hpp:151
RHIPipelineStageBits piplineStages
Definition RenderPass.hpp:140
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage, RHITextureSubresourceRange, RHITextureLayout > > textureUsages
Definition RenderPass.hpp:102
UniquePtr< RenderPass > pass
Definition RenderPass.hpp:134
Vector< RHIDeviceDescriptorSet * > pDescriptorSets
Definition RenderPass.hpp:155
RHIDeviceQueueType queue
Definition RenderPass.hpp:82
RHIPipelineState::PipelineStateDesc::Rasterizer psoRasterizer
Definition RenderPass.hpp:144
int groupIndex
Definition RenderPass.hpp:138
size_t ord
Definition RenderPass.hpp:96
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > textureBindings
Definition RenderPass.hpp:116
Vector< Pair< ResourceHandle, String > > samplers
Definition RenderPass.hpp:121
RHIDeviceScopedHandle< RHIPipelineState > pso
Definition RenderPass.hpp:142
Vector< RHIDeviceScopedHandle< RHIDeviceDescriptorSetLayout > > descriptorLayouts
Definition RenderPass.hpp:149
bool isRayTracingPass
Definition RenderPass.hpp:92
Vector< RHIPipelineState::PipelineStateDesc::PushConstant > pushConstants
Definition RenderPass.hpp:123
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > asUsages
Definition RenderPass.hpp:106
Optional< RHIPipelineState::PipelineStateDesc::Attachment::Blending > backbufferRTV
Definition RenderPass.hpp:85
bool used
Definition RenderPass.hpp:83
Vector< RHIVertexAttribute > vertexInputAttributes
Definition RenderPass.hpp:132
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > bufferBindings
Definition RenderPass.hpp:116
Vector< Tuple< size_t, RHIDeviceDescriptorSetLayout * > > pExternalDescriptorSets
Definition RenderPass.hpp:157
Vector< Tuple< RHIShaderStage, size_t, Vector< char > > > specializationConstants
Definition RenderPass.hpp:125
Vector< RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > > descriptorSets
Definition RenderPass.hpp:153
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > asBindings
Definition RenderPass.hpp:116
PassHandle handle
Definition RenderPass.hpp:79
Tuple< uint32_t, uint32_t, uint32_t > groupLocalSize
Definition RenderPass.hpp:94
Vector< ResourceHandle > texviews
Definition RenderPass.hpp:110
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > bufferUsages
Definition RenderPass.hpp:104
Optional< int > backbufferUAV
Definition RenderPass.hpp:86
size_t depth
Definition RenderPass.hpp:95
Vector< PassHandle > bindPasses
Definition RenderPass.hpp:99
Vector< Pair< ResourceHandle, RHIPipelineState::PipelineStateDesc::Attachment::Blending > > rtvs
Definition RenderPass.hpp:127
bool isComputePass
Definition RenderPass.hpp:89
RHIPipelineState::PipelineStateDesc::Topology psoTopology
Definition RenderPass.hpp:146
Vector< ResourceHandle > resources
Definition RenderPass.hpp:108
String name
Definition RenderPass.hpp:78
Vector< Tuple< String, RHIDeviceDescriptorSetLayout *, int > > externalBindings
Definition RenderPass.hpp:119
void ResetPipeline()
Definition RenderPass.cpp:11
RHIDevicePipelineType GetPipelineType() const
Definition RenderPass.hpp:160