2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2014-08-20 21:10:29 -04:00
2014-05-29 17:22:40 -04:00
# if WITH_ENGINE
2014-08-20 21:10:29 -04:00
# include "StaticMeshResources.h"
2014-05-29 17:22:40 -04:00
# endif // WITH_ENGINE
2014-03-14 14:13:41 -04:00
2014-09-09 12:20:43 -04:00
# define LOCTEXT_NAMESPACE "TGenericWindowsTargetPlatform"
2014-08-20 21:10:29 -04:00
2014-03-14 14:13:41 -04:00
/**
* Template for Windows target platforms
*/
template < bool HAS_EDITOR_DATA , bool IS_DEDICATED_SERVER , bool IS_CLIENT_ONLY >
class TGenericWindowsTargetPlatform
: public TTargetPlatformBase < FWindowsPlatformProperties < HAS_EDITOR_DATA , IS_DEDICATED_SERVER , IS_CLIENT_ONLY > >
{
public :
2014-09-09 12:20:43 -04:00
typedef FWindowsPlatformProperties < HAS_EDITOR_DATA , IS_DEDICATED_SERVER , IS_CLIENT_ONLY > TProperties ;
typedef TTargetPlatformBase < TProperties > TSuper ;
2014-03-14 14:13:41 -04:00
/**
* Default constructor .
*/
TGenericWindowsTargetPlatform ( )
{
LocalDevice = MakeShareable ( new TLocalPcTargetDevice < HAS_EDITOR_DATA > ( * this ) ) ;
# if WITH_ENGINE
FConfigCacheIni : : LoadLocalIniFile ( EngineSettings , TEXT ( " Engine " ) , true , * PlatformName ( ) ) ;
2015-03-17 09:50:32 -04:00
TextureLODSettings = nullptr ; // These are registered by the device profile system.
2014-03-14 14:13:41 -04:00
StaticMeshLODSettings . Initialize ( EngineSettings ) ;
2014-05-09 08:51:44 -04:00
// Get the Target RHIs for this platform, we do not always want all those that are supported.
GConfig - > GetArray ( TEXT ( " /Script/WindowsTargetPlatform.WindowsTargetSettings " ) , TEXT ( " TargetedRHIs " ) , TargetedShaderFormats , GEngineIni ) ;
// Gather the list of Target RHIs and filter out any that may be invalid.
TArray < FName > PossibleShaderFormats ;
GetAllPossibleShaderFormats ( PossibleShaderFormats ) ;
for ( int32 ShaderFormatIdx = TargetedShaderFormats . Num ( ) - 1 ; ShaderFormatIdx > = 0 ; ShaderFormatIdx - - )
{
FString ShaderFormat = TargetedShaderFormats [ ShaderFormatIdx ] ;
if ( PossibleShaderFormats . Contains ( FName ( * ShaderFormat ) ) = = false )
{
2015-04-13 13:55:16 -04:00
TargetedShaderFormats . RemoveAt ( ShaderFormatIdx ) ;
2014-05-09 08:51:44 -04:00
}
}
2015-02-03 18:35:25 -05:00
// If we're targeting only DX11 we can use DX11 texture formats. Otherwise we'd have to compress fallbacks and increase the size of cooked content significantly.
static FString NAME_PCD3D_SM5 ( TEXT ( " PCD3D_SM5 " ) ) ;
bSupportDX11TextureFormats = TargetedShaderFormats . Num ( ) = = 1
& & TargetedShaderFormats [ 0 ] = = NAME_PCD3D_SM5 ;
2014-03-14 14:13:41 -04:00
# endif
}
public :
// Begin ITargetPlatform interface
2014-06-13 06:14:46 -04:00
virtual void EnableDeviceCheck ( bool OnOff ) override { }
2014-04-23 17:23:52 -04:00
2014-06-13 06:14:46 -04:00
virtual void GetAllDevices ( TArray < ITargetDevicePtr > & OutDevices ) const override
2014-03-14 14:13:41 -04:00
{
OutDevices . Reset ( ) ;
OutDevices . Add ( LocalDevice ) ;
}
2014-06-13 06:14:46 -04:00
virtual ECompressionFlags GetBaseCompressionMethod ( ) const override
2014-03-14 14:13:41 -04:00
{
return COMPRESS_ZLIB ;
}
2014-06-13 06:14:46 -04:00
virtual bool GenerateStreamingInstallManifest ( const TMultiMap < FString , int32 > & ChunkMap , const TSet < int32 > & ChunkIDsInUse ) const override
2014-03-14 14:13:41 -04:00
{
return true ;
}
2014-06-13 06:14:46 -04:00
virtual ITargetDevicePtr GetDefaultDevice ( ) const override
2014-03-14 14:13:41 -04:00
{
return LocalDevice ;
}
virtual ITargetDevicePtr GetDevice ( const FTargetDeviceId & DeviceId )
{
if ( LocalDevice . IsValid ( ) & & ( DeviceId = = LocalDevice - > GetId ( ) ) )
{
return LocalDevice ;
}
2014-08-20 21:10:29 -04:00
return nullptr ;
2014-03-14 14:13:41 -04:00
}
2014-06-13 06:14:46 -04:00
virtual bool IsRunningPlatform ( ) const override
2014-03-14 14:13:41 -04:00
{
// Must be Windows platform as editor for this to be considered a running platform
return PLATFORM_WINDOWS & & ! UE_SERVER & & ! UE_GAME & & WITH_EDITOR & & HAS_EDITOR_DATA ;
}
2014-10-10 20:14:21 -04:00
virtual bool SupportsFeature ( ETargetPlatformFeatures Feature ) const override
2014-03-14 14:13:41 -04:00
{
// we currently do not have a build target for WindowsServer
if ( Feature = = ETargetPlatformFeatures : : Packaging )
{
return ( HAS_EDITOR_DATA | | ! IS_DEDICATED_SERVER ) ;
}
return TSuper : : SupportsFeature ( Feature ) ;
}
2015-06-03 08:40:17 -04:00
virtual void GetBuildProjectSettingKeys ( FString & OutSection , TArray < FString > & InBoolKeys , TArray < FString > & InIntKeys , TArray < FString > & InStringKeys ) const override
{
OutSection = TEXT ( " /Script/WindowsTargetPlatform.WindowsTargetSettings " ) ;
InStringKeys . Add ( TEXT ( " MinimumOSVersion " ) ) ;
}
2014-03-14 14:13:41 -04:00
# if WITH_ENGINE
2014-06-13 06:14:46 -04:00
virtual void GetAllPossibleShaderFormats ( TArray < FName > & OutFormats ) const override
2014-03-14 14:13:41 -04:00
{
// no shaders needed for dedicated server target
if ( ! IS_DEDICATED_SERVER )
{
static FName NAME_PCD3D_SM5 ( TEXT ( " PCD3D_SM5 " ) ) ;
static FName NAME_PCD3D_SM4 ( TEXT ( " PCD3D_SM4 " ) ) ;
2014-05-09 08:51:44 -04:00
static FName NAME_GLSL_150 ( TEXT ( " GLSL_150 " ) ) ;
static FName NAME_GLSL_430 ( TEXT ( " GLSL_430 " ) ) ;
2014-03-14 14:13:41 -04:00
OutFormats . AddUnique ( NAME_PCD3D_SM5 ) ;
OutFormats . AddUnique ( NAME_PCD3D_SM4 ) ;
2014-05-09 08:51:44 -04:00
OutFormats . AddUnique ( NAME_GLSL_150 ) ;
OutFormats . AddUnique ( NAME_GLSL_430 ) ;
}
}
2014-06-13 06:14:46 -04:00
virtual void GetAllTargetedShaderFormats ( TArray < FName > & OutFormats ) const override
2014-05-09 08:51:44 -04:00
{
for ( const FString & ShaderFormat : TargetedShaderFormats )
{
OutFormats . AddUnique ( FName ( * ShaderFormat ) ) ;
2014-03-14 14:13:41 -04:00
}
}
2014-06-13 06:14:46 -04:00
virtual const class FStaticMeshLODSettings & GetStaticMeshLODSettings ( ) const override
2014-03-14 14:13:41 -04:00
{
return StaticMeshLODSettings ;
}
2014-06-13 06:14:46 -04:00
virtual void GetTextureFormats ( const UTexture * InTexture , TArray < FName > & OutFormats ) const override
2014-03-14 14:13:41 -04:00
{
if ( ! IS_DEDICATED_SERVER )
{
2015-02-17 09:57:44 -05:00
FName TextureFormatName = GetDefaultTextureFormatName ( InTexture , EngineSettings , bSupportDX11TextureFormats ) ;
2015-02-03 18:35:25 -05:00
OutFormats . Add ( TextureFormatName ) ;
2014-03-14 14:13:41 -04:00
}
}
2015-03-17 09:50:32 -04:00
virtual const UTextureLODSettings & GetTextureLODSettings ( ) const override
2014-03-14 14:13:41 -04:00
{
2015-03-17 09:50:32 -04:00
return * TextureLODSettings ;
}
virtual void RegisterTextureLODSettings ( const UTextureLODSettings * InTextureLODSettings ) override
{
TextureLODSettings = InTextureLODSettings ;
2014-03-14 14:13:41 -04:00
}
2014-10-03 14:56:20 -04:00
virtual FName GetWaveFormat ( const class USoundWave * Wave ) const override
2014-03-14 14:13:41 -04:00
{
static FName NAME_OGG ( TEXT ( " OGG " ) ) ;
2014-06-09 11:13:16 -04:00
static FName NAME_OPUS ( TEXT ( " OPUS " ) ) ;
if ( Wave - > IsStreaming ( ) )
{
return NAME_OPUS ;
}
2014-03-14 14:13:41 -04:00
return NAME_OGG ;
}
2014-09-09 12:20:43 -04:00
2014-03-14 14:13:41 -04:00
# endif //WITH_ENGINE
2014-09-09 12:20:43 -04:00
virtual bool SupportsVariants ( ) const override
{
return true ;
}
virtual FText GetVariantDisplayName ( ) const override
{
if ( IS_DEDICATED_SERVER )
{
return LOCTEXT ( " WindowsServerVariantTitle " , " Dedicated Server " ) ;
}
if ( HAS_EDITOR_DATA )
{
return LOCTEXT ( " WindowsClientEditorDataVariantTitle " , " Client with Editor Data " ) ;
}
if ( IS_CLIENT_ONLY )
{
return LOCTEXT ( " WindowsClientOnlyVariantTitle " , " Client only " ) ;
}
return LOCTEXT ( " WindowsClientVariantTitle " , " Client " ) ;
}
virtual FText GetVariantTitle ( ) const override
{
return LOCTEXT ( " WindowsVariantTitle " , " Build Type " ) ;
}
virtual float GetVariantPriority ( ) const override
{
return TProperties : : GetVariantPriority ( ) ;
}
2014-03-14 14:13:41 -04:00
DECLARE_DERIVED_EVENT ( TGenericWindowsTargetPlatform , ITargetPlatform : : FOnTargetDeviceDiscovered , FOnTargetDeviceDiscovered ) ;
2014-06-13 06:14:46 -04:00
virtual FOnTargetDeviceDiscovered & OnDeviceDiscovered ( ) override
2014-03-14 14:13:41 -04:00
{
return DeviceDiscoveredEvent ;
}
DECLARE_DERIVED_EVENT ( TGenericWindowsTargetPlatform , ITargetPlatform : : FOnTargetDeviceLost , FOnTargetDeviceLost ) ;
2014-06-13 06:14:46 -04:00
virtual FOnTargetDeviceLost & OnDeviceLost ( ) override
2014-03-14 14:13:41 -04:00
{
return DeviceLostEvent ;
}
// End ITargetPlatform interface
protected :
/**
* Temporary helper until we refactor Windows build targets .
* Basically maps WindowsNoEditor to Win32 and Windows to Win64 .
*/
FString GetBinariesSubDir ( ) const
{
if ( HAS_EDITOR_DATA )
{
return TEXT ( " Win64 " ) ;
}
return TEXT ( " Win32 " ) ;
}
private :
// Holds the local device.
ITargetDevicePtr LocalDevice ;
# if WITH_ENGINE
// Holds the Engine INI settings for quick use.
FConfigFile EngineSettings ;
// Holds the texture LOD settings.
2015-03-17 09:50:32 -04:00
const UTextureLODSettings * TextureLODSettings ;
2014-03-14 14:13:41 -04:00
// Holds static mesh LOD settings.
FStaticMeshLODSettings StaticMeshLODSettings ;
2014-05-09 08:51:44 -04:00
// List of shader formats specified as targets
TArray < FString > TargetedShaderFormats ;
2015-02-03 18:35:25 -05:00
// True if the project supports non-DX11 texture formats.
bool bSupportDX11TextureFormats ;
2014-03-14 14:13:41 -04:00
# endif // WITH_ENGINE
private :
// Holds an event delegate that is executed when a new target device has been discovered.
FOnTargetDeviceDiscovered DeviceDiscoveredEvent ;
// Holds an event delegate that is executed when a target device has been lost, i.e. disconnected or timed out.
FOnTargetDeviceLost DeviceLostEvent ;
} ;
2014-09-09 12:20:43 -04:00
# undef LOCTEXT_NAMESPACE