2019-12-26 15:32:37 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2016-11-23 15:48:37 -05:00
# include "CoreMinimal.h"
# include "Interfaces/ITargetPlatform.h"
2014-06-05 12:13:44 -04:00
# include "PlatformInfo.h"
2020-10-22 17:31:58 -04:00
# include "Misc/ConfigCacheIni.h"
2014-03-14 14:13:41 -04:00
/**
* Base class for target platforms.
*/
2020-02-12 13:27:19 -05:00
class FTargetPlatformBase
2014-03-14 14:13:41 -04:00
: public ITargetPlatform
{
public :
2014-10-10 20:59:10 -04:00
// ITargetPlatform interface
2014-03-14 14:13:41 -04:00
2014-06-13 06:14:46 -04:00
virtual bool AddDevice ( const FString & DeviceName , bool bDefault ) override
2014-03-14 14:13:41 -04:00
{
return false ;
}
2020-02-12 13:27:19 -05:00
virtual bool AddDevice ( const FString & DeviceId , const FString & DeviceUserFriendlyName , const FString & Username , const FString & Password , bool bDefault ) override
{
return AddDevice ( DeviceId , bDefault ) ;
}
2014-10-10 20:59:10 -04:00
virtual FText DisplayName ( ) const override
2014-06-05 12:13:44 -04:00
{
return PlatformInfo - > DisplayName ;
}
2020-07-01 17:07:12 -04:00
virtual const PlatformInfo : : FTargetPlatformInfo & GetTargetPlatformInfo ( ) const override
2014-06-05 12:13:44 -04:00
{
return * PlatformInfo ;
}
2020-07-01 17:07:12 -04:00
virtual const FDataDrivenPlatformInfo & GetPlatformInfo ( ) const override
{
return * PlatformInfo - > DataDrivenPlatformInfo ;
}
2020-10-14 09:45:12 -04:00
virtual FConfigCacheIni * GetConfigSystem ( ) const override
{
return FConfigCacheIni : : ForPlatform ( * IniPlatformName ( ) ) ;
}
2018-09-25 10:11:35 -04:00
TARGETPLATFORM_API virtual bool UsesForwardShading ( ) const override ;
TARGETPLATFORM_API virtual bool UsesDBuffer ( ) const override ;
2019-04-12 13:00:25 -04:00
TARGETPLATFORM_API virtual bool UsesBasePassVelocity ( ) const override ;
2020-09-24 00:43:27 -04:00
TARGETPLATFORM_API virtual bool VelocityEncodeDepth ( ) const override ;
2020-02-12 13:27:19 -05:00
2020-09-24 00:43:27 -04:00
TARGETPLATFORM_API virtual bool UsesSelectiveBasePassOutputs ( ) const override ;
2019-04-24 17:06:13 -04:00
TARGETPLATFORM_API virtual bool UsesDistanceFields ( ) const override ;
2019-04-12 13:00:25 -04:00
2020-02-12 13:27:19 -05:00
TARGETPLATFORM_API virtual bool UsesRayTracing ( ) const override ;
2020-09-01 14:07:48 -04:00
TARGETPLATFORM_API virtual bool ForcesSimpleSkyDiffuse ( ) const override ;
2019-05-15 10:21:41 -04:00
TARGETPLATFORM_API virtual float GetDownSampleMeshDistanceFieldDivider ( ) const override ;
2020-08-11 01:36:57 -04:00
TARGETPLATFORM_API virtual int32 GetHeightFogModeForOpaque ( ) const override ;
2014-03-14 14:13:41 -04:00
# if WITH_ENGINE
2015-04-01 07:20:55 -04:00
virtual void GetReflectionCaptureFormats ( TArray < FName > & OutFormats ) const override
2014-03-14 14:13:41 -04:00
{
OutFormats . Add ( FName ( TEXT ( " FullHDR " ) ) ) ;
}
2018-09-11 14:44:10 -04:00
2020-09-24 00:43:27 -04:00
virtual FName FinalizeVirtualTextureLayerFormat ( FName Format ) const override
{
return Format ;
}
2018-09-11 14:44:10 -04:00
virtual FName GetVirtualTextureLayerFormat (
int32 SourceFormat ,
bool bAllowCompression , bool bNoAlpha ,
bool bSupportDX11TextureFormats , int32 Settings ) const override
{
return FName ( ) ;
}
2014-03-14 14:13:41 -04:00
# endif //WITH_ENGINE
2014-06-13 06:14:46 -04:00
virtual bool PackageBuild ( const FString & InPackgeDirectory ) override
2014-03-14 14:13:41 -04:00
{
return true ;
}
2018-03-24 09:22:20 -04:00
virtual bool CanSupportXGEShaderCompile ( ) const override
{
return true ;
}
2014-06-13 06:14:46 -04:00
virtual bool IsSdkInstalled ( bool bProjectHasCode , FString & OutDocumentationPath ) const override
2014-03-14 14:13:41 -04:00
{
return true ;
}
2019-09-10 16:11:58 -04:00
virtual int32 CheckRequirements ( bool bProjectHasCode , EBuildConfiguration Configuration , bool bRequiresAssetNativization , FString & OutTutorialPath , FString & OutDocumentationPath , FText & CustomizedLogMessage ) const override
2014-07-22 17:53:31 -04:00
{
2014-10-10 20:49:06 -04:00
int32 bReadyToBuild = ETargetPlatformReadyStatus : : Ready ; // @todo How do we check that the iOS SDK is installed when building from Windows? Is that even possible?
2017-08-21 15:05:19 -04:00
if ( ! IsSdkInstalled ( bProjectHasCode , OutTutorialPath ) )
2014-07-22 18:28:41 -04:00
{
2014-10-10 20:49:06 -04:00
bReadyToBuild | = ETargetPlatformReadyStatus : : SDKNotFound ;
2014-07-22 18:28:41 -04:00
}
return bReadyToBuild ;
2014-07-22 17:53:31 -04:00
}
2019-09-10 16:11:58 -04:00
TARGETPLATFORM_API virtual bool RequiresTempTarget ( bool bProjectHasCode , EBuildConfiguration Configuration , bool bRequiresAssetNativization , FText & OutReason ) const override ;
2019-09-30 15:13:56 -04:00
virtual bool SupportsValueForType ( FName SupportedType , FName RequiredSupportedValue ) const override
{
# if WITH_ENGINE
// check if the given shader format is returned by this TargetPlatform
if ( SupportedType = = TEXT ( " ShaderFormat " ) )
{
TArray < FName > AllPossibleShaderFormats ;
GetAllPossibleShaderFormats ( AllPossibleShaderFormats ) ;
return AllPossibleShaderFormats . Contains ( RequiredSupportedValue ) ;
}
# endif
return false ;
}
2014-09-09 12:20:43 -04:00
virtual bool SupportsVariants ( ) const override
{
return false ;
}
virtual float GetVariantPriority ( ) const override
{
2018-02-22 11:25:06 -05:00
return IsClientOnly ( ) ? 0.0f : 0.2f ;
2014-09-09 12:20:43 -04:00
}
2014-11-19 14:20:49 -05:00
virtual bool SendLowerCaseFilePaths ( ) const override
{
return false ;
}
2015-05-01 14:00:34 -04:00
virtual void GetBuildProjectSettingKeys ( FString & OutSection , TArray < FString > & InBoolKeys , TArray < FString > & InIntKeys , TArray < FString > & InStringKeys ) const override
{
// do nothing in the base class
}
2018-08-08 10:57:55 -04:00
virtual void RefreshSettings ( ) override
{
}
2018-08-14 18:32:34 -04:00
virtual int32 GetPlatformOrdinal ( ) const override
{
return PlatformOrdinal ;
}
2019-01-29 08:56:46 -05:00
TARGETPLATFORM_API virtual TSharedPtr < IDeviceManagerCustomPlatformWidgetCreator > GetCustomWidgetCreator ( ) const override ;
2020-02-12 13:27:19 -05:00
virtual bool ShouldExpandTo32Bit ( const uint16 * Indices , const int32 NumIndices ) const override
{
return false ;
}
# if WITH_ENGINE
virtual FName GetMeshBuilderModuleName ( ) const override
{
// MeshBuilder is the default module. Platforms may override this to provide platform specific mesh data.
static const FName NAME_MeshBuilder ( TEXT ( " MeshBuilder " ) ) ;
return NAME_MeshBuilder ;
}
# endif
2020-04-07 10:45:54 -04:00
virtual bool CopyFileToTarget ( const FString & TargetAddress , const FString & HostFilename , const FString & TargetFilename , const TMap < FString , FString > & CustomPlatformData ) override
{
return false ;
}
2020-07-01 17:07:12 -04:00
virtual bool InitializeHostPlatform ( )
{
// if the platform doesn't need anything, it's valid to do nothing
return true ;
}
2014-06-05 12:13:44 -04:00
protected :
2014-10-10 20:59:10 -04:00
2020-07-01 17:07:12 -04:00
FTargetPlatformBase ( const PlatformInfo : : FTargetPlatformInfo * const InPlatformInfo )
2014-06-05 12:13:44 -04:00
: PlatformInfo ( InPlatformInfo )
{
2019-08-12 18:12:07 -04:00
checkf ( PlatformInfo , TEXT ( " Null PlatformInfo was passed to FTargetPlatformBase. Check the static IsUsable function before creating this object. See FWindowsTargetPlatformModule::GetTargetPlatform() " ) ) ;
2018-08-14 18:32:34 -04:00
PlatformOrdinal = AssignPlatformOrdinal ( * this ) ;
2014-06-05 12:13:44 -04:00
}
/** Information about this platform */
2020-07-01 17:07:12 -04:00
const PlatformInfo : : FTargetPlatformInfo * PlatformInfo ;
2018-08-14 18:32:34 -04:00
int32 PlatformOrdinal ;
2019-09-10 16:11:58 -04:00
private :
bool HasDefaultBuildSettings ( ) const ;
static bool DoProjectSettingsMatchDefault ( const FString & InPlatformName , const FString & InSection , const TArray < FString > * InBoolKeys , const TArray < FString > * InIntKeys , const TArray < FString > * InStringKeys ) ;
2014-03-14 14:13:41 -04:00
} ;
/**
* Template for target platforms.
*
2014-09-21 20:35:48 -04:00
* @param TPlatformProperties Type of platform properties.
2014-03-14 14:13:41 -04:00
*/
template < typename TPlatformProperties >
class TTargetPlatformBase
: public FTargetPlatformBase
{
public :
2019-08-12 18:12:07 -04:00
/**
* Returns true if the target platform will be able to be initialized with an FPlatformInfo. Because FPlatformInfo now comes from a .ini file,
* it's possible that the .dll exists, but the .ini does not (should be uncommon, but is necessary to be handled)
*/
static bool IsUsable ( )
{
2020-07-29 16:19:10 -04:00
return true ;
2019-08-12 18:12:07 -04:00
}
2020-07-29 16:19:10 -04:00
/**
* Constructor that already has a TPI (notably coming from TNonDesktopTargetPlatform)
*/
TTargetPlatformBase ( PlatformInfo : : FTargetPlatformInfo * PremadePlatformInfo )
: FTargetPlatformBase ( PremadePlatformInfo )
2014-03-14 14:13:41 -04:00
{
// HasEditorOnlyData and RequiresCookedData are mutually exclusive.
check ( TPlatformProperties : : HasEditorOnlyData ( ) ! = TPlatformProperties : : RequiresCookedData ( ) ) ;
}
2020-07-29 16:19:10 -04:00
/**
* Constructor that makes a TPI based solely on TPlatformProperties
*/
TTargetPlatformBase ( )
: TTargetPlatformBase ( new PlatformInfo : : FTargetPlatformInfo (
TPlatformProperties : : IniPlatformName ( ) ,
TPlatformProperties : : HasEditorOnlyData ( ) ? EBuildTargetType : : Editor :
TPlatformProperties : : IsServerOnly ( ) ? EBuildTargetType : : Server :
TPlatformProperties : : IsClientOnly ( ) ? EBuildTargetType : : Client :
EBuildTargetType : : Game ,
TEXT ( " " ) )
)
{
}
2014-03-14 14:13:41 -04:00
public :
2014-09-21 20:35:48 -04:00
// ITargetPlatform interface
2014-03-14 14:13:41 -04:00
2014-10-10 20:59:10 -04:00
virtual bool HasEditorOnlyData ( ) const override
2014-03-14 14:13:41 -04:00
{
return TPlatformProperties : : HasEditorOnlyData ( ) ;
}
2014-10-10 20:59:10 -04:00
virtual bool IsLittleEndian ( ) const override
2014-03-14 14:13:41 -04:00
{
return TPlatformProperties : : IsLittleEndian ( ) ;
}
2014-10-10 20:59:10 -04:00
virtual bool IsServerOnly ( ) const override
2014-03-14 14:13:41 -04:00
{
return TPlatformProperties : : IsServerOnly ( ) ;
}
2014-10-10 20:59:10 -04:00
virtual bool IsClientOnly ( ) const override
2014-03-14 14:13:41 -04:00
{
return TPlatformProperties : : IsClientOnly ( ) ;
}
2014-10-10 20:59:10 -04:00
virtual FString PlatformName ( ) const override
2014-03-14 14:13:41 -04:00
{
2020-07-29 16:19:10 -04:00
// we assume these match for DesktopPlatforms (NonDesktop doesn't return "FooClient", but Desktop does, for legacy reasons)
checkSlow ( this - > PlatformInfo - > Name = = TPlatformProperties : : PlatformName ( ) ) ;
2014-03-14 14:13:41 -04:00
return FString ( TPlatformProperties : : PlatformName ( ) ) ;
}
2014-10-10 20:59:10 -04:00
virtual FString IniPlatformName ( ) const override
2014-03-14 14:13:41 -04:00
{
return FString ( TPlatformProperties : : IniPlatformName ( ) ) ;
}
2014-10-10 20:59:10 -04:00
virtual bool RequiresCookedData ( ) const override
2014-03-14 14:13:41 -04:00
{
return TPlatformProperties : : RequiresCookedData ( ) ;
}
2018-09-25 10:11:35 -04:00
virtual bool HasSecurePackageFormat ( ) const override
{
return TPlatformProperties : : HasSecurePackageFormat ( ) ;
}
2020-02-12 13:27:19 -05:00
virtual EPlatformAuthentication RequiresUserCredentials ( ) const override
2014-03-14 14:13:41 -04:00
{
2020-02-12 13:27:19 -05:00
if ( TPlatformProperties : : RequiresUserCredentials ( ) )
{
return EPlatformAuthentication : : Always ;
}
else
{
return EPlatformAuthentication : : Never ;
}
2014-03-14 14:13:41 -04:00
}
2019-08-09 16:46:25 -04:00
virtual bool SupportsBuildTarget ( EBuildTargetType TargetType ) const override
2014-03-14 14:13:41 -04:00
{
2019-08-09 16:46:25 -04:00
return TPlatformProperties : : SupportsBuildTarget ( TargetType ) ;
2014-03-14 14:13:41 -04:00
}
2014-07-22 17:59:23 -04:00
virtual bool SupportsAutoSDK ( ) const override
{
return TPlatformProperties : : SupportsAutoSDK ( ) ;
}
2014-10-10 20:14:21 -04:00
virtual bool SupportsFeature ( ETargetPlatformFeatures Feature ) const override
2014-03-14 14:13:41 -04:00
{
switch ( Feature )
{
2014-07-03 06:07:49 -04:00
case ETargetPlatformFeatures : : AudioStreaming :
return TPlatformProperties : : SupportsAudioStreaming ( ) ;
2014-03-14 14:13:41 -04:00
case ETargetPlatformFeatures : : DistanceFieldShadows :
return TPlatformProperties : : SupportsDistanceFieldShadows ( ) ;
2018-09-12 15:59:49 -04:00
case ETargetPlatformFeatures : : DistanceFieldAO :
return TPlatformProperties : : SupportsDistanceFieldAO ( ) ;
2014-03-14 14:13:41 -04:00
case ETargetPlatformFeatures : : GrayscaleSRGB :
return TPlatformProperties : : SupportsGrayscaleSRGB ( ) ;
case ETargetPlatformFeatures : : HighQualityLightmaps :
return TPlatformProperties : : SupportsHighQualityLightmaps ( ) ;
case ETargetPlatformFeatures : : LowQualityLightmaps :
return TPlatformProperties : : SupportsLowQualityLightmaps ( ) ;
case ETargetPlatformFeatures : : MultipleGameInstances :
return TPlatformProperties : : SupportsMultipleGameInstances ( ) ;
case ETargetPlatformFeatures : : Packaging :
return false ;
case ETargetPlatformFeatures : : Tessellation :
return TPlatformProperties : : SupportsTessellation ( ) ;
case ETargetPlatformFeatures : : TextureStreaming :
return TPlatformProperties : : SupportsTextureStreaming ( ) ;
2019-02-07 10:01:58 -05:00
case ETargetPlatformFeatures : : MeshLODStreaming :
return TPlatformProperties : : SupportsMeshLODStreaming ( ) ;
2020-03-11 12:57:20 -04:00
case ETargetPlatformFeatures : : LandscapeMeshLODStreaming :
return false ;
2014-03-14 14:13:41 -04:00
2019-02-12 21:08:26 -05:00
case ETargetPlatformFeatures : : MemoryMappedFiles :
return TPlatformProperties : : SupportsMemoryMappedFiles ( ) ;
case ETargetPlatformFeatures : : MemoryMappedAudio :
return TPlatformProperties : : SupportsMemoryMappedAudio ( ) ;
2019-02-20 15:06:37 -05:00
case ETargetPlatformFeatures : : MemoryMappedAnimation :
return TPlatformProperties : : SupportsMemoryMappedAnimation ( ) ;
2019-02-12 21:08:26 -05:00
2019-06-19 08:52:32 -04:00
case ETargetPlatformFeatures : : VirtualTextureStreaming :
return TPlatformProperties : : SupportsVirtualTextureStreaming ( ) ;
2015-03-31 20:12:31 -04:00
case ETargetPlatformFeatures : : SdkConnectDisconnect :
case ETargetPlatformFeatures : : UserCredentials :
break ;
2016-06-13 12:20:22 -04:00
case ETargetPlatformFeatures : : MobileRendering :
return false ;
case ETargetPlatformFeatures : : DeferredRendering :
return true ;
2017-01-27 23:32:44 -05:00
case ETargetPlatformFeatures : : ShouldSplitPaksIntoSmallerSizes :
return false ;
2018-07-12 10:41:46 -04:00
case ETargetPlatformFeatures : : HalfFloatVertexFormat :
return true ;
2020-07-06 18:58:26 -04:00
case ETargetPlatformFeatures : : LumenGI :
return TPlatformProperties : : SupportsLumenGI ( ) ;
2020-09-09 04:50:52 -04:00
case ETargetPlatformFeatures : : HardwareLZDecompression :
return TPlatformProperties : : SupportsHardwareLZDecompression ( ) ;
2014-03-14 14:13:41 -04:00
}
return false ;
}
2019-01-23 10:59:53 -05:00
virtual FName GetZlibReplacementFormat ( ) const override
{
return TPlatformProperties : : GetZlibReplacementFormat ( ) ! = nullptr ? FName ( TPlatformProperties : : GetZlibReplacementFormat ( ) ) : NAME_Zlib ;
}
2014-03-14 14:13:41 -04:00
2019-02-12 21:08:26 -05:00
virtual int32 GetMemoryMappingAlignment ( ) const override
{
return TPlatformProperties : : GetMemoryMappingAlignment ( ) ;
}
2014-03-14 14:13:41 -04:00
# if WITH_ENGINE
2014-06-13 06:14:46 -04:00
virtual FName GetPhysicsFormat ( class UBodySetup * Body ) const override
2014-03-14 14:13:41 -04:00
{
return FName ( TPlatformProperties : : GetPhysicsFormat ( ) ) ;
}
# endif // WITH_ENGINE
} ;
2020-07-29 16:19:10 -04:00
template < typename TPlatformProperties >
class TNonDesktopTargetPlatformBase
: public TTargetPlatformBase < TPlatformProperties >
{
public :
/**
* A simplified version for TPs that never will have Editor or ServerOnly versions, potentially multiple CookFlavors, as well as IN VERY RARE CASES,
* a different runtime IniPlatformName than what is passed in here (an example being TVOS and IOS, where passing in TVOS properties is very complicated)
* Note that if we delayed the Info creation, we could just use this->IniPlatformName() and override that in, say TVOS, but we can't call a virtual here,
* so we pass it up into the ctor
*/
TNonDesktopTargetPlatformBase ( bool bInIsClientOnly , const TCHAR * CookFlavor = nullptr , const TCHAR * OverrideIniPlatformName = nullptr )
2020-07-30 09:58:14 -04:00
: TTargetPlatformBase < TPlatformProperties > ( new PlatformInfo : : FTargetPlatformInfo (
2020-07-29 16:19:10 -04:00
OverrideIniPlatformName ? FString ( OverrideIniPlatformName ) : FString ( TPlatformProperties : : IniPlatformName ( ) ) ,
bInIsClientOnly ? EBuildTargetType : : Client : EBuildTargetType : : Game ,
CookFlavor ) )
, bIsClientOnly ( bInIsClientOnly )
{
}
virtual FString PlatformName ( ) const override
{
// instead of TPlatformProperties (which won't have Client for non-desktop platforms), use the Info's name, which is programmatically made
return this - > PlatformInfo - > Name . ToString ( ) ;
}
virtual FString IniPlatformName ( ) const override
{
// we use the Info's IniPlatformName as it may have been overridden in the constructor IN RARE CASES
return this - > PlatformInfo - > IniPlatformName . ToString ( ) ;
}
virtual bool HasEditorOnlyData ( ) const override
{
return false ;
}
virtual bool IsServerOnly ( ) const override
{
return false ;
}
virtual bool IsClientOnly ( ) const override
{
return bIsClientOnly ;
}
virtual bool IsRunningPlatform ( ) const override
{
// IsRunningPlatform is only for editor platforms
return false ;
}
protected :
// true if this target platform is client-only, ie strips out server stuff
bool bIsClientOnly ;
} ;