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

Utilizes rasterization to render a GBuffer output. More...

#include <foray_gbuffer.hpp>

Inheritance diagram for foray::stages::GBufferStage:
foray::stages::RasterizedRenderStage foray::stages::RenderStage

Classes

struct  PerImageInfo
 

Public Types

enum class  EOutput {
  Position , Normal , Albedo , Motion ,
  MaterialIdx , MeshInstanceIdx , LinearZ , Depth ,
  MaxEnum
}
 

Public Member Functions

 GBufferStage ()=default
 
virtual void Init (core::Context *context, scene::Scene *scene, std::string_view vertexShaderPath="", std::string_view fragmentShaderPath="", bench::DeviceBenchmark *benchmark=nullptr)
 
virtual void RecordFrame (VkCommandBuffer cmdBuffer, base::FrameRenderInfo &renderInfo) override
 Records a frame to cmdBuffer.
 
virtual void Resize (const VkExtent2D &extent) override
 Default implementation accesses mImageOutputs and calls ManagedImage::Resize(extent) on any set image.
 
virtual void Destroy () override
 Destroy the render stage. Finalizes all components.
 
core::ManagedImageGetImageEOutput (EOutput output, bool noThrow=false)
 
- Public Member Functions inherited from foray::stages::RasterizedRenderStage
 RasterizedRenderStage ()=default
 
virtual void UpdateDescriptors ()
 
- 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 PositionOutputName = "Gbuf.Position"
 
static constexpr std::string_view NormalOutputName = "Gbuf.Normal"
 
static constexpr std::string_view AlbedoOutputName = "Gbuf.Albedo"
 
static constexpr std::string_view MotionOutputName = "Gbuf.Motion"
 
static constexpr std::string_view MaterialIdxOutputName = "Gbuf.MaterialIdx"
 
static constexpr std::string_view MeshInstanceIdOutputName = "Gbuf.MeshInstanceIdx"
 
static constexpr std::string_view LinearZOutputName = "Gbuf.LinearZ"
 
static constexpr std::string_view DepthOutputName = "Gbuf.Depth"
 

Protected Member Functions

virtual void DestroyFrameBufferAndRenderpass ()
 
void CreateImages ()
 
void PrepareRenderpass ()
 
virtual void SetupDescriptors () override
 
virtual void CreateDescriptorSets () override
 
virtual void CreatePipelineLayout () override
 
void CreatePipeline ()
 
- Protected Member Functions inherited from foray::stages::RenderStage
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

scene::ScenemScene
 
std::array< PerImageInfo,(size_t) EOutput::MaxEnummImageInfos
 
std::string mVertexShaderPath = ""
 
std::string mFragmentShaderPath = ""
 
core::ShaderModule mVertexShaderModule
 
core::ShaderModule mFragmentShaderModule
 
bench::DeviceBenchmarkmBenchmark = nullptr
 
- Protected Attributes inherited from foray::stages::RasterizedRenderStage
VkFramebuffer mFrameBuffer = nullptr
 
VkRenderPass mRenderpass = nullptr
 
core::DescriptorSet mDescriptorSet
 
VkPipeline mPipeline = nullptr
 
util::PipelineLayout mPipelineLayout
 
- 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.
 

Static Protected Attributes

static const char * TIMESTAMP_VERT_BEGIN = "Vertex Begin"
 
static const char * TIMESTAMP_VERT_END = "Vertex End"
 
static const char * TIMESTAMP_FRAG_BEGIN = "Fragment Begin"
 
static const char * TIMESTAMP_FRAG_END = "Fragment End"
 

Detailed Description

Utilizes rasterization to render a GBuffer output.

Outputs

Member Enumeration Documentation

◆ EOutput

Enumerator
Position 
Normal 
Albedo 
Motion 
MaterialIdx 
MeshInstanceIdx 
LinearZ 
Depth 
MaxEnum 

Constructor & Destructor Documentation

◆ GBufferStage()

foray::stages::GBufferStage::GBufferStage ( )
default

Member Function Documentation

◆ CreateDescriptorSets()

virtual void foray::stages::GBufferStage::CreateDescriptorSets ( )
overrideprotectedvirtual

◆ CreateImages()

void foray::stages::GBufferStage::CreateImages ( )
protected

◆ CreatePipeline()

void foray::stages::GBufferStage::CreatePipeline ( )
protected

◆ CreatePipelineLayout()

virtual void foray::stages::GBufferStage::CreatePipelineLayout ( )
overrideprotectedvirtual

