94 RHIPipelineStageBits::VertexShader | RHIPipelineStageBits::MeshShader | RHIPipelineStageBits::RayTracingShader |
95 RHIPipelineStageBits::AllGraphics;
97 RHIResourceAccessBits::RenderTargetWrite | RHIResourceAccessBits::DepthStencilWrite |
98 RHIResourceAccessBits::TransferWrite | RHIResourceAccessBits::HostWrite;
100 RHIResourceAccessBits::RenderTargetRead | RHIResourceAccessBits::DepthStencilRead |
101 RHIResourceAccessBits::UniformRead | RHIResourceAccessBits::TransferRead | RHIResourceAccessBits::HostRead;
193 state.
mip <= mip_end && state.
layer >= layer_begin && state.
layer <= layer_end;
230 views.resize(std::max(
views.size(),
static_cast<size_t>(handle + 1)));
231 samplers.resize(std::max(
samplers.size(),
static_cast<size_t>(handle + 1)));
283 template <
typename FSetup,
typename FRecord>
289 mSetup(std::forward<FSetup>(setup)),
mRecord(std::forward<FRecord>(record))
387 return RHIDevicePipelineType::Compute;
389 return RHIDevicePipelineType::RayTracing;
390 return RHIDevicePipelineType::Graphics;
456 while (u >=
graph.size())
458 graph[u].emplace_back(v, hdl);
459 while (v >=
in.size())
555 ExecutePerThreadCommandLists(
RHIDevice* device,
size_t maxPerThread,
Allocator* alloc);
576 case RHIDeviceQueueType::Undefined:
578 case RHIDeviceQueueType::Graphics:
580 case RHIDeviceQueueType::Compute:
583 CHECK_MSG(
false,
"Unhandled queue type");
651 RHIResourceAccess access = RHIResourceAccessBits::ShaderRead)
const;
661 RHIResourceAccess access = RHIResourceAccessBits::ShaderRead,
669#pragma region Render Graph Setup
686 template <
typename T,
typename... Args>
687 requires std::is_base_of_v<RenderPass, T>
691 CHECK_MSG(queue == RHIDeviceQueueType::Graphics || queue == RHIDeviceQueueType::Compute,
692 "Invalid queue type. Only Graphics and Compute queues are supported.");
696 queue = RHIDeviceQueueType::Graphics;
697 mSetup->trackedPasses.emplace_back(
699 ConstructUniqueBase<RenderPass, T>(
mAllocator, std::forward<Args>(args)...), priority);
700 mSetup->epilogue = handle;
718 template <
typename FSetup,
typename FRecord>
722 return CreatePassImpl<LambdaPass<FSetup, FRecord>>(name, queue, priority, std::forward<FSetup>(setup),
723 std::forward<FRecord>(record));
743 template <
typename T>
751 return mSetup->trackedResources.size() - 1;
759 template <
typename T>
762 static_assert(std::is_same_v<T, RHIBufferDesc> || std::is_same_v<T, RHITextureDesc>,
763 "Temporal resources currently support owned buffers and textures only");
770 mSetup->trackedResources[current].temporalFamily = family;
771 mSetup->trackedResources[current].temporalFramesAgo = 0;
772 mSetup->trackedResources[previous].temporalFamily = family;
773 mSetup->trackedResources[previous].temporalFramesAgo = 1;
785#pragma region Resource Binding
807 RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType::Triangles)
const;
999 bool readOnly =
false)
const;
1043#pragma region PSO Flags
1071#pragma region Diagnostics
1088#pragma region Swapchain
1114 return {xy.x, xy.y, 1};
1117#pragma region Render Graph Runtime
1150 CHECK(
mSetup && handle < mSetup->trackedSamplers.size());
1158 CHECK(
mSetup && pass < mSetup->trackedPasses.size());
1159 auto& tpass =
mSetup->trackedPasses[pass];
1160 return tpass.pso.Get();
1167 CHECK(
mSetup && pass < mSetup->trackedPasses.size());
1168 auto& tpass =
mSetup->trackedPasses[pass];
1169 return tpass.pDescriptorSets;
1176#pragma region Command Recording Helpers
1235 template <
typename T>
1240 auto& tpass =
mSetup->trackedPasses[pass];
1241 cmd->
PushConstant(tpass.pso.Get(), stage,
static_cast<uint32_t
>(offset),
1242 {reinterpret_cast<const char*>(&data), sizeof(T)});
1245#pragma region Frame Execution
1301 CHECK_MSG(
mSetup && pass < mSetup->trackedPasses.size(),
"No passes available or out of bounds");
1302 return mSetup->trackedPasses[pass];
1405#pragma region Debugging
#define CHECK_MSG(expr, format_str,...)
#define CHECK(expr)
Definition Logging.hpp:92
#define ENUM_NAME_CONV_BEGIN(T)
Defines convince to_string() method and format_as() [fmt] for the respective enum class Example usage...
Definition Enums.hpp:82
#define ENUM_NAME(E)
Definition Enums.hpp:93
Implements a lock-free stack-based bump allocator.
Definition AllocatorStack.hpp:13
Allocator interface (noexcept)
Definition Allocator.hpp:29
Definition JobSystem.hpp:86
Definition JobSystem.hpp:135
Atomic, lock-free Thread Pool implementation with fixed bounds.
Definition ThreadPool.hpp:51
Definition Resource.hpp:332
The root object of everything RHI. Implementation of this class inherently defines the RHI backend.
Definition Application.hpp:24
Definition Resource.hpp:57
Definition Command.hpp:42
virtual RHICommandList & PushConstant(RHIPipelineState *pipeline, RHIShaderStage stage, uint32_t offset, Span< const char > data)=0
Definition Descriptor.hpp:12
virtual uint32_t GetVkQueueFamily() const =0
Definition Device.hpp:105
Definition Device.hpp:246
Handle type for RHI Objects.
Definition Details.hpp:43
Base class for all RHI objects.
Definition Details.hpp:17
Definition PipelineState.hpp:43
Definition PipelineState.hpp:60
Scoped move-only RAII handle wrapper for RHI Objects.
Definition Details.hpp:85
Definition Swapchain.hpp:32
Definition Resource.hpp:238
Definition Resource.hpp:216
Definition Presenter.hpp:12
Interface for a render pass.
Definition Renderer.hpp:238
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:404
PassHandle CreatePass(StringView name, RHIDeviceQueueType queue, size_t priority, FSetup &&setup, FRecord &&record)
Create a render pass from a Setup(Renderer*, PassHandle) and Record(Renderer*, PassHandle,...
Definition Renderer.hpp:719
void DbgGetTexturePreviews(Vector< TexturePreviewStat > &outStats) const
Definition Renderer.cpp:1520
Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * > DerefResource(const ResourceHandle handle) const
Dereference a resource handle to its underlying RHI resource.
Definition Renderer.hpp:1130
void BindTextureRTV(PassHandle pass, ResourceHandle texture, RHITextureViewDesc const &desc, RHIPipelineState::PipelineStateDesc::Attachment::Blending const &blending={}) const
Binds a texture as a Render Target View (color attachment) for a graphics pass.
Definition Renderer.cpp:441
void PassSetRasterizerFlags(PassHandle pass, RHIPipelineState::PipelineStateDesc::Rasterizer const &rasterizer={}, RHIPipelineState::PipelineStateDesc::DepthStencil const &depth_stencil={}) const
Sets the rasterizer and depth-stencil state for a graphics pass.
Definition Renderer.cpp:557
Atomic< bool > mPipelineStateCompilationComplete
Definition Renderer.hpp:484
UniquePtr< ExecuteResources > mResources
Definition Renderer.hpp:495
RHIDeviceSemaphore * mExecuteImageAcquire
Definition Renderer.hpp:493
void BindTextureShaderRead(PassHandle pass, ResourceHandle texture, RHIPipelineStage stage, RHITextureSubresourceRange const &range) const
Declares a shader read dependency for a texture without creating an internal binding.
Definition Renderer.cpp:431
void BeginSetup()
Begins the setup phase of the render graph.
Definition Renderer.cpp:126
void DbgGetMemoryStatistics(Vector< MemoryStat > &outStats) const
Definition Renderer.cpp:1481
RHICommandList * ExecuteAllocateCommandList(RHIDeviceQueueType queue, int thread_id=-1)
Definition Renderer.cpp:1957
RHIDeviceHandle< RHISwapchain > mSwapchain
Definition Renderer.hpp:526
void DeclareBufferAccess(PassHandle pass, ResourceHandle handle, RHIPipelineStage stage, RHIResourceAccess access=RHIResourceAccessBits::ShaderRead) const
Explicitly declares that this pass will access the buffer in the specified stage with the specified a...
Definition Renderer.cpp:215
void BindBufferShaderRead(PassHandle pass, ResourceHandle buffer, RHIPipelineStage stage) const
Declares this pass has shaders that will read from this buffer. e.g. Vertex, Index.
Definition Renderer.cpp:332
Vector< Pair< RHIDeviceQueueType, RHIDeviceQueue::SubmitDesc > > * mExecuteSubmits
Definition Renderer.hpp:546
void WaitForFrame()
Blocks until the most recently submitted frame has finished executing on the GPU.
Definition Renderer.cpp:1651
State mState
Definition Renderer.hpp:481
void CmdBindDescriptorSet(PassHandle pass, RHICommandList *cmd, uint32_t set_index, RHIDeviceDescriptorSet *descriptor_set) const
Helper that binds a single descriptor set to the current command list.
Definition Renderer.cpp:2348
Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * > DerefPhysicalResource(ResourceHandle handle) const
Definition Renderer.cpp:170
void ExecuteBarrierAccelerationStructure(PassHandle pass, TrackedResource &res, RHIResourceAccess access, RHIPipelineStage stage, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes barriers for an acceleration structure.
Definition Renderer.cpp:1838
Core::JobBarrier BuildPipelineStateAll()
Definition Renderer.cpp:1333
void BindTextureSRV(PassHandle pass, ResourceHandle texture, StringView bind_point, RHIPipelineStage stage, RHITextureViewDesc const &desc) const
Binds a texture as a Shader Resource View (read-only sampling / fetch).
Definition Renderer.cpp:404
Vector< Vector< UniquePtr< ExecutePerThreadCommandLists > > > mExecutePerSwapCmds
Definition Renderer.hpp:561
RHIDeviceScopedHandle< RHIDeviceDescriptorSetLayout > mSwapDescriptorSetLayout
Definition Renderer.hpp:520
RHIDeviceSampler * DerefSampler(const ResourceHandle handle) const
Dereference a sampler handle to its underlying RHI sampler.
Definition Renderer.hpp:1148
void ExecuteFrame()
Executes all passes in the render graph for one frame.
Definition Renderer.cpp:1974
void ExecuteBarrierSubresourceState(PassHandle pass, RHITexture *res, TrackedResource::SubresourceState &sta, RHIResourceAccess access, RHIPipelineStage stage, RHITextureLayout layout, ExecuteBarrierPCmdOrPBarrierList cmd) const
Definition Renderer.cpp:1759
RHIDeviceQueue * mGraphicsQueue
Definition Renderer.hpp:527
Vector< RHIDeviceDescriptorSet * > const & DerefDescriptorSets(const PassHandle pass) const
Dereference the built descriptor sets associated with a given pass.
Definition Renderer.hpp:1165
uint32_t ExecuteGetQueueFamily(RHIDeviceQueueType queue) const
Helper to get the queue index of a queue type.
Definition Renderer.hpp:572
ResourceHandle CreateTextureView(PassHandle pass, ResourceHandle handle, RHITextureViewDesc const &desc) const
Definition Renderer.cpp:147
void BindTextureSampler(PassHandle pass, ResourceHandle sampler, StringView bind_point) const
Binds a sampler to the shader.
Definition Renderer.cpp:356
void ExecuteBarrierSubresource(PassHandle pass, TrackedResource &res, RHITextureSubresourceRange const &range, RHIResourceAccess access, RHIPipelineStage stage, RHITextureLayout layout, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes barriers for a subresource range of a texture.
Definition Renderer.cpp:1793
void BindDescriptorSetWrite(PassHandle pass, StringView bind_point, RHIDeviceDescriptorSetLayout *layout, RHIDeviceDescriptorSetLayout *reading_layout=nullptr)
Binds an externally managed descriptor set that this pass writes.
Definition Renderer.cpp:363
Vector< Pair< Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * >, RHICommandList::TransitionDesc > > ExecuteBarrierList
Definition Renderer.hpp:588
const RHIApplication * GetApplication() const
Get the RHIApplication this Renderer was constructed with.
Definition Renderer.hpp:1096
ScopedArena mExecuteArena
Definition Renderer.hpp:540
void MakePassUncullable(PassHandle pass) const
Marks a pass as "uncullable", meaning it will always be executed even if it has no dependencies.
Definition Renderer.cpp:141
void CmdDispatch(PassHandle pass, RHICommandList *cmd, RHIExtent3D thread_size) const
Helper that dispatches a compute shader with the specified THREAD count.
Definition Renderer.cpp:2434
Mutex mDescPoolMutex
Definition Renderer.hpp:497
void BindBackbufferRTV(PassHandle pass, RHIPipelineState::PipelineStateDesc::Attachment::Blending const &blending={}) const
Definition Renderer.cpp:483
void BindVertexInput(PassHandle pass, RHIPipelineState::PipelineStateDesc::VertexInput const &info) const
Associates Vertex Input description with this pass.
Definition Renderer.cpp:285
void CmdSetPipeline(PassHandle pass, RHICommandList *cmd) const
Helper that sets the current pass's PSO and descriptor sets to the current command list.
Definition Renderer.cpp:2332
uint32_t mFrameSwaps
Definition Renderer.hpp:490
void InvalidateTemporalResource(TemporalResourceHandle resource)
Invalidates Previous() until the current frame has produced a replacement.
Definition Renderer.cpp:1641
void FinalizePasses()
Definition Renderer.cpp:1360
void BuildPipelineState(PassHandle pass)
Definition Renderer.cpp:833
void BindPass(PassHandle pass, PassHandle other)
Declares an inter-pass dependency, where the other pass should execute-before the current pass.
Definition Renderer.cpp:205
void BindBufferStorageRead(PassHandle pass, ResourceHandle buffer, RHIPipelineStage stage, StringView bind_point) const
Binds a read-only storage buffer to a specified binding point.
Definition Renderer.cpp:314
RHIDeviceScopedHandle< RHIDeviceSemaphore > mGraphicsTimeline
Definition Renderer.hpp:524
void SetSwapchain(RHIDeviceHandle< RHISwapchain > swapchain)
Update the swapchain to a new one. You must call this when the window is resized or the swapchain is ...
Definition Renderer.cpp:1572
String DbgDumpActivePasses() const
Definition Renderer.cpp:2523
RHIPipelineState * DerefPipelineState(const PassHandle pass) const
Dereference the automatically built pipeline state object handle associated with a given pass.
Definition Renderer.hpp:1156
ResourceHandle ResolveResourceHandle(ResourceHandle handle, uint64_t frame) const
Definition Renderer.cpp:156
PassHandle CreatePassImpl(StringView name, RHIDeviceQueueType queue, size_t priority, Args &&... args)
Create a render pass from a RenderPass* implementation and add it to the render graph.
Definition Renderer.hpp:688
uint32_t GetFrameSwaps() const
Get the number of frames that can be simultaneously in-flight.
Definition Renderer.hpp:1253
AllocatorStack mExecuteAlloc
Definition Renderer.hpp:543
Vector< FrameSyncObjects > mSwaps
Definition Renderer.hpp:522
String DbgDumpExecutionGroups() const
Definition Renderer.cpp:2536
void BindAccelerationStructureSRV(PassHandle pass, ResourceHandle as, RHIPipelineStage stage, StringView bind_point) const
Declares that this pass has shaders that will read from this AS.
Definition Renderer.cpp:543
uint64_t mFrameSwapped
Definition Renderer.hpp:488
void CmdBeginGraphics(PassHandle pass, RHICommandList *cmd, RHIExtent2D const &extent, Span< const RHIColorAttachmentLoad > rtv_loads={}, RHIDepthAttachmentLoad dsv_load={RHIAttachmentLoadOp::Clear, {0.0f, 0u}})
Helper that pushes correct descriptor sets and PSO to the current command list, and pushes correct Be...
Definition Renderer.cpp:2371
RHIDeviceScopedHandle< RHIDeviceDescriptorPool > mDescPool
Definition Renderer.hpp:496
ThreadPool mExecuteThreadPool
Definition Renderer.hpp:548
RHITextureView * DerefTextureViewAtFrame(ResourceHandle handle, uint64_t frame) const
Definition Renderer.cpp:188
void AcquireSync()
Acquires the synchronization primitives for the current frame. Internal. Called by BeginExecute.
Definition Renderer.cpp:1679
void SetFrameSyncObjects()
Sets backbuffer views and sync primitives.
Definition Renderer.cpp:1546
RHISwapchain * GetSwapchain() const
Returns the currently used RHISwapchain object.
Definition Renderer.hpp:1336
void BindBufferCopySrc(PassHandle pass, ResourceHandle buffer) const
Declares that this pass will read from the buffer via copy.
Definition Renderer.cpp:350
Core::JobBarrier EndSetup(bool wait=true)
Finish setting up the render graph.
Definition Renderer.cpp:574
uint32_t mCurrentSwap
Definition Renderer.hpp:492
RHIDevice * GetDevice() const
Get the RHIDevice this Renderer was constructed with.
Definition Renderer.hpp:1092
void BindTextureUAV(PassHandle pass, ResourceHandle texture, StringView bind_point, RHIPipelineStage stage, RHITextureViewDesc const &desc) const
Binds a texture for unordered (UAV) read-write access in shaders.
Definition Renderer.cpp:417
void DeclareTextureAccess(PassHandle pass, ResourceHandle handle, RHIPipelineStage stage, RHITextureSubresourceRange range={}, RHIResourceAccess access=RHIResourceAccessBits::ShaderRead, RHITextureLayout layout=RHITextureLayout::ShaderReadOnly) const
Declares that this pass will access the texture in the specified stage with the specified access.
Definition Renderer.cpp:248
RHIExtent3D GetSwapchainExtent3D() const
Get the current swapchain extents as a 3D extent with depth 1.
Definition Renderer.hpp:1110
UniquePtr< RendererSetup > mSetup
Definition Renderer.hpp:529
void CullPasses(PassHandle epilogue) const
Definition Renderer.cpp:599
void BindTextureDSV(PassHandle pass, ResourceHandle texture, RHITextureViewDesc const &desc, bool readOnly=false) const
Binds a texture as a Depth-Stencil View for a graphics pass.
Definition Renderer.cpp:461
Allocator * GetAllocator() const
Definition Renderer.hpp:1174
void BindTextureCopyDst(PassHandle pass, ResourceHandle texture, RHITextureSubresourceRange const &range={}) const
Declares that this pass will write to the texture via copy / blit (transfer destination).
Definition Renderer.cpp:511
RHIExtent2D GetSwapchainExtent() const
Get the current swapchain extents.
Definition Renderer.hpp:1101
RHIDeviceHandle< RHIDeviceSemaphore > GetRenderCompleteSemaphore() const
Binary semaphore signaled when GPU work for the current swap image is complete.
Definition Renderer.cpp:1625
RHIApplicationHandle< RHIDevice > mDevice
Definition Renderer.hpp:525
RendererDesc mDesc
Definition Renderer.hpp:486
Allocator * mAllocator
Definition Renderer.hpp:482
void ExecuteBarriers(TrackedPass &pass, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes all barriers for a pass.
Definition Renderer.cpp:1868
void BindBufferCopyDst(PassHandle pass, ResourceHandle buffer) const
Declares that this pass will write to the buffer via copy.
Definition Renderer.cpp:344
void BeginExecute()
Begins execution for a headless (no swapchain) frame.
Definition Renderer.cpp:1743
TrackedPass const & GetTrackedPass(PassHandle pass)
Retrieves an internal tracked pass associated with the given handle, read-only.
Definition Renderer.hpp:1299
void BindBufferIndirectRead(PassHandle pass, ResourceHandle buffer) const
Declares that this pass will consume this buffer as the source of an indirect draw/dispatch command.
Definition Renderer.cpp:338
void EndExecute()
Ends the execution phase and performs GPU submission.
Definition Renderer.cpp:2290
void FinalizeResources()
Definition Renderer.cpp:1381
uint32_t mCurrentSync
Definition Renderer.hpp:491
void BindPushConstant(PassHandle pass, RHIShaderStage stage, size_t offset, size_t size) const
Declares a range of Push Constant used in a stage.
Definition Renderer.cpp:294
void ExecuteBarrierBuffer(PassHandle pass, TrackedResource &res, RHIResourceAccess access, RHIPipelineStage stage, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes barriers for a whole buffer.
Definition Renderer.cpp:1809
Span< const uint64_t > DbgProfilePassTiming(uint64_t sync, float &resolutionNS) const
Retrieves timings for all passes executed in the last frame associated with the specified sync index....
Definition Renderer.cpp:2551
String DbgDumpGraphviz() const
Definition Renderer.cpp:2475
Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * > DerefResourceAtFrame(ResourceHandle handle, uint64_t frame) const
Definition Renderer.cpp:183
void BindTextureCopySrc(PassHandle pass, ResourceHandle texture, RHITextureSubresourceRange const &range={}) const
Declares that this pass will read from the texture via copy / blit (transfer source).
Definition Renderer.cpp:521
void BindBufferUnordered(PassHandle pass, ResourceHandle buffer, RHIPipelineStage stage, StringView bind_point) const
Binds a buffer for unordered (UAV) access from shaders (read and/or write in any order).
Definition Renderer.cpp:323
void PassSetTopology(PassHandle pass, RHIPipelineState::PipelineStateDesc::Topology topology) const
Sets the input assembly topology for a graphics pass (TriangleList, LineList, etc....
Definition Renderer.cpp:567
RHIDeviceQueue * mComputeQueue
Definition Renderer.hpp:527
void BindAccelerationStructureWrite(PassHandle pass, ResourceHandle as) const
Declares that this pass will build, or update the AS.
Definition Renderer.cpp:531
void BindShader(PassHandle pass, RHIShaderStage stage, StringView entry_point, StringView shader_path, Span< const char > specializationData={}, uint32_t rtHitGroupIndex=0, RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType rtHitGroupType=RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType::Triangles) const
Binds shader file path to a certain pass at a certain stage.
Definition Renderer.cpp:274
Core::JobSystem * mJobs
Definition Renderer.hpp:483
RHIDeviceScopedHandle< RHIDeviceSemaphore > mComputeTimeline
Definition Renderer.hpp:524
void CmdSetPushConstant(PassHandle pass, RHICommandList *cmd, RHIShaderStage stage, size_t offset, T const &data)
Helper that sets a Push Constant range data with a single l-value.
Definition Renderer.hpp:1236
void BindDescriptorSetRead(PassHandle pass, StringView bind_point, RHIDeviceDescriptorSetLayout *layout)
Binds an externally managed descriptor set that this pass reads.
Definition Renderer.cpp:390
bool IsAsyncComputeEnabled() const
Returns whether async compute is enabled.
Definition Renderer.hpp:1310
RHIDeviceIdleGuard mWaitIdle
Definition Renderer.hpp:663
uint64_t GetSync() const
Retrieves the current synchronization index.
Definition Renderer.hpp:1295
State
Definition Renderer.hpp:473
bool IsPresentEnabled() const
Returns whether a swapchain is bound.
Definition Renderer.hpp:1320
TemporalResourceHandle CreateTemporalResource(StringView name, T const &desc)
Creates a double-buffered resource with frame-relative handles.
Definition Renderer.hpp:760
RHIExtent3D CmdGetComputeLocalSize(PassHandle pass) const
Helper that retrieves the local size declared by a compute pass.
Definition Renderer.cpp:2425
uint32_t GetSwap() const
Retrieves the current swap index at the time of ExecuteFrame().
Definition Renderer.hpp:1281
uint64_t GetFrame() const
Retrieves the current frame number.
Definition Renderer.hpp:1260
bool IsPreviousValid(TemporalResourceHandle resource) const
Returns whether Previous() contains a frame produced since the last invalidation.
Definition Renderer.cpp:1633
State GetState() const
Retrieves the current state of the renderer.
Definition Renderer.hpp:1249
void DbgGetGraph(Vector< DebugGraphNode > &outNodes, Vector< DebugGraphEdge > &outEdges) const
Definition Renderer.cpp:2443
RHITextureView * DerefTextureView(const ResourceHandle handle) const
Dereference a texture view handle to its underlying RHI texture view.
Definition Renderer.hpp:1139
void BindBufferUniform(PassHandle pass, ResourceHandle buffer, RHIPipelineStage stage, StringView bind_point) const
Binds a uniform buffer to a specified binding point in a rendering pass.
Definition Renderer.cpp:305
ResourceHandle CreateSampler(RHIDeviceSampler::SamplerDesc const &desc) const
Creates a sampler with the specified name and descriptor.
Definition Renderer.cpp:198
ResourceHandle CreateResource(StringView name, T const &desc)
Create a new resource to be used in the render graph.
Definition Renderer.hpp:744
void BindBackbufferUAV(PassHandle pass, int set_index) const
Binds the backbuffer as RW access at binding 0 of set index.
Definition Renderer.cpp:497
RHIDeviceScopedHandle< RHIDeviceDescriptorPool > mSwapDescriptorPool
Definition Renderer.hpp:519
Definition Renderer.hpp:24
ResourceHandle Current() const
Definition Renderer.hpp:36
TemporalResourceHandle(ResourceHandle current, ResourceHandle previous)
Definition Renderer.hpp:29
bool IsValid() const
Definition Renderer.hpp:38
ResourceHandle mPrevious
Definition Renderer.hpp:27
ResourceHandle mCurrent
Definition Renderer.hpp:26
TemporalResourceHandle()=default
ResourceHandle Previous() const
Definition Renderer.hpp:37
std::vector< T, StlAllocator< T > > Vector
std::vector with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:149
std::tuple< Args... > Tuple
Alias for std::tuple
Definition Container.hpp:39
std::mutex Mutex
Definition Thread.hpp:10
constexpr String Format(fmt::format_string< Args... > format, Args &&... args)
String wrapper for Format().
Definition Container.hpp:126
std::map< K, V, Predicate, StlAllocator< Pair< const K, V > > > Map
std::map with explicit Foundation::Core::StlAllocator constructor
Definition Container.hpp:178
std::atomic< T > Atomic
Alias of std::atomic<T>.
Definition Atomic.hpp:26
std::basic_string< char, std::char_traits< char >, StlDefaultAllocator< char > > String
Alias for std::basic_string<char>, without an explicit allocator constructor.
Definition Container.hpp:120
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:56
std::unique_ptr< T, Deleter > UniquePtr
std::unique_ptr with custom deleter that uses a Foundation::Core::Allocator to deallocate memory.
Definition Allocator.hpp:180
std::span< T > Span
Alias for std::span
Definition Container.hpp:62
const uint32_t kCommandQueueTransferIgnored
Definition Command.hpp:40
RHITextureLayout
Definition Common.hpp:218
uintptr_t Handle
Definition Details.hpp:9
glm::vec< 3, uint32_t > RHIExtent3D
Definition Common.hpp:11
RHIDeviceQueueType
Definition Common.hpp:179
static constexpr Handle kInvalidHandle
Definition Details.hpp:10
RHIResourceFormat
Definition Common.hpp:34
glm::vec< 2, uint32_t > RHIExtent2D
Definition Common.hpp:10
RHISwapchainResult
Definition Swapchain.hpp:9
Core functionalities for rendering, including the Frame Graph implementation.
Definition Bindless.cpp:2
Handle ResourceHandle
Definition Renderer.hpp:22
const size_t kTextureAspectCount
Definition Renderer.hpp:106
const RHIResourceAccessBits kAllShaderWrites
Definition Renderer.hpp:96
constexpr size_t kMaxRenderPasses
Definition Renderer.hpp:88
const RHIResourceAccessBits kAllShaderReads
Definition Renderer.hpp:99
const RHIPipelineStage kComputeStagesMask
Definition Renderer.hpp:93
Handle PassHandle
Definition Renderer.hpp:21
constexpr size_t kExecuteArenaSize
Definition Renderer.hpp:92
constexpr size_t kMaxCommandListsPerThread
Definition Renderer.hpp:90
Definition Allocator.hpp:6
std::optional with convenience Get()/GetIf() methods.
Definition Container.hpp:256
RAII wrapper for an arena allocated from an Allocator.
Definition Allocator.hpp:49
Definition Resource.hpp:28
Definition Command.hpp:50
RAII guard to wait for device idle on destruction.
Definition Device.hpp:378
Definition Device.hpp:111
Definition PipelineState.hpp:134
Definition PipelineState.hpp:117
Definition PipelineState.hpp:93
enum Foundation::RHI::RHIPipelineState::PipelineStateDesc::Topology TriangleList
Topology
Definition PipelineState.hpp:77
RayTracingHitGroupType
Definition PipelineState.hpp:186
Definition Resource.hpp:142
RHITextureAspectFlag aspect
Definition Resource.hpp:161
Definition Resource.hpp:167
RHITextureSubresourceLayer layer
Definition Resource.hpp:169
Pair< uint32_t, uint32_t > GetMipLevelRange() const
Definition Resource.hpp:173
Pair< uint32_t, uint32_t > GetArrayLayerRange() const
Definition Resource.hpp:178
Definition Resource.hpp:210
Definition Renderer.hpp:217
TextureViewHandle slots[2]
Definition Renderer.hpp:218
bool temporal
Definition Renderer.hpp:219
Helper class containing runtime resources either imported, or created by the Renderer.
Definition Renderer.hpp:214
Vector< Variant< RHIBuffer *, RHIDeviceScopedHandle< RHIBuffer >, RHITexture *, RHIDeviceScopedHandle< RHITexture >, RHIAccelerationStructure * > > resources
Definition Renderer.hpp:223
Vector< RHIDeviceScopedHandle< RHIDeviceSampler > > samplers
Definition Renderer.hpp:225
ExecuteResources(Allocator *allocator)
Definition Renderer.hpp:226
Vector< TextureViews > views
Definition Renderer.hpp:224
void fit(ResourceHandle handle)
Definition Renderer.hpp:227
Default "no-op" functor for Record()
Definition Renderer.hpp:275
void operator()(PassHandle, Renderer *, RHICommandList *) const
Definition Renderer.hpp:276
Default "no-op" functor for Setup()
Definition Renderer.hpp:268
void operator()(PassHandle, Renderer *) const
Definition Renderer.hpp:269
Functional wrapper for a render pass.
Definition Renderer.hpp:285
LambdaPass(FSetup &&setup, FRecord &&record)
Definition Renderer.hpp:288
void Record(PassHandle self, Renderer *r, RHICommandList *cmd) override
Record the commands of this pass into the given command list.
Definition Renderer.hpp:293
FRecord mRecord
Definition Renderer.hpp:287
void Setup(PassHandle self, Renderer *r) override
Perform any setup required for this pass. This may include creating resources, declaring resource acc...
Definition Renderer.hpp:292
FSetup mSetup
Definition Renderer.hpp:286
Parameters for Renderer creation.
Definition Renderer.hpp:47
bool profilePasses
Enable or disable GPU profiling for the frame graph execution.
Definition Renderer.hpp:82
uint32_t threadCount
Number of worker threads to use for recording command lists.
Definition Renderer.hpp:67
bool asyncCompute
Enable Async Compute support.
Definition Renderer.hpp:62
RHIPipelineStateCache * pipelineCache
Optional PSO cache to potentially speed up pipeline state recompilation in Setup time.
Definition Renderer.hpp:72
Definition Renderer.hpp:1418
PassHandle consumer
Definition Renderer.hpp:1419
StringView resourceName
Definition Renderer.hpp:1421
PassHandle producer
Definition Renderer.hpp:1420
Definition Renderer.hpp:1407
size_t depth
Definition Renderer.hpp:1413
int groupIndex
Definition Renderer.hpp:1415
bool epilogue
Definition Renderer.hpp:1412
size_t ord
Definition Renderer.hpp:1414
StringView name
Definition Renderer.hpp:1408
bool used
Definition Renderer.hpp:1411
RHIDeviceQueueType queue
Definition Renderer.hpp:1410
PassHandle handle
Definition Renderer.hpp:1409
Definition Renderer.hpp:550
Vector< RHICommandPoolScopedHandle< RHICommandList > > computeCmds
Definition Renderer.hpp:552
RHICommandList * AllocateCompute()
Definition Renderer.cpp:1946
size_t graphicsCtr
Definition Renderer.hpp:554
RHIDeviceScopedHandle< RHICommandPool > computePool
Definition Renderer.hpp:551
RHICommandList * AllocateGraphics()
Definition Renderer.cpp:1935
RHIDeviceScopedHandle< RHICommandPool > graphicsPool
Definition Renderer.hpp:551
Vector< RHICommandPoolScopedHandle< RHICommandList > > graphicsCmds
Definition Renderer.hpp:552
size_t computeCtr
Definition Renderer.hpp:554
void Reset()
Definition Renderer.cpp:1927
Definition Renderer.hpp:500
ResourceHandle backbuffer
Definition Renderer.hpp:509
RHIDeviceScopedHandle< RHIDeviceQueryPool > dbgQueryPool
Definition Renderer.hpp:511
RHIDeviceScopedHandle< RHIDeviceFence > computeFence
Definition Renderer.hpp:504
RHIDeviceScopedHandle< RHIDeviceFence > graphicsFence
Definition Renderer.hpp:504
FrameSyncObjects(size_t swapIndex, Allocator *alloc)
Definition Renderer.hpp:514
const size_t swapIndex
Definition Renderer.hpp:502
Vector< uint64_t > dbgQueryPassTimestampsResults
Definition Renderer.hpp:512
RHITextureScopedHandle< RHITextureView > view
Definition Renderer.hpp:506
RHIDeviceScopedHandle< RHIDeviceSemaphore > render
Definition Renderer.hpp:503
RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > viewSet
Definition Renderer.hpp:507
Definition Renderer.hpp:1073
String name
Definition Renderer.hpp:1074
size_t bytes
Definition Renderer.hpp:1075
Definition Renderer.hpp:434
const int groupIndex
Definition Renderer.hpp:435
Vector< PassHandle > passes
Definition Renderer.hpp:439
int graphicsGroupIndex
Definition Renderer.hpp:436
bool isLastGraphics
Definition Renderer.hpp:442
int computeGroupIndex
Definition Renderer.hpp:437
Vector< ResourceHandle > resources
Definition Renderer.hpp:441
bool isLastCompute
Definition Renderer.hpp:443
ExecutionGroups(int groupIndex, RHIDeviceQueueType queue, Allocator *allocator)
Definition Renderer.hpp:445
const RHIDeviceQueueType queue
Definition Renderer.hpp:438
Definition Renderer.hpp:415
ResourceHandle slots[2]
Definition Renderer.hpp:416
uint64_t invalidatedFrame
Definition Renderer.hpp:417
Helper class containing all states pertaining to Renderer's Setup phase.
Definition Renderer.hpp:409
Vector< ExecutionGroups > executionGroups
Definition Renderer.hpp:450
PassHandle lastBackbufferProducer
Definition Renderer.hpp:421
bool executionAnyCompute
Definition Renderer.hpp:451
int executionNumGraphicsGroups
Definition Renderer.hpp:452
Vector< PassHandle > execution
Definition Renderer.hpp:429
Vector< Vector< Pair< PassHandle, ResourceHandle > > > graph
Definition Renderer.hpp:410
Vector< TrackedPass > trackedPasses
Definition Renderer.hpp:412
Map< ResourceHandle, Pair< PassHandle, PassHandle > > activeResources
Definition Renderer.hpp:426
int executionNumComputeGroups
Definition Renderer.hpp:452
Vector< PassHandle > in
Definition Renderer.hpp:411
Map< uintptr_t, PassHandle > descriptorSetWriters
Definition Renderer.hpp:427
void add_edge(const PassHandle u, const PassHandle v, const ResourceHandle hdl)
Definition Renderer.hpp:453
PassHandle epilogue
Definition Renderer.hpp:431
Vector< RHIDeviceSampler::SamplerDesc > trackedSamplers
Definition Renderer.hpp:424
Map< RHIDescriptorType, uint32_t > bindingCounts
Definition Renderer.hpp:430
Vector< TrackedResource > trackedResources
Definition Renderer.hpp:413
Vector< Pair< ResourceHandle, RHITextureViewDesc > > trackedViews
Definition Renderer.hpp:423
bool executionAnyGraphics
Definition Renderer.hpp:451
Vector< TemporalResourceFamily > temporalResources
Definition Renderer.hpp:419
RendererSetup(Allocator *allocator)
Definition Renderer.hpp:463
Definition Renderer.hpp:1078
String name
Definition Renderer.hpp:1079
ResourceHandle resourceHandle
Definition Renderer.hpp:1080
RHITextureView * view
Definition Renderer.hpp:1083
RHIResourceFormat format
Definition Renderer.hpp:1082
ResourceHandle viewHandle
Definition Renderer.hpp:1081
Internal tracking information for a render pass in the frame graph.
Definition Renderer.hpp:299
size_t frameExec
Definition Renderer.hpp:320
int priority
Definition Renderer.hpp:302
RHIPipelineState::PipelineStateDesc::DepthStencil psoDepthStencil
Definition Renderer.hpp:371
ResourceHandle dsv
Definition Renderer.hpp:354
Vector< Tuple< String, String, RHIShaderStage, Vector< char >, uint32_t, RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType > > shaders
Definition Renderer.hpp:339
Vector< RHIPipelineState::PipelineStateDesc::VertexInput::Binding > vertexInputBindings
Definition Renderer.hpp:357
Vector< RHIDeviceDescriptorSetLayout * > pDescriptorLayouts
Definition Renderer.hpp:376
RHIPipelineStageBits piplineStages
Definition Renderer.hpp:366
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage, RHITextureSubresourceRange, RHITextureLayout > > textureUsages
Definition Renderer.hpp:325
UniquePtr< RenderPass > pass
Definition Renderer.hpp:360
Vector< RHIDeviceDescriptorSet * > pDescriptorSets
Definition Renderer.hpp:379
RHIDeviceQueueType queue
Definition Renderer.hpp:304
RHIPipelineState::PipelineStateDesc::Rasterizer psoRasterizer
Definition Renderer.hpp:370
int groupIndex
Definition Renderer.hpp:364
size_t ord
Definition Renderer.hpp:319
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > textureBindings
Definition Renderer.hpp:341
Vector< Pair< ResourceHandle, String > > samplers
Definition Renderer.hpp:346
RHIDeviceScopedHandle< RHIPipelineState > pso
Definition Renderer.hpp:368
Vector< RHIDeviceScopedHandle< RHIDeviceDescriptorSetLayout > > descriptorLayouts
Definition Renderer.hpp:374
Vector< RHIDeviceDescriptorSet * > pAlternateDescriptorSets
Definition Renderer.hpp:379
bool unCullable
Definition Renderer.hpp:306
bool isRayTracingPass
Definition Renderer.hpp:315
Vector< RHIPipelineState::PipelineStateDesc::PushConstant > pushConstants
Definition Renderer.hpp:348
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > asUsages
Definition Renderer.hpp:330
Optional< RHIPipelineState::PipelineStateDesc::Attachment::Blending > backbufferRTV
Definition Renderer.hpp:308
bool isDepthReadOnly
Definition Renderer.hpp:355
bool used
Definition Renderer.hpp:305
Vector< RHIVertexAttribute > vertexInputAttributes
Definition Renderer.hpp:358
void ResetPipeline()
Definition Renderer.cpp:60
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > bufferBindings
Definition Renderer.hpp:341
Vector< Tuple< size_t, RHIDeviceDescriptorSetLayout * > > pExternalDescriptorSets
Definition Renderer.hpp:381
Vector< Tuple< RHIShaderStage, size_t, Vector< char > > > specializationConstants
Definition Renderer.hpp:350
Vector< RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > > descriptorSets
Definition Renderer.hpp:378
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > asBindings
Definition Renderer.hpp:341
PassHandle handle
Definition Renderer.hpp:301
Tuple< uint32_t, uint32_t, uint32_t > groupLocalSize
Definition Renderer.hpp:317
Vector< ResourceHandle > texviews
Definition Renderer.hpp:334
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > bufferUsages
Definition Renderer.hpp:327
Optional< int > backbufferUAV
Definition Renderer.hpp:309
size_t depth
Definition Renderer.hpp:318
Vector< PassHandle > bindPasses
Definition Renderer.hpp:322
Vector< Pair< ResourceHandle, RHIPipelineState::PipelineStateDesc::Attachment::Blending > > rtvs
Definition Renderer.hpp:352
bool isComputePass
Definition Renderer.hpp:312
RHIPipelineState::PipelineStateDesc::Topology psoTopology
Definition Renderer.hpp:372
Vector< ResourceHandle > resources
Definition Renderer.hpp:332
String name
Definition Renderer.hpp:300
Vector< Tuple< String, RHIDeviceDescriptorSetLayout *, int > > externalBindings
Definition Renderer.hpp:344
Vector< RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > > alternateDescriptorSets
Definition Renderer.hpp:378
RHIDevicePipelineType GetPipelineType() const
Definition Renderer.hpp:384
Definition Renderer.hpp:126
RHIPipelineStage stage
Definition Renderer.hpp:138
size_t lastProducedFrame
Definition Renderer.hpp:132
PassHandle lastProducer
Definition Renderer.hpp:130
RHIResourceAccess access
Definition Renderer.hpp:137
bool executeTempTransitionFlag
Definition Renderer.hpp:136
RHIDeviceQueueType lastOwnerQueue
Definition Renderer.hpp:134
PassHandle producer
Definition Renderer.hpp:128
void reset()
Definition Renderer.hpp:139
Definition Renderer.hpp:150
RHIResourceAccess access
Definition Renderer.hpp:164
RHIDeviceQueueType lastOwnerQueue
Definition Renderer.hpp:161
void reset()
Definition Renderer.hpp:167
bool executeTempTransitionFlag
Definition Renderer.hpp:163
RHIPipelineStage stage
Definition Renderer.hpp:165
RHITextureAspectFlagBits aspect
Definition Renderer.hpp:152
RHITextureLayout layout
Definition Renderer.hpp:166
PassHandle producer
Definition Renderer.hpp:155
size_t lastProducedFrame
Definition Renderer.hpp:159
PassHandle lastProducer
Definition Renderer.hpp:157
RHITextureSubresourceRange ToRange() const
Definition Renderer.cpp:8
size_t mip
Definition Renderer.hpp:151
size_t layer
Definition Renderer.hpp:151
Internal tracking information for a resource in the frame graph.
Definition Renderer.hpp:111
Vector< SubresourceState > lastSubresourceStates
Definition Renderer.hpp:179
auto GetLastSubresourceStateOf(RHITextureSubresourceRange const &range)
Definition Renderer.hpp:180
bool hasGraphicsUsage
Definition Renderer.hpp:118
uint8_t temporalFramesAgo
Definition Renderer.hpp:116
String name
Definition Renderer.hpp:113
ResourceHandle temporalFamily
Definition Renderer.hpp:115
void ResetStates()
Definition Renderer.hpp:200
ResourceDefinition desc
Definition Renderer.hpp:114
AccelerationStructureState lastASState
Definition Renderer.hpp:199
uint32_t textureMips
Definition Renderer.hpp:148
uint32_t textureLayers
Definition Renderer.hpp:148
bool hasComputeUsage
Definition Renderer.hpp:117
struct Foundation::RenderCore::TrackedResource::BufferState lastBufferState
ResourceHandle handle
Definition Renderer.hpp:112