class CoreObjectManager

Manager that keeps track of all active CoreObjects.

Public

Constructors

CoreObjectManager

CoreObjectManager()

Methods

~CoreObjectManager

~CoreObjectManager() noexcept

staticGenerateId

static u64 GenerateId()

Generates a new unique ID for a core object.

RegisterObject

void RegisterObject(CoreObject *object)

Registers a new CoreObject notifying the manager the object is created.

UnregisterObject

void UnregisterObject(CoreObject *object)

Unregisters a CoreObject notifying the manager the object is destroyed.

NotifyRenderProxyDirty

void NotifyRenderProxyDirty(CoreObject *object)

Notifies the system that a CoreObject's render proxy data is dirty and needs to be synced with the render thread.

NotifyDependenciesDirty

void NotifyDependenciesDirty(CoreObject *object)

Notifies the system that CoreObject dependencies are dirty and should be updated.

SyncToRenderThread

void SyncToRenderThread(bool swapBuffers)

Synchronizes all CoreObjects with dirty render proxy data with the render thread.

Their dirty data will be allocated using the global frame allocator and then queued for update using the render thread queue for the calling thread.

swapBuffers
Switch ownership of the current buffer from the main thread to the render thread. All data written during sync download will now become owned by the render thread, and a new buffer will be made available on the main thread. Note that there is a limited number of buffers (as specified by RenderThread::kSyncBufferCount), and the caller must ensure that the render thread is still not using the oldest buffer. Generally this is done by ensuring that the render thread never runs more than RenderThread::kSyncBufferCount - 1 frames ahead of the main thread).

SyncToRenderThread

void SyncToRenderThread(CoreObject *object)

Synchronizes an individual dirty CoreObject with the render thread.

Its dirty data will be allocated using the global frame allocator and then queued for update the render thread queue for the calling thread.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Methods

SyncDownload

void SyncDownload(FrameAllocator *allocator)

Stores all syncable data from dirty core objects into memory allocated by the provided allocator.

Additional meta-data is stored internally to be used by call to SyncUpload().

allocator
Allocator to use for allocating memory for stored data.

SyncUpload

void SyncUpload()

Copies all the data stored by previous call to SyncDownload() into destination render proxies.

UpdateDependencies

void UpdateDependencies(CoreObject *object, Vector<CoreObject *> *dependencies)

Updates the cached list of dependencies and dependants for the specified object.

object
Object to update dependencies for.
dependencies
New set of dependencies, or null to clear all dependencies.

Fields

mObjects

Map<u64, CoreObject *> mObjects

mDirtyObjects

Map<u64, DirtyObjectData> mDirtyObjects

mDependencies

Map<u64, Vector<CoreObject *>> mDependencies

mDependants

Map<u64, Vector<CoreObject *>> mDependants

mDestroyedSyncData

Vector<PerObjectSyncData> mDestroyedSyncData

mPerFrameSyncData

List<PerFrameSyncData> mPerFrameSyncData

mSyncAllocators

FrameAllocator *[3] mSyncAllocators

Allocators used for passing temporary data from main thread to the render thread every frame.

As external code guarantees that render thread will never go more than RenderThread::kSyncBufferCount frames ahead of the main thread, we use a ring-buffer of allocators. We use one extra buffer as one buffer could currently be in progress of being passed from main to render thread.

mActiveFrameAllocatorIndex

u32 mActiveFrameAllocatorIndex

mObjectsMutex

Mutex mObjectsMutex