◆ Destroy()

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

Destroy the render stage. Finalizes all components.

Reimplemented from foray::stages::RenderStage.

◆ DestroyFrameBufferAndRenderpass()

virtual void foray::stages::GBufferStage::DestroyFrameBufferAndRenderpass ( )
protectedvirtual

◆ GetImageEOutput()

core::ManagedImage * foray::stages::GBufferStage::GetImageEOutput ( EOutput  output,
bool  noThrow = false 
)

◆ Init()

virtual void foray::stages::GBufferStage::Init ( core::Context context,
scene::Scene scene,
std::string_view  vertexShaderPath = "",
std::string_view  fragmentShaderPath = "",
bench::DeviceBenchmark benchmark = nullptr 
)
virtual
Parameters
sceneScene required for transforms, vertex/index buffers, materials, textures, ...
vertexShaderPath(optional) override with a custom vertex shader
fragmentShaderPath(optional) override with a custom fragment shader
benchmark(optional) enable benchmarking by passing a devicebenchmark object here

◆ PrepareRenderpass()

void foray::stages::GBufferStage::PrepareRenderpass ( )
protected

◆ RecordFrame()

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

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 from foray::stages::RenderStage.

◆ Resize()

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

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 from foray::stages::RenderStage.

◆ SetupDescriptors()

virtual void foray::stages::GBufferStage::SetupDescriptors ( )
overrideprotectedvirtual

Member Data Documentation

◆ AlbedoOutputName

constexpr std::string_view foray::stages::GBufferStage::AlbedoOutputName = "Gbuf.Albedo"
inlinestaticconstexpr

◆ DepthOutputName

constexpr std::string_view foray::stages::GBufferStage::DepthOutputName = "Gbuf.Depth"
inlinestaticconstexpr

◆ LinearZOutputName

constexpr std::string_view foray::stages::GBufferStage::LinearZOutputName = "Gbuf.LinearZ"
inlinestaticconstexpr

◆ MaterialIdxOutputName

constexpr std::string_view foray::stages::GBufferStage::MaterialIdxOutputName = "Gbuf.MaterialIdx"
inlinestaticconstexpr

◆ mBenchmark

bench::DeviceBenchmark* foray::stages::GBufferStage::mBenchmark = nullptr
protected

◆ MeshInstanceIdOutputName

constexpr std::string_view foray::stages::GBufferStage::MeshInstanceIdOutputName = "Gbuf.MeshInstanceIdx"
inlinestaticconstexpr

◆ mFragmentShaderModule

core::ShaderModule foray::stages::GBufferStage::mFragmentShaderModule
protected

◆ mFragmentShaderPath

std::string foray::stages::GBufferStage::mFragmentShaderPath = ""
protected

◆ mImageInfos

std::array<PerImageInfo, (size_t)EOutput::MaxEnum> foray::stages::GBufferStage::mImageInfos
protected

◆ MotionOutputName

constexpr std::string_view foray::stages::GBufferStage::MotionOutputName = "Gbuf.Motion"
inlinestaticconstexpr

◆ mScene

scene::Scene* foray::stages::GBufferStage::mScene
protected

◆ mVertexShaderModule

core::ShaderModule foray::stages::GBufferStage::mVertexShaderModule
protected

◆ mVertexShaderPath

std::string foray::stages::GBufferStage::mVertexShaderPath = ""
protected

◆ NormalOutputName

constexpr std::string_view foray::stages::GBufferStage::NormalOutputName = "Gbuf.Normal"
inlinestaticconstexpr

◆ PositionOutputName

constexpr std::string_view foray::stages::GBufferStage::PositionOutputName = "Gbuf.Position"
inlinestaticconstexpr

◆ TIMESTAMP_FRAG_BEGIN

const char* foray::stages::GBufferStage::TIMESTAMP_FRAG_BEGIN = "Fragment Begin"
inlinestaticprotected

◆ TIMESTAMP_FRAG_END

const char* foray::stages::GBufferStage::TIMESTAMP_FRAG_END = "Fragment End"
inlinestaticprotected

◆ TIMESTAMP_VERT_BEGIN

const char* foray::stages::GBufferStage::TIMESTAMP_VERT_BEGIN = "Vertex Begin"
inlinestaticprotected

◆ TIMESTAMP_VERT_END

const char* foray::stages::GBufferStage::TIMESTAMP_VERT_END = "Vertex End"
inlinestaticprotected

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