struct
TRendererObjectECSSyncChannel
template<typename Derived, typename PacketType, typename DirtyTagType, typename ...FragmentTypes>CRTP interface that serves as a helper to synchronize data between the main and render thread.
A single channel is used to synchronize data from one or multiple ECS fragments from the main thread, into a single packet struct which is then sent to the render thread to be applied.
Different channels can be defined for different purposes. For example one channel might be used for only updating object transform (fast path), and other channel for more substantial updates (e.g. renderable mesh or material changed). Generally each channel type also requires its own ECS dirty tag.
Derived types must provide:
- void CreateAndPopulatePacket(FragmentTypes
&
... fragments, FrameAllocator
& allocator)
- Must call CreatePacket() to create a packet with data to sync, then populate it with data from .
- void ApplyPacket(PacketType
& packet, PackedRendererId rendererId, StorageType
& storage)
- Use provided to access the render thread packed array data for the object from , then update it to latest version using the data you stored in .
Template parameters
Derived | CRTP derived type. |
|---|---|
PacketType | Data type that will store the intermediate data being transferred. |
DirtyTagType | ECS tag type used to mark dirty entities (e.g. ecs::RenderableDirty). CreateAndPopulatePacket() will be called for each dirty entity. |
FragmentTypes | ECS fragment types included in the view and passed to CreateAndPopulatePacket (e.g. ecs::Renderable, ecs::WorldTransform, ecs::RenderableId). |
Public
Methods
GetPacketCount
Returns the number of packets that have been added to this channel.
staticGetDirtyCount
Returns the number of entities marked with DirtyTag in the registry.
Read
Allocates the packet storage, iterates all dirty entities, populating packet data via Derived::CreateAndPopulatePacket().
Private
Methods
FreePacketStorage
Frees the frame-allocated packet and renderer ID arrays.
AllocatePacketStorage
Allocate internal arrays for of packet data and renderer ID entries using .