示例#1
0
void FProfilerManager::SetDataCapture( const bool bRequestedDataCaptureState )
{
	ProfilerClient->SetCaptureState( bRequestedDataCaptureState );
	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		FProfilerSessionRef ProfilerSession = It.Value();
		ProfilerSession->bDataCapturing = bRequestedDataCaptureState;
	}
}
示例#2
0
void FProfilerManager::TrackDefaultStats()
{
	// Find StatId for the game thread.
	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		FProfilerSessionRef ProfilerSession = It.Value();
		if( ProfilerSession->GetMetaData()->IsReady() )
		{
			TrackStat( ProfilerSession->GetMetaData()->GetGameThreadStatID() );
		}
		break;
	}
}
示例#3
0
void FProfilerManager::DataGraph_OnSelectionChangedForIndex( uint32 FrameStartIndex, uint32 FrameEndIndex )
{
	PROFILER_SCOPE_LOG_TIME( TEXT( "FProfilerManager::DataGraph_OnSelectionChangedForIndex" ), nullptr );

	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		FProfilerSessionRef ProfilerSession = It.Value();
	
		FEventGraphDataRef EventGraphDataAverage = ProfilerSession->CreateEventGraphData( FrameStartIndex, FrameEndIndex, EEventGraphTypes::Average );
		FEventGraphDataRef EventGraphDataMaximum = ProfilerSession->CreateEventGraphData( FrameStartIndex, FrameEndIndex, EEventGraphTypes::Maximum );

		GetProfilerWindow()->UpdateEventGraph( ProfilerSession->GetInstanceID(), EventGraphDataAverage, EventGraphDataMaximum, false );
	}
}
示例#4
0
void FProfilerManager::CloseAllEventGraphTabs()
{
	TSharedPtr<SProfilerWindow> ProfilerWindowPtr = GetProfilerWindow();
	if( ProfilerWindowPtr.IsValid() )
	{
		// Iterate through all profiler sessions.
		for( auto It = GetProfilerInstancesIterator(); It; ++It )
		{
			FProfilerSessionRef ProfilerSession = It.Value();
			ProfilerWindowPtr->ManageEventGraphTab( ProfilerSession->GetInstanceID(), false, TEXT("") );
		}

		ProfilerWindowPtr->ProfilerMiniView->Reset();
	}
}
示例#5
0
void FProfilerManager::ClearStatsAndInstances()
{
	CloseAllEventGraphTabs();

	ProfilerType = EProfilerSessionTypes::InvalidOrMax;
	ViewMode = EProfilerViewMode::InvalidOrMax;
	SetDataPreview( false );
	bLivePreview = false;
	SetDataCapture( false );

	bHasCaptureFileFullyProcessed = false;

	for( auto It = TrackedStats.CreateConstIterator(); It; ++It )
	{
		const FTrackedStat& TrackedStat = It.Value();
		UntrackStat( TrackedStat.StatID );
	}
	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		const FGuid ProfilerInstanceID = It.Key();
		ProfilerClient->Untrack( ProfilerInstanceID );
	}
	ProfilerSessionInstances.Empty();
}
示例#6
0
bool FProfilerManager::TrackStat( const uint32 StatID )
{
	bool bAdded = false;

	// Check if all profiler instances have this stat ready.
	int32 NumReadyStats = 0;
	for( auto It = GetProfilerInstancesIterator(); It; ++It )
	{
		const FProfilerSessionRef ProfilerSession = It.Value();
		NumReadyStats += ProfilerSession->GetAggregatedStat(StatID) != nullptr ? 1 : 0;
	}
	const bool bStatIsReady = NumReadyStats == GetProfilerInstancesNum();

	if( StatID != 0 && bStatIsReady )
	{
		FTrackedStat* TrackedStat = TrackedStats.Find( StatID );

		if( TrackedStat == nullptr )
		{
			// R = H, G = S, B = V
			const FLinearColor& ColorAverage = GetColorForStatID( StatID );
			const FLinearColor ColorAverageHSV = ColorAverage.LinearRGBToHSV();

			FLinearColor ColorBackgroundHSV = ColorAverageHSV;
			ColorBackgroundHSV.G = FMath::Max( 0.0f, ColorBackgroundHSV.G-0.25f );

			FLinearColor ColorExtremesHSV = ColorAverageHSV;
			ColorExtremesHSV.G = FMath::Min( 1.0f, ColorExtremesHSV.G+0.25f );
			ColorExtremesHSV.B = FMath::Min( 1.0f, ColorExtremesHSV.B+0.25f );

			const FLinearColor ColorBackground = ColorBackgroundHSV.HSVToLinearRGB();
			const FLinearColor ColorExtremes = ColorExtremesHSV.HSVToLinearRGB();

			TrackedStat = &TrackedStats.Add( StatID, FTrackedStat(CreateCombinedGraphDataSource( StatID ),ColorAverage,ColorExtremes,ColorBackground,StatID) );
			bAdded = true;

			// @TODO: Convert a reference parameter to copy parameter/sharedptr/ref/weak, to avoid problems when a reference is no longer valid.
			TrackedStatChangedEvent.Broadcast( *TrackedStat, true );
		}

		if( TrackedStat != nullptr )
		{
			uint32 NumAddedInstances = 0;
			bool bMetadataInitialized = false;

			for( auto It = GetProfilerInstancesIterator(); It; ++It )
			{
				const FGuid& SessionInstanceID = It.Key();// ProfilerSessionInstanceID, ProfilerInstanceID, InstanceID
				const FProfilerSessionRef ProfilerSession = It.Value();
				const bool bInstanceAdded = TrackStatForSessionInstance( StatID, SessionInstanceID );
				NumAddedInstances += bInstanceAdded ? 1 : 0;

				// Initialize metadata for combine graph data source.
				// TODO: This should be checked against the remaining elements to detect inconsistent data.
				// The first instance should be the main.
				if( !bMetadataInitialized )
				{
					const bool bIsStatReady = ProfilerSession->GetMetaData()->IsStatInitialized( StatID );
					if( bIsStatReady )
					{
						const FProfilerStatMetaDataRef MetaData = ProfilerSession->GetMetaData();
						const FProfilerStat& Stat = MetaData->GetStatByID( StatID );
						const FProfilerGroup& Group = Stat.OwningGroup();

						TrackedStat->CombinedGraphDataSource->Initialize( Stat.Name().GetPlainNameString(), Group.ID(), Group.Name().GetPlainNameString(), Stat.Type(), ProfilerSession->GetCreationTime() );
						bMetadataInitialized = true;
					}
				}
			}
		}
	}

	return bAdded;
}