Foundation
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
Foundation::RenderCore Namespace Reference

Core functionalities for rendering, including the Frame Graph implementation. More...

Classes

struct  ExecuteResources
 Helper class containing runtime resources either imported, or created by the Renderer. More...
 
struct  FRecordDefault
 Default "no-op" functor for Record() More...
 
struct  FSetupDefault
 Default "no-op" functor for Setup() More...
 
struct  FSkipDefault
 Default "not skipped" functor for IsSkipped() More...
 
struct  LambdaPass
 Functional wrapper for a render pass. More...
 
class  Renderer
 Renderer implementing a Frame Graph system with automatic resource tracking and synchronization. More...
 
struct  RendererDesc
 Parameters for Renderer creation. More...
 
class  RenderPass
 Interface for a render pass. More...
 
class  Shader
 Runtime reflection data for a shader module. More...
 
struct  TrackedPass
 Internal tracking information for a render pass in the frame graph. More...
 
struct  TrackedResource
 Internal tracking information for a resource in the frame graph. More...
 

Typedefs

using PassHandle = size_t
 
using ResourceHandle = size_t
 
using ResourceDefinition = Variant< RHIBufferDesc, RHITextureDesc, RHIDeviceObjectHandle< RHIBuffer >, RHIDeviceObjectHandle< RHITexture >, RHIBuffer *, RHITexture * >
 

Functions

 ENUM_NAME (Undefined)
 
 ENUM_NAME (Setup)
 
 ENUM_NAME (PostSetup)
 
 ENUM_NAME (Execute)
 
 ENUM_NAME_CONV_END ()
 
template<typename T >
ResourceHandle createResource (Renderer *r, StringView name, T const &desc)
 Convenient functional wrapper to create a resource.
 
ResourceHandle createSampler (Renderer *r, RHIDeviceSampler::SamplerDesc const &desc)
 Convenient functional wrapper to create a sampler.
 
template<typename T , typename... Args>
requires std::is_base_of_v<RenderPass, T>
TcreatePassImplPriority (Renderer *r, StringView name, RHIDeviceQueueType queue, size_t priority, Args &&... args)
 Convenient functional wrapper to create a pass from a RenderPass* implementation with custom priority.
 
template<typename T , typename... Args>
requires std::is_base_of_v<RenderPass, T>
TcreatePassImpl (Renderer *r, StringView name, RHIDeviceQueueType queue, Args &&... args)
 Convenient functional wrapper to create a pass from a RenderPass* implementation.
 
template<typename FSetup , typename FRecord , typename FSkip = FSkipDefault>
LambdaPass< FSetup, FRecord, FSkip > * createPassPriority (Renderer *r, StringView name, RHIDeviceQueueType queue, size_t priority, FSetup &&setup, FRecord &&record, FSkip &&skip={})
 Convenient functional wrapper to create a pass from Setup/Record lambdas with custom priority.
 
template<typename FSetup , typename FRecord , typename FSkip = FSkipDefault>
LambdaPass< FSetup, FRecord, FSkip > * createPass (Renderer *r, StringView name, RHIDeviceQueueType queue, FSetup &&setup, FRecord &&record, FSkip &&skip={})
 Convenient functional wrapper to create a pass from Setup/Record lambdas.
 

Variables

constexpr size_t kMaxRenderPasses = 1024
 
constexpr size_t kMaxCommandListsPerThread = kMaxRenderPasses
 
constexpr size_t kExecuteArenaSize = 16 * (1 << 20)
 
const String kBindpointIgnored = "<ignored>"
 
const RHIPipelineStage kComputeStagesMask
 
const RHIResourceAccessBits kAllShaderWrites
 
const RHIResourceAccessBits kAllShaderReads
 
const size_t kTextureAspectCount = 3
 

Detailed Description

Core functionalities for rendering, including the Frame Graph implementation.

Typedef Documentation

◆ PassHandle

◆ ResourceDefinition

◆ ResourceHandle

Function Documentation

◆ createPass()

template<typename FSetup , typename FRecord , typename FSkip = FSkipDefault>
LambdaPass< FSetup, FRecord, FSkip > * Foundation::RenderCore::createPass ( Renderer r,
StringView  name,
RHIDeviceQueueType  queue,
FSetup &&  setup,
FRecord &&  record,
FSkip &&  skip = {} 
)

Convenient functional wrapper to create a pass from Setup/Record lambdas.

This is equivalent to calling createPassPriority with priority 0 for Graphics passes, and priority kMaxRenderPasses for Compute passes, which schedules all Compute passes first with the best effort.

Note
Avoid using Lambdas with stateful captures (i.e. capturing this or [&]), as resource lifetimes could be much involved and unpredictable. Coupled with how passes may be scheduled on different threads - refrain from shooting yourself in the foot. Prefer using stateless captures (i.e. [=]) or no captures at all, unless the states are trivial, and you really know what you're doing.
The priority parameter is omitted here for simplicity. If you need custom priority, use createPassPriority instead.
Parameters
queueQueue to prefer running this pass in - this is a hint, and might be ignored if async compute is disabled.
setupLambda of type void(PassHandle self, Renderer*) called at Setup time.
recordLambda of type void(PassHandel self, Renderer*, RHICommandList*) called at Record time.
skip(Optional) Lambda of type bool(PassHandle self, Renderer*) called at Record time to determine whether this pass should be skipped if true. This is by default always false.

◆ createPassImpl()

template<typename T , typename... Args>
requires std::is_base_of_v<RenderPass, T>
T * Foundation::RenderCore::createPassImpl ( Renderer r,
StringView  name,
RHIDeviceQueueType  queue,
Args &&...  args 
)

Convenient functional wrapper to create a pass from a RenderPass* implementation.

