Files
UnrealEngineUWP/Engine/Source/Developer/TaskGraph/Private/STaskGraph.cpp

187 lines
5.0 KiB
C++
Raw Normal View History

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "STaskGraph.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Stats/Stats.h"
#include "Modules/ModuleManager.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Application/SlateWindowHelper.h"
#include "Framework/Docking/TabManager.h"
#include "Tickable.h"
#include "SProfileVisualizer.h"
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "Widgets/Docking/SDockTab.h"
#include "TaskGraphStyle.h"
/**
* Creates Visualizer using Visualizer profile data format
*
* @param ProfileData Visualizer data
* @return Visualizer window
*/
void MakeTaskGraphVisualizerWindow( TSharedPtr< FVisualizerEvent > ProfileData, const FText& WindowTitle, const FText& ProfilerType, const FText& HeaderMessageText = FText::GetEmpty(), const FLinearColor& HeaderMessageTextColor = FLinearColor::White )
{
FGlobalTabmanager::Get()->InsertNewDocumentTab
(
"VisualizerSpawnPoint", FTabManager::ESearchPreference::RequireClosedTab,
SNew( SDockTab )
.Label( WindowTitle )
.TabRole( ETabRole::DocumentTab )
[
SNew( SProfileVisualizer )
.ProfileData( ProfileData )
.ProfilerType( ProfilerType )
.HeaderMessageText( HeaderMessageText )
.HeaderMessageTextColor( HeaderMessageTextColor )
]
);
}
/** Helper class that counts down when to unpause and stop movie. */
class FDelayedVisualizerSpawner : public FTickableGameObject
{
public:
struct FPendingWindow
{
FText Title;
FText Type;
TSharedPtr< FVisualizerEvent > ProfileData;
FPendingWindow( TSharedPtr<FVisualizerEvent> InData, const FText& InTitle, const FText& InType )
: Title( InTitle )
, Type( InType )
, ProfileData( InData )
{}
};
FDelayedVisualizerSpawner( )
{
}
virtual ~FDelayedVisualizerSpawner()
{
}
void AddPendingData( TSharedPtr<FVisualizerEvent> InProfileData, const FText& InTitle, const FText& InType )
{
DataLock.Lock();
VisualizerDataToSpawn.Add( MakeShareable( new FPendingWindow( InProfileData, InTitle, InType ) ) );
DataLock.Unlock();
}
// FTickableGameObject interface
void Tick(float DeltaTime) override
{
DataLock.Lock();
for ( int32 Index = 0; Index < VisualizerDataToSpawn.Num(); Index++ )
{
TSharedPtr<FPendingWindow> Window = VisualizerDataToSpawn[ Index ];
MakeTaskGraphVisualizerWindow( Window->ProfileData, Window->Title, Window->Type );
}
VisualizerDataToSpawn.Empty();
DataLock.Unlock();
}
/** We should call Tick on this object */
virtual bool IsTickable() const override
{
return true;
}
/** Need this to be ticked when paused (that is the point!) */
virtual bool IsTickableWhenPaused() const override
{
return true;
}
virtual TStatId GetStatId() const override
{
RETURN_QUICK_DECLARE_CYCLE_STAT(FDelayedVisualizerSpawner, STATGROUP_Tickables);
}
private:
FCriticalSection DataLock;
/** List of profile data sets to spawn visualizers for */
TArray< TSharedPtr<FPendingWindow> > VisualizerDataToSpawn;
};
static TSharedPtr< FDelayedVisualizerSpawner > GDelayedVisualizerSpawner;
void InitProfileVisualizer()
{
FTaskGraphStyle::Initialize();
if( GDelayedVisualizerSpawner.IsValid() == false )
{
GDelayedVisualizerSpawner = MakeShareable( new FDelayedVisualizerSpawner() );
}
}
void ShutdownProfileVisualizer()
{
FTaskGraphStyle::Shutdown();
GDelayedVisualizerSpawner.Reset();
}
static bool GHasRegisteredVisualizerLayout = false;
void DisplayProfileVisualizer(TSharedPtr< FVisualizerEvent > InProfileData, const TCHAR* InProfilerType, const FText& HeaderMessageText = FText::GetEmpty(), const FLinearColor& HeaderMessageTextColor = FLinearColor::White)
{
check( IsInGameThread() );
if ( !GHasRegisteredVisualizerLayout )
{
TSharedRef<FTabManager::FLayout> Layout = FTabManager::NewLayout( "Visualizer_Layout" )
->AddArea
(
FTabManager::NewArea(720, 768)
->Split
(
FTabManager::NewStack()
->AddTab("VisualizerSpawnPoint", ETabState::ClosedTab)
)
);
FGlobalTabmanager::Get()->RestoreFrom( Layout, TSharedPtr<SWindow>() );
GHasRegisteredVisualizerLayout = true;
}
FFormatNamedArguments Args;
Args.Add( TEXT("ProfilerType"), FText::FromString( InProfilerType ) );
const FText WindowTitle = FText::Format( NSLOCTEXT("TaskGraph", "WindowTitle", "{ProfilerType} Visualizer"), Args );
const FText ProfilerType = FText::Format( NSLOCTEXT("TaskGraph", "ProfilerType", "{ProfilerType} Profile"), Args );
MakeTaskGraphVisualizerWindow( InProfileData, WindowTitle, ProfilerType, HeaderMessageText, HeaderMessageTextColor );
}
/**
* Module for profile visualizer.
*/
class FProfileVisualizerModule : public IProfileVisualizerModule
{
public:
virtual void StartupModule() override
{
::InitProfileVisualizer();
}
virtual void ShutdownModule() override
{
::ShutdownProfileVisualizer();
}
virtual void DisplayProfileVisualizer(TSharedPtr< FVisualizerEvent > InProfileData, const TCHAR* InProfilerType, const FText& HeaderMessageText, const FLinearColor& HeaderMessageTextColor) override
{
#if WITH_EDITOR
::DisplayProfileVisualizer( InProfileData, InProfilerType, HeaderMessageText, HeaderMessageTextColor );
#endif // WITH_EDITOR
}
};
IMPLEMENT_MODULE(FProfileVisualizerModule, TaskGraph);