Optimize updating actor rendering entry with better thread locking that support async writes on actor update
This commit is contained in:
@@ -43,7 +43,7 @@ FORCE_INLINE bool FrustumsListCull(const BoundingSphere& bounds, const Array<Bou
|
||||
void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory category)
|
||||
{
|
||||
PROFILE_MEM(Graphics);
|
||||
ScopeLock lock(Locker);
|
||||
ConcurrentSystemLocker::ReadScope lock(Locker);
|
||||
if (category == PreRender)
|
||||
{
|
||||
// Register scene
|
||||
@@ -51,12 +51,12 @@ void SceneRendering::Draw(RenderContextBatch& renderContextBatch, DrawCategory c
|
||||
renderContext.List->Scenes.Add(this);
|
||||
|
||||
// Add additional lock during scene rendering (prevents any Actors cache modifications on content streaming threads - eg. when model residency changes)
|
||||
Locker.Lock();
|
||||
Locker.Begin(false);
|
||||
}
|
||||
else if (category == PostRender)
|
||||
{
|
||||
// Release additional lock
|
||||
Locker.Unlock();
|
||||
Locker.End(false);
|
||||
}
|
||||
auto& view = renderContextBatch.GetMainContext().View;
|
||||
auto& list = Actors[(int32)category];
|
||||
@@ -127,7 +127,7 @@ void SceneRendering::CollectPostFxVolumes(RenderContext& renderContext)
|
||||
|
||||
void SceneRendering::Clear()
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
ConcurrentSystemLocker::WriteScope lock(Locker);
|
||||
for (auto* listener : _listeners)
|
||||
{
|
||||
listener->OnSceneRenderingClear(this);
|
||||
@@ -149,7 +149,7 @@ void SceneRendering::AddActor(Actor* a, int32& key)
|
||||
return;
|
||||
PROFILE_MEM(Graphics);
|
||||
const int32 category = a->_drawCategory;
|
||||
ScopeLock lock(Locker);
|
||||
ConcurrentSystemLocker::WriteScope lock(Locker);
|
||||
auto& list = Actors[category];
|
||||
if (FreeActors[category].HasItems())
|
||||
{
|
||||
@@ -174,7 +174,7 @@ void SceneRendering::AddActor(Actor* a, int32& key)
|
||||
void SceneRendering::UpdateActor(Actor* a, int32& key, ISceneRenderingListener::UpdateFlags flags)
|
||||
{
|
||||
const int32 category = a->_drawCategory;
|
||||
ScopeLock lock(Locker);
|
||||
ConcurrentSystemLocker::ReadScope lock(Locker); // Read-access only as list doesn't get resized (like Add/Remove do) so allow updating actors from different threads at once
|
||||
auto& list = Actors[category];
|
||||
if (list.Count() <= key) // Ignore invalid key softly
|
||||
return;
|
||||
@@ -193,7 +193,7 @@ void SceneRendering::UpdateActor(Actor* a, int32& key, ISceneRenderingListener::
|
||||
void SceneRendering::RemoveActor(Actor* a, int32& key)
|
||||
{
|
||||
const int32 category = a->_drawCategory;
|
||||
ScopeLock lock(Locker);
|
||||
ConcurrentSystemLocker::WriteScope lock(Locker);
|
||||
auto& list = Actors[category];
|
||||
if (list.Count() > key) // Ignore invalid key softly (eg. list after batch clear during scene unload)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user