This is equivalent to calling createPassPriority with priority 0 for Graphics passes, and priority kMaxRenderPasses for Compute passes, which schedules all Compute passes first with the best effort.

Template Parameters
TType of RenderPass to create.
Parameters
queueQueue to prefer running this pass in - this is a hint, and might be ignored if async compute is disabled.

◆ createPassImplPriority()

template<typename T , typename... Args>
requires std::is_base_of_v<RenderPass, T>
T * Foundation::RenderCore::createPassImplPriority ( Renderer r,
StringView  name,
RHIDeviceQueueType  queue,
size_t  priority,
Args &&...  args 
)

Convenient functional wrapper to create a pass from a RenderPass* implementation with custom priority.

This is equivalent to calling Renderer::CreatePassImpl

Template Parameters
TType of RenderPass to create.
Parameters
queueQueue to prefer running this pass in - this is a hint, and might be ignored if async compute is disabled.
priorityPriority of this pass. Higher priority passes are scheduled earlier.

◆ createPassPriority()

template<typename FSetup , typename FRecord , typename FSkip = FSkipDefault>
LambdaPass< FSetup, FRecord, FSkip > * Foundation::RenderCore::createPassPriority ( Renderer r,
StringView  name,
RHIDeviceQueueType  queue,
size_t  priority,
FSetup &&  setup,
FRecord &&  record,
FSkip &&  skip = {} 
)

Convenient functional wrapper to create a pass from Setup/Record lambdas with custom priority.

This is equivalent to calling Renderer::CreatePass

Note
Avoid using Lambdas with stateful captures (i.e. capturing this or [&]), as resource lifetimes could be much involved and unpredictable. Coupled with how passes may be scheduled on different threads - refrain from shooting yourself in the foot. Prefer using stateless captures (i.e. [=]) or no captures at all, unless the states are trivial, and you really know what you're doing.
Parameters
queueQueue to prefer running this pass in - this is a hint, and might be ignored if async compute is disabled.
priorityPriority of this pass. Higher priority passes are scheduled earlier.
setupLambda of type void(PassHandle self, Renderer*) called at Setup time.
recordLambda of type void(PassHandel self, Renderer*, RHICommandList*) called at Record time.
skip(Optional) Lambda of type bool(PassHandle self, Renderer*) called at Record time to determine whether this pass should be skipped if true. This is by default always false.

◆ createResource()

template<typename T >
ResourceHandle Foundation::RenderCore::createResource ( Renderer r,
StringView  name,
T const desc 
)

Convenient functional wrapper to create a resource.

This is equivalent to calling CreateResource(name, desc);

Parameters
descResources can be created by passing in RHIBufferDesc, RHITextureDesc, and can be imported by passing in RHIDeviceObjectHandle<RHIBuffer>, RHIDeviceObjectHandle<RHITexture>, or raw, pinned pointers RHIBuffer*, or RHITexture*
Note
ALWAYS ENSURE that your IMPORTED resources OUTLIVE the Renderer. There's NO reference counting or tracking of the underlying resource lifetime.

◆ createSampler()

ResourceHandle Foundation::RenderCore::createSampler ( Renderer r,
RHIDeviceSampler::SamplerDesc const desc 
)
inline

Convenient functional wrapper to create a sampler.

This is equivalent to calling CreateSampler(name, desc);

◆ ENUM_NAME() [1/4]

Foundation::RenderCore::ENUM_NAME ( Execute  )

◆ ENUM_NAME() [2/4]

Foundation::RenderCore::ENUM_NAME ( PostSetup  )

◆ ENUM_NAME() [3/4]

Foundation::RenderCore::ENUM_NAME ( Setup  )

◆ ENUM_NAME() [4/4]

Foundation::RenderCore::ENUM_NAME ( Undefined  )

◆ ENUM_NAME_CONV_END()

Foundation::RenderCore::ENUM_NAME_CONV_END ( )

Variable Documentation

◆ kAllShaderReads

const RHIResourceAccessBits Foundation::RenderCore::kAllShaderReads
Initial value:
= RHIResourceAccessBits::ShaderRead |
RHIResourceAccessBits::RenderTargetRead | RHIResourceAccessBits::UniformRead |
RHIResourceAccessBits::TransferRead | RHIResourceAccessBits::HostRead

◆ kAllShaderWrites

const RHIResourceAccessBits Foundation::RenderCore::kAllShaderWrites
Initial value:
= RHIResourceAccessBits::ShaderWrite |
RHIResourceAccessBits::RenderTargetWrite | RHIResourceAccessBits::DepthStencilWrite |
RHIResourceAccessBits::TransferWrite | RHIResourceAccessBits::HostWrite

◆ kBindpointIgnored

const String Foundation::RenderCore::kBindpointIgnored = "<ignored>"

◆ kComputeStagesMask

const RHIPipelineStage Foundation::RenderCore::kComputeStagesMask
Initial value:
= RHIPipelineStageBits::FragmentShader |
RHIPipelineStageBits::VertexShader | RHIPipelineStageBits::MeshShader | RHIPipelineStageBits::RayTracingShader |
RHIPipelineStageBits::AllGraphics

◆ kExecuteArenaSize

constexpr size_t Foundation::RenderCore::kExecuteArenaSize = 16 * (1 << 20)
constexpr

◆ kMaxCommandListsPerThread

constexpr size_t Foundation::RenderCore::kMaxCommandListsPerThread = kMaxRenderPasses
constexpr

◆ kMaxRenderPasses

constexpr size_t Foundation::RenderCore::kMaxRenderPasses = 1024
constexpr

◆ kTextureAspectCount

const size_t Foundation::RenderCore::kTextureAspectCount = 3