Lysa  0.0
Lysa 3D Engine
Scene::PipelineData Struct Reference

Detailed Description

Per-pipeline cache for instances, draw command streams and culling.

Stores instance data, staging/copy buffers and the compute pipeline used to perform frustum culling and produce culled indirect draws.

Public Member Functions

 PipelineData::PipelineData (const SceneConfiguration &config, uint32 pipelineId, const DeviceMemoryArray &meshInstancesDataArray)
 
void addNode (const std::shared_ptr< MeshInstance > &meshInstance, const std::unordered_map< std::shared_ptr< MeshInstance >, MemoryBlock > &meshInstancesDataMemoryBlocks)
 
void removeNode (const std::shared_ptr< MeshInstance > &meshInstance)
 
void addInstance (const std::shared_ptr< MeshInstance > &meshInstance, const MemoryBlock &instanceMemoryBlock, const MemoryBlock &meshInstanceMemoryBlock)
 
void updateData (const vireo::CommandList &commandList, std::unordered_set< std::shared_ptr< vireo::Buffer >> &drawCommandsStagingBufferRecycleBin, const std::unordered_map< std::shared_ptr< MeshInstance >, MemoryBlock > &meshInstancesDataMemoryBlocks)
 

Public Attributes

pipeline_id pipelineId
 
const SceneConfigurationconfig
 
std::shared_ptr< vireo::DescriptorSet > descriptorSet
 
FrustumCulling frustumCullingPipeline
 
bool instancesUpdated {false}
 
bool instancesRemoved {false}
 
DeviceMemoryArray instancesArray
 
std::unordered_map< std::shared_ptr< MeshInstance >, MemoryBlockinstancesMemoryBlocks
 
uint32 drawCommandsCount {0}
 
std::vector< DrawCommanddrawCommands
 
std::shared_ptr< vireo::Buffer > drawCommandsBuffer
 
std::shared_ptr< vireo::Buffer > culledDrawCommandsCountBuffer
 
std::shared_ptr< vireo::Buffer > culledDrawCommandsBuffer
 
std::shared_ptr< vireo::Buffer > drawCommandsStagingBuffer
 
uint32 drawCommandsStagingBufferCount {0}
 

Member Function Documentation

void addInstance ( const std::shared_ptr< MeshInstance > &  meshInstance,
const MemoryBlock instanceMemoryBlock,
const MemoryBlock meshInstanceMemoryBlock 
)

Adds a single draw instance and wires memory blocks.

void addNode ( const std::shared_ptr< MeshInstance > &  meshInstance,
const std::unordered_map< std::shared_ptr< MeshInstance >, MemoryBlock > &  meshInstancesDataMemoryBlocks 
)

Registers a mesh instance into this pipeline cache.

PipelineData::PipelineData ( const SceneConfiguration config,
uint32  pipelineId,
const DeviceMemoryArray meshInstancesDataArray 
)

Constructs a per-pipeline cache and GPU resources holder.

Parameters
configScene configuration reference.
pipelineIdUnique id of the graphics pipeline family.
meshInstancesDataArrayGlobal mesh instances device array.
void removeNode ( const std::shared_ptr< MeshInstance > &  meshInstance)

Removes a previously registered mesh instance.

void updateData ( const vireo::CommandList &  commandList,
std::unordered_set< std::shared_ptr< vireo::Buffer >> &  drawCommandsStagingBufferRecycleBin,
const std::unordered_map< std::shared_ptr< MeshInstance >, MemoryBlock > &  meshInstancesDataMemoryBlocks 
)

Uploads/refreshes GPU buffers and prepares culled draw streams.

Member Data Documentation

const SceneConfiguration& config

Reference to the scene configuration.

std::shared_ptr<vireo::Buffer> culledDrawCommandsBuffer

GPU buffer holding culled indirect draw commands.

std::shared_ptr<vireo::Buffer> culledDrawCommandsCountBuffer

GPU buffer storing the count of culled draw commands.

std::shared_ptr<vireo::DescriptorSet> descriptorSet

Descriptor set bound when drawing with this pipeline.

std::vector<DrawCommand> drawCommands

CPU-side list of draw commands to upload.

std::shared_ptr<vireo::Buffer> drawCommandsBuffer

GPU buffer holding indirect draw commands.

uint32 drawCommandsCount {0}

Number of indirect draw commands before culling.

std::shared_ptr<vireo::Buffer> drawCommandsStagingBuffer

Staging buffer used to stream draw commands to the GPU.

uint32 drawCommandsStagingBufferCount {0}

Number of draw commands stored in the current staging buffer.

FrustumCulling frustumCullingPipeline

Compute pipeline used to cull draw commands against the frustum.

DeviceMemoryArray instancesArray

Device memory array that stores InstanceData blocks.

std::unordered_map<std::shared_ptr<MeshInstance>, MemoryBlock> instancesMemoryBlocks

Mapping of mesh instance to its memory block within instancesArray.

bool instancesRemoved {false}
bool instancesUpdated {false}

Flags tracking mutations in the instances set.

pipeline_id pipelineId

Identifier of the material/pipeline family.