Add Streaming.Stats for resources streaming statistics

This commit is contained in:
Wojtek Figat
2021-07-07 10:14:39 +02:00
parent 7985196155
commit 3cfdf8871f
2 changed files with 29 additions and 0 deletions

View File

@@ -251,6 +251,20 @@ void StreamingSystem::Execute(TaskGraph* graph)
graph->DispatchJob(job, 1);
}
StreamingStats Streaming::GetStats()
{
StreamingStats stats;
ResourcesLock.Lock();
stats.ResourcesCount = Resources.Count();
for (auto e : Resources)
{
if (e->Streaming.TargetResidency > e->GetCurrentResidency())
stats.StreamingResourcesCount++;
}
ResourcesLock.Unlock();
return stats;
}
void Streaming::RequestStreamingUpdate()
{
PROFILE_CPU();

View File

@@ -8,6 +8,16 @@
class GPUSampler;
// Streaming service statistics container.
API_STRUCT() struct FLAXENGINE_API StreamingStats
{
DECLARE_SCRIPTING_TYPE_MINIMAL(StreamingStats);
// Amount of active streamable resources.
API_FIELD() int32 ResourcesCount = 0;
// Amount of resources that are during streaming in (target residency is higher that the current). Zero if all resources are streamed in.
API_FIELD() int32 StreamingResourcesCount = 0;
};
/// <summary>
/// The content streaming service.
/// </summary>
@@ -20,6 +30,11 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Streaming);
/// </summary>
API_FIELD() static Array<TextureGroup, InlinedAllocation<32>> TextureGroups;
/// <summary>
/// Gets streaming statistics.
/// </summary>
API_PROPERTY() static StreamingStats GetStats();
/// <summary>
/// Requests the streaming update for all the loaded resources. Use it to refresh content streaming after changing configuration.
/// </summary>