Lysa  0.0
Lysa 3D Engine
GraphicPipelineData Struct Reference

Detailed Description

Per-pipeline data for instances, draw command arrays, 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

 GraphicPipelineData (uint32 pipelineId, const DeviceMemoryArray &meshInstancesDataArray, DeviceMemoryArray &instancesArray, size_t initialCapacity)
 
void addInstance (DeviceMemoryArray::WriteSession instancesWriteSession, const MeshInstance *meshInstance, const std::unordered_map< const MeshInstance *, MemoryBlock > &meshInstancesDataMemoryBlocks)
 
void removeInstance (const MeshInstance *meshInstance)
 
void addInstance (DeviceMemoryArray::WriteSession instancesWriteSession, const MeshInstance *meshInstance, const MemoryBlock &instanceMemoryBlock, const MemoryBlock &meshInstanceMemoryBlock)
 
void updateInstance (DeviceMemoryArray::WriteSession instancesWriteSession, const MeshInstance *meshInstance, const std::unordered_map< const MeshInstance *, MemoryBlock > &meshInstancesDataMemoryBlocks)
 
void updateData (const vireo::CommandList &commandList)
 

Public Attributes

pipeline_id pipelineId
 
MaterialManager & materialManager
 
std::shared_ptr< vireo::Vireo > vireo
 
bool instancesUpdated {false}
 
DeviceMemoryArray & instancesArray
 
const DeviceMemoryArray & meshInstancesDataArray
 
vireo::ResourceState activeInstancesState {vireo::ResourceState::UNDEFINED}
 
std::unordered_map< const MeshInstance *, MemoryBlock > instancesMemoryBlocks
 
uint32 activeInstancesCount {0}
 
std::vector< InstanceGroupData > activeInstances
 
std::unordered_map< const MeshInstance *, uint32 > instanceActiveIndex
 
std::shared_ptr< vireo::Buffer > activeInstancesBuffer
 
std::shared_ptr< vireo::Buffer > activeInstancesStagingBuffer
 
uint32 drawCommandsCount {0}
 
std::shared_ptr< vireo::Buffer > drawCommandsBuffer
 
std::shared_ptr< vireo::Buffer > drawCommandGroupsBuffer
 
std::shared_ptr< vireo::Buffer > drawCommandsCountBuffer
 
std::shared_ptr< vireo::Buffer > culledDrawCommandsBuffer
 
std::shared_ptr< vireo::Buffer > culledDrawCommandsCountBuffer
 
GenerateDrawCommands generateDrawCommandsPipeline
 
FrustumCulling frustumCullingPipeline
 

Constructor & Destructor Documentation

GraphicPipelineData ( uint32  pipelineId,
const DeviceMemoryArray &  meshInstancesDataArray,
DeviceMemoryArray &  instancesArray,
size_t  initialCapacity 
)

Create a pipeline data object for a specific material/pipeline ID.

Parameters
pipelineIdIdentifier of the pipeline.
meshInstancesDataArrayArray storing per-mesh-instance data.
instancesArray
initialCapacityInitial group and draw capacities, grown independently on demand.

Member Function Documentation

void addInstance ( DeviceMemoryArray::WriteSession  instancesWriteSession,
const MeshInstance *  meshInstance,
const MemoryBlock &  instanceMemoryBlock,
const MemoryBlock &  meshInstanceMemoryBlock 
)

Adds a single draw instance and wires memory blocks.

Parameters
instancesWriteSessionWrite session for batch writing
meshInstancePointer to the mesh instance.
instanceMemoryBlockMemory block for the instance data.
meshInstanceMemoryBlockMemory block for the mesh instance data.
void addInstance ( DeviceMemoryArray::WriteSession  instancesWriteSession,
const MeshInstance *  meshInstance,
const std::unordered_map< const MeshInstance *, MemoryBlock > &  meshInstancesDataMemoryBlocks 
)

Registers a mesh instance into this pipeline data object.

Parameters
meshInstancePointer to the mesh instance to add.
meshInstancesDataMemoryBlocksMap of memory blocks for mesh instance data.
void removeInstance ( const MeshInstance *  meshInstance)

Removes a previously registered mesh instance.

Parameters
meshInstancePointer to the mesh instance to remove.
void updateData ( const vireo::CommandList &  commandList)

Uploads/refreshes GPU buffers and prepares culled draw arrays.

Parameters
commandListCommand buffer for GPU operations.
void updateInstance ( DeviceMemoryArray::WriteSession  instancesWriteSession,
const MeshInstance *  meshInstance,
const std::unordered_map< const MeshInstance *, MemoryBlock > &  meshInstancesDataMemoryBlocks 
)

Updates the materialIndex of all surfaces for a registered mesh instance.

Parameters
instancesWriteSessionWrite session for batch writing.
meshInstancePointer to the mesh instance to update.
meshInstancesDataMemoryBlocksMap of memory blocks for mesh instance data.

Member Data Documentation

std::vector<InstanceGroupData> activeInstances

CPU-side compact list of mesh/pipeline surface groups.

std::shared_ptr<vireo::Buffer> activeInstancesBuffer

GPU buffer holding the active instanceIndex list

uint32 activeInstancesCount {0}

Number of entries in activeInstances

std::shared_ptr<vireo::Buffer> activeInstancesStagingBuffer

Staging buffer for activeInstancesBuffer uploads

vireo::ResourceState activeInstancesState {vireo::ResourceState::UNDEFINED}
std::shared_ptr<vireo::Buffer> culledDrawCommandsBuffer

GPU buffer storing culled indirect draw commands.

std::shared_ptr<vireo::Buffer> culledDrawCommandsCountBuffer

GPU buffer storing the count of culled draw commands.

std::shared_ptr<vireo::Buffer> drawCommandGroupsBuffer

GPU ranges of commands belonging to each mesh/pipeline group.

std::shared_ptr<vireo::Buffer> drawCommandsBuffer

GPU buffer storing generated surface draw commands.

uint32 drawCommandsCount {0}
std::shared_ptr<vireo::Buffer> drawCommandsCountBuffer

GPU buffer storing the count of draw commands.

FrustumCulling frustumCullingPipeline

Compute pipeline used to cull draw commands against the frustum.

GenerateDrawCommands generateDrawCommandsPipeline

Compute pipeline used to generate draw commands.

std::unordered_map<const MeshInstance*, uint32> instanceActiveIndex

Mapping of meshes instances to the instanceIndex stored in activeInstances[]

DeviceMemoryArray& instancesArray

Device memory array that stores InstanceData blocks.

std::unordered_map<const MeshInstance*, MemoryBlock> instancesMemoryBlocks

Mapping of mesh instance to its memory block within instancesArray.

bool instancesUpdated {false}

Flag tracking if the instances set has been updated.

MaterialManager& materialManager

Reference to the material manager.

const DeviceMemoryArray& meshInstancesDataArray

Persistent per-mesh data array.

pipeline_id pipelineId

Identifier of the material/pipeline family.

std::shared_ptr<vireo::Vireo> vireo

Reference to Vireo.