Files
UnrealEngineUWP/Engine/Source/Developer/Windows/WindowsTargetPlatform/Private/GenericWindowsTargetPlatform.h
Rolando Caloca e3ec1a0d94 Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 4358666)
#lockdown Nick.Penwarden

============================
  MAJOR FEATURES & CHANGES
============================

Change 4073167 by Krzysztof.Narkowicz

	Added subsurface profile for eye shading model.
	#jira none

Change 4073422 by Krzysztof.Narkowicz

	Added dual specular for subsurface profile shading model.
	#jira none

Change 4075278 by Krzysztof.Narkowicz

	Fixed forward reflection/refraction rendering issues, which caused ShaderModels.Material.Refraction to fail.
	#jira none

Change 4084231 by Krzysztof.Narkowicz

	Dual specular - replace lobe spread with two separate roughness multipliers. Default material roughness is now replaced by an average lobe roughness in order to support non dual specular features.
	#jira none

Change 4092798 by Matt.Collins

	Some HDR refactoring.

	Previously the DisplayOutput and ColorGamut were only set in GameUserSettings.
	I added a Sink that checks the HDR enable. If it's toggled we apply the correct DisplayOutput and ColorGamut for the current platform (this way we get good settings even if you toggle via the console). These settings are still exposed via the console and can be set independently if the user wants.

Change 4096954 by Chris.Bunner

	Added ShaderModelID as scene texture option and renamed existing value to ShaderModelColor to better reflect the internal code.

Change 4111285 by Brian.Karis

	Eye shading update.
	Added Iris normal (disabled). Removed wrap. Fixed contact shadows.

Change 4155261 by Krzysztof.Narkowicz

	Planar reflection prefilter - use scene viewport size instead of reflection target size in order to keep filter size constant in screen space. This makes planar reflection filter more stable in case of dynamic resolution.

	#jira none

Change 4167644 by Krzysztof.Narkowicz

	Global shader map is now stored in multiple DDC entries (one per shader filename) instead of keeping everything in a single one. This allows to skip recompilation of unchanged shader files.

Change 4183727 by Yuriy.ODonnell

	Implemented auto-conversion from deferred to DBuffer decals in forward shading mode (when GBuffer is not available).

	Added support for specular and metallic channels for DBuffer decals, based on work by Chris Bunner.
	This requires DBufferC to be expanded from 2 to 4 channels, leading to slight increase in DBuffer bandwidth and memory requirements.

	Appearance of DBuffer decals is affected by this change, as specular and metallic channel values previously hard-coded in DBufferDecalShared.ush.
	Decals were forced to be non-metallic and have specular of 4% (0.5 numeric value). Now the authored decal material values will be used, which matches GBuffer decals.

	Added support for DBuffer decals with emissive component.

	Most decal types can now be automatically converted, with the exception of stain decals. Those are currently approximated as regular translucent decals.

Change 4197684 by laz.matech

	Added a PostProcess Volume test to the map to test that Cinematic Depth of View can be achieved through PPVs as well. Changed the BP_DepthOfFeildPOV asset - I exposed Focus Method so that it can be disabled for the PPV test. Added a second Hair Model head to the InFocusHair test so that it tests in and out of focus hair models (changed the name of the test to FocusHair).

	#jira none

Change 4225614 by Rolando.Caloca

	DR - Enable depth collision particles on Vulkan mobile

Change 4235489 by Uriel.Doyon

	Removed r.DefaultFeature.PointLightUnits and r.DefaultFeature.SpotLightUnits and replaced them by a single r.DefaultFeature.LightUnits which also controls the units of newly placed rect lights.

	#jira UE-59525

Change 4260154 by Mark.Satterthwaite

	Parallelize the creation of Metal archives and libraries when they are broken up into smaller sub-libraries, this should reduce apparent cook time by going wide across threads on the host of the cooker.

Change 4270594 by Brian.Karis

	Fix for textured rect light L pointing away from plane due to approximate diffuse integration.

Change 4273361 by Daniel.Wright

	Particle Cutouts with 8 verts now always use stochastic approach.  Circle textures with > 234 edges in the convex hull were overflowing the uint64 calculation of the total number of combinations, causing an infinite loop.

