74 RHIPipelineStageBits::VertexShader | RHIPipelineStageBits::MeshShader | RHIPipelineStageBits::RayTracingShader |
75 RHIPipelineStageBits::AllGraphics;
77 RHIResourceAccessBits::RenderTargetWrite | RHIResourceAccessBits::DepthStencilWrite |
78 RHIResourceAccessBits::TransferWrite | RHIResourceAccessBits::HostWrite;
80 RHIResourceAccessBits::RenderTargetRead | RHIResourceAccessBits::DepthStencilRead |
81 RHIResourceAccessBits::UniformRead | RHIResourceAccessBits::TransferRead | RHIResourceAccessBits::HostRead;
171 state.
mip <= mip_end && state.
layer >= layer_begin && state.
layer <= layer_end;
202 views.resize(std::max(
views.size(),
static_cast<size_t>(handle + 1)));
203 samplers.resize(std::max(
samplers.size(),
static_cast<size_t>(handle + 1)));
255 template <
typename FSetup,
typename FRecord>
261 mSetup(std::forward<FSetup>(setup)),
mRecord(std::forward<FRecord>(record))
360 return RHIDevicePipelineType::Compute;
362 return RHIDevicePipelineType::RayTracing;
363 return RHIDevicePipelineType::Graphics;
423 while (u >=
graph.size())
425 graph[u].emplace_back(v, hdl);
426 while (v >=
in.size())
522 ExecutePerThreadCommandLists(
RHIDevice* device,
size_t maxPerThread,
Allocator* alloc);
543 case RHIDeviceQueueType::Undefined:
545 case RHIDeviceQueueType::Graphics:
547 case RHIDeviceQueueType::Compute:
550 CHECK_MSG(
false,
"Unhandled queue type");
612 RHIResourceAccess access = RHIResourceAccessBits::ShaderRead)
const;
622 RHIResourceAccess access = RHIResourceAccessBits::ShaderRead,
630#pragma region Render Graph Setup
647 template <
typename T,
typename... Args>
648 requires std::is_base_of_v<RenderPass, T>
652 CHECK_MSG(queue == RHIDeviceQueueType::Graphics || queue == RHIDeviceQueueType::Compute,
653 "Invalid queue type. Only Graphics and Compute queues are supported.");
657 queue = RHIDeviceQueueType::Graphics;
658 mSetup->trackedPasses.emplace_back(
660 ConstructUniqueBase<RenderPass, T>(
mAllocator, std::forward<Args>(args)...), priority);
661 mSetup->epilogue = handle;
679 template <
typename FSetup,
typename FRecord>
683 return CreatePassImpl<LambdaPass<FSetup, FRecord>>(name, queue, priority, std::forward<FSetup>(setup),
684 std::forward<FRecord>(record));
704 template <
typename T>
712 return mSetup->trackedResources.size() - 1;
723#pragma region Resource Binding
745 RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType::Triangles)
const;
937 bool readOnly =
false)
const;
981#pragma region PSO Flags
1009#pragma region Diagnostics
1026#pragma region Swapchain
1052 return {xy.x, xy.y, 1};
1055#pragma region Render Graph Runtime
1073 CHECK_MSG(!res.valueless_by_exception(),
"Resource handle {} is valueless", handle);
1074 auto ptr = res.Visit([](
auto* ptr) -> Tv {
return ptr; }, [](
auto& hdl) -> Tv {
return hdl.Get(); });
1075 CHECK_MSG(!ptr.valueless_by_exception(),
"Resource handle {} is null", handle);
1088 CHECK_MSG(!view.valueless_by_exception(),
"Texture view handle {} is valueless", handle);
1089 return view.Visit([](
auto& hdl) -> Tv {
return hdl.Get(); });
1098 CHECK(
mSetup && handle < mSetup->trackedSamplers.size());
1106 CHECK(
mSetup && pass < mSetup->trackedPasses.size());
1107 auto& tpass =
mSetup->trackedPasses[pass];
1108 return tpass.pso.Get();
1115 CHECK(
mSetup && pass < mSetup->trackedPasses.size());
1116 auto& tpass =
mSetup->trackedPasses[pass];
1117 return tpass.pDescriptorSets;
1124#pragma region Command Recording Helpers
1183 template <
typename T>
1188 auto& tpass =
mSetup->trackedPasses[pass];
1189 cmd->
PushConstant(tpass.pso.Get(), stage,
static_cast<uint32_t
>(offset),
1190 {reinterpret_cast<const char*>(&data), sizeof(T)});
1193#pragma region Frame Execution
1239 CHECK_MSG(
mSetup && pass < mSetup->trackedPasses.size(),
"No passes available or out of bounds");
1240 return mSetup->trackedPasses[pass];
1341#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:210
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:377
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:680
void DbgGetTexturePreviews(Vector< TexturePreviewStat > &outStats) const
Definition Renderer.cpp:1401
Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * > DerefResource(const ResourceHandle handle) const
Dereference a resource handle to its underlying RHI resource.
Definition Renderer.hpp:1068
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:388
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:504
Atomic< bool > mPipelineStateCompilationComplete
Definition Renderer.hpp:451
UniquePtr< ExecuteResources > mResources
Definition Renderer.hpp:462
RHIDeviceSemaphore * mExecuteImageAcquire
Definition Renderer.hpp:460
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:378
void BeginSetup()
Begins the setup phase of the render graph.
Definition Renderer.cpp:123
void DbgGetMemoryStatistics(Vector< MemoryStat > &outStats) const
Definition Renderer.cpp:1362
RHICommandList * ExecuteAllocateCommandList(RHIDeviceQueueType queue, int thread_id=-1)
Definition Renderer.cpp:1816
RHIDeviceHandle< RHISwapchain > mSwapchain
Definition Renderer.hpp:493
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:170
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:279
Vector< Pair< RHIDeviceQueueType, RHIDeviceQueue::SubmitDesc > > * mExecuteSubmits
Definition Renderer.hpp:513
void WaitForFrame()
Blocks until the most recently submitted frame has finished executing on the GPU.
Definition Renderer.cpp:1510
State mState
Definition Renderer.hpp:448
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:2186
void ExecuteBarrierAccelerationStructure(PassHandle pass, TrackedResource &res, RHIResourceAccess access, RHIPipelineStage stage, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes barriers for an acceleration structure.
Definition Renderer.cpp:1697
Core::JobBarrier BuildPipelineStateAll()
Definition Renderer.cpp:1223
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:351
Vector< Vector< UniquePtr< ExecutePerThreadCommandLists > > > mExecutePerSwapCmds
Definition Renderer.hpp:528
RHIDeviceScopedHandle< RHIDeviceDescriptorSetLayout > mSwapDescriptorSetLayout
Definition Renderer.hpp:487
RHIDeviceSampler * DerefSampler(const ResourceHandle handle) const
Dereference a sampler handle to its underlying RHI sampler.
Definition Renderer.hpp:1096
void ExecuteFrame()
Executes all passes in the render graph for one frame.
Definition Renderer.cpp:1833
void ExecuteBarrierSubresourceState(PassHandle pass, RHITexture *res, TrackedResource::SubresourceState &sta, RHIResourceAccess access, RHIPipelineStage stage, RHITextureLayout layout, ExecuteBarrierPCmdOrPBarrierList cmd) const
Definition Renderer.cpp:1618
RHIDeviceQueue * mGraphicsQueue
Definition Renderer.hpp:494
Vector< RHIDeviceDescriptorSet * > const & DerefDescriptorSets(const PassHandle pass) const
Dereference the built descriptor sets associated with a given pass.
Definition Renderer.hpp:1113
uint32_t ExecuteGetQueueFamily(RHIDeviceQueueType queue) const
Helper to get the queue index of a queue type.
Definition Renderer.hpp:539
ResourceHandle CreateTextureView(PassHandle pass, ResourceHandle handle, RHITextureViewDesc const &desc) const
Definition Renderer.cpp:144
void BindTextureSampler(PassHandle pass, ResourceHandle sampler, StringView bind_point) const
Binds a sampler to the shader.
Definition Renderer.cpp:303
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:1652
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:310
Vector< Pair< Variant< RHIBuffer *, RHITexture *, RHIAccelerationStructure * >, RHICommandList::TransitionDesc > > ExecuteBarrierList
Definition Renderer.hpp:555
const RHIApplication * GetApplication() const
Get the RHIApplication this Renderer was constructed with.
Definition Renderer.hpp:1034
ScopedArena mExecuteArena
Definition Renderer.hpp:507
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:138
void CmdDispatch(PassHandle pass, RHICommandList *cmd, RHIExtent3D thread_size) const
Helper that dispatches a compute shader with the specified THREAD count.
Definition Renderer.cpp:2272
Mutex mDescPoolMutex
Definition Renderer.hpp:464
void BindBackbufferRTV(PassHandle pass, RHIPipelineState::PipelineStateDesc::Attachment::Blending const &blending={}) const
Definition Renderer.cpp:430
void BindVertexInput(PassHandle pass, RHIPipelineState::PipelineStateDesc::VertexInput const &info) const
Associates Vertex Input description with this pass.
Definition Renderer.cpp:232
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:2174
uint32_t mFrameSwaps
Definition Renderer.hpp:457
void FinalizePasses()
Definition Renderer.cpp:1250
void BuildPipelineState(PassHandle pass)
Definition Renderer.cpp:766
void BindPass(PassHandle pass, PassHandle other)
Declares an inter-pass dependency, where the other pass should execute-before the current pass.
Definition Renderer.cpp:160
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:261
RHIDeviceScopedHandle< RHIDeviceSemaphore > mGraphicsTimeline
Definition Renderer.hpp:491
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:1451
String DbgDumpActivePasses() const
Definition Renderer.cpp:2329
RHIPipelineState * DerefPipelineState(const PassHandle pass) const
Dereference the automatically built pipeline state object handle associated with a given pass.
Definition Renderer.hpp:1104
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:649
uint32_t GetFrameSwaps() const
Get the number of frames that can be simultaneously in-flight.
Definition Renderer.hpp:1201
AllocatorStack mExecuteAlloc
Definition Renderer.hpp:510
Vector< FrameSyncObjects > mSwaps
Definition Renderer.hpp:489
String DbgDumpExecutionGroups() const
Definition Renderer.cpp:2342
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:490
uint64_t mFrameSwapped
Definition Renderer.hpp:455
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:2209
RHIDeviceScopedHandle< RHIDeviceDescriptorPool > mDescPool
Definition Renderer.hpp:463
ThreadPool mExecuteThreadPool
Definition Renderer.hpp:515
void AcquireSync()
Acquires the synchronization primitives for the current frame. Internal. Called by BeginExecute.
Definition Renderer.cpp:1538
void SetFrameSyncObjects()
Sets backbuffer views and sync primitives.
Definition Renderer.cpp:1425
RHISwapchain * GetSwapchain() const
Returns the currently used RHISwapchain object.
Definition Renderer.hpp:1272
void BindBufferCopySrc(PassHandle pass, ResourceHandle buffer) const
Declares that this pass will read from the buffer via copy.
Definition Renderer.cpp:297
Core::JobBarrier EndSetup(bool wait=true)
Finish setting up the render graph.
Definition Renderer.cpp:521
uint32_t mCurrentSwap
Definition Renderer.hpp:459
RHIDevice * GetDevice() const
Get the RHIDevice this Renderer was constructed with.
Definition Renderer.hpp:1030
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:364
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:199
RHIExtent3D GetSwapchainExtent3D() const
Get the current swapchain extents as a 3D extent with depth 1.
Definition Renderer.hpp:1048
UniquePtr< RendererSetup > mSetup
Definition Renderer.hpp:496
void CullPasses(PassHandle epilogue) const
Definition Renderer.cpp:546
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:408
Allocator * GetAllocator() const
Definition Renderer.hpp:1122
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:458
RHIExtent2D GetSwapchainExtent() const
Get the current swapchain extents.
Definition Renderer.hpp:1039
RHIDeviceHandle< RHIDeviceSemaphore > GetRenderCompleteSemaphore() const
Binary semaphore signaled when GPU work for the current swap image is complete.
Definition Renderer.cpp:1502
RHIApplicationHandle< RHIDevice > mDevice
Definition Renderer.hpp:492
RendererDesc mDesc
Definition Renderer.hpp:453
Allocator * mAllocator
Definition Renderer.hpp:449
void ExecuteBarriers(TrackedPass &pass, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes all barriers for a pass.
Definition Renderer.cpp:1727
void BindBufferCopyDst(PassHandle pass, ResourceHandle buffer) const
Declares that this pass will write to the buffer via copy.
Definition Renderer.cpp:291
void BeginExecute()
Begins execution for a headless (no swapchain) frame.
Definition Renderer.cpp:1602
TrackedPass const & GetTrackedPass(PassHandle pass)
Retrieves an internal tracked pass associated with the given handle, read-only.
Definition Renderer.hpp:1237
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:285
void EndExecute()
Ends the execution phase and performs GPU submission.
Definition Renderer.cpp:2132
void FinalizeResources()
Definition Renderer.cpp:1270
uint32_t mCurrentSync
Definition Renderer.hpp:458
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:241
void ExecuteBarrierBuffer(PassHandle pass, TrackedResource &res, RHIResourceAccess access, RHIPipelineStage stage, ExecuteBarrierPCmdOrPBarrierList cmd)
Executes barriers for a whole buffer.
Definition Renderer.cpp:1668
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:2357
String DbgDumpGraphviz() const
Definition Renderer.cpp:2281
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:468
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:270
void PassSetTopology(PassHandle pass, RHIPipelineState::PipelineStateDesc::Topology topology) const
Sets the input assembly topology for a graphics pass (TriangleList, LineList, etc....
Definition Renderer.cpp:514
RHIDeviceQueue * mComputeQueue
Definition Renderer.hpp:494
void BindAccelerationStructureWrite(PassHandle pass, ResourceHandle as) const
Declares that this pass will build, or update the AS.
Definition Renderer.cpp:478
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:221
Core::JobSystem * mJobs
Definition Renderer.hpp:450
RHIDeviceScopedHandle< RHIDeviceSemaphore > mComputeTimeline
Definition Renderer.hpp:491
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:1184
void BindDescriptorSetRead(PassHandle pass, StringView bind_point, RHIDeviceDescriptorSetLayout *layout)
Binds an externally managed descriptor set that this pass reads.
Definition Renderer.cpp:337
bool IsAsyncComputeEnabled() const
Returns whether async compute is enabled.
Definition Renderer.hpp:1248
RHIDeviceIdleGuard mWaitIdle
Definition Renderer.hpp:624
uint64_t GetSync() const
Retrieves the current synchronization index.
Definition Renderer.hpp:1233
State
Definition Renderer.hpp:440
bool IsPresentEnabled() const
Returns whether a swapchain is bound.
Definition Renderer.hpp:1258
RHIExtent3D CmdGetComputeLocalSize(PassHandle pass) const
Helper that retrieves the local size declared by a compute pass.
Definition Renderer.cpp:2263
uint32_t GetSwap() const
Retrieves the current swap index at the time of ExecuteFrame().
Definition Renderer.hpp:1219
uint64_t GetFrame() const
Retrieves the current frame number.
Definition Renderer.hpp:1208
State GetState() const
Retrieves the current state of the renderer.
Definition Renderer.hpp:1197
RHITextureView * DerefTextureView(const ResourceHandle handle) const
Dereference a texture view handle to its underlying RHI texture view.
Definition Renderer.hpp:1083
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:252
ResourceHandle CreateSampler(RHIDeviceSampler::SamplerDesc const &desc) const
Creates a sampler with the specified name and descriptor.
Definition Renderer.cpp:153
ResourceHandle CreateResource(StringView name, T const &desc)
Create a new resource to be used in the render graph.
Definition Renderer.hpp:705
void BindBackbufferUAV(PassHandle pass, int set_index) const
Binds the backbuffer as RW access at binding 0 of set index.
Definition Renderer.cpp:444
RHIDeviceScopedHandle< RHIDeviceDescriptorPool > mSwapDescriptorPool
Definition Renderer.hpp:486
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
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:86
const RHIResourceAccessBits kAllShaderWrites
Definition Renderer.hpp:76
constexpr size_t kMaxRenderPasses
Definition Renderer.hpp:68
const RHIResourceAccessBits kAllShaderReads
Definition Renderer.hpp:79
const RHIPipelineStage kComputeStagesMask
Definition Renderer.hpp:73
Handle PassHandle
Definition Renderer.hpp:21
constexpr size_t kExecuteArenaSize
Definition Renderer.hpp:72
constexpr size_t kMaxCommandListsPerThread
Definition Renderer.hpp:70
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
Helper class containing runtime resources either imported, or created by the Renderer.
Definition Renderer.hpp:192
Vector< Variant< RHIBuffer *, RHIDeviceScopedHandle< RHIBuffer >, RHITexture *, RHIDeviceScopedHandle< RHITexture >, RHIAccelerationStructure * > > resources
Definition Renderer.hpp:195
Vector< RHIDeviceScopedHandle< RHIDeviceSampler > > samplers
Definition Renderer.hpp:197
Vector< Variant< RHITextureScopedHandle< RHITextureView >, RHITextureHandle< RHITextureView > > > views
Definition Renderer.hpp:196
ExecuteResources(Allocator *allocator)
Definition Renderer.hpp:198
void fit(ResourceHandle handle)
Definition Renderer.hpp:199
Default "no-op" functor for Record()
Definition Renderer.hpp:247
void operator()(PassHandle, Renderer *, RHICommandList *) const
Definition Renderer.hpp:248
Default "no-op" functor for Setup()
Definition Renderer.hpp:240
void operator()(PassHandle, Renderer *) const
Definition Renderer.hpp:241
Functional wrapper for a render pass.
Definition Renderer.hpp:257
LambdaPass(FSetup &&setup, FRecord &&record)
Definition Renderer.hpp:260
void Record(PassHandle self, Renderer *r, RHICommandList *cmd) override
Record the commands of this pass into the given command list.
Definition Renderer.hpp:265
FRecord mRecord
Definition Renderer.hpp:259
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:264
FSetup mSetup
Definition Renderer.hpp:258
Parameters for Renderer creation.
Definition Renderer.hpp:27
bool profilePasses
Enable or disable GPU profiling for the frame graph execution.
Definition Renderer.hpp:62
uint32_t threadCount
Number of worker threads to use for recording command lists.
Definition Renderer.hpp:47
bool asyncCompute
Enable Async Compute support.
Definition Renderer.hpp:42
RHIPipelineStateCache * pipelineCache
Optional PSO cache to potentially speed up pipeline state recompilation in Setup time.
Definition Renderer.hpp:52
Definition Renderer.hpp:517
Vector< RHICommandPoolScopedHandle< RHICommandList > > computeCmds
Definition Renderer.hpp:519
RHICommandList * AllocateCompute()
Definition Renderer.cpp:1805
size_t graphicsCtr
Definition Renderer.hpp:521
RHIDeviceScopedHandle< RHICommandPool > computePool
Definition Renderer.hpp:518
RHICommandList * AllocateGraphics()
Definition Renderer.cpp:1794
RHIDeviceScopedHandle< RHICommandPool > graphicsPool
Definition Renderer.hpp:518
Vector< RHICommandPoolScopedHandle< RHICommandList > > graphicsCmds
Definition Renderer.hpp:519
size_t computeCtr
Definition Renderer.hpp:521
void Reset()
Definition Renderer.cpp:1786
Definition Renderer.hpp:467
ResourceHandle backbuffer
Definition Renderer.hpp:476
RHIDeviceScopedHandle< RHIDeviceQueryPool > dbgQueryPool
Definition Renderer.hpp:478
RHIDeviceScopedHandle< RHIDeviceFence > computeFence
Definition Renderer.hpp:471
RHIDeviceScopedHandle< RHIDeviceFence > graphicsFence
Definition Renderer.hpp:471
FrameSyncObjects(size_t swapIndex, Allocator *alloc)
Definition Renderer.hpp:481
const size_t swapIndex
Definition Renderer.hpp:469
Vector< uint64_t > dbgQueryPassTimestampsResults
Definition Renderer.hpp:479
RHITextureScopedHandle< RHITextureView > view
Definition Renderer.hpp:473
RHIDeviceScopedHandle< RHIDeviceSemaphore > render
Definition Renderer.hpp:470
RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > viewSet
Definition Renderer.hpp:474
Definition Renderer.hpp:1011
String name
Definition Renderer.hpp:1012
size_t bytes
Definition Renderer.hpp:1013
Definition Renderer.hpp:401
const int groupIndex
Definition Renderer.hpp:402
Vector< PassHandle > passes
Definition Renderer.hpp:406
int graphicsGroupIndex
Definition Renderer.hpp:403
bool isLastGraphics
Definition Renderer.hpp:409
int computeGroupIndex
Definition Renderer.hpp:404
Vector< ResourceHandle > resources
Definition Renderer.hpp:408
bool isLastCompute
Definition Renderer.hpp:410
ExecutionGroups(int groupIndex, RHIDeviceQueueType queue, Allocator *allocator)
Definition Renderer.hpp:412
const RHIDeviceQueueType queue
Definition Renderer.hpp:405
Helper class containing all states pertaining to Renderer's Setup phase.
Definition Renderer.hpp:382
Vector< ExecutionGroups > executionGroups
Definition Renderer.hpp:417
PassHandle lastBackbufferProducer
Definition Renderer.hpp:388
bool executionAnyCompute
Definition Renderer.hpp:418
int executionNumGraphicsGroups
Definition Renderer.hpp:419
Vector< PassHandle > execution
Definition Renderer.hpp:396
Vector< Vector< Pair< PassHandle, ResourceHandle > > > graph
Definition Renderer.hpp:383
Vector< TrackedPass > trackedPasses
Definition Renderer.hpp:385
Map< ResourceHandle, Pair< PassHandle, PassHandle > > activeResources
Definition Renderer.hpp:393
int executionNumComputeGroups
Definition Renderer.hpp:419
Vector< PassHandle > in
Definition Renderer.hpp:384
Map< uintptr_t, PassHandle > descriptorSetWriters
Definition Renderer.hpp:394
void add_edge(const PassHandle u, const PassHandle v, const ResourceHandle hdl)
Definition Renderer.hpp:420
PassHandle epilogue
Definition Renderer.hpp:398
Vector< RHIDeviceSampler::SamplerDesc > trackedSamplers
Definition Renderer.hpp:391
Map< RHIDescriptorType, uint32_t > bindingCounts
Definition Renderer.hpp:397
Vector< TrackedResource > trackedResources
Definition Renderer.hpp:386
Vector< Pair< ResourceHandle, RHITextureViewDesc > > trackedViews
Definition Renderer.hpp:390
bool executionAnyGraphics
Definition Renderer.hpp:418
RendererSetup(Allocator *allocator)
Definition Renderer.hpp:430
Definition Renderer.hpp:1016
String name
Definition Renderer.hpp:1017
ResourceHandle resourceHandle
Definition Renderer.hpp:1018
RHITextureView * view
Definition Renderer.hpp:1021
RHIResourceFormat format
Definition Renderer.hpp:1020
ResourceHandle viewHandle
Definition Renderer.hpp:1019
Internal tracking information for a render pass in the frame graph.
Definition Renderer.hpp:271
size_t frameExec
Definition Renderer.hpp:292
int priority
Definition Renderer.hpp:274
RHIPipelineState::PipelineStateDesc::DepthStencil psoDepthStencil
Definition Renderer.hpp:343
ResourceHandle dsv
Definition Renderer.hpp:326
Vector< Tuple< String, String, RHIShaderStage, Vector< char >, uint32_t, RHIPipelineState::PipelineStateDesc::RayTracingHitGroupType > > shaders
Definition Renderer.hpp:311
Vector< RHIPipelineState::PipelineStateDesc::VertexInput::Binding > vertexInputBindings
Definition Renderer.hpp:329
Vector< RHIDeviceDescriptorSetLayout * > pDescriptorLayouts
Definition Renderer.hpp:348
RHIPipelineStageBits piplineStages
Definition Renderer.hpp:338
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage, RHITextureSubresourceRange, RHITextureLayout > > textureUsages
Definition Renderer.hpp:297
UniquePtr< RenderPass > pass
Definition Renderer.hpp:332
Vector< RHIDeviceDescriptorSet * > pDescriptorSets
Definition Renderer.hpp:352
RHIDeviceQueueType queue
Definition Renderer.hpp:276
RHIPipelineState::PipelineStateDesc::Rasterizer psoRasterizer
Definition Renderer.hpp:342
int groupIndex
Definition Renderer.hpp:336
size_t ord
Definition Renderer.hpp:291
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > textureBindings
Definition Renderer.hpp:313
Vector< Pair< ResourceHandle, String > > samplers
Definition Renderer.hpp:318
RHIDeviceScopedHandle< RHIPipelineState > pso
Definition Renderer.hpp:340
Vector< RHIDeviceScopedHandle< RHIDeviceDescriptorSetLayout > > descriptorLayouts
Definition Renderer.hpp:346
bool unCullable
Definition Renderer.hpp:278
bool isRayTracingPass
Definition Renderer.hpp:287
Vector< RHIPipelineState::PipelineStateDesc::PushConstant > pushConstants
Definition Renderer.hpp:320
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > asUsages
Definition Renderer.hpp:302
Optional< RHIPipelineState::PipelineStateDesc::Attachment::Blending > backbufferRTV
Definition Renderer.hpp:280
bool isDepthReadOnly
Definition Renderer.hpp:327
bool used
Definition Renderer.hpp:277
Vector< RHIVertexAttribute > vertexInputAttributes
Definition Renderer.hpp:330
void ResetPipeline()
Definition Renderer.cpp:59
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > bufferBindings
Definition Renderer.hpp:313
Vector< Tuple< size_t, RHIDeviceDescriptorSetLayout * > > pExternalDescriptorSets
Definition Renderer.hpp:354
Vector< Tuple< RHIShaderStage, size_t, Vector< char > > > specializationConstants
Definition Renderer.hpp:322
Vector< RHIDeviceDescriptorPoolScopedHandle< RHIDeviceDescriptorSet > > descriptorSets
Definition Renderer.hpp:350
Vector< Tuple< ResourceHandle, RHIDescriptorType, String > > asBindings
Definition Renderer.hpp:313
PassHandle handle
Definition Renderer.hpp:273
Tuple< uint32_t, uint32_t, uint32_t > groupLocalSize
Definition Renderer.hpp:289
Vector< ResourceHandle > texviews
Definition Renderer.hpp:306
Vector< Tuple< ResourceHandle, RHIResourceAccess, RHIPipelineStage > > bufferUsages
Definition Renderer.hpp:299
Optional< int > backbufferUAV
Definition Renderer.hpp:281
size_t depth
Definition Renderer.hpp:290
Vector< PassHandle > bindPasses
Definition Renderer.hpp:294
Vector< Pair< ResourceHandle, RHIPipelineState::PipelineStateDesc::Attachment::Blending > > rtvs
Definition Renderer.hpp:324
bool isComputePass
Definition Renderer.hpp:284
RHIPipelineState::PipelineStateDesc::Topology psoTopology
Definition Renderer.hpp:344
Vector< ResourceHandle > resources
Definition Renderer.hpp:304
String name
Definition Renderer.hpp:272
Vector< Tuple< String, RHIDeviceDescriptorSetLayout *, int > > externalBindings
Definition Renderer.hpp:316
RHIDevicePipelineType GetPipelineType() const
Definition Renderer.hpp:357
Definition Renderer.hpp:104
RHIPipelineStage stage
Definition Renderer.hpp:116
size_t lastProducedFrame
Definition Renderer.hpp:110
PassHandle lastProducer
Definition Renderer.hpp:108
RHIResourceAccess access
Definition Renderer.hpp:115
bool executeTempTransitionFlag
Definition Renderer.hpp:114
RHIDeviceQueueType lastOwnerQueue
Definition Renderer.hpp:112
PassHandle producer
Definition Renderer.hpp:106
void reset()
Definition Renderer.hpp:117
Definition Renderer.hpp:128
RHIResourceAccess access
Definition Renderer.hpp:142
RHIDeviceQueueType lastOwnerQueue
Definition Renderer.hpp:139
void reset()
Definition Renderer.hpp:145
bool executeTempTransitionFlag
Definition Renderer.hpp:141
RHIPipelineStage stage
Definition Renderer.hpp:143
RHITextureAspectFlagBits aspect
Definition Renderer.hpp:130
RHITextureLayout layout
Definition Renderer.hpp:144
PassHandle producer
Definition Renderer.hpp:133
size_t lastProducedFrame
Definition Renderer.hpp:137
PassHandle lastProducer
Definition Renderer.hpp:135
RHITextureSubresourceRange ToRange() const
Definition Renderer.cpp:8
size_t mip
Definition Renderer.hpp:129
size_t layer
Definition Renderer.hpp:129
Internal tracking information for a resource in the frame graph.
Definition Renderer.hpp:91
Vector< SubresourceState > lastSubresourceStates
Definition Renderer.hpp:157
auto GetLastSubresourceStateOf(RHITextureSubresourceRange const &range)
Definition Renderer.hpp:158
bool hasGraphicsUsage
Definition Renderer.hpp:96
String name
Definition Renderer.hpp:93
void ResetStates()
Definition Renderer.hpp:178
ResourceDefinition desc
Definition Renderer.hpp:94
AccelerationStructureState lastASState
Definition Renderer.hpp:177
uint32_t textureMips
Definition Renderer.hpp:126
uint32_t textureLayers
Definition Renderer.hpp:126
bool hasComputeUsage
Definition Renderer.hpp:95
struct Foundation::RenderCore::TrackedResource::BufferState lastBufferState
ResourceHandle handle
Definition Renderer.hpp:92