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, uint32 maxPipelines)
 
 ~SceneFrameData ()
 
void update (vireo::CommandList &commandList, const Camera &camera, const RendererConfiguration &config, const vireo::Extent &extent, uint32 frameIndex)
 
void computeCulling (vireo::CommandList &commandList, const Camera &camera) const
 
void addOperation (SceneOperationType type, const MeshInstance &meshInstance, unique_id oldPipeline=INVALID_ID)
 
void addOperation (SceneOperationType type, const Light &light)
 
void addOperation (SceneOperationType, const Environment &environment)
 
void processOperations ()
 
void drawOpaquesModels (const std::shared_ptr< vireo::CommandList > &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawTransparentModels (const std::shared_ptr< vireo::CommandList > &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawShaderMaterialModels (const std::shared_ptr< vireo::CommandList > &commandList, const std::unordered_map< uint32, std::shared_ptr< vireo::GraphicPipeline >> &pipelines) const
 
void drawModels (const std::shared_ptr< vireo::CommandList > &commandList, const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &culledDrawCommandsBuffers, const std::map< pipeline_id, std::shared_ptr< vireo::Buffer >> &culledDrawCommandsCountBuffers) const
 
const auto & getPipelineIds () const
 
void createPipeline (const Material &material)
 
auto isMaterialsUpdated () const
 
void resetMaterialsUpdated ()
 
auto getDescriptorSet () const
 
auto getShadowMapRenderers () const
 
auto getCurrentSceneData () 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_INSTANCES {3}
 
static constexpr vireo::DescriptorIndex BINDING_SHADOW_MAPS {4}
 
static std::shared_ptr< vireo::DescriptorLayout > sceneDescriptorLayout {nullptr}
 
static std::shared_ptr< vireo::PipelineResources > scenePipelinesResources {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,
uint32  maxPipelines 
)

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.
maxPipelinesMaximum number of graphic pipeline per scene
~SceneFrameData ( )
SceneFrameData ( SceneFrameData &  )
delete

Member Function Documentation

void addOperation ( SceneOperationType  type,
const Light light 
)
void addOperation ( SceneOperationType  type,
const MeshInstance meshInstance,
unique_id  oldPipeline = INVALID_ID 
)
void addOperation ( SceneOperationType  ,
const Environment environment 
)
inline
void computeCulling ( 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.

void createPipeline ( const Material material)

Used to pre create pipelines

static void destroyDescriptorLayouts ( )
static

Destroys static descriptor layouts created by createDescriptorLayouts().

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

Issues multi-draw indirect calls for models.

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

Issues draw calls for opaque models.SAMPLED_IMAGE

Parameters
commandListCommand buffer to record into.
pipelinesMap of material/pipeline identifiers to pipelines.
void drawShaderMaterialModels ( const std::shared_ptr< 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 ( const std::shared_ptr< 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 getCurrentSceneData ( ) const
inline
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 processOperations ( )
void resetMaterialsUpdated ( )
inline

Resets the materials updated flag.

void update ( 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.

Member Data Documentation

constexpr vireo::DescriptorIndex BINDING_INSTANCES {3}
staticconstexpr

Descriptor binding for per-instance buffer used by pipelines.

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 {4}
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.

std::shared_ptr<vireo::PipelineResources> scenePipelinesResources {nullptr}
inlinestatic

Resources for all the scene pipelines