Add events for streamable resources residency changes tracking
This commit is contained in:
@@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
// Update residency level
|
// Update residency level
|
||||||
model->_loadedLODs++;
|
model->_loadedLODs++;
|
||||||
|
model->ResidencyChanged();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -697,11 +698,8 @@ bool Model::Init(const Span<int32>& meshesCountPerLod)
|
|||||||
|
|
||||||
// Setup LODs
|
// Setup LODs
|
||||||
for (int32 lodIndex = 0; lodIndex < LODs.Count(); lodIndex++)
|
for (int32 lodIndex = 0; lodIndex < LODs.Count(); lodIndex++)
|
||||||
{
|
|
||||||
LODs[lodIndex].Dispose();
|
LODs[lodIndex].Dispose();
|
||||||
}
|
|
||||||
LODs.Resize(meshesCountPerLod.Length());
|
LODs.Resize(meshesCountPerLod.Length());
|
||||||
_loadedLODs = meshesCountPerLod.Length();
|
|
||||||
|
|
||||||
// Setup meshes
|
// Setup meshes
|
||||||
for (int32 lodIndex = 0; lodIndex < meshesCountPerLod.Length(); lodIndex++)
|
for (int32 lodIndex = 0; lodIndex < meshesCountPerLod.Length(); lodIndex++)
|
||||||
@@ -720,6 +718,10 @@ bool Model::Init(const Span<int32>& meshesCountPerLod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update resource residency
|
||||||
|
_loadedLODs = meshesCountPerLod.Length();
|
||||||
|
ResidencyChanged();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -836,6 +838,7 @@ Task* Model::CreateStreamingTask(int32 residency)
|
|||||||
for (int32 i = HighestResidentLODIndex(); i < LODs.Count() - residency; i++)
|
for (int32 i = HighestResidentLODIndex(); i < LODs.Count() - residency; i++)
|
||||||
LODs[i].Unload();
|
LODs[i].Unload();
|
||||||
_loadedLODs = residency;
|
_loadedLODs = residency;
|
||||||
|
ResidencyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -945,7 +948,7 @@ Asset::LoadResult Model::load()
|
|||||||
sdfStream.Read(&data);
|
sdfStream.Read(&data);
|
||||||
if (!SDF.Texture)
|
if (!SDF.Texture)
|
||||||
SDF.Texture = GPUTexture::New();
|
SDF.Texture = GPUTexture::New();
|
||||||
if (SDF.Texture->Init(GPUTextureDescription::New3D(data.Width, data.Height, data.Depth, data.Format, GPUTextureFlags::ShaderResource | GPUTextureFlags::UnorderedAccess, data.MipLevels)))
|
if (SDF.Texture->Init(GPUTextureDescription::New3D(data.Width, data.Height, data.Depth, data.Format, GPUTextureFlags::ShaderResource, data.MipLevels)))
|
||||||
return LoadResult::Failed;
|
return LoadResult::Failed;
|
||||||
SDF.LocalToUVWMul = data.LocalToUVWMul;
|
SDF.LocalToUVWMul = data.LocalToUVWMul;
|
||||||
SDF.LocalToUVWAdd = data.LocalToUVWAdd;
|
SDF.LocalToUVWAdd = data.LocalToUVWAdd;
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
|
|
||||||
// Update residency level
|
// Update residency level
|
||||||
model->_loadedLODs++;
|
model->_loadedLODs++;
|
||||||
|
model->ResidencyChanged();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -676,11 +677,8 @@ bool SkinnedModel::Init(const Span<int32>& meshesCountPerLod)
|
|||||||
|
|
||||||
// Setup LODs
|
// Setup LODs
|
||||||
for (int32 lodIndex = 0; lodIndex < LODs.Count(); lodIndex++)
|
for (int32 lodIndex = 0; lodIndex < LODs.Count(); lodIndex++)
|
||||||
{
|
|
||||||
LODs[lodIndex].Dispose();
|
LODs[lodIndex].Dispose();
|
||||||
}
|
|
||||||
LODs.Resize(meshesCountPerLod.Length());
|
LODs.Resize(meshesCountPerLod.Length());
|
||||||
_loadedLODs = meshesCountPerLod.Length();
|
|
||||||
|
|
||||||
// Setup meshes
|
// Setup meshes
|
||||||
for (int32 lodIndex = 0; lodIndex < meshesCountPerLod.Length(); lodIndex++)
|
for (int32 lodIndex = 0; lodIndex < meshesCountPerLod.Length(); lodIndex++)
|
||||||
@@ -699,6 +697,10 @@ bool SkinnedModel::Init(const Span<int32>& meshesCountPerLod)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update resource residency
|
||||||
|
_loadedLODs = meshesCountPerLod.Length();
|
||||||
|
ResidencyChanged();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -827,6 +829,7 @@ Task* SkinnedModel::CreateStreamingTask(int32 residency)
|
|||||||
for (int32 i = HighestResidentLODIndex(); i < LODs.Count() - residency; i++)
|
for (int32 i = HighestResidentLODIndex(); i < LODs.Count() - residency; i++)
|
||||||
LODs[i].Unload();
|
LODs[i].Unload();
|
||||||
_loadedLODs = residency;
|
_loadedLODs = residency;
|
||||||
|
ResidencyChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -814,4 +814,5 @@ void GPUTexture::SetResidentMipLevels(int32 count)
|
|||||||
return;
|
return;
|
||||||
_residentMipLevels = count;
|
_residentMipLevels = count;
|
||||||
OnResidentMipsChanged();
|
OnResidentMipsChanged();
|
||||||
|
ResidentMipsChanged(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -568,6 +568,11 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
API_PROPERTY() void SetResidentMipLevels(int32 count);
|
API_PROPERTY() void SetResidentMipLevels(int32 count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event called when texture residency gets changed. Texture Mip gets loaded into GPU memory and is ready to use.
|
||||||
|
/// </summary>
|
||||||
|
Delegate<GPUTexture*> ResidentMipsChanged;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual bool OnInit() = 0;
|
virtual bool OnInit() = 0;
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ protected:
|
|||||||
{
|
{
|
||||||
Swap(_streamingTexture->_texture, _newTexture);
|
Swap(_streamingTexture->_texture, _newTexture);
|
||||||
_streamingTexture->GetTexture()->SetResidentMipLevels(_uploadedMipCount);
|
_streamingTexture->GetTexture()->SetResidentMipLevels(_uploadedMipCount);
|
||||||
|
_streamingTexture->ResidencyChanged();
|
||||||
SAFE_DELETE_GPU_RESOURCE(_newTexture);
|
SAFE_DELETE_GPU_RESOURCE(_newTexture);
|
||||||
|
|
||||||
// Base
|
// Base
|
||||||
@@ -447,6 +448,7 @@ Task* StreamingTexture::CreateStreamingTask(int32 residency)
|
|||||||
{
|
{
|
||||||
// Do the quick data release
|
// Do the quick data release
|
||||||
_texture->ReleaseGPU();
|
_texture->ReleaseGPU();
|
||||||
|
ResidencyChanged();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Engine/Core/Delegate.h"
|
||||||
#include "Engine/Core/Collections/SamplesBuffer.h"
|
#include "Engine/Core/Collections/SamplesBuffer.h"
|
||||||
|
|
||||||
class StreamingGroup;
|
class StreamingGroup;
|
||||||
@@ -111,6 +112,11 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
StreamingCache Streaming;
|
StreamingCache Streaming;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event called when current resource residency gets changed (eg. model LOD or texture MIP gets loaded). Usually called from async thread.
|
||||||
|
/// </summary>
|
||||||
|
Action ResidencyChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requests the streaming update for this resource during next streaming manager update.
|
/// Requests the streaming update for this resource during next streaming manager update.
|
||||||
|
|||||||
Reference in New Issue
Block a user