Lysa  0.0
Lysa 3D Engine
PostProcessingCompute Class Reference

Detailed Description

Base class for compute-based post-processing passes.

+ Inheritance diagram for PostProcessingCompute:

Classes

struct  FrameData
 
struct  PostProcessingComputeParams
 

Public Member Functions

 PostProcessingCompute (const RendererConfiguration &config, vireo::ImageFormat outputFormat, const std::string &compShaderName, void *data=nullptr, uint32 dataSize=0, const std::string &name="")
 
void update (uint32 frameIndex) override
 
virtual void render (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::Image > &colorAttachment, uint32 frameIndex)
 
virtual void render (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::Image > &colorAttachment, const std::shared_ptr< vireo::Image > &depthAttachment, uint32 frameIndex)
 
virtual void render (const std::shared_ptr< vireo::CommandList > &commandList, const SceneFrameData &scene, const std::shared_ptr< vireo::Image > &depthAttachment, uint32 frameIndex)
 
void resize (const vireo::Extent &extent, const std::shared_ptr< vireo::CommandList > &commandList) override
 
std::shared_ptr< vireo::Image > getColorAttachment (const uint32 frameIndex) const
 
std::shared_ptr< vireo::RenderTarget > getColorRenderTarget (const uint32 frameIndex)
 
virtual vireo::ImageFormat getColorAttachmentFormat () const
 
const auto & getCompShaderName () const
 
- Public Member Functions inherited from Renderpass
 Renderpass (const RendererConfiguration &config, const std::string &name)
 
virtual ~Renderpass () = default
 
 Renderpass (Renderpass &) = delete
 
Renderpass & operator= (Renderpass &) = delete
 

Static Public Attributes

static constexpr vireo::DescriptorIndex BINDING_PARAMS {0}
 
static constexpr vireo::DescriptorIndex BINDING_DATA {1}
 
static constexpr vireo::DescriptorIndex BINDING_OUTPUT {2}
 
static constexpr vireo::DescriptorIndex BINDING_TEXTURES {3}
 
static constexpr int INPUT_BUFFER {0}
 
static constexpr int DEPTH_BUFFER {1}
 
static constexpr int BLOOM_BUFFER {2}
 
static constexpr int OPT1_BUFFER {3}
 
static constexpr int OPT2_BUFFER {4}
 
static constexpr int TEXTURES_COUNT {OPT2_BUFFER + 1}
 
static constexpr uint32 TILE_SIZE {16}
 

Protected Member Functions

virtual void render (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::Image > &colorAttachment, const std::shared_ptr< vireo::Image > &depthAttachment, const std::shared_ptr< vireo::Image > &bloomColorAttachment, uint32 frameIndex)
 
- Protected Member Functions inherited from Renderpass
std::shared_ptr< vireo::ShaderModule > loadShader (const std::string &shaderName) const
 
void init (vireo::GraphicPipelineConfiguration &pipelineConfig, vireo::RenderingConfiguration &renderingConfig, const std::shared_ptr< vireo::DescriptorLayout > &descriptorLayout, bool withStencil)
 
void init (vireo::GraphicPipelineConfiguration &pipelineConfig, vireo::RenderingConfiguration &renderingConfig, bool withStencil) const
 
void initForScene (vireo::GraphicPipelineConfiguration &pipelineConfig, vireo::RenderingConfiguration &renderingConfig, bool withStencil) const
 
void initRendering (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::GraphicPipeline > &pipeline, const std::shared_ptr< vireo::DescriptorSet > &sceneDescriptorSet, const std::shared_ptr< vireo::DescriptorSet > &descriptorSet)
 
void initCompute (const std::shared_ptr< vireo::CommandList > &commandList, const std::shared_ptr< vireo::ComputePipeline > &pipeline, const std::shared_ptr< vireo::DescriptorSet > &sceneDescriptorSet, const std::shared_ptr< vireo::DescriptorSet > &descriptorSet)
 

Protected Attributes

const vireo::ImageFormat outputFormat
 
const std::string compShaderName
 
uint8 dummyData {0}
 
void * data {nullptr}
 
std::vector< FrameDataframesData
 
std::vector< std::shared_ptr< vireo::Image > > textures
 
std::shared_ptr< vireo::DescriptorLayout > descriptorLayout
 
std::shared_ptr< vireo::Pipeline > pipeline
 
- Protected Attributes inherited from Renderpass
const std::string name
 
const RendererConfigurationconfig
 

Additional Inherited Members

- Static Public Member Functions inherited from Renderpass
static void destroyShaderModules ()
 
- Static Protected Attributes inherited from Renderpass
static std::mutex shaderModulesMutex
 
static std::unordered_map< std::string, std::shared_ptr< vireo::ShaderModule > > shaderModules
 

Constructor & Destructor Documentation

PostProcessingCompute ( const RendererConfiguration config,
vireo::ImageFormat  outputFormat,
const std::string &  compShaderName,
void *  data = nullptr,
uint32  dataSize = 0,
const std::string &  name = "" 
)

Constructs a PostProcessingCompute pass.

Parameters
configRenderer configuration.
outputFormatPixel format of the output render-target image.
compShaderNameName of the compute shader (without extension).
dataPointer to the per-subclass uniform payload.
dataSizeSize in bytes of that payload.
nameDebug label for the pass.

