![]() |
ezEngine Release 26.3
|
Manager for render data and instance data buffers. More...
#include <RenderDataManager.h>

Public Member Functions | |
| ezRenderDataManager (ezWorld *pWorld) | |
| virtual void | Initialize () override |
| This method is called after the constructor. A derived type can override this method to do initialization work. Typically this is the method where updates function are registered. | |
| template<typename T > | |
| T * | CreateRenderDataForThisFrame (const ezGameObject *pOwner) const |
| Creates render data that is only valid for this frame. The data is automatically deleted after the frame has been rendered. | |
| ezArrayPtr< ezPerInstanceData > | GetOrCreateInstanceData (const ezComponent *pOwnerComponent, bool bDynamic, ezGALDynamicBufferHandle &out_hBuffer, ezInstanceDataOffset &inout_instanceDataOffset, ezUInt32 uiCount=1) const |
| Gets or creates per-instance data for the given instance data offset. | |
| void | DeleteInstanceData (ezInstanceDataOffset &inout_instanceDataOffset) const |
| Deletes the instance data associated with the given instance data offset. | |
| ezGALDynamicBufferHandle | GetOrCreateInstanceDataAndFill (const ezComponent &ownerComponent, bool bDynamic, const ezTransform &globalTransform, ezInstanceDataOffset &inout_instanceDataOffset, ezUInt32 uiUniqueID=0, const ezColor &color=ezColor::White, const ezVec4 &vCustomData=ezVec4(0, 1, 0, 1)) const |
| Helper function that combines GetOrCreateInstanceData and FillPerInstanceData. | |
| ezUInt32 | RegisterCustomInstanceData (const ezGALBufferCreationDescription &desc, ezStringView sDebugName, ezDelegate< void()> beforeUploadCallback={}) |
| Registers a custom instance data buffer that can be used to store additional per-instance data. | |
| template<typename T > | |
| ezArrayPtr< T > | GetOrCreateCustomInstanceData (ezUInt32 uiCustomDataIndex, const ezComponent *pOwnerComponent, ezGALDynamicBufferHandle &out_hBuffer, ezCustomInstanceDataOffset &inout_instanceDataOffset, ezUInt32 uiCount=1) const |
| Gets or creates custom per-instance data for the given instance data offset. | |
| void | DeleteCustomInstanceData (ezUInt32 uiCustomDataIndex, ezCustomInstanceDataOffset &inout_instanceDataOffset) const |
| Deletes the custom instance data associated with the given instance data offset. | |
| template<typename T > | |
| ezGALDynamicBufferHandle | GetOrCreateCustomInstanceDataAndFill (ezUInt32 uiCustomDataIndex, const ezComponent &ownerComponent, ezCustomInstanceDataOffset &inout_instanceDataOffset, const T &data) const |
| Helper function that combines GetOrCreateCustomInstanceData and fills it with the given data. | |
| ezGALDynamicBufferHandle | GetCustomInstanceDataBuffer (ezUInt32 uiCustomDataIndex) const |
| Returns the underlying dynamic buffer for the given custom instance data buffer index. | |
| void | CompactCustomInstanceDataBuffer (ezUInt32 uiCustomDataIndex, ezUInt32 uiMaxSteps=16) |
| Compacts the given custom instance data buffer to reduce fragmentation. | |
| ezArrayPtr< ezShaderTransform > | GetOrCreateSkinningData (const ezComponent *pOwnerComponent, ezCustomInstanceDataOffset &inout_instanceDataOffset, ezUInt32 uiNumTransforms) const |
| Gets or creates skinning data for the given instance data offset. | |
| ezArrayPtr< const ezShaderTransform > | GetSkinningData (const ezCustomInstanceDataOffset &instanceDataOffset) const |
| Gets the skinning data for reading for the given instance data offset. | |
| void | DeleteSkinningData (ezCustomInstanceDataOffset &inout_instanceDataOffset) const |
| Deletes the skinning data associated with the given instance data offset. | |
| ezGALDynamicBufferHandle | GetSkinningDataBuffer () const |
| Returns the underlying dynamic buffer that holds the skinning data. | |
| template<typename T > | |
| EZ_ALWAYS_INLINE ezArrayPtr< T > | GetOrCreateCustomInstanceData (ezUInt32 uiCustomDataIndex, const ezComponent *pOwnerComponent, ezGALDynamicBufferHandle &out_hBuffer, ezCustomInstanceDataOffset &inout_instanceDataOffset, ezUInt32 uiCount) const |
| template<typename T > | |
| EZ_FORCE_INLINE ezGALDynamicBufferHandle | GetOrCreateCustomInstanceDataAndFill (ezUInt32 uiCustomDataIndex, const ezComponent &ownerComponent, ezCustomInstanceDataOffset &inout_instanceDataOffset, const T &data) const |
Public Member Functions inherited from ezWorldModule | |
| ezWorld * | GetWorld () |
| Returns the corresponding world to this module. | |
| const ezWorld * | GetWorld () const |
| Returns the corresponding world to this module. | |
| ezUInt32 | GetWorldIndex () const |
| Same as GetWorld()->GetIndex(). Needed to break circular include dependencies. | |
Public Member Functions inherited from ezReflectedClass | |
| virtual const ezRTTI * | GetDynamicRTTI () const |
| bool | IsInstanceOf (const ezRTTI *pType) const |
| Returns whether the type of this instance is of the given type or derived from it. | |
| template<typename T > | |
| EZ_ALWAYS_INLINE bool | IsInstanceOf () const |
| Returns whether the type of this instance is of the given type or derived from it. | |
Static Public Member Functions | |
| static void | FillPerInstanceData (ezPerInstanceData &out_perInstanceData, const ezGameObject *pObject, const ezTransform &globalTransform, ezUInt32 uiUniqueID=0, const ezColor &color=ezColor::White, const ezVec4 &vCustomData=ezVec4(0, 1, 0, 1), float fBoundingSphereRadius=1.0f, ezUInt32 uiRandomSeed=0) |
| Helper function to fill ezPerInstanceData. | |
Static Public Member Functions inherited from ezNoBase | |
| static const ezRTTI * | GetStaticRTTI () |
Additional Inherited Members | |
Protected Types inherited from ezWorldModule | |
| using | UpdateFunction = ezDelegate< void(const UpdateContext &)> |
| Update function delegate. | |
Protected Member Functions inherited from ezWorldModule | |
| ezWorldModule (ezWorld *pWorld) | |
| void | RegisterUpdateFunction (const UpdateFunctionDesc &desc) |
| Registers the given update function at the world. | |
| void | DeregisterUpdateFunction (const UpdateFunctionDesc &desc) |
| De-registers the given update function from the world. Note that only the m_Function and the m_Phase of the description have to be valid for de-registration. | |
| ezAllocator * | GetAllocator () |
| Returns the allocator used by the world. | |
| ezInternal::WorldLargeBlockAllocator * | GetBlockAllocator () |
| Returns the block allocator used by the world. | |
| bool | GetWorldSimulationEnabled () const |
| Returns whether the world simulation is enabled. | |
| virtual void | Deinitialize () |
| This method is called before the destructor. A derived type can override this method to do deinitialization work. | |
| virtual void | OnSimulationStarted () |
| This method is called at the start of the next world update when the world is simulated. This method will be called after the initialization method. | |
| virtual void | WorldClear () |
| Called by ezWorld::Clear(). Can be used to clear cached data when a world is completely cleared of objects (but not deleted). | |
Protected Attributes inherited from ezWorldModule | |
| ezWorld * | m_pWorld |
Manager for render data and instance data buffers.
Render data is used to extract rendering information from components during the extraction phase that is then used for rendering. If many objects should be rendered with one instanced draw call, instance data buffers are used to hold the per-instance information. For that the render data should derive from ezInstanceableRenderData. See ezPerInstanceData what data is supported by default for each instance. When more per instance data is needed it is possible to register a custom instance data buffer and attach that to the render data as well.
| void ezRenderDataManager::CompactCustomInstanceDataBuffer | ( | ezUInt32 | uiCustomDataIndex, |
| ezUInt32 | uiMaxSteps = 16 |
||
| ) |
Compacts the given custom instance data buffer to reduce fragmentation.
This is only necessary if allocations with different counts were created and deleted over time.
| void ezRenderDataManager::DeleteCustomInstanceData | ( | ezUInt32 | uiCustomDataIndex, |
| ezCustomInstanceDataOffset & | inout_instanceDataOffset | ||
| ) | const |
Deletes the custom instance data associated with the given instance data offset.
This function is thread-safe but is typically called in the OnDeactivated function of a component.
| void ezRenderDataManager::DeleteInstanceData | ( | ezInstanceDataOffset & | inout_instanceDataOffset | ) | const |
Deletes the instance data associated with the given instance data offset.
This function is thread-safe but is typically called in the OnDeactivated function of a component.
| ezArrayPtr< T > ezRenderDataManager::GetOrCreateCustomInstanceData | ( | ezUInt32 | uiCustomDataIndex, |
| const ezComponent * | pOwnerComponent, | ||
| ezGALDynamicBufferHandle & | out_hBuffer, | ||
| ezCustomInstanceDataOffset & | inout_instanceDataOffset, | ||
| ezUInt32 | uiCount = 1 |
||
| ) | const |
Gets or creates custom per-instance data for the given instance data offset.
This function is thread-safe and is typically called in an ezMsgExtractRenderData message handler.
| ezArrayPtr< ezPerInstanceData > ezRenderDataManager::GetOrCreateInstanceData | ( | const ezComponent * | pOwnerComponent, |
| bool | bDynamic, | ||
| ezGALDynamicBufferHandle & | out_hBuffer, | ||
| ezInstanceDataOffset & | inout_instanceDataOffset, | ||
| ezUInt32 | uiCount = 1 |
||
| ) | const |
Gets or creates per-instance data for the given instance data offset.
This function is thread-safe and is typically called in an ezMsgExtractRenderData message handler. The render data manager holds two instance data buffers, one for static objects and one for dynamic objects. Typically one would pass GetOwner()->IsDynamic() as bDynamic. If the corresponding render data is not cached it is better to always pass true so that the static buffer does not need to be uploaded every frame.
| ezArrayPtr< ezShaderTransform > ezRenderDataManager::GetOrCreateSkinningData | ( | const ezComponent * | pOwnerComponent, |
| ezCustomInstanceDataOffset & | inout_instanceDataOffset, | ||
| ezUInt32 | uiNumTransforms | ||
| ) | const |
Gets or creates skinning data for the given instance data offset.
ezSkinningState wraps around these functions to manage skinning data for skinned meshes and should be preferred instead of calling these functions directly.
|
overridevirtual |
This method is called after the constructor. A derived type can override this method to do initialization work. Typically this is the method where updates function are registered.
Reimplemented from ezWorldModule.
| ezUInt32 ezRenderDataManager::RegisterCustomInstanceData | ( | const ezGALBufferCreationDescription & | desc, |
| ezStringView | sDebugName, | ||
| ezDelegate< void()> | beforeUploadCallback = {} |
||
| ) |
Registers a custom instance data buffer that can be used to store additional per-instance data.
The beforeUploadCallback is called just before the buffer is uploaded each frame, so it can be used to e.g. wait for a task that generated the data.