Lysa  0.0
Lysa 3D Engine
Renderer Class Referenceabstract

Detailed Description

High-level scene renderer orchestrating the frame graph.

  • 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.
  • Drive the typical frame flow: compute → preRender → render → postprocess.

Notes:

+ Inheritance diagram for Renderer:

Classes

struct  BlurData
 
struct  FrameData
 

Public Member Functions

 Renderer (const RenderingConfiguration &config, bool withStencil, const std::string &name)
 
virtual void resize (const vireo::Extent &extent, const std::shared_ptr< vireo::CommandList > &commandList)
 
std::shared_ptr< vireo::RenderTarget > getColorAttachment (uint32 frameIndex) const
 
auto getColorRenderTarget (const uint32 frameIndex) const
 
auto getDepthRenderTarget (const uint32 frameIndex) const
 
virtual std::shared_ptr< vireo::RenderTarget > getBloomColorAttachment (uint32 frameIndex) const = 0
 
void updatePipelines (const Scene &scene)
 
virtual void updatePipelines (const std::unordered_map< pipeline_id, std::vector< std::shared_ptr< Material >>> &pipelineIds)
 
virtual void update (uint32 frameIndex)
 
void compute (vireo::CommandList &commandList, Scene &scene, uint32 frameIndex) const
 
void preRender (vireo::CommandList &commandList, const Scene &scene, uint32 frameIndex)
 
void render (vireo::CommandList &commandList, const Scene &scene, bool clearAttachment, uint32 frameIndex)
 
void postprocess (vireo::CommandList &commandList, const vireo::Viewport &viewport, const vireo::Rect &scissor, uint32 frameIndex)
 
void addPostprocessing (const std::string &fragShaderName, vireo::ImageFormat outputFormat, void *data=nullptr, uint32 dataSize=0)
 
void removePostprocessing (const std::string &fragShaderName)
 
virtual ~Renderer () = default
 
 Renderer (Renderer &) = delete
 
Renderer & operator= (Renderer &) = delete
 

Protected Member Functions

virtual void colorPass (vireo::CommandList &commandList, const Scene &scene, const std::shared_ptr< vireo::RenderTarget > &colorAttachment, const std::shared_ptr< vireo::RenderTarget > &depthAttachment, bool clearAttachment, uint32 frameIndex) = 0
 
void updateBlurData (BlurData &blurData, const vireo::Extent &extent, float strength) const
 

Protected Attributes

const RenderingConfigurationconfig
 
const std::string name
 
const bool withStencil
 

Constructor & Destructor Documentation

Renderer ( const RenderingConfiguration config,
bool  withStencil,
const std::string &  name 
)

Constructs a renderer with the given configuration.

Parameters
configGlobal rendering configuration (formats, buffering).
withStencilTrue when depth buffers include a stencil component.
nameHuman-readable renderer name (for debugging).
virtual ~Renderer ( )
virtualdefault
Renderer ( Renderer &  )
delete

Member Function Documentation

void addPostprocessing ( const std::string &  fragShaderName,
vireo::ImageFormat  outputFormat,
void *  data = nullptr,
uint32  dataSize = 0 
)

Adds a full-screen post-processing pass by fragment shader name.

virtual void colorPass ( vireo::CommandList &  commandList,
const Scene scene,
const std::shared_ptr< vireo::RenderTarget > &  colorAttachment,
const std::shared_ptr< vireo::RenderTarget > &  depthAttachment,
bool  clearAttachment,
uint32  frameIndex 
)
protectedpure virtual

Records the pipeline-specific color pass for the concrete renderer. Implementations dispatch scene draws into colorAttachment/depthAttachment.

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

void compute ( vireo::CommandList &  commandList,
Scene scene,
uint32  frameIndex 
) const

Executes compute workloads such as frustum culling.

virtual std::shared_ptr<vireo::RenderTarget> getBloomColorAttachment ( uint32  frameIndex) const
pure virtual

Returns the color buffer used for bloom extraction for the frame. Concrete renderers decide which buffer carries the bright pass.

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

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

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

auto getColorRenderTarget ( const uint32  frameIndex) const
inline

Short-hand accessor for the color render target of the frame.

auto getDepthRenderTarget ( const uint32  frameIndex) const
inline

Short-hand accessor for the depth render target of the frame.

Renderer& operator= ( Renderer &  )
delete
void postprocess ( vireo::CommandList &  commandList,
const vireo::Viewport &  viewport,
const vireo::Rect &  scissor,
uint32  frameIndex 
)

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

void preRender ( vireo::CommandList &  commandList,
const Scene scene,
uint32  frameIndex 
)

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

void removePostprocessing ( const std::string &  fragShaderName)

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

void render ( vireo::CommandList &  commandList,
const Scene scene,
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 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 updateBlurData ( BlurData blurData,
const vireo::Extent &  extent,
float  strength 
) const
protected

Precomputes Gaussian weights and texel size based on extent/strength.

void updatePipelines ( const Scene 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< std::shared_ptr< Material >>> &  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 RenderingConfiguration& config
protected
float exposure
float gamma
const std::string name
protected
float reduceMin {1.0f / 128.0f}
float reduceMul {1.0f / 8.0f}
float spanMax {8.0f}
const bool withStencil
protected