Remove system lockers during asset loads or saving (only unload needs it)
This commit is contained in:
@@ -600,7 +600,6 @@ void Animation::OnScriptingDispose()
|
||||
Asset::LoadResult Animation::load()
|
||||
{
|
||||
PROFILE_MEM(AnimationsData);
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
|
||||
// Get stream with animations data
|
||||
const auto dataChunk = GetChunk(0);
|
||||
|
||||
@@ -27,7 +27,6 @@ AnimationGraph::AnimationGraph(const SpawnParams& params, const AssetInfo* info)
|
||||
Asset::LoadResult AnimationGraph::load()
|
||||
{
|
||||
PROFILE_MEM(AnimationsData);
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
|
||||
// Get stream with graph data
|
||||
const auto surfaceChunk = GetChunk(0);
|
||||
@@ -86,7 +85,6 @@ bool AnimationGraph::InitAsAnimation(SkinnedModel* baseModel, Animation* anim, b
|
||||
return true;
|
||||
}
|
||||
PROFILE_MEM(AnimationsData);
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
|
||||
// Create Graph data
|
||||
MemoryWriteStream writeStream(512);
|
||||
@@ -172,7 +170,6 @@ bool AnimationGraph::SaveSurface(const BytesContainer& data)
|
||||
{
|
||||
if (OnCheckSave())
|
||||
return true;
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
if (IsVirtual())
|
||||
|
||||
@@ -22,7 +22,6 @@ AnimationGraphFunction::AnimationGraphFunction(const SpawnParams& params, const
|
||||
Asset::LoadResult AnimationGraphFunction::load()
|
||||
{
|
||||
PROFILE_MEM(AnimationsData);
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
|
||||
// Get graph data from chunk
|
||||
const auto surfaceChunk = GetChunk(0);
|
||||
@@ -98,7 +97,6 @@ bool AnimationGraphFunction::SaveSurface(const BytesContainer& data) const
|
||||
{
|
||||
if (OnCheckSave())
|
||||
return true;
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
// Set Visject Surface data
|
||||
|
||||
@@ -106,7 +106,6 @@ namespace
|
||||
Asset::LoadResult ParticleEmitter::load()
|
||||
{
|
||||
PROFILE_MEM(Particles);
|
||||
ScopeWriteLock systemScope(Particles::SystemLocker);
|
||||
|
||||
// Load the graph
|
||||
const auto surfaceChunk = GetChunk(SHADER_FILE_CHUNK_VISJECT_SURFACE);
|
||||
@@ -330,8 +329,6 @@ Asset::LoadResult ParticleEmitter::load()
|
||||
|
||||
// Wait for resources used by the emitter to be loaded
|
||||
// eg. texture used to place particles on spawn needs to be available
|
||||
// Free Particles::SystemLocker when waiting on asset load to prevent lock-contention.
|
||||
bool waitForAsset = false;
|
||||
for (const auto& node : Graph.Nodes)
|
||||
{
|
||||
if ((node.Type == GRAPH_NODE_MAKE_TYPE(5, 1) || node.Type == GRAPH_NODE_MAKE_TYPE(5, 2)) && node.Assets.Count() > 0)
|
||||
@@ -339,11 +336,6 @@ Asset::LoadResult ParticleEmitter::load()
|
||||
const auto texture = node.Assets[0].As<TextureBase>();
|
||||
if (texture)
|
||||
{
|
||||
if (!waitForAsset)
|
||||
{
|
||||
waitForAsset = true;
|
||||
Particles::SystemLocker.WriteUnlock();
|
||||
}
|
||||
WaitForAsset(texture);
|
||||
}
|
||||
}
|
||||
@@ -352,16 +344,9 @@ Asset::LoadResult ParticleEmitter::load()
|
||||
{
|
||||
if (parameter.Type.Type == VariantType::Asset)
|
||||
{
|
||||
if (!waitForAsset)
|
||||
{
|
||||
waitForAsset = true;
|
||||
Particles::SystemLocker.WriteUnlock();
|
||||
}
|
||||
WaitForAsset((Asset*)parameter.Value);
|
||||
}
|
||||
}
|
||||
if (waitForAsset)
|
||||
Particles::SystemLocker.WriteLock();
|
||||
|
||||
return LoadResult::Ok;
|
||||
}
|
||||
@@ -459,7 +444,6 @@ bool ParticleEmitter::SaveSurface(const BytesContainer& data)
|
||||
{
|
||||
if (OnCheckSave())
|
||||
return true;
|
||||
ScopeWriteLock systemScope(Particles::SystemLocker);
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
// Release all chunks
|
||||
|
||||
@@ -43,7 +43,6 @@ ParticleEmitterFunction::ParticleEmitterFunction(const SpawnParams& params, cons
|
||||
Asset::LoadResult ParticleEmitterFunction::load()
|
||||
{
|
||||
PROFILE_MEM(Particles);
|
||||
ScopeWriteLock systemScope(Particles::SystemLocker);
|
||||
|
||||
// Load graph
|
||||
const auto surfaceChunk = GetChunk(0);
|
||||
@@ -189,7 +188,6 @@ bool ParticleEmitterFunction::SaveSurface(const BytesContainer& data) const
|
||||
{
|
||||
if (OnCheckSave())
|
||||
return true;
|
||||
ScopeWriteLock systemScope(Particles::SystemLocker);
|
||||
ScopeLock lock(Locker);
|
||||
|
||||
// Set Visject Surface data
|
||||
|
||||
Reference in New Issue
Block a user