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, uint32 maxMeshSurfacePerPipeline)
 
void addInstance (const MeshInstance *meshInstance, const std::unordered_map< const MeshInstance *, MemoryBlock > &meshInstancesDataMemoryBlocks)
 
void removeInstance (const MeshInstance *meshInstance)
 
void addInstance (const 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< const MeshInstance *, MemoryBlock > &meshInstancesDataMemoryBlocks)
 

Static Public Member Functions

static void createDescriptorLayouts (const std::shared_ptr< vireo::Vireo > &vireo)
 
static void destroyDescriptorLayouts ()
 

Public Attributes

pipeline_id pipelineId
 
std::shared_ptr< vireo::DescriptorSet > descriptorSet
 
FrustumCulling frustumCullingPipeline
 
MaterialManagermaterialManager
 
std::shared_ptr< vireo::Vireo > vireo
 
bool instancesUpdated {false}
 
std::unordered_set< const MeshInstance * > instancesToRemove
 
DeviceMemoryArray instancesArray
 
std::unordered_map< const 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}
 

Static Public Attributes

static constexpr vireo::DescriptorIndex BINDING_INSTANCES {0}
 
static std::shared_ptr< vireo::DescriptorLayout > pipelineDescriptorLayout {nullptr}
 

Constructor & Destructor Documentation

GraphicPipelineData ( uint32  pipelineId,
const DeviceMemoryArray meshInstancesDataArray,
uint32  maxMeshSurfacePerPipeline 
)

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

Parameters
pipelineIdIdentifier of the pipeline.
meshInstancesDataArrayArray storing per-mesh-instance data.
maxMeshSurfacePerPipelineMaximum number of mesh surfaces supported by this pipeline.

Member Function Documentation

void addInstance ( const MeshInstance meshInstance,
const MemoryBlock instanceMemoryBlock,
const MemoryBlock meshInstanceMemoryBlock 
)

Adds a single draw instance and wires memory blocks.

Parameters
meshInstancePointer to the mesh instance.
instanceMemoryBlockMemory block for the instance data.
meshInstanceMemoryBlockMemory block for the mesh instance data.
void addInstance ( 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.
static void createDescriptorLayouts ( const std::shared_ptr< vireo::Vireo > &  vireo)
static

Create the shared descriptor layout.

Parameters
vireoShared pointer to the Vireo instance.
static void destroyDescriptorLayouts ( )
static

Destroy the shared descriptor layout.

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,
std::unordered_set< std::shared_ptr< vireo::Buffer >> &  drawCommandsStagingBufferRecycleBin,
const std::unordered_map< const MeshInstance *, MemoryBlock > &  meshInstancesDataMemoryBlocks 
)

Uploads/refreshes GPU buffers and prepares culled draw arrays.

Parameters
commandListCommand buffer for GPU operations.
drawCommandsStagingBufferRecycleBinSet for recycling staging buffers.
meshInstancesDataMemoryBlocksMap of memory blocks for mesh instance data.

Member Data Documentation

constexpr vireo::DescriptorIndex BINDING_INSTANCES {0}
staticconstexpr

Descriptor binding for per-instance buffer used by pipelines.

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::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 storing indirect draw commands.

uint32 drawCommandsCount {0}

Number of indirect draw commands before culling.

std::shared_ptr<vireo::Buffer> drawCommandsStagingBuffer

Staging buffer used to copy 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<const MeshInstance*, MemoryBlock> instancesMemoryBlocks

Mapping of mesh instance to its memory block within instancesArray.

std::unordered_set<const MeshInstance*> instancesToRemove

Set of mesh instances scheduled for removal.

bool instancesUpdated {false}

Flag tracking if the instances set has been updated.

MaterialManager& materialManager

Reference to the material manager.

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

Shared descriptor layout for pipeline-local resources.

pipeline_id pipelineId

Identifier of the material/pipeline family.

std::shared_ptr<vireo::Vireo> vireo

Reference to Vireo.