Member Function Documentation

std::shared_ptr<vireo::Image> getColorAttachment ( const uint32  frameIndex) const
inline

Returns the output image for a given frame so that downstream passes can use it as a texture.

Parameters
frameIndexCurrent frame index.
virtual vireo::ImageFormat getColorAttachmentFormat ( ) const
inlinevirtual

Gets the image format used for the output buffer

Reimplemented in lysa::GTAOPass::getColorAttachmentFormat(), lysa::SSAOPass::getColorAttachmentFormat()

std::shared_ptr<vireo::RenderTarget> getColorRenderTarget ( const uint32  frameIndex)
inline

Returns the output image for a given frame so that downstream passes can use it as a render taregt.

Parameters
frameIndexCurrent frame index.
const auto& getCompShaderName ( ) const
inline

Returns the compute shader name (used as identifier for add/remove).

virtual void render ( const std::shared_ptr< vireo::CommandList > &  commandList,
const SceneFrameData scene,
const std::shared_ptr< vireo::Image > &  depthAttachment,
uint32  frameIndex 
)
inlinevirtual

Renders a post-processing that needs the scene data

Parameters
commandListThe command list to record rendering commands into
sceneThe scene frame data
depthAttachmentThe target depth attachment
frameIndexIndex of the current frame

Reimplemented in lysa::SSAOPass::render(), lysa::GTAOPass::render()

virtual void render ( const std::shared_ptr< vireo::CommandList > &  commandList,
const std::shared_ptr< vireo::Image > &  colorAttachment,
const std::shared_ptr< vireo::Image > &  depthAttachment,
const std::shared_ptr< vireo::Image > &  bloomColorAttachment,
uint32  frameIndex 
)
protectedvirtual
virtual void render ( const std::shared_ptr< vireo::CommandList > &  commandList,
const std::shared_ptr< vireo::Image > &  colorAttachment,
const std::shared_ptr< vireo::Image > &  depthAttachment,
uint32  frameIndex 
)
virtual

Dispatches the compute shader using color + depth attachments.

Parameters
commandListCommand list to record into.
colorAttachmentInput color render-target.
depthAttachmentInput depth render-target (may be nullptr).
frameIndexCurrent frame index.

Reimplemented in lysa::BloomPass::render()

virtual void render ( const std::shared_ptr< vireo::CommandList > &  commandList,
const std::shared_ptr< vireo::Image > &  colorAttachment,
uint32  frameIndex 
)
virtual

Dispatches the compute shader using the provided color attachment as input.

Parameters
commandListCommand list to record into.
colorAttachmentInput color render-target.
frameIndexCurrent frame index.

Reimplemented in lysa::SMAAPass::render()

void resize ( const vireo::Extent &  extent,
const std::shared_ptr< vireo::CommandList > &  commandList 
)
overridevirtual

Recreates the output image to match the new extent.

Parameters
extentNew viewport dimensions.

Reimplemented from lysa::Renderpass::resize()

Reimplemented in lysa::SSAOPass::resize(), lysa::GTAOPass::resize(), lysa::FrameScalingPass::resize(), lysa::SMAAPass::resize(), lysa::BloomPass::resize()

void update ( uint32  frameIndex)
overridevirtual

Update any per-frame state (default: no-op).

Reimplemented from lysa::Renderpass::update()

Reimplemented in lysa::BloomPass::update()

Member Data Documentation

constexpr vireo::DescriptorIndex BINDING_DATA {1}
staticconstexpr

Descriptor binding for the custom data uniform buffer

constexpr vireo::DescriptorIndex BINDING_OUTPUT {2}
staticconstexpr

Descriptor binding for the output buffer

constexpr vireo::DescriptorIndex BINDING_PARAMS {0}
staticconstexpr

Descriptor binding for the params uniform buffer

constexpr vireo::DescriptorIndex BINDING_TEXTURES {3}
staticconstexpr

Descriptor binding for the array of input Texture2D

constexpr int BLOOM_BUFFER {2}
staticconstexpr

Texture array index – bloom buffer

const std::string compShaderName
protected
void* data {nullptr}
protected
constexpr int DEPTH_BUFFER {1}
staticconstexpr

Texture array index – depth buffer

std::shared_ptr<vireo::DescriptorLayout> descriptorLayout
protected
uint8 dummyData {0}
protected
std::vector<FrameData> framesData
protected
constexpr int INPUT_BUFFER {0}
staticconstexpr

Texture array index – input HDR / colour buffer

constexpr int OPT1_BUFFER {3}
staticconstexpr

Optional texture, pass defined

constexpr int OPT2_BUFFER {4}
staticconstexpr

Optional texture, pass defined

const vireo::ImageFormat outputFormat
protected
std::shared_ptr<vireo::Pipeline> pipeline
protected
std::vector<std::shared_ptr<vireo::Image> > textures
protected
constexpr int TEXTURES_COUNT {OPT2_BUFFER + 1}
staticconstexpr

Total number of input texture slots

constexpr uint32 TILE_SIZE {16}
staticconstexpr

Compute shader local workgroup size (X and Y axes) - must be updated in postprocess.inc.slang