Change 4309174 by Mark.Satterthwaite

	Graph device utilization from the driver monitor stats - really helps see how well the GPU is being used.

Change 4310121 by Matt.Collins

	Optmizing RemoveUniformBuffersFromSource. Brings it from ~20% to ~1.5% in my testing.

	#jira none

Change 4312960 by Daniel.Wright

	Fix from Stephen Hill for incorrect light grid culling near the near plane

Change 4314169 by Richard.Wallis

	FShaderCache and associated public structures are now marked as deprecated.  All FShaderCache code hooks removed from MetalRHI, OpenGLDrv and engine Launch/Shutdown logic.

	#jira none

Change 4320760 by Arne.Schober

	DR - Remove SV_Coverage from basepass interpolants when running with Masked in early Depth with ForwardShading as otherwise earlyZ will be disabled (as the PS has to run).
	#jira UE-60992

Change 4334607 by Uriel.Doyon

	Added custom overrides to reset ULightComponent::Intensity to default (in FLightComponentDetails).
	Now settings a light Intesity to default resets the brightness to the archetype brightness.
	This handles correctly cases where the intensity units differs between the two objects.
	Also changed FLocalLightComponentDetails so that changing intensity units kepts the same brightness
	(by recomputing the Intensity).

	#jira UE-61401

Change 4336188 by Rolando.Caloca

	DR - Added -ReduceThreadUsage so programs can use less threads (for SCW )

Change 4337967 by Rolando.Caloca

	DR - Remove unused RHISupportsShaderCompression function

#rb none

[CL 4358751 by Rolando Caloca in Main branch]
2018-09-11 14:44:10 -04:00

524 lines
15 KiB
C++

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Common/TargetPlatformBase.h"
#include "Misc/ConfigCacheIni.h"
#include "LocalPcTargetDevice.h"
#if WITH_ENGINE
#include "Sound/SoundWave.h"
#include "TextureResource.h"
#include "Engine/VolumeTexture.h"
#include "StaticMeshResources.h"
#include "RHI.h"
#endif // WITH_ENGINE
#define LOCTEXT_NAMESPACE "TGenericWindowsTargetPlatform"
/**
* 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:
typedef FWindowsPlatformProperties<HAS_EDITOR_DATA, IS_DEDICATED_SERVER, IS_CLIENT_ONLY> TProperties;
typedef TTargetPlatformBase<TProperties> TSuper;
/**
* Default constructor.
*/
TGenericWindowsTargetPlatform( )
{
#if PLATFORM_WINDOWS
// only add local device if actually running on Windows
LocalDevice = MakeShareable(new TLocalPcTargetDevice<PLATFORM_64BITS>(*this));
#endif
#if WITH_ENGINE
FConfigCacheIni::LoadLocalIniFile(EngineSettings, TEXT("Engine"), true, *this->PlatformName());
TextureLODSettings = nullptr; // These are registered by the device profile system.
StaticMeshLODSettings.Initialize(EngineSettings);
// Get the Target RHIs for this platform, we do not always want all those that are supported.
TArray<FName> TargetedShaderFormats;
GetAllTargetedShaderFormats(TargetedShaderFormats);
static FName NAME_PCD3D_SM5(TEXT("PCD3D_SM5"));
static FName NAME_PCD3D_SM4(TEXT("PCD3D_SM4"));
static FName NAME_VULKAN_SM5(TEXT("SF_VULKAN_SM5"));
bSupportDX11TextureFormats = true;
bSupportCompressedVolumeTexture = true;
for (FName TargetedShaderFormat : TargetedShaderFormats)
{
EShaderPlatform ShaderPlatform = SP_NumPlatforms;
// Can't use ShaderFormatToLegacyShaderPlatform() because of link dependency
{
if (TargetedShaderFormat == NAME_PCD3D_SM5)
{
ShaderPlatform = SP_PCD3D_SM5;
}
else if (TargetedShaderFormat == NAME_PCD3D_SM4)
{
ShaderPlatform = SP_PCD3D_SM4;
}
else if (TargetedShaderFormat == NAME_VULKAN_SM5)
{
ShaderPlatform = SP_VULKAN_SM5;
}
}
// 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.
if (ShaderPlatform != SP_PCD3D_SM5 && ShaderPlatform != SP_VULKAN_SM5)
{
bSupportDX11TextureFormats = false;
}
if (!UVolumeTexture::ShaderPlatformSupportsCompression(ShaderPlatform))
{
bSupportCompressedVolumeTexture = false;
}
}
// If we are targeting ES 2.0/3.1, we also must cook encoded HDR reflection captures
static FName NAME_SF_VULKAN_ES31(TEXT("SF_VULKAN_ES31"));
static FName NAME_OPENGL_150_ES2(TEXT("GLSL_150_ES2"));
static FName NAME_OPENGL_150_ES3_1(TEXT("GLSL_150_ES31"));
bRequiresEncodedHDRReflectionCaptures = TargetedShaderFormats.Contains(NAME_SF_VULKAN_ES31)
|| TargetedShaderFormats.Contains(NAME_OPENGL_150_ES2)
|| TargetedShaderFormats.Contains(NAME_OPENGL_150_ES3_1);
#endif
}
public:
//~ Begin ITargetPlatform Interface
virtual void EnableDeviceCheck(bool OnOff) override {}
virtual void GetAllDevices( TArray<ITargetDevicePtr>& OutDevices ) const override
{
OutDevices.Reset();
if (LocalDevice.IsValid())
{
OutDevices.Add(LocalDevice);
}
}
virtual ECompressionFlags GetBaseCompressionMethod( ) const override
{
return COMPRESS_ZLIB;
}
virtual bool GenerateStreamingInstallManifest(const TMultiMap<FString, int32>& ChunkMap, const TSet<int32>& ChunkIDsInUse) const override
{
return true;
}
virtual ITargetDevicePtr GetDefaultDevice( ) const override
{
if (LocalDevice.IsValid())
{
return LocalDevice;
}
return nullptr;
}
virtual ITargetDevicePtr GetDevice( const FTargetDeviceId& DeviceId )
{
if (LocalDevice.IsValid() && (DeviceId == LocalDevice->GetId()))
{
return LocalDevice;
}
return nullptr;
}
virtual bool IsRunningPlatform( ) const override
{
// 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;
}
virtual bool SupportsFeature( ETargetPlatformFeatures Feature ) const override
{
// we currently do not have a build target for WindowsServer
if (Feature == ETargetPlatformFeatures::Packaging)
{
return (HAS_EDITOR_DATA || !IS_DEDICATED_SERVER);
}
if ( Feature == ETargetPlatformFeatures::ShouldSplitPaksIntoSmallerSizes )
{
return IS_CLIENT_ONLY;
}
if (Feature == ETargetPlatformFeatures::MobileRendering)
{
static bool bCachedSupportsMobileRendering = false;
#if WITH_ENGINE
static bool bHasCachedValue = false;
if (!bHasCachedValue)
{
TArray<FName> TargetedShaderFormats;
GetAllTargetedShaderFormats(TargetedShaderFormats);
for (const FName& Format : TargetedShaderFormats)
{
if (IsMobilePlatform(ShaderFormatToLegacyShaderPlatform(Format)))
{
bCachedSupportsMobileRendering = true;
break;
}
}
bHasCachedValue = true;
}
#endif
return bCachedSupportsMobileRendering;
}
return TSuper::SupportsFeature(Feature);
}
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"));
}
#if WITH_ENGINE
virtual void GetReflectionCaptureFormats(TArray<FName>& OutFormats) const override
{
if (bRequiresEncodedHDRReflectionCaptures)
{
OutFormats.Add(FName(TEXT("EncodedHDR")));
}
OutFormats.Add(FName(TEXT("FullHDR")));
}
virtual void GetAllPossibleShaderFormats( TArray<FName>& OutFormats ) const override
{
// 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"));
static FName NAME_GLSL_150(TEXT("GLSL_150"));
static FName NAME_GLSL_430(TEXT("GLSL_430"));
static FName NAME_VULKAN_ES31(TEXT("SF_VULKAN_ES31"));
static FName NAME_OPENGL_150_ES2(TEXT("GLSL_150_ES2"));
static FName NAME_OPENGL_150_ES3_1(TEXT("GLSL_150_ES31"));
static FName NAME_VULKAN_SM5(TEXT("SF_VULKAN_SM5"));
static FName NAME_PCD3D_ES3_1(TEXT("PCD3D_ES31"));
static FName NAME_PCD3D_ES2(TEXT("PCD3D_ES2"));
OutFormats.AddUnique(NAME_PCD3D_SM5);
OutFormats.AddUnique(NAME_PCD3D_SM4);
OutFormats.AddUnique(NAME_GLSL_150);
OutFormats.AddUnique(NAME_GLSL_430);
OutFormats.AddUnique(NAME_VULKAN_ES31);
OutFormats.AddUnique(NAME_OPENGL_150_ES2);
OutFormats.AddUnique(NAME_OPENGL_150_ES3_1);
OutFormats.AddUnique(NAME_VULKAN_SM5);
OutFormats.AddUnique(NAME_PCD3D_ES3_1);
OutFormats.AddUnique(NAME_PCD3D_ES2);
}
}
virtual void GetAllTargetedShaderFormats( TArray<FName>& OutFormats ) const override
{
// Get the Target RHIs for this platform, we do not always want all those that are supported. (reload in case user changed in the editor)
TArray<FString>TargetedShaderFormats;
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)
{
TargetedShaderFormats.RemoveAt(ShaderFormatIdx);
}
}
for(const FString& ShaderFormat : TargetedShaderFormats)
{
OutFormats.AddUnique(FName(*ShaderFormat));
}
}
virtual const class FStaticMeshLODSettings& GetStaticMeshLODSettings( ) const override
{
return StaticMeshLODSettings;
}
virtual void GetTextureFormats( const UTexture* InTexture, TArray<FName>& OutFormats ) const override
{
if (!IS_DEDICATED_SERVER)
{
FName TextureFormatName = GetDefaultTextureFormatName(this, InTexture, EngineSettings, bSupportDX11TextureFormats, bSupportCompressedVolumeTexture);
OutFormats.Add(TextureFormatName);
}
}
virtual void GetAllTextureFormats(TArray<FName>& OutFormats) const override
{
if (!IS_DEDICATED_SERVER)
{
GetAllDefaultTextureFormats(this, OutFormats, bSupportDX11TextureFormats);
}
}
FName GetVirtualTextureLayerFormat(int32 SourceFormat, bool bAllowCompression, bool bNoAlpha, bool bDX11TextureFormatsSupported, int32 Settings) const override
{
FName TextureFormatName = NAME_None;
// Supported texture format names.
static FName NameDXT1(TEXT("DXT1"));
static FName NameDXT3(TEXT("DXT3"));
static FName NameDXT5(TEXT("DXT5"));
static FName NameDXT5n(TEXT("DXT5n"));
static FName NameBC4(TEXT("BC4"));
static FName NameBC5(TEXT("BC5"));
static FName NameBGRA8(TEXT("BGRA8"));
static FName NameXGXR8(TEXT("XGXR8"));
static FName NameG8(TEXT("G8"));
static FName NameVU8(TEXT("VU8"));
static FName NameRGBA16F(TEXT("RGBA16F"));
static FName NameBC6H(TEXT("BC6H"));
static FName NameBC7(TEXT("BC7"));
// Note: We can't use things here like autoDXT here which defer the exact choice to the compressor as it would mean that
// some textures on a VT layer may get a different format than others.
// We need to guarantee the format to be the same for all textures on the layer so we need to decide on the exact final format here.
bool bUseDXT5NormalMap = false;
FString UseDXT5NormalMapsString;
if (EngineSettings.GetString(TEXT("SystemSettings"), TEXT("Compat.UseDXT5NormalMaps"), UseDXT5NormalMapsString))
{
bUseDXT5NormalMap = FCString::ToBool(*UseDXT5NormalMapsString);
}
// Determine the pixel format of the (un/)compressed texture
if (!bAllowCompression)
{
if (SourceFormat == TSF_RGBA16F)
{
TextureFormatName = NameRGBA16F;
}
else if (SourceFormat == TSF_G8 || Settings == TC_Grayscale)
{
TextureFormatName = NameG8;
}
else if (Settings == TC_Normalmap && bUseDXT5NormalMap)
{
TextureFormatName = NameXGXR8;
}
else
{
TextureFormatName = NameBGRA8;
}
}
else if (Settings == TC_HDR)
{
TextureFormatName = NameRGBA16F;
}
else if (Settings == TC_Normalmap)
{
TextureFormatName = bUseDXT5NormalMap ? NameDXT5n : NameBC5;
}
else if (Settings == TC_Displacementmap)
{
TextureFormatName = NameG8;
}
else if (Settings == TC_VectorDisplacementmap)
{
TextureFormatName = NameBGRA8;
}
else if (Settings == TC_Grayscale)
{
TextureFormatName = NameG8;
}
else if (Settings == TC_Alpha)
{
TextureFormatName = NameBC4;
}
else if (Settings == TC_DistanceFieldFont)
{
TextureFormatName = NameG8;
}
else if (Settings == TC_HDR_Compressed)
{
TextureFormatName = NameBC6H;
}
else if (Settings == TC_BC7)
{
TextureFormatName = NameBC7;
}
else if (bNoAlpha)
{
TextureFormatName = NameDXT1;
}
else
{
TextureFormatName = NameDXT5;
}
/*
FIXME: IS this still relevant for VT ? comes from the texture variant
// Some PC GPUs don't support sRGB read from G8 textures (e.g. AMD DX10 cards on ShaderModel3.0)
// This solution requires 4x more memory but a lot of PC HW emulate the format anyway
if ((TextureFormatName == NameG8) && Texture->SRGB && !SupportsFeature(ETargetPlatformFeatures::GrayscaleSRGB))
{
TextureFormatName = NameBGRA8;
}*/
// fallback to non-DX11 formats if one was chosen, but we can't use it
if (!bDX11TextureFormatsSupported)
{
if (TextureFormatName == NameBC6H)
{
TextureFormatName = NameRGBA16F;
}
else if (TextureFormatName == NameBC7)
{
TextureFormatName = NameDXT5;
}
}
return TextureFormatName;
}
virtual const UTextureLODSettings& GetTextureLODSettings() const override
{
return *TextureLODSettings;
}
virtual void RegisterTextureLODSettings(const UTextureLODSettings* InTextureLODSettings) override
{
TextureLODSettings = InTextureLODSettings;
}
virtual FName GetWaveFormat( const class USoundWave* Wave ) const override
{
static FName NAME_OGG(TEXT("OGG"));
static FName NAME_OPUS(TEXT("OPUS"));
if (Wave->IsStreaming())
{
return NAME_OPUS;
}
return NAME_OGG;
}
virtual void GetAllWaveFormats(TArray<FName>& OutFormats) const override
{
static FName NAME_OGG(TEXT("OGG"));
static FName NAME_OPUS(TEXT("OPUS"));
OutFormats.Add(NAME_OGG);
OutFormats.Add(NAME_OPUS);
}
virtual FPlatformAudioCookOverrides* GetAudioCompressionSettings() const override
{
return nullptr;
}
#endif //WITH_ENGINE
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();
}
DECLARE_DERIVED_EVENT(TGenericWindowsTargetPlatform, ITargetPlatform::FOnTargetDeviceDiscovered, FOnTargetDeviceDiscovered);
virtual FOnTargetDeviceDiscovered& OnDeviceDiscovered( ) override
{
return DeviceDiscoveredEvent;
}
DECLARE_DERIVED_EVENT(TGenericWindowsTargetPlatform, ITargetPlatform::FOnTargetDeviceLost, FOnTargetDeviceLost);
virtual FOnTargetDeviceLost& OnDeviceLost( ) override
{
return DeviceLostEvent;
}
//~ End ITargetPlatform Interface
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.
const UTextureLODSettings* TextureLODSettings;
// Holds static mesh LOD settings.
FStaticMeshLODSettings StaticMeshLODSettings;
// True if the project supports non-DX11 texture formats.
bool bSupportDX11TextureFormats;
// True if the project requires encoded HDR reflection captures
bool bRequiresEncodedHDRReflectionCaptures;
// True if the project supports only compressed volume texture formats.
bool bSupportCompressedVolumeTexture;
#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;
};
#undef LOCTEXT_NAMESPACE