Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
foray::stages::DefaultRaytracingStageBase Class Referenceabstract

Extended version of MinimalRaytracingStageBase limited to a single output image, descriptorset but providing built in support for scene (Camera, Tlas, Geometry, Materials), EnvironmentMap and Noise Texture. More...

#include <foray_defaultraytracingstage.hpp>

Inheritance diagram for foray::stages::DefaultRaytracingStageBase:
foray::stages::RenderStage

Public Member Functions

void Init (core::Context *context, scene::Scene *scene, core::CombinedImageSampler *envMap=nullptr, core::ManagedImage *noiseImage=nullptr)
 Nominal init for DefaultRaytracingStageBase.
 
virtual void RecordFrame (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
 Calls RecordFramePrepare(), RecordFrameBind(), RecordFrameTraceRays() in this order.
 
virtual void Resize (const VkExtent2D &extent) override
 Calls RenderStage::Resize(..) which resizes any image registered to mImageOutputs, calls CreateOrUpdateDescriptors() afterwards.
 
virtual void Destroy () override
 Calls ApiDestroyRtPipeline(), mPipelineLayout.Destroy(), DestroyDescriptors(), ApiCustomObjectsDestroy() and DestroyOutputImages() in this order.
 
core::ManagedImageGetRtOutput ()
 
- Public Member Functions inherited from foray::stages::RenderStage
 RenderStage ()=default
 
std::vector< core::ManagedImage * > GetImageOutputs ()
 Gets a vector to all color attachments that will be included in a texture array and can be referenced in the shader pass.
 
core::ManagedImageGetImageOutput (std::string_view name, bool noThrow=false)
 Gets an image output.
 
virtual void OnShadersRecompiled (const std::unordered_set< uint64_t > &recompiled)
 Notifies the stage that the shader compiler instance has recompiled a shader.
 
virtual ~RenderStage ()
 

Static Public Attributes

static constexpr std::string_view OutputName = "Rt.Output"
 Image Output of the Raytracing Stage.
 

Protected Member Functions

virtual void CreateOutputImages ()
 Initializes mOutput.
 
virtual void CreatePipelineLayout ()
 Creates Pipeline layout with mDescriptorSets layout and an optional single uint pushconstant (see mRngSeedPushCOffset)
 
virtual void ApiCreateRtPipeline ()=0
 Inheriting types should create mPipeline here (load shaders, configure sbts, build)
 
virtual void ApiDestroyRtPipeline ()=0
 Destroys mPipeline and all shaders registered to RenderStage::mShaders.
 
virtual void ApiCustomObjectsCreate ()
 Inheriting types may use this function to initialize stage specific objects such as configuration Ubo buffers.
 
virtual void ApiCustomObjectsDestroy ()
 Inheriting types may use this function to destroy options created during ApiCustomObjectsCreate()
 
virtual void CreateOrUpdateDescriptors ()
 Creates a fully populated descriptorset. See rtbindpoints and shaders/rt_common/bindpoints.glsl.
 
virtual void DestroyDescriptors ()
 Destroys the descriptor set.
 
virtual void ReloadShaders () override
 Calls ApiDestroyRtPipeline(), ApiCreateRtPipeline() in this order.
 
virtual void RecordFramePrepare (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo)
 Pipeline barriers.
 
virtual void RecordFrameBind (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo)
 Bind pipeline and descriptorset.
 
virtual void RecordFrameTraceRays (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo)
 Push constant and Trace rays.
 
- Protected Member Functions inherited from foray::stages::RenderStage
virtual void DestroyOutputImages ()
 Calls Destroy() on any image in mImageOutputs and clears mImageOutputs.
 

Protected Attributes

scene::ScenemScene = nullptr
 Provides Camera, Tlas, Geometry and Materials.
 
core::CombinedImageSamplermEnvironmentMap = nullptr
 (Optional) Environment Map
 
core::ManagedImagemNoiseTexture = nullptr
 (Optional) Noise source image
 
core::ManagedImage mOutput
 Image output.
 
core::DescriptorSet mDescriptorSet
 Main DescriptorSet & Layout.
 
VkWriteDescriptorSetAccelerationStructureKHR mDescriptorAccelerationStructureInfo {}
 DescriptorSet::SetDescriptorAt requires persistent .pNext objects.
 
util::PipelineLayout mPipelineLayout
 The pipeline layout manages descriptorset and pushconstant layouts.
 
rtpipe::RtPipeline mPipeline
 The pipeline manages shader binding tables.
 
uint32_t mRngSeedPushCOffset = 0
 If set to anything other than ~0U a uint push constant containing the current frame idx as a seed value is added.
 
- Protected Attributes inherited from foray::stages::RenderStage
std::unordered_map< std::string, core::ManagedImage * > mImageOutputs
 Inheriting types should emplace their images onto this collection to provide them in GetImageOutput interface.
 
std::vector< uint64_t > mShaderKeys
 Inheriting types should emplace their shader keys onto this collection such that if a shader has been recompiled, ReloadShaders() will be called.
 
core::ContextmContext = nullptr
 Context object the renderstage is built upon.
 

Detailed Description

Extended version of MinimalRaytracingStageBase limited to a single output image, descriptorset but providing built in support for scene (Camera, Tlas, Geometry, Materials), EnvironmentMap and Noise Texture.

Features

Inheriting

Member Function Documentation

◆ ApiCreateRtPipeline()

virtual void foray::stages::DefaultRaytracingStageBase::ApiCreateRtPipeline ( )
protectedpure virtual

Inheriting types should create mPipeline here (load shaders, configure sbts, build)

◆ ApiCustomObjectsCreate()

virtual void foray::stages::DefaultRaytracingStageBase::ApiCustomObjectsCreate ( )
inlineprotectedvirtual

Inheriting types may use this function to initialize stage specific objects such as configuration Ubo buffers.

◆ ApiCustomObjectsDestroy()

virtual void foray::stages::DefaultRaytracingStageBase::ApiCustomObjectsDestroy ( )
inlineprotectedvirtual

Inheriting types may use this function to destroy options created during ApiCustomObjectsCreate()

◆ ApiDestroyRtPipeline()

virtual void foray::stages::DefaultRaytracingStageBase::ApiDestroyRtPipeline ( )
protectedpure virtual

Destroys mPipeline and all shaders registered to RenderStage::mShaders.

◆ CreateOrUpdateDescriptors()

virtual void foray::stages::DefaultRaytracingStageBase::CreateOrUpdateDescriptors ( )
protectedvirtual

Creates a fully populated descriptorset. See rtbindpoints and shaders/rt_common/bindpoints.glsl.

◆ CreateOutputImages()

virtual void foray::stages::DefaultRaytracingStageBase::CreateOutputImages ( )
protectedvirtual

Initializes mOutput.

mOutput initialized as rgba32f with Swapchains extent and usage flags VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT

◆ CreatePipelineLayout()

virtual void foray::stages::DefaultRaytracingStageBase::CreatePipelineLayout ( )
protectedvirtual

Creates Pipeline layout with mDescriptorSets layout and an optional single uint pushconstant (see mRngSeedPushCOffset)

◆ Destroy()

virtual void foray::stages::DefaultRaytracingStageBase::Destroy ( )
overridevirtual

Calls ApiDestroyRtPipeline(), mPipelineLayout.Destroy(), DestroyDescriptors(), ApiCustomObjectsDestroy() and DestroyOutputImages() in this order.

Reimplemented from foray::stages::RenderStage.

◆ DestroyDescriptors()

virtual void foray::stages::DefaultRaytracingStageBase::DestroyDescriptors ( )
protectedvirtual

Destroys the descriptor set.

◆ GetRtOutput()

core::ManagedImage * foray::stages::DefaultRaytracingStageBase::GetRtOutput ( )
inline

◆ Init()

void foray::stages::DefaultRaytracingStageBase::Init ( core::Context context,
scene::Scene scene,
core::CombinedImageSampler envMap = nullptr,
core::ManagedImage noiseImage = nullptr 
)

Nominal init for DefaultRaytracingStageBase.

Parameters
sceneScene provides Camera, Tlas, Geometry and Materials
envMapEnvironment Map
noiseImageNoise Texture

◆ RecordFrame()

virtual void foray::stages::DefaultRaytracingStageBase::RecordFrame ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
overridevirtual

◆ RecordFrameBind()

virtual void foray::stages::DefaultRaytracingStageBase::RecordFrameBind ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
protectedvirtual

Bind pipeline and descriptorset.

◆ RecordFramePrepare()

virtual void foray::stages::DefaultRaytracingStageBase::RecordFramePrepare ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
protectedvirtual

Pipeline barriers.

◆ RecordFrameTraceRays()

virtual void foray::stages::DefaultRaytracingStageBase::RecordFrameTraceRays ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
protectedvirtual

Push constant and Trace rays.

◆ ReloadShaders()

virtual void foray::stages::DefaultRaytracingStageBase::ReloadShaders ( )
overrideprotectedvirtual

Calls ApiDestroyRtPipeline(), ApiCreateRtPipeline() in this order.

Reimplemented from foray::stages::RenderStage.

◆ Resize()

virtual void foray::stages::DefaultRaytracingStageBase::Resize ( const VkExtent2D &  extent)
overridevirtual

Calls RenderStage::Resize(..) which resizes any image registered to mImageOutputs, calls CreateOrUpdateDescriptors() afterwards.

Parameters
extentNew render extent

Reimplemented from foray::stages::RenderStage.

Member Data Documentation

◆ mDescriptorAccelerationStructureInfo

VkWriteDescriptorSetAccelerationStructureKHR foray::stages::DefaultRaytracingStageBase::mDescriptorAccelerationStructureInfo {}
protected

DescriptorSet::SetDescriptorAt requires persistent .pNext objects.

◆ mDescriptorSet

core::DescriptorSet foray::stages::DefaultRaytracingStageBase::mDescriptorSet
protected

Main DescriptorSet & Layout.

◆ mEnvironmentMap

core::CombinedImageSampler* foray::stages::DefaultRaytracingStageBase::mEnvironmentMap = nullptr
protected

(Optional) Environment Map

◆ mNoiseTexture

core::ManagedImage* foray::stages::DefaultRaytracingStageBase::mNoiseTexture = nullptr
protected

(Optional) Noise source image

◆ mOutput

core::ManagedImage foray::stages::DefaultRaytracingStageBase::mOutput
protected

Image output.

◆ mPipeline

rtpipe::RtPipeline foray::stages::DefaultRaytracingStageBase::mPipeline
protected

The pipeline manages shader binding tables.

◆ mPipelineLayout

util::PipelineLayout foray::stages::DefaultRaytracingStageBase::mPipelineLayout
protected

The pipeline layout manages descriptorset and pushconstant layouts.

◆ mRngSeedPushCOffset

uint32_t foray::stages::DefaultRaytracingStageBase::mRngSeedPushCOffset = 0
protected

If set to anything other than ~0U a uint push constant containing the current frame idx as a seed value is added.

◆ mScene

scene::Scene* foray::stages::DefaultRaytracingStageBase::mScene = nullptr
protected

Provides Camera, Tlas, Geometry and Materials.

◆ OutputName

constexpr std::string_view foray::stages::DefaultRaytracingStageBase::OutputName = "Rt.Output"
inlinestaticconstexpr

Image Output of the Raytracing Stage.


The documentation for this class was generated from the following file: