Lysa  0.0
Lysa 3D Engine
SceneFrameData Class Reference

Detailed Description

Manages per-frame scene data for rendering.

SceneFrameData handles the storage and update of scene-wide information, including cameras, lights, environment settings, and mesh instance data. It also manages descriptor sets and buffers required for rendering.

Classes

struct  InstanceIndexConstant
 

Public Member Functions

 SceneFrameData (uint32 maxLights, uint32 maxMeshInstancesPerScene, uint32 maxMeshSurfacePerPipeline)
 
void setEnvironment (const Environment &environment)
 
void update (const vireo::CommandList &commandList, const Camera &camera, const RendererConfiguration &config, const vireo::Extent &extent, uint32 frameIndex)
 
void compute (vireo::CommandList &commandList, const Camera &camera) const
 
void addInstance (const MeshInstance *meshInstance)
 
void updateInstance (const MeshInstance *meshInstance)
 
void removeInstance (const MeshInstance *meshInstance)
 
void addLight (const Light *light)
 
void removeLight (const Light *light)
 
void drawOpaquesModels (vireo::CommandList &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawTransparentModels (vireo::CommandList &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawShaderMaterialModels (vireo::CommandList &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawModels (vireo::CommandList &commandList, uint32 set, const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &culledDrawCommandsBuffers, const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &culledDrawCommandsCountBuffers, const std::map< pipeline_id, std::shared_ptr< FrustumCulling >> &frustumCullingPipelines) const
 
const auto & getPipelineIds () const
 
auto isMaterialsUpdated () const
 
void resetMaterialsUpdated ()
 
auto getDescriptorSet () const
 
auto getShadowMapRenderers () const
 
 SceneFrameData (SceneFrameData &) = delete
 
SceneFrameData & operator= (SceneFrameData &) = delete
 

Static Public Member Functions

static void createDescriptorLayouts ()
 
static void destroyDescriptorLayouts ()
 

Static Public Attributes

static constexpr vireo::DescriptorIndex BINDING_SCENE {0}
 
static constexpr vireo::DescriptorIndex BINDING_MODELS {1}
 
static constexpr vireo::DescriptorIndex BINDING_LIGHTS {2}
 
static constexpr vireo::DescriptorIndex BINDING_SHADOW_MAPS {3}
 
static std::shared_ptr< vireo::DescriptorLayout > sceneDescriptorLayout {nullptr}
 
static constexpr vireo::DescriptorIndex BINDING_SHADOW_MAP_TRANSPARENCY_COLOR {0}
 
static constexpr auto instanceIndexConstantDesc
 

Constructor & Destructor Documentation

SceneFrameData ( uint32  maxLights,
uint32  maxMeshInstancesPerScene,
uint32  maxMeshSurfacePerPipeline 
)

Constructs a new SceneFrameData object.

Parameters
maxLightsMaximum number of lights supported.
maxMeshInstancesPerSceneMaximum number of mesh instances per scene.
maxMeshSurfacePerPipelineMaximum number of mesh surfaces per pipeline.
SceneFrameData ( SceneFrameData &  )
delete

Member Function Documentation

void addInstance ( const MeshInstance meshInstance)

Adds a mesh instance to the scene.

Parameters
meshInstancePointer to the mesh instance to add.
void addLight ( const Light light)

Adds a light to the scene.

Parameters
lightPointer to the light to add.
void compute ( vireo::CommandList &  commandList,
const Camera camera 
) const

Executes compute workloads.

Performs operations such as frustum culling.

Parameters
commandListCommand buffer for GPU operations.
cameraThe current camera.
static void createDescriptorLayouts ( )
static

Creates all static descriptor layouts used by scenes and pipelines.

static void destroyDescriptorLayouts ( )
static

Destroys static descriptor layouts created by createDescriptorLayouts().

void drawModels ( vireo::CommandList &  commandList,
uint32  set,
const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &  culledDrawCommandsBuffers,
const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &  culledDrawCommandsCountBuffers,
const std::map< pipeline_id, std::shared_ptr< FrustumCulling >> &  frustumCullingPipelines 
) const

Issues multi-draw indirect calls for models.

Parameters
commandListCommand buffer to record into.
setDescriptor set index.
culledDrawCommandsBuffersMap of buffers containing indirect draw commands.
culledDrawCommandsCountBuffersMap of buffers containing indirect draw counts.
frustumCullingPipelinesMap of frustum culling pipelines.
void drawOpaquesModels ( vireo::CommandList &  commandList,
const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &  pipelines 
) const

Issues draw calls for opaque models.

Parameters
commandListCommand buffer to record into.
pipelinesMap of material/pipeline identifiers to pipelines.
void drawShaderMaterialModels ( vireo::CommandList &  commandList,
const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &  pipelines 
) const

Issues draw calls for models driven by shader materials/special passes.

Parameters
commandListCommand buffer to record into.
pipelinesMap of material/pipeline identifiers to pipelines.
void drawTransparentModels ( vireo::CommandList &  commandList,
const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &  pipelines 
) const

Issues draw calls for transparent models.

Parameters
commandListCommand buffer to record into.
pipelinesMap of material/pipeline identifiers to pipelines.
auto getDescriptorSet ( ) const
inline

Returns the main descriptor set.

Returns
The main descriptor set containing scene resources.
const auto& getPipelineIds ( ) const
inline

Returns the mapping of pipeline identifiers to their materials.

Returns
A reference to the pipeline to materials map.
auto getShadowMapRenderers ( ) const
inline

Returns the shadow map renderers.

Returns
A view over the shadow map renderer values.
auto isMaterialsUpdated ( ) const
inline

Checks if materials have been updated.

Returns
True if materials were updated and pipelines/descriptors must be refreshed.
SceneFrameData& operator= ( SceneFrameData &  )
delete
void removeInstance ( const MeshInstance meshInstance)

Removes a mesh instance from the scene.

Parameters
meshInstancePointer to the mesh instance to remove.
void removeLight ( const Light light)

Removes a light from the scene.

Parameters
lightPointer to the light to remove.
void resetMaterialsUpdated ( )
inline

Resets the materials updated flag.

void setEnvironment ( const Environment environment)
inline

Sets the scene's environment settings.

Parameters
environmentThe environment to set (e.g., skybox, ambient lighting).
void update ( const vireo::CommandList &  commandList,
const Camera camera,
const RendererConfiguration config,
const vireo::Extent &  extent,
uint32  frameIndex 
)

Updates CPU/GPU scene state.

Synchronizes uniforms, lights, instances, and descriptors for the current frame.

Parameters
commandListCommand buffer for GPU operations.
cameraThe current camera.
configRenderer configuration.
extentCurrent render target extent
frameIndexIndex of the current frame.
void updateInstance ( const MeshInstance meshInstance)

Updates an existing mesh instance in the scene.

Parameters
meshInstancePointer to the mesh instance to update.

Member Data Documentation

constexpr vireo::DescriptorIndex BINDING_LIGHTS {2}
staticconstexpr

Descriptor binding for lights buffer.

constexpr vireo::DescriptorIndex BINDING_MODELS {1}
staticconstexpr

Descriptor binding for per-model/instance data buffer.

constexpr vireo::DescriptorIndex BINDING_SCENE {0}
staticconstexpr

Descriptor binding for SceneData uniform buffer.

constexpr vireo::DescriptorIndex BINDING_SHADOW_MAP_TRANSPARENCY_COLOR {0}
staticconstexpr

Optional descriptor binding: transparency color for shadow maps.

constexpr vireo::DescriptorIndex BINDING_SHADOW_MAPS {3}
staticconstexpr

Descriptor binding for shadow maps array.

constexpr auto instanceIndexConstantDesc
staticconstexpr
Initial value:
vireo::PushConstantsDesc {
.stage = vireo::ShaderStage::VERTEX,
.size = sizeof(InstanceIndexConstant),
}

Push constants description for the instance index.

std::shared_ptr<vireo::DescriptorLayout> sceneDescriptorLayout {nullptr}
inlinestatic

Shared descriptor layout for the main scene set.