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

Render stage base class giving a common interface for rendering processes. More...

#include <foray_renderstage.hpp>

Inheritance diagram for foray::stages::RenderStage:
foray::stages::BlitStage foray::stages::ComparerStage foray::stages::ComputeStageBase foray::stages::DefaultRaytracingStageBase foray::stages::DenoiserStage foray::stages::ImguiStage foray::stages::MinimalRaytracingStageBase foray::stages::RasterizedRenderStage

Public Member Functions

 RenderStage ()=default
 
virtual void RecordFrame (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo)
 Records a frame to cmdBuffer.
 
virtual void Destroy ()
 Destroy the render stage. Finalizes all components.
 
virtual void Resize (const VkExtent2D &extent)
 Default implementation accesses mImageOutputs and calls ManagedImage::Resize(extent) on any set image.
 
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 ()
 

Protected Member Functions

virtual void ReloadShaders ()
 Override this to reload all shaders and rebuild pipelines after a registered shader has been recompiled.
 
virtual void DestroyOutputImages ()
 Calls Destroy() on any image in mImageOutputs and clears mImageOutputs.
 

Protected Attributes

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

Render stage base class giving a common interface for rendering processes.

Constructor & Destructor Documentation

◆ RenderStage()

foray::stages::RenderStage::RenderStage ( )
default

◆ ~RenderStage()

virtual foray::stages::RenderStage::~RenderStage ( )
inlinevirtual

Member Function Documentation

◆ Destroy()

virtual void foray::stages::RenderStage::Destroy ( )
inlinevirtual

◆ DestroyOutputImages()

virtual void foray::stages::RenderStage::DestroyOutputImages ( )
protectedvirtual

Calls Destroy() on any image in mImageOutputs and clears mImageOutputs.

◆ GetImageOutput()

core::ManagedImage * foray::stages::RenderStage::GetImageOutput ( std::string_view  name,
bool  noThrow = false 
)

Gets an image output.

Parameters
nameIdentifier
noThrowIf set, will return nullptr instead of throwing std::exception if no match is found

◆ GetImageOutputs()

std::vector< core::ManagedImage * > foray::stages::RenderStage::GetImageOutputs ( )

Gets a vector to all color attachments that will be included in a texture array and can be referenced in the shader pass.

◆ OnShadersRecompiled()

virtual void foray::stages::RenderStage::OnShadersRecompiled ( const std::unordered_set< uint64_t > &  recompiled)
virtual

Notifies the stage that the shader compiler instance has recompiled a shader.

Implementation will check through shaders registered in 'mShaderKeys'. If any of them have been marked as recompiled, calls ReloadShaders()

◆ RecordFrame()

virtual void foray::stages::RenderStage::RecordFrame ( VkCommandBuffer  cmdBuffer,
base::FrameRenderInfo renderInfo 
)
inlinevirtual

Records a frame to cmdBuffer.

Parameters
cmdBufferCommand buffer to record to
renderInfoAdditional information about the current frame being rendered

Inheriting

  • Any resources accessed (images, buffers) must be protected by pipeline barriers, unless the providing entity defines them as constants
  • All commands must be submitted to cmdBuffer

Reimplemented in foray::stages::BlitStage, foray::stages::ComparerStage, foray::stages::ComputeStageBase, foray::stages::DefaultRaytracingStageBase, foray::stages::GBufferStage, foray::stages::ImageToSwapchainStage, foray::stages::ImguiStage, and foray::stages::MinimalRaytracingStageBase.

◆ ReloadShaders()

virtual void foray::stages::RenderStage::ReloadShaders ( )
inlineprotectedvirtual

Override this to reload all shaders and rebuild pipelines after a registered shader has been recompiled.

Reimplemented in foray::stages::ComputeStageBase, foray::stages::DefaultRaytracingStageBase, and foray::stages::MinimalRaytracingStageBase.

◆ Resize()

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

Default implementation accesses mImageOutputs and calls ManagedImage::Resize(extent) on any set image.

Parameters
extentNew render size
Remarks
Inheriting stages may override to update descriptor sets

Reimplemented in foray::stages::ComparerStage, foray::stages::DefaultRaytracingStageBase, foray::stages::GBufferStage, foray::stages::ImguiStage, and foray::stages::MinimalRaytracingStageBase.

Member Data Documentation

◆ mContext

core::Context* foray::stages::RenderStage::mContext = nullptr
protected

Context object the renderstage is built upon.

◆ mImageOutputs

std::unordered_map<std::string, core::ManagedImage*> foray::stages::RenderStage::mImageOutputs
protected

Inheriting types should emplace their images onto this collection to provide them in GetImageOutput interface.

◆ mShaderKeys

std::vector<uint64_t> foray::stages::RenderStage::mShaderKeys
protected

Inheriting types should emplace their shader keys onto this collection such that if a shader has been recompiled, ReloadShaders() will be called.


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