Lysa  0.0
Lysa 3D Engine
Renderer Class Referenceabstract

Detailed Description

High-level scene renderer

  • Own and manage the set of render passes required by a rendering path (depth pre-pass, opaque/transparent color, shader-material passes, SMAA, bloom and other post-processing).
  • Allocate per-frame color/depth attachments and expose them to callers.
  • Update and (re)build graphics pipelines when the set of materials changes.
+ Inheritance diagram for Renderer:

Classes

struct  FrameData
 

Public Member Functions

virtual std::shared_ptr< vireo::RenderTarget > getColorAttachment (const uint32 frameIndex) const
 
auto getDepthAttachment (const uint32 frameIndex) const
 
std::shared_ptr< vireo::RenderTarget > getCurrentColorAttachment (uint32 frameIndex) const
 
virtual std::shared_ptr< vireo::RenderTarget > getBrightnessAttachment (uint32 frameIndex) const = 0
 
virtual void resize (const vireo::Extent &extent, const std::shared_ptr< vireo::CommandList > &commandList)
 
void updatePipelines (const SceneFrameData &scene)
 
virtual void updatePipelines (const std::unordered_map< pipeline_id, std::vector< unique_id >> &pipelineIds)
 
virtual void update (uint32 frameIndex)
 
void prepare (vireo::CommandList &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, uint32 frameIndex)
 
void render (vireo::CommandList &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, bool clearAttachment, uint32 frameIndex)
 
void postprocess (vireo::CommandList &commandList, uint32 frameIndex)
 
void addPostprocessing (PostProcessing &postProcessingPass)
 
void removePostprocessing (const std::string &fragShaderName)
 
void removePostprocessing (const PostProcessing &postProcessingPass)
 
TransparencyPassgetTransparencyPass ()
 
SMAAPassgetSMAAPass () const
 
BloomPassgetBloomPass () const
 
const auto & getExtent () const
 
virtual ~Renderer () = default
 
 Renderer (Renderer &) = delete
 
Renderer & operator= (Renderer &) = delete
 

Static Public Member Functions

static std::unique_ptr< Renderer > create (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 

Protected Member Functions

 Renderer (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 
virtual void colorPass (vireo::CommandList &commandList, const SceneFrameData &scene, const vireo::Viewport &viewport, const vireo::Rect &scissors, bool clearAttachment, uint32 frameIndex) = 0
 

Protected Attributes

const bool withStencil
 
const RendererConfiguration config
 
std::vector< FrameDataframesData
 
DepthPrepass depthPrePass
 

Constructor & Destructor Documentation

virtual ~Renderer ( )
virtualdefault
Renderer ( Renderer &  )
delete
Renderer ( const RendererConfiguration config,
vireo::ImageFormat  outputFormat 
)
protected

Member Function Documentation

void addPostprocessing ( PostProcessing postProcessingPass)

Adds a full-screen post-processing pass.

virtual void colorPass ( vireo::CommandList &  commandList,
const SceneFrameData scene,
const vireo::Viewport &  viewport,
const vireo::Rect &  scissors,
bool  clearAttachment,
uint32  frameIndex 
)
protectedpure virtual
static std::unique_ptr<Renderer> create ( const RendererConfiguration config,
vireo::ImageFormat  outputFormat 
)
static
BloomPass& getBloomPass ( ) const
inline
virtual std::shared_ptr<vireo::RenderTarget> getBrightnessAttachment ( uint32  frameIndex) const
pure virtual

Returns the color buffer used for bloom extraction for a frame.

Implemented in lysa::DeferredRenderer::getBrightnessAttachment(), lysa::ForwardRenderer::getBrightnessAttachment()

virtual std::shared_ptr<vireo::RenderTarget> getColorAttachment ( const uint32  frameIndex) const
inlinevirtual

Accessor for the color render target of the current frame.

Reimplemented in lysa::DeferredRenderer::getColorAttachment()

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

Returns the color attachment of the current renderer for a frame.

auto getDepthAttachment ( const uint32  frameIndex) const
inline

Accessor for the depth render target of the current frame.

const auto& getExtent ( ) const
inline
SMAAPass& getSMAAPass ( ) const
inline
TransparencyPass& getTransparencyPass ( )
inline
Renderer& operator= ( Renderer &  )
delete
void postprocess ( vireo::CommandList &  commandList,
uint32  frameIndex 
)

Applies post-processing chain (SMAA, bloom, custom passes).

void prepare ( vireo::CommandList &  commandList,
const SceneFrameData scene,
const vireo::Viewport &  viewport,
const vireo::Rect &  scissors,
uint32  frameIndex 
)

Pre-render stage: uploads, layout transitions, depth pre pass and shadow maps.

void removePostprocessing ( const PostProcessing postProcessingPass)
inline

Removes a previously added post-processing pass.

void removePostprocessing ( const std::string &  fragShaderName)

Removes a previously added post-processing pass by fragment name.

void render ( vireo::CommandList &  commandList,
const SceneFrameData scene,
const vireo::Viewport &  viewport,
const vireo::Rect &  scissors,
bool  clearAttachment,
uint32  frameIndex 
)

Main render stage: records opaque/transparent draw calls.

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

Recreates attachments/pipelines after a render target resize.

Parameters
extentNew swap chain extent.
commandListCommand list used for any required transitions/copies.

Reimplemented in lysa::DeferredRenderer::resize(), lysa::ForwardRenderer::resize()

virtual void update ( uint32  frameIndex)
virtual

Performs per-frame housekeeping (e.g., pass-local data updates).

Reimplemented in lysa::ForwardRenderer::update(), lysa::DeferredRenderer::update()

void updatePipelines ( const SceneFrameData scene)

Updates graphics pipelines according to the Scene material mapping. Convenience overload that pulls mapping from the Scene.

virtual void updatePipelines ( const std::unordered_map< pipeline_id, std::vector< unique_id >> &  pipelineIds)
virtual

Updates graphics pipelines according to the provided materials mapping.

Parameters
pipelineIdsMap of pipeline family id to materials.

Reimplemented in lysa::DeferredRenderer::updatePipelines(), lysa::ForwardRenderer::updatePipelines()

Member Data Documentation

const RendererConfiguration config
protected
DepthPrepass depthPrePass
protected
std::vector<FrameData> framesData
protected
const bool withStencil
protected