Files
UnrealEngineUWP/Engine/Source/Runtime/RHI/Private/Windows/WindowsDynamicRHI.cpp

796 lines
26 KiB
C++
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#include "RHI.h"
Copying //UE4/Dev-Core to //UE4/Dev-Main (Source: //UE4/Dev-Core @ 3847469) #lockdown Nick.Penwarden #rb none ============================ MAJOR FEATURES & CHANGES ============================ Change 3805828 by Gil.Gribb UE4 - Fixed a bug in the lock free stalling task queue and adjusted a comment. The code is not current used, so this is not actually change the way the code works. Change 3806784 by Ben.Marsh UAT: Remove code to compile UBT when using UE4Build. It should already be compiled as a dependency of UAT. Change 3807549 by Graeme.Thornton Add a cook timer around VerifyCanCookPackage. A licensee reports this taking a lot of time so it'll be good to account for it. Change 3807727 by Graeme.Thornton Unhide the text asset format experimental editor option Change 3807746 by Josh.Engebretson Remove WER from iOS platform Change 3807928 by Robert.Manuszewski When async loading, GC Clusters will be created after packages have been processed to avoid situations where some of the objects that are being added to a cluster haven't been fully loaded yet Change 3808221 by Steve.Robb GitHub #4307 - Made GetModulePtr() thread safe by not using GetModule() ^ I'm not convinced by how much thread-safer this is really, but it's tidier anyway. Change 3809233 by Graeme.Thornton TBA: Misc changes to text asset commandlet - Rename mode to "loadsave" - Add -outputFormat option which can be assigned "text" or "binary" - When saving binary, use a differentiated filename so that source assets aren't overwritten Change 3809518 by Ben.Marsh Remove the outdated UnrealSync automation script. Change 3809643 by Steve.Robb GitHub #4277 : fix bug; FMath::FormatIntToHumanReadable 3rd comma and negative value #jira UE-53037 Change 3809862 by Steve.Robb GitHub #3342 : [FRotator.h] Fix to DecompressAxisFromByte to be more efficient and reflect its intent accurately #jira UE-42593 Change 3811190 by Graeme.Thornton Add support for writing specific log channels to their own files Change 3811197 by Graeme.Thornton Minor updates to output formatting and timing for the text asset commandlet Change 3811257 by Robert.Manuszewski Cluster creation will now be time-sliced Change 3811565 by Steve.Robb Define out non-monolithic module functions. Change 3812561 by Steve.Robb GitHub #3886 : Enable Brace-Initialization for Declaring Variables Incorrect semi-colon search removed after discussion with author. Test added. #jira UE-48242 Change 3812864 by Steve.Robb Removal of some unproven code which was supposed to fix hot reloading BP class functions in plugins. See: https://udn.unrealengine.com/questions/376978/aitask-blueprint-nodes-disappear-when-their-module.html #jira UE-53089 Change 3820358 by Ben.Marsh PR #4358: Incredibuild use ShowAgent by default (Contributed by projectgheist) Change 3822594 by Ben.Marsh UAT: Improvements to log file handling. - Always create log files in the final location, rather than writing to a temp directory and copying in later. - Now supports -Verbose and -VeryVerbose for increasing log verbosity, rather than -Verbose=XXX. - Keep a backlog of log output before the log system is initialized, and flush it to the log file once it is. - Allow buildmachines to specify the uebp_FinalLogFolder environment variable, which is used to form paths for display. When build machines copy log files elsewhere after UAT finishes (eg. a network share), this allows error messages to display the right location. Change 3823695 by Ben.Marsh UGS: Fix issue where precompiled binaries would not be shown as available for a change until scrolling the last submitted code change into the buffer (other symptoms, like de-focussing the main window would cause it to go back to an unavailable state, since the changes buffer was shrunk). Now always queries changes up to the last change for which zipped binaries are available. Change 3823845 by Ben.Marsh UBT: Exclude C# projects for unsupported platforms when generating project files. Change 3824180 by Ben.Marsh UGS: Add an option to show changes by build machines, and move the "only show reviewed" option in there too (Options > Show Changes). #jira Change 3825777 by Steve.Robb Fix to return value of StringToBytes. Change 3825810 by Ben.Marsh UBT: Reduce length of include paths for MSVC toolchain. Change 3825822 by Robert.Manuszewski Optimized PIE lazy pointer fixup. Should be up to 8x faster now. Change 3826734 by Ben.Marsh Remove code to disable TextureFormatAndroid on Linux. It seems to be an editor dependency. Change 3827730 by Steve.Robb Try to avoid decltype(auto) if it's not supported. See: https://udn.unrealengine.com/questions/395644/build-417-with-c11-on-linux-ttuple-errors.html Change 3827745 by Steve.Robb Initializer list support for TMap. Change 3827770 by Steve.Robb GitHub #4399 : Added a CONSTEXPR qualifiers to FVariant::GetType() #jira UE-53813 Change 3829189 by Ben.Marsh UBT: Now always writes a minimal log file. By default, just contains the regular console output and any reasons why actions are outdated and needed to be executed. UAT directs child UBT instances to output logs into its own log folder, so that build machines can save them off. Change 3830444 by Steve.Robb BuildVersion and ModuleManifest moved to Core, and parsing of these files reimplemented to avoid a JSON library. This should be revisited when Core has its own JSON library. Change 3830718 by Ben.Marsh Fix incorrect group name being returned by FStatNameAndInfo::GetGroupName() for stat groups. The editor populates the viewport stats list by calling this for every registered stat and stat group (via FLevelViewportCommands::HandleNewStatGroup). The menu entry attempts to show the stat name with STAT_XXX stripped from the start as the menu item label, with the free-form text description as a tooltip. For stat groups, the it would previously just return the stat group name as "Groups" (due to the raw naming convention of "//Groups//STATGROUP_Foo//..."). Since this didn't match the expected naming convention in FLevelViewportCommands::HandleNewStat (ie. STAT_XXX or STATGROUP_XXX), it would fail to add it. When the first actual stat belonging to that group is added, it would add a menu entry for the group based on that, but the stat description no longer makes sense as a tooltip for the group. As a result, all the editor tooltips were junk. #jira UE-53845 Change 3831064 by Ben.Marsh Fix log file contention when spawning UBT recursively. Change 3832654 by Ben.Marsh UGS: Fix error panel not being selected when opened, and weird alignment/color issues on it. Change 3832680 by Ben.Marsh UGS: Fix failing to detect workspace if synced to a different stream. Seems to be a regression caused by recent P4D upgrade. Change 3832695 by Ben.Marsh UGS: Invert the options in the 'Show Changes' submenu for simplicity. Change 3833528 by Ben.Marsh UAT: Script to rewrite source files with public include paths relative to the 'Public' folder. Usage is: RebasePublicIncludePaths -UpdateDir=<Dir> [-Project=<Dir>] [-Write]. Change 3833543 by Ben.Marsh UBT: Allow targets to opt-out of having public include paths added for every dependent module. This reduces the command line length when building a target, which has recently become a problem with larger games (due to Microsoft's compiler embedding the command line into each object file, with a maximum length of 64kb). All engine modules are compiled with this enabled; games may opt into it by setting bLegacyPublicIncludePaths = false; from their .target.cs, as may individual modules. Change 3834354 by Robert.Manuszewski Archetype pointer will now be cached to avoid locking the object tables when acquiring its info. It should also be faster this way regardless of any locks. #jira UE-52035 Change 3834400 by Robert.Manuszewski Fixing crash on exit caused by cached archetypes not being cleaned up before static exit cleanup. #jira UE-52035 Change 3834947 by Steve.Robb USE_FORMAT_STRING_TYPE_CHECKING removed from FMsg::Logf and FMsg::Logf_Internal. Change 3835004 by Ben.Marsh Fix code that relies on dubious behavior of requiring referenced "include path only" modules having their _API macros set to be empty, even if the module is actually implemented in a separate DLL. Change 3835340 by Ben.Marsh Fix errors making installed build from directories with spaces in the name. Change 3835972 by Ben.Marsh UBT: Improved diagnostic message for targets which don't need a version file. Change 3836019 by Ben.Marsh UBT: Fix warnings caused by defining linkage macros for third party libraries. Change 3836269 by Ben.Marsh Fix message box larger than the screen height being created when a large number of modules are incompatible on startup. Change 3836543 by Ben.Marsh Enable SoundMod plugin on Linux, since it's already supported through the editor. Change 3836546 by Ben.Marsh PR #4412: fix type mismatch (Contributed by nakapon) Change 3836805 by Ben.Marsh Fix commandlet to compile marketplace plugins. Change 3836829 by Ben.Marsh UBT: Fix ability to precompile plugins from installed engine builds. Change 3837036 by Ben.Marsh UBT: Write the previous and new contents of intermediate files to the log if they change. Makes it easier to debug unexpected rebuilds. Change 3837037 by Ben.Marsh UBT: Fix engine modules having inconsistent definitions depending on whether modules are only referenced for their include paths vs being linked into a binary (due to different _API macro). Change 3837040 by Ben.Marsh UBT: Remove code that initializes members in ModuleRules and TargetRules objects before the constructor is run. This is no longer necessary, now that the backwards-compatible default constructors have been removed. Change 3837247 by Ben.Marsh UBT: Remove UELinkerFixups module, now that plugins and precompiled modules do not require hacks to force initialization (since they're linked in as object files). Encryption and signing keys are now set via macros expanded from the IMPLEMENT_PRIMARY_GAME_MODULE macro, via project-specific macros added in the TargetRules constructor. Change 3837262 by Ben.Marsh UBT: Set whether a module is an engine module or not via a default value for the rules assembly. All non-program engine and enterprise modules are created with this flag set to true; program targets and modules are now created from a different assembly that sets it to false. This removes hacks from UEBuildModule needed to adjust behavior for different module types based on the directory containing the module. Also add a bUseBackwardsCompatibleDefaults flag to the TargetRules class, also initialized to a default value from a setting passed to the RulesAssembly constructor. This controls whether modules created for the target should be configured to allow breaking changes to default settings, and is set to false for all engine targets, and true for all project targets. Change 3837343 by Ben.Marsh UBT: Remove the OverrideExecutableFileExtension target property. Change the only current use for this (the MayaLiveLinkPlugin target) to use a post build step to copy the file instead. Change 3837356 by Ben.Marsh Fix invalid character encodings. Change 3837727 by Graeme.Thornton UnrealPak: KeyGenerator: Only generate prime table when required, not all the time Change 3837823 by Ben.Marsh UBT: Output warnings and errors when compiling module rules assembly in a way that allows them to be double-clicked in the Visual Studio output window. Change 3837831 by Graeme.Thornton UBT: When parsing crypto settings, always load legacy data first, then allow the new system to override it. Provides the same key backwards compatibility that the editor settings class gives Change 3837857 by Robert.Manuszewski PR #4404: Make FGCArrayPool singleton global instead of per-CU (Contributed by mhutch) Change 3837943 by Robert.Manuszewski PR #4405: Fix FGarbageCollectionTracer (Contributed by mhutch) Change 3838451 by Ben.Marsh UBT: Fix exceptions thrown on a background thread while caching C++ includes not being caught and logged correctly. Now captures exceptions and re-throws on the main thread. #jira UE-53996 Change 3839519 by Ben.Marsh UBT: Simplify configuring bPrecompile and bUsePrecompile settings for modules. Each rules assembly can now be configured as installed, which defaults the module rules it creates to use precompiled data. Change 3843790 by Graeme.Thornton UnrealPak: Log the size of all encrypted data Change 3844258 by Ben.Marsh Fix plugin compile failure when created via new plugin wizard. Passing -plugin on the command line is unnecessary, and is now reserved for packaging external plugins for the marketplace. Also extend the length of time that the error toast stays visible, and don't delete the plugin on failure. #jira UE-54157 Change 3845796 by Ben.Marsh Workaround for slow performance of String.EndsWith() on Mono. Change 3845823 by Ben.Marsh Fix case sensitive matching of platform names in -TargetPlatform=X argument to BuildCookRun. #jira UE-54123 Change 3845901 by Arciel.Rekman Linux: fix crash due to lambda lifetime issues (UE-54040). - The lambda goes out of scope in FBufferVisualizationMenuCommands::CreateVisualizationCommands, crashing the editor if compiled with a recent clang (5.0+). (Edigrating 3819174 to Dev-Core) Change 3846439 by Ben.Marsh Revert CL 3822742 to always call Process.WaitForExit(). The Android target platform module in the editor spawns ADB.EXE, which inherits the editor's stdout/stderr handles and forks itself. Process.WaitForExit() waits for EOF on those pipes, which never occurs because the forked process never terminates. Proper fix is probably to have the engine explicitly duplicate stdout/stderr handles for new pipes to output process, but too risky before copying up to Main. Change 3816608 by Ben.Marsh UBT: Use DirectoryReference objects for all include paths. Change 3816954 by Ben.Marsh UBT: Remove bIncludeDependentLibrariesInLibrary option. This is not widely supported by platform toolchains, and is not used anywhere. Change 3816986 by Ben.Marsh UBT: Remove UEBuildBinaryConfig; UEBuildBinary objects are now just created directly. Change 3816991 by Ben.Marsh UBT: Deprecate PlatformSpecificDynamicallyLoadedModules. We no longer have any special behavior for these modules. Change 3823090 by Ben.Marsh UAT: Improve logging for child UAT instances. - Calling RunUAT now requires an identifier for prefixing into the parent log, which is also used to determine the name of the log folder. - Stdout is no longer written to its own output file, since it's written to the parent stdout, the parent log file, and the child log file anyway. - Log folders for child UAT instances are left intact, rather than being copied to the parent folder. The derived names for the copied names were confusing and hard to read. - Output from UAT is no longer returned as a string. It should not be parsed anyway (but may be huge!). ProcessResult now supports running without capturing output. Change 3826082 by Ben.Marsh UBT: Add a check to make sure that all modules that are precompiled are correctly marked to enable it, even if they are part of the build target. Change 3827025 by Ben.Marsh UBT: Move the compile output directory into a property on the module, and explicitly pass it to the toolchain when compiling. Change 3829927 by James.Hopkin Made HTTP interface const correct Change 3833533 by Ben.Marsh Rewrite engine source files to base include paths relative to the "Public" directory. This allows reducing the number of public include paths that have to be added for engine modules. Change 3835826 by Ben.Marsh UBT: Precompiled targets now generate a separate manifest for each precompiled module, rather than adding object files to a library. This fixes issues where object files from static libraries would not be linked into a target if a symbol in them was not referenced. Change 3835969 by Ben.Marsh UBT: Fix cases where text is being written directly to the console rather than via logging functions. Change 3837777 by Steve.Robb Format string type checking added to FOutputDevice::Logf. Fixes for those. Change 3838569 by Steve.Robb Algo moved up a folder. [CL 3847482 by Ben Marsh in Main branch]
2018-01-20 11:19:29 -05:00
#include "Modules/ModuleManager.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 "Misc/CommandLine.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/MessageDialog.h"
#include "Containers/StaticArray.h"
#if WINDOWS_USE_FEATURE_DYNAMIC_RHI
#include "Windows/WindowsPlatformApplicationMisc.h"
#if defined(NV_GEFORCENOW) && NV_GEFORCENOW
#include "GeForceNOWWrapper.h"
#endif
static const TCHAR* GLoadedRHIModuleName;
enum class EWindowsRHI
{
D3D11,
D3D12,
Vulkan,
OpenGL,
count
};
static constexpr int32 EWindowsRHICount = static_cast<int32>(EWindowsRHI::count);
static const TCHAR* ModuleNameFromWindowsRHI(EWindowsRHI InWindowsRHI)
{
switch (InWindowsRHI)
{
default: check(false);
case EWindowsRHI::D3D11: return TEXT("D3D11RHI");
case EWindowsRHI::D3D12: return TEXT("D3D12RHI");
case EWindowsRHI::Vulkan: return TEXT("VulkanRHI");
case EWindowsRHI::OpenGL: return TEXT("OpenGLDrv");
}
}
static FString GetRHINameFromWindowsRHI(EWindowsRHI InWindowsRHI, ERHIFeatureLevel::Type InFeatureLevel)
{
switch (InWindowsRHI)
{
default: check(false);
case EWindowsRHI::D3D11: return TEXT("DirectX 11");
case EWindowsRHI::D3D12:
{
FString FeatureLevelName;
GetFeatureLevelName(InFeatureLevel, FeatureLevelName);
return FString::Printf(TEXT("DirectX 12 (%s)"), *FeatureLevelName);
}
case EWindowsRHI::Vulkan: return TEXT("Vulkan");
case EWindowsRHI::OpenGL: return TEXT("OpenGL");
}
}
static ERHIFeatureLevel::Type GetDefaultFeatureLevelForRHI(EWindowsRHI InWindowsRHI)
{
switch (InWindowsRHI)
{
case EWindowsRHI::D3D11: return ERHIFeatureLevel::SM5;
case EWindowsRHI::D3D12: return ERHIFeatureLevel::SM5;
case EWindowsRHI::Vulkan: return ERHIFeatureLevel::SM5;
case EWindowsRHI::OpenGL: return ERHIFeatureLevel::ES3_1;
default: check(false); return ERHIFeatureLevel::SM5;
}
}
struct FWindowsRHIConfig
{
TArray<EShaderPlatform> ShaderPlatforms;
TArray<ERHIFeatureLevel::Type> FeatureLevels;
};
struct FParsedWindowsDynamicRHIConfig
{
TOptional<EWindowsRHI> DefaultRHI{};
TStaticArray<FWindowsRHIConfig, EWindowsRHICount> RHIConfigs;
bool IsEmpty() const;
bool IsRHISupported(EWindowsRHI InWindowsRHI) const;
TOptional<ERHIFeatureLevel::Type> GetHighestSupportedFeatureLevel(EWindowsRHI InWindowsRHI) const;
TOptional<ERHIFeatureLevel::Type> GetNextHighestTargetedFeatureLevel(EWindowsRHI InWindowsRHI, ERHIFeatureLevel::Type InFeatureLevel) const;
bool IsFeatureLevelTargeted(EWindowsRHI InWindowsRHI, ERHIFeatureLevel::Type InFeatureLevel) const;
void MergeConfig(EWindowsRHI InWindowsRHI, const FWindowsRHIConfig& Other);
};
bool FParsedWindowsDynamicRHIConfig::IsEmpty() const
{
for (const FWindowsRHIConfig& Config : RHIConfigs)
{
if (!Config.ShaderPlatforms.IsEmpty())
{
return false;
}
}
return true;
}
bool FParsedWindowsDynamicRHIConfig::IsRHISupported(EWindowsRHI InWindowsRHI) const
{
// If we don't require cooked data, then we should be able to support this RHI at any feature level.
if (!FPlatformProperties::RequiresCookedData())
{
return true;
}
return !RHIConfigs[(int32)InWindowsRHI].ShaderPlatforms.IsEmpty();
}
TOptional<ERHIFeatureLevel::Type> FParsedWindowsDynamicRHIConfig::GetHighestSupportedFeatureLevel(EWindowsRHI InWindowsRHI) const
{
const TArray<ERHIFeatureLevel::Type>& FeatureLevels = RHIConfigs[(int32)InWindowsRHI].FeatureLevels;
if (FeatureLevels.Num() == 0)
{
return TOptional<ERHIFeatureLevel::Type>();
}
ERHIFeatureLevel::Type MaxFeatureLevel = (ERHIFeatureLevel::Type)0;
for (ERHIFeatureLevel::Type SupportedFeatureLevel : FeatureLevels)
{
MaxFeatureLevel = std::max(MaxFeatureLevel, SupportedFeatureLevel);
}
return MaxFeatureLevel;
}
TOptional<ERHIFeatureLevel::Type> FParsedWindowsDynamicRHIConfig::GetNextHighestTargetedFeatureLevel(EWindowsRHI InWindowsRHI, ERHIFeatureLevel::Type InFeatureLevel) const
{
TArray<ERHIFeatureLevel::Type> LowerFeatureLevels(RHIConfigs[(int32)InWindowsRHI].FeatureLevels);
LowerFeatureLevels.RemoveAll([InFeatureLevel](ERHIFeatureLevel::Type OtherFeatureLevel) { return OtherFeatureLevel >= InFeatureLevel; });
if (LowerFeatureLevels.Num())
{
ERHIFeatureLevel::Type MaxFeatureLevel = (ERHIFeatureLevel::Type)0;
for (ERHIFeatureLevel::Type SupportedFeatureLevel : LowerFeatureLevels)
{
MaxFeatureLevel = std::max(MaxFeatureLevel, SupportedFeatureLevel);
}
return MaxFeatureLevel;
}
return TOptional<ERHIFeatureLevel::Type>();
}
bool FParsedWindowsDynamicRHIConfig::IsFeatureLevelTargeted(EWindowsRHI InWindowsRHI, ERHIFeatureLevel::Type InFeatureLevel) const
{
for (ERHIFeatureLevel::Type SupportedFeatureLevel : RHIConfigs[(int32)InWindowsRHI].FeatureLevels)
{
if (SupportedFeatureLevel == InFeatureLevel)
{
return true;
}
}
return false;
}
void FParsedWindowsDynamicRHIConfig::MergeConfig(EWindowsRHI InWindowsRHI, const FWindowsRHIConfig& Other)
{
FWindowsRHIConfig& ExistingConfig = RHIConfigs[(int32)InWindowsRHI];
for (EShaderPlatform ShaderPlatform : Other.ShaderPlatforms)
{
ExistingConfig.ShaderPlatforms.AddUnique(ShaderPlatform);
}
for (ERHIFeatureLevel::Type FeatureLevel : Other.FeatureLevels)
{
ExistingConfig.FeatureLevels.AddUnique(FeatureLevel);
}
}
TOptional<EWindowsRHI> ParseDefaultWindowsRHI()
{
TOptional<EWindowsRHI> DefaultRHI{};
FString DefaultGraphicsRHI;
if (GConfig->GetString(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), TEXT("DefaultGraphicsRHI"), DefaultGraphicsRHI, GEngineIni))
{
const FString NAME_DX11(TEXT("DefaultGraphicsRHI_DX11"));
const FString NAME_DX12(TEXT("DefaultGraphicsRHI_DX12"));
const FString NAME_VULKAN(TEXT("DefaultGraphicsRHI_Vulkan"));
DefaultRHI = EWindowsRHI::D3D11;
if (DefaultGraphicsRHI == NAME_DX11)
{
DefaultRHI = EWindowsRHI::D3D11;
}
else if (DefaultGraphicsRHI == NAME_DX12)
{
DefaultRHI = EWindowsRHI::D3D12;
}
else if (DefaultGraphicsRHI == NAME_VULKAN)
{
DefaultRHI = EWindowsRHI::Vulkan;
}
else if (DefaultGraphicsRHI != TEXT("DefaultGraphicsRHI_Default"))
{
UE_LOG(LogRHI, Error, TEXT("Unrecognized setting '%s' for DefaultGraphicsRHI"), *DefaultGraphicsRHI);
}
}
return DefaultRHI;
}
static TArray<EShaderPlatform> ParseShaderPlatformsConfig(const TCHAR* InSettingName)
{
TArray<FString> TargetedShaderFormats;
GConfig->GetArray(TEXT("/Script/WindowsTargetPlatform.WindowsTargetSettings"), InSettingName, TargetedShaderFormats, GEngineIni);
TArray<EShaderPlatform> ShaderPlatforms;
ShaderPlatforms.Reserve(TargetedShaderFormats.Num());
for (const FString& ShaderFormat : TargetedShaderFormats)
{
ShaderPlatforms.AddUnique(ShaderFormatToLegacyShaderPlatform(FName(*ShaderFormat)));
}
return ShaderPlatforms;
}
static TArray<ERHIFeatureLevel::Type> FeatureLevelsFromShaderPlatforms(const TArray<EShaderPlatform>& InShaderPlatforms)
{
TArray<ERHIFeatureLevel::Type> FeatureLevels;
FeatureLevels.Reserve(InShaderPlatforms.Num());
for (EShaderPlatform ShaderPlatform : InShaderPlatforms)
{
FeatureLevels.AddUnique(FDataDrivenShaderPlatformInfo::GetMaxFeatureLevel(ShaderPlatform));
}
return FeatureLevels;
}
static FWindowsRHIConfig ParseWindowsRHIConfig(const TCHAR* ShaderFormatsSettingName)
{
FWindowsRHIConfig Config;
Config.ShaderPlatforms = ParseShaderPlatformsConfig(ShaderFormatsSettingName);
Config.FeatureLevels = FeatureLevelsFromShaderPlatforms(Config.ShaderPlatforms);
return Config;
}
FParsedWindowsDynamicRHIConfig ParseWindowsDynamicRHIConfig()
{
FParsedWindowsDynamicRHIConfig Config;
Config.DefaultRHI = ParseDefaultWindowsRHI();
Config.RHIConfigs[(int32)EWindowsRHI::D3D11] = ParseWindowsRHIConfig(TEXT("D3D11TargetedShaderFormats"));
Config.RHIConfigs[(int32)EWindowsRHI::D3D12] = ParseWindowsRHIConfig(TEXT("D3D12TargetedShaderFormats"));
Config.RHIConfigs[(int32)EWindowsRHI::Vulkan] = ParseWindowsRHIConfig(TEXT("VulkanTargetedShaderFormats"));
// Only add OpenGL support to non-client programs.
if (!FPlatformProperties::RequiresCookedData())
{
Config.RHIConfigs[(int32)EWindowsRHI::OpenGL].ShaderPlatforms.Add(SP_OPENGL_PCES3_1);
Config.RHIConfigs[(int32)EWindowsRHI::OpenGL].FeatureLevels.Add(ERHIFeatureLevel::ES3_1);
}
if (FWindowsRHIConfig DeprecatedConfig = ParseWindowsRHIConfig(TEXT("TargetedRHIs")); !DeprecatedConfig.ShaderPlatforms.IsEmpty())
{
// Since we don't have context here, we have to add this old config setting to every potential RHI.
Config.MergeConfig(EWindowsRHI::D3D11, DeprecatedConfig);
Config.MergeConfig(EWindowsRHI::D3D12, DeprecatedConfig);
Config.MergeConfig(EWindowsRHI::Vulkan, DeprecatedConfig);
Config.MergeConfig(EWindowsRHI::OpenGL, DeprecatedConfig);
}
return Config;
}
// Default to Performance Mode on low-end machines
static bool DefaultFeatureLevelES31()
{
static TOptional<bool> ForceES31;
if (ForceES31.IsSet())
{
return ForceES31.GetValue();
}
// Force Performance mode for machines with too few cores including hyperthreads
int MinCoreCount = 0;
if (GConfig->GetInt(TEXT("PerformanceMode"), TEXT("MinCoreCount"), MinCoreCount, GEngineIni) && FPlatformMisc::NumberOfCoresIncludingHyperthreads() < MinCoreCount)
{
ForceES31 = true;
return true;
}
FWindowsPlatformApplicationMisc::FGPUInfo BestGPUInfo = FWindowsPlatformApplicationMisc::GetBestGPUInfo();
FString MinMemorySizeBucketString;
FString MinIntegratedMemorySizeBucketString;
if (GConfig->GetString(TEXT("PerformanceMode"), TEXT("MinMemorySizeBucket"), MinMemorySizeBucketString, GEngineIni) && GConfig->GetString(TEXT("PerformanceMode"), TEXT("MinIntegratedMemorySizeBucket"), MinIntegratedMemorySizeBucketString, GEngineIni))
{
for (int EnumIndex = int(EPlatformMemorySizeBucket::Largest); EnumIndex <= int(EPlatformMemorySizeBucket::Tiniest); EnumIndex++)
{
const TCHAR* BucketString = LexToString(EPlatformMemorySizeBucket(EnumIndex));
// Force Performance mode for machines with too little memory
if (MinMemorySizeBucketString == BucketString)
{
if (FPlatformMemory::GetMemorySizeBucket() >= EPlatformMemorySizeBucket(EnumIndex))
{
ForceES31 = true;
return true;
}
}
// Force Performance mode for machines with too little memory when shared with the GPU
if (MinIntegratedMemorySizeBucketString == BucketString)
{
const int MIN_GPU_MEMORY = 512 * 1024 * 1024;
if (FPlatformMemory::GetMemorySizeBucket() >= EPlatformMemorySizeBucket(EnumIndex) && BestGPUInfo.DedicatedVideoMemory < MIN_GPU_MEMORY)
{
ForceES31 = true;
return true;
}
}
}
}
TArray<FString> DeviceDefaultRHIList;
GConfig->GetArray(TEXT("Devices"), TEXT("DeviceDefaultRHIList"), DeviceDefaultRHIList, GHardwareIni);
FString GPUBrand = FPlatformMisc::GetPrimaryGPUBrand();
for (const FString& DeviceDefaultRHIString : DeviceDefaultRHIList)
{
const TCHAR* Line = *DeviceDefaultRHIString;
ensure(Line[0] == TCHAR('('));
FString RHIName;
FParse::Value(Line+1, TEXT("RHI="), RHIName);
FString DeviceName;
FParse::Value(Line+1, TEXT("DeviceName="), DeviceName);
if (RHIName.Compare("D3D11_ES31", ESearchCase::IgnoreCase) == 0 && GPUBrand.Compare(DeviceName, ESearchCase::IgnoreCase) == 0)
{
ForceES31 = true;
return true;
}
FString VendorId;
FParse::Value(Line + 1, TEXT("VendorId="), VendorId);
uint32 VendorIdInt = FParse::HexNumber(*VendorId);
FString DeviceId;
FParse::Value(Line + 1, TEXT("DeviceId="), DeviceId);
uint32 DeviceIdInt = FParse::HexNumber(*DeviceId);
if (BestGPUInfo.VendorId && BestGPUInfo.DeviceId &&
BestGPUInfo.VendorId == VendorIdInt && BestGPUInfo.DeviceId == DeviceIdInt &&
RHIName.Compare("D3D11_ES31", ESearchCase::IgnoreCase) == 0)
{
ForceES31 = true;
return true;
}
}
ForceES31 = false;
return false;
}
static bool PreferFeatureLevelES31()
{
if (!GIsEditor)
{
bool bIsRunningInGFN = false;
#if defined(NV_GEFORCENOW) && NV_GEFORCENOW
//Prevent ES31 from being forced since we have other ways of setting scalability issues on GFN.
GeForceNOWWrapper::Get().Initialize();
bIsRunningInGFN = GeForceNOWWrapper::Get().IsRunningInGFN();
#endif
bool bPreferFeatureLevelES31 = false;
bool bFoundPreference = GConfig->GetBool(TEXT("D3DRHIPreference"), TEXT("bPreferFeatureLevelES31"), bPreferFeatureLevelES31, GGameUserSettingsIni);
// Force low-spec users into performance mode but respect their choice once they have set a preference
bool bDefaultES31 = false;
if (!bFoundPreference && !bIsRunningInGFN)
{
bDefaultES31 = DefaultFeatureLevelES31();
}
if (bPreferFeatureLevelES31 || bDefaultES31)
{
if (!bFoundPreference)
{
GConfig->SetBool(TEXT("D3DRHIPreference"), TEXT("bPreferFeatureLevelES31"), true, GGameUserSettingsIni);
}
return true;
}
}
return false;
}
static bool IsES31D3DOnly()
{
bool bES31DXOnly = false;
#if !WITH_EDITOR
if (!GIsEditor)
{
GConfig->GetBool(TEXT("PerformanceMode"), TEXT("bES31DXOnly"), bES31DXOnly, GEngineIni);
}
#endif
return bES31DXOnly;
}
static bool AllowD3D12FeatureLevelES31(const FParsedWindowsDynamicRHIConfig& Config)
{
if (!GIsEditor)
{
return Config.IsFeatureLevelTargeted(EWindowsRHI::D3D12, ERHIFeatureLevel::ES3_1);
}
return true;
}
// Choose the default from DefaultGraphicsRHI or TargetedRHIs. DefaultGraphicsRHI has precedence.
static EWindowsRHI ChooseDefaultRHI(const FParsedWindowsDynamicRHIConfig& Config)
{
// Default graphics RHI is the main project setting that governs the choice, so it takes the priority
if (TOptional<EWindowsRHI> ConfigDefault = Config.DefaultRHI)
{
return ConfigDefault.GetValue();
}
const EWindowsRHI DefaultRHIOrder[] =
{
EWindowsRHI::D3D12,
EWindowsRHI::D3D11,
EWindowsRHI::Vulkan,
};
// Find the first RHI with configured support based on the order above
for (EWindowsRHI DefaultRHI : DefaultRHIOrder)
{
if (TOptional<ERHIFeatureLevel::Type> HighestFL = Config.GetHighestSupportedFeatureLevel(DefaultRHI))
{
return DefaultRHI;
}
}
return EWindowsRHI::D3D11;
}
static TOptional<EWindowsRHI> ChoosePreferredRHI(EWindowsRHI InDefaultRHI)
{
TOptional<EWindowsRHI> RHIPreference{};
// If we are in game, there is a separate setting that can make it prefer D3D12 over D3D11 (but not over other RHIs).
if (!GIsEditor && (InDefaultRHI == EWindowsRHI::D3D11 || InDefaultRHI == EWindowsRHI::D3D12))
{
bool bUseD3D12InGame = false;
if (GConfig->GetBool(TEXT("D3DRHIPreference"), TEXT("bUseD3D12InGame"), bUseD3D12InGame, GGameUserSettingsIni) && bUseD3D12InGame)
{
RHIPreference = EWindowsRHI::D3D12;
}
}
return RHIPreference;
}
static TOptional<EWindowsRHI> ChooseForcedRHI(const FParsedWindowsDynamicRHIConfig& Config)
{
TOptional<EWindowsRHI> ForcedRHI = {};
// Command line overrides
uint32 Sum = 0;
if (FParse::Param(FCommandLine::Get(), TEXT("vulkan")))
{
ForcedRHI = EWindowsRHI::Vulkan;
Sum++;
}
if (FParse::Param(FCommandLine::Get(), TEXT("opengl")))
{
ForcedRHI = EWindowsRHI::OpenGL;
Sum++;
}
if (FParse::Param(FCommandLine::Get(), TEXT("d3d11")) || FParse::Param(FCommandLine::Get(), TEXT("dx11")))
{
ForcedRHI = EWindowsRHI::D3D11;
Sum++;
}
if (FParse::Param(FCommandLine::Get(), TEXT("d3d12")) || FParse::Param(FCommandLine::Get(), TEXT("dx12")))
{
ForcedRHI = EWindowsRHI::D3D12;
Sum++;
}
if (Sum > 1)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RHIOptionsError", "-d3d12/dx12, -d3d11/dx11, -vulkan, and -opengl are mutually exclusive options, but more than one was specified on the command-line."));
UE_LOG(LogRHI, Fatal, TEXT("-d3d12, -d3d11, -vulkan, and -opengl are mutually exclusive options, but more than one was specified on the command-line."));
}
#if !WITH_EDITOR && UE_BUILD_SHIPPING
// In Shipping builds we can limit ES31 on Windows to only DX11. All RHIs are allowed by default.
// FeatureLevelES31 is also a command line override, so it will determine the underlying RHI unless one is specified
if (IsES31D3DOnly() && (FParse::Param(FCommandLine::Get(), TEXT("FeatureLevelES31")) || FParse::Param(FCommandLine::Get(), TEXT("FeatureLevelES3_1"))))
{
if (ForcedRHI == EWindowsRHI::OpenGL)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RHIPerformanceOpenGL", "OpenGL is not supported for Performance Mode."));
UE_LOG(LogRHI, Fatal, TEXT("OpenGL is not supported for Performance Mode."));
}
else if (ForcedRHI == EWindowsRHI::Vulkan)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RHIPerformanceVulkan", "Vulkan is not supported for Performance Mode."));
UE_LOG(LogRHI, Fatal, TEXT("Vulkan is not supported for Performance Mode."));
}
else if (ForcedRHI == EWindowsRHI::D3D12)
{
if (!AllowD3D12FeatureLevelES31(Config))
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RHIPerformanceDX12", "DirectX 12 is not supported for Performance Mode."));
UE_LOG(LogRHI, Fatal, TEXT("DirectX 12 is not supported for Performance Mode."));
}
}
else
{
ForcedRHI = EWindowsRHI::D3D11;
}
}
#endif //!WITH_EDITOR && UE_BUILD_SHIPPING
return ForcedRHI;
}
static TOptional<ERHIFeatureLevel::Type> GetForcedFeatureLevel()
{
TOptional<ERHIFeatureLevel::Type> ForcedFeatureLevel{};
if (FParse::Param(FCommandLine::Get(), TEXT("es31")) || FParse::Param(FCommandLine::Get(), TEXT("FeatureLevelES31")) || FParse::Param(FCommandLine::Get(), TEXT("FeatureLevelES3_1")))
{
ForcedFeatureLevel = ERHIFeatureLevel::ES3_1;
}
if (FParse::Param(FCommandLine::Get(), TEXT("sm5")))
{
ForcedFeatureLevel = ERHIFeatureLevel::SM5;
}
if (FParse::Param(FCommandLine::Get(), TEXT("sm6")))
{
ForcedFeatureLevel = ERHIFeatureLevel::SM6;
}
return ForcedFeatureLevel;
}
static ERHIFeatureLevel::Type ChooseFeatureLevel(EWindowsRHI ChosenRHI, const TOptional<EWindowsRHI> ForcedRHI, const TOptional<ERHIFeatureLevel::Type> ForcedFeatureLevel, const FParsedWindowsDynamicRHIConfig& Config)
{
if (ForcedFeatureLevel)
{
// Allow the forced feature level if we're in a position to compile its shaders
if (!FPlatformProperties::RequiresCookedData())
{
return ForcedFeatureLevel.GetValue();
}
// Make sure the feature level is supported by the runtime, otherwise fall back to the default
if (Config.IsFeatureLevelTargeted(ChosenRHI, ForcedFeatureLevel.GetValue()))
{
return ForcedFeatureLevel.GetValue();
}
}
TOptional<ERHIFeatureLevel::Type> FeatureLevel{};
if ((ChosenRHI == EWindowsRHI::D3D11 || ChosenRHI == EWindowsRHI::D3D12) && Config.IsFeatureLevelTargeted(ChosenRHI, ERHIFeatureLevel::ES3_1) && PreferFeatureLevelES31())
{
FeatureLevel = TOptional<ERHIFeatureLevel::Type>(ERHIFeatureLevel::ES3_1);
}
else
{
FeatureLevel = Config.GetHighestSupportedFeatureLevel(ChosenRHI);
}
// If we were forced to a specific RHI while not forced to a specific feature level and the project isn't configured for it, find the default Feature Level for that RHI
if (!FeatureLevel && ForcedRHI)
{
FeatureLevel = GetDefaultFeatureLevelForRHI(ChosenRHI);
if (FPlatformProperties::RequiresCookedData())
{
const TCHAR* RHIName = ModuleNameFromWindowsRHI(ForcedRHI.GetValue());
const FString FeatureLevelName = LexToString(FeatureLevel.GetValue());
UE_LOG(LogRHI, Warning, TEXT("User requested RHI '%s' but that is not supported by this project's data. Defaulting to Feature Level '%s'."), RHIName, *FeatureLevelName);
}
}
// If the user wanted to force a feature level and we couldn't set it, log out why and what we're actually running with
if (ForcedFeatureLevel)
{
const FString ForcedName = LexToString(ForcedFeatureLevel.GetValue());
const FString UsedName = LexToString(FeatureLevel.GetValue());
UE_LOG(LogRHI, Warning, TEXT("User requested Feature Level '%s' but that is not supported by this project. Falling back to Feature Level '%s'."), *ForcedName, *UsedName);
}
return FeatureLevel.GetValue();
}
static bool HandleUnsupportedFeatureLevel(EWindowsRHI& WindowsRHI, ERHIFeatureLevel::Type& FeatureLevel, TOptional<ERHIFeatureLevel::Type> ForcedFeatureLevel, const FParsedWindowsDynamicRHIConfig& Config)
{
if (ForcedFeatureLevel)
{
if (WindowsRHI == EWindowsRHI::D3D12 && FeatureLevel == ERHIFeatureLevel::SM6)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredDX12SM6", "DX12 SM6 is not supported on your system. Try running without the -sm6 command line argument."));
FPlatformMisc::RequestExit(1);
}
return false;
}
if (TOptional<ERHIFeatureLevel::Type> FallbackFeatureLevel = Config.GetNextHighestTargetedFeatureLevel(WindowsRHI, FeatureLevel))
{
UE_LOG(LogRHI, Log, TEXT("RHI %s with Feature Level %s not supported, falling back to Feature Level %s"), ModuleNameFromWindowsRHI(WindowsRHI), *LexToString(FeatureLevel), *LexToString(FallbackFeatureLevel.GetValue()));
FeatureLevel = FallbackFeatureLevel.GetValue();
return true;
}
return false;
}
static bool HandleUnsupportedRHI(EWindowsRHI& WindowsRHI, ERHIFeatureLevel::Type& FeatureLevel, TOptional<EWindowsRHI> ForcedRHI, const FParsedWindowsDynamicRHIConfig& Config)
{
if (ForcedRHI)
{
if (ForcedRHI == EWindowsRHI::D3D12)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredDX12", "DX12 is not supported on your system. Try running without the -dx12 or -d3d12 command line argument."));
FPlatformMisc::RequestExit(1);
}
}
if (WindowsRHI == EWindowsRHI::D3D12)
{
if (TOptional<ERHIFeatureLevel::Type> D3D11FeatureLevel = Config.GetHighestSupportedFeatureLevel(EWindowsRHI::D3D11))
{
UE_LOG(LogRHI, Log, TEXT("D3D12 is not supported, falling back to D3D11 with Feature Level %s"), *LexToString(D3D11FeatureLevel.GetValue()));
WindowsRHI = EWindowsRHI::D3D11;
FeatureLevel = D3D11FeatureLevel.GetValue();
return true;
}
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredDX12", "DX12 is not supported on your system. Try running without the -dx12 or -d3d12 command line argument."));
FPlatformMisc::RequestExit(1);
}
if (WindowsRHI == EWindowsRHI::D3D11)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredDX11Feature_11_SM5", "A D3D11-compatible GPU (Feature Level 11.0, Shader Model 5.0) is required to run the engine."));
FPlatformMisc::RequestExit(1);
}
if (WindowsRHI == EWindowsRHI::Vulkan)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredVulkan", "Vulkan Driver is required to run the engine."));
FPlatformMisc::RequestExit(1);
}
if (WindowsRHI == EWindowsRHI::OpenGL)
{
FMessageDialog::Open(EAppMsgType::Ok, NSLOCTEXT("WindowsDynamicRHI", "RequiredOpenGL", "OpenGL 4.3 is required to run the engine."));
FPlatformMisc::RequestExit(1);
}
return false;
}
static IDynamicRHIModule* LoadDynamicRHIModule(ERHIFeatureLevel::Type& DesiredFeatureLevel, const TCHAR*& LoadedRHIModuleName)
{
// Make sure the DDSPI is initialized before we try and read from it
FGenericDataDrivenShaderPlatformInfo::Initialize();
bool bUseGPUCrashDebugging = false;
if (!GIsEditor && GConfig->GetBool(TEXT("D3DRHIPreference"), TEXT("bUseGPUCrashDebugging"), bUseGPUCrashDebugging, GGameUserSettingsIni))
{
auto GPUCrashDebuggingCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.GPUCrashDebugging"));
*GPUCrashDebuggingCVar = bUseGPUCrashDebugging;
}
const FParsedWindowsDynamicRHIConfig Config = ParseWindowsDynamicRHIConfig();
// RHI is chosen by the project settings (first DefaultGraphicsRHI, then TargetedRHIs are consulted, "Default" maps to D3D12).
// After this, a separate game-only setting (does not affect editor) bPreferD3D12InGame selects between D3D12 or D3D11 (but will not have any effect if Vulkan or OpenGL are chosen).
// Commandline switches apply after this and can force an arbitrary RHIs. If RHI isn't supported, the game will refuse to start.
EWindowsRHI DefaultRHI = ChooseDefaultRHI(Config);
const TOptional<EWindowsRHI> PreferredRHI = ChoosePreferredRHI(DefaultRHI);
const TOptional<EWindowsRHI> ForcedRHI = ChooseForcedRHI(Config);
EWindowsRHI ChosenRHI = DefaultRHI;
if (ForcedRHI)
{
ChosenRHI = ForcedRHI.GetValue();
}
else if (PreferredRHI)
{
ChosenRHI = PreferredRHI.GetValue();
}
const TOptional<ERHIFeatureLevel::Type> ForcedFeatureLevel = GetForcedFeatureLevel();
DesiredFeatureLevel = ChooseFeatureLevel(ChosenRHI, ForcedRHI, ForcedFeatureLevel, Config);
// Load the dynamic RHI module.
bool bTryWithNewConfig = false;
do
{
const FString RHIName = GetRHINameFromWindowsRHI(ChosenRHI, DesiredFeatureLevel);
FApp::SetGraphicsRHI(RHIName);
const TCHAR* ModuleName = ModuleNameFromWindowsRHI(ChosenRHI);
IDynamicRHIModule* DynamicRHIModule = FModuleManager::LoadModulePtr<IDynamicRHIModule>(ModuleName);
if (DynamicRHIModule && DynamicRHIModule->IsSupported(DesiredFeatureLevel))
{
LoadedRHIModuleName = ModuleName;
return DynamicRHIModule;
}
bTryWithNewConfig = HandleUnsupportedFeatureLevel(ChosenRHI, DesiredFeatureLevel, ForcedFeatureLevel, Config);
if (!bTryWithNewConfig)
{
bTryWithNewConfig = HandleUnsupportedRHI(ChosenRHI, DesiredFeatureLevel, ForcedRHI, Config);
}
} while (bTryWithNewConfig);
return nullptr;
}
FDynamicRHI* PlatformCreateDynamicRHI()
{
Copying //UE4/Dev-Rendering to Dev-Main (//UE4/Dev-Main) (Source: //UE4/Dev-Rendering @ 2943238) #lockdown nick.penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2932679 on 2016/04/04 by Martin.Mittring remove hack/cvar that is not longer needed as we fixed the bug #rb:Bob.Tellez #code_review:Bob.Tellez Change 2932681 on 2016/04/04 by Martin.Mittring fixed cvars in consolevariables.ini can affect engine even if marked with cheat (no longer load consolevariables.ini in shipping and test), unified 3 code path, added testcase, cvars with cheat in ini file other than consolevariables.ini now trigger ensure, =on/off/true/false/.. works in all ini files, added enure if non scalability setting are used in ScalabilityIni (get now ignored) #rb:David.Hill #code_review:Marcus.Wassmer, Michael.Noland Change 2932719 on 2016/04/04 by Marcus.Wassmer Merge 3 band SH back to DevRendering #rb Daniel.Wright Change 2932760 on 2016/04/04 by Zabir.Hoque Migrating high resolution cubemaps for skylight and reflection probes. #rb: Daniel.Wright Change 2933121 on 2016/04/05 by Rolando.Caloca DR - vk - Fix free blocks not getting joined - Fix compile issue Change 2933122 on 2016/04/05 by Rolando.Caloca DR - Do not shorten dumped shaders path Change 2933126 on 2016/04/05 by Rolando.Caloca DR - vk - Index Buffers using new resource management Change 2933127 on 2016/04/05 by Rolando.Caloca DR - vk - Extract multibuffer off index buffer Change 2933131 on 2016/04/05 by Rolando.Caloca DR - vk - Transition to vb's using mutlibuffer Change 2933136 on 2016/04/05 by Rolando.Caloca DR - vk - Change staging buffers to use resource allocation system - Fix free block not getting joined - Remove define Change 2933140 on 2016/04/05 by Rolando.Caloca DR - vk - 'static' textures now use resource mgmt - Release free pages back to the OS - Remove ensure Change 2933152 on 2016/04/05 by Rolando.Caloca DR - vk - Fix aliasing granularity - Fix renderpass end/copy buffer ensure Change 2933155 on 2016/04/05 by Rolando.Caloca DR - SCW - Fix for -directcompile to directly load file for preprocessor Change 2933158 on 2016/04/05 by Rolando.Caloca DR - hlslcc - Error on Metal if trying to R & W on RWTextures - Fix indices on RW reads to be unsigned #codereview Mark.Satterthwaite, Michael.Trepka Change 2933169 on 2016/04/05 by Rolando.Caloca DR - vk - Move header to public to match changes on DevMobile Change 2933173 on 2016/04/05 by David.Hill Deferred decal rendering with negative scale #rb:Matrin.Mittring #jira:UE-27389 Change 2933273 on 2016/04/05 by Rolando.Caloca DR - vk - Fix renderdoc markers Change 2933274 on 2016/04/05 by Rolando.Caloca DR - Support for -AttachDebugger Change 2933316 on 2016/04/05 by Rolando.Caloca DR - vk - Compile fix whene enabling define Change 2933334 on 2016/04/05 by Rolando.Caloca DR - Compile fix #codereview Martin.Mittring Change 2933805 on 2016/04/05 by Brian.Karis Temporal AA dynamic antighosting. Fixed DOF Change 2933811 on 2016/04/05 by Brian.Karis Fixed area light NaNs. Improvements to area lights. Horizen handling for wrap around. Change 2933812 on 2016/04/05 by Brian.Karis Fixed fresnel on SSS skin. Change 2933813 on 2016/04/05 by Brian.Karis Tessellation fix Change 2933816 on 2016/04/05 by Brian.Karis Improved forward shading support [CL 2943241 by Gil Gribb in Main branch]
2016-04-13 21:24:38 -04:00
FDynamicRHI* DynamicRHI = nullptr;
ERHIFeatureLevel::Type RequestedFeatureLevel;
const TCHAR* LoadedRHIModuleName;
IDynamicRHIModule* DynamicRHIModule = LoadDynamicRHIModule(RequestedFeatureLevel, LoadedRHIModuleName);
if (DynamicRHIModule)
{
// Create the dynamic RHI.
Copying //UE4/Dev-Rendering to //UE4/Dev-Main (Source: //UE4/Dev-Rendering @ 3091903) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3072947 on 2016/08/01 by Uriel.Doyon Texture GUIDs are now included in cooked builds, as they are required by the texture streamer to link build data to in game texture. #review-3072934 @marcus.wassmer #jira UE-34045 Change 3073301 on 2016/08/02 by Ben.Woodhouse Fix for large spotlight culling precision issues, reported on UDN by Aaron Jacobs at Double Fine. For a full description, see the UDN post https://udn.unrealengine.com/questions/305440/shadowed-light-flicker-caused-by-floating-point-pr.html #jira UE-34052 Change 3073689 on 2016/08/02 by Ben.Woodhouse Improved skin postprocess - support for full resolution, with diffuse/spec lighting combined into single RGBA (sharing chroma) Full res lighting gives less temporal AA flickering, sharper diffuse and specular lighting in the surface (since this is now at full resolution), faster postprocessing if using a 64-bit rendertarget (on NV 980Ti). Checkerboard rendering is controlled via the r.sss.checkerboard cvar. - 0 is off/full res, 1 is checkerboard, 2 is automatic based on scenecolor (non-checkerboard requires 64bit or more rendertarget w/separate alpha) Tested/profiled on PC, PS4 Change 3074666 on 2016/08/02 by Daniel.Wright Fixed stationary skylight brightness Change 3074667 on 2016/08/02 by Daniel.Wright Fixed r.ReflectionEnvironmentLightmapMixing Change 3074687 on 2016/08/02 by Daniel.Wright Disallowed DrawMaterialToRenderTarget and Begin/EndDrawCanvasToRenderTarget in construction scripts, since they don't work in game. Blutilities can be used to do blueprint rendering in the editor. Change 3075241 on 2016/08/03 by Rolando.Caloca DR - Fix linux compile issue & static analysis warning Change 3075746 on 2016/08/03 by Daniel.Wright Removed bOverride_AntiAliasingMethod and outdated ini references to PP AntiAliasingMethod Change 3075783 on 2016/08/03 by Ryan.Brucks #code.review Marcus.Wassmer Added two material nodes that return Atmospheric Light Vector and Light Direction using: View.AtmosphericFogSunColor View.AtmosphericFogSunDirection Nodes are called: AtmosphericLightVector AtmosphericLightColor Also changed SceneRendering.cpp so that values will be grabbed from directional lights without needing an Atmospheric Fog actor in the scene. Change 3075969 on 2016/08/03 by Uriel.Doyon Material GUIDs are not updated anymore when parents or textures change. Lighting now uses a hash built from the list of parents, textures and shader functions. #review-3072980 @marcus.wassmer @daniel.wright Change 3076116 on 2016/08/03 by Ryan.Brucks #code.review marcus.wassmer Fixed typo in the Caption of new Nodes "Atmospheric Light Vector" and "Atmospheric Light Color" Change 3076456 on 2016/08/03 by Rolando.Caloca DR - Fix geometry shader gl_Layer for SPIR-V Change 3076730 on 2016/08/03 by Uriel.Doyon Added user warning logic for the texture streaming build. Ran in MapCheck, BeginPlay and PreSave. #review-3072984 @marcus.wassmer Change 3077616 on 2016/08/04 by Daniel.Wright Planar reflection show flags can now be edited Change 3077621 on 2016/08/04 by Daniel.Wright Changed default Planar Reflection DistanceFromPlaneFadeoutEnd from 600 to 100, which reduces artifacts and is a more intuitive initial setting Change 3077792 on 2016/08/04 by Daniel.Wright Fixed an unnecessary sky capture caused by the sky light component owned by the default ASkyLight Change 3077799 on 2016/08/04 by Daniel.Wright Skip RF_ArchetypeObject for reflection captures Change 3077876 on 2016/08/04 by Marc.Olano Noise material perf improvements Change random number generator for Gradient-ALU (1.7x perf boost), improve speed of Voronoi noise quality level 3. Removes integer BBS random number generators. Fewer instructions, but too slow to use (see 1.7x perf boost above) Change 3077884 on 2016/08/04 by Daniel.Wright Lighting channels can now be edited on components with static mobility, since dynamic lights can still affect them Change 3078994 on 2016/08/05 by Simon.Tovey Fix for UE-34241 Scene proxy ptr was being cached during a downcast. Inside a call to CreateDynamicData, CheckMaterialUsage_Concurrent() was causing the scene proxy to be recreated an so the cached ptr was stale. I've fixed the immediate issue but recreating the scene proxy here doesn't seem great. Maybe CheckMaterailUsage() should be rethought a bit. Change 3079162 on 2016/08/05 by Ben.Woodhouse Fix for jittering in Paper2D. Was caused by override being ignored due to a change in intiialization order for AA settings. #jira UE-34091 Change 3079613 on 2016/08/05 by Daniel.Wright New blueprint function ClearRenderTarget2D, which is the only way to set a render target alpha directly New blueprint function CreateRenderTarget2D Change 3079708 on 2016/08/05 by Uriel.Doyon Fixed crash when building texture streaming on some levels. Change 3079795 on 2016/08/05 by Uriel.Doyon Fixed issue with instanced static meshes when building texture streaming. Fixed typo with func "GetNumTextureStreamingPrimitives" Change 3079806 on 2016/08/05 by Uriel.Doyon Enabled PerTexture MipBias. The per texture mip bias now resets to 0 when the texture gets required at low resolution. New scalability setting named "r.Streaming.LimitPoolSizeToVRAM" enabling the PoolSize to be limited the available VRAM (according to GPoolSizeVRAMPercentage) #review-3074662 @marcus.wassmer Change 3082698 on 2016/08/09 by Daniel.Wright Copy - CreateRenderTarget2D uses a world context object as owner, allows use in a construction script Change 3082699 on 2016/08/09 by Daniel.Wright Changed display name for 'Two Sided' shading model to 'Two Sided Foliage' to make it clear what it's intended to be used for Change 3083909 on 2016/08/10 by Olaf.Piesche #jira UE-34106 #jira UE-32784 #jira UE-31198 Reset vertex factories on mesh emitters if mesh has been reimported (if mesh package is dirty) Change 3084645 on 2016/08/10 by Olaf.Piesche #jira UE-30398 Fix offset added to particle collision locations. Change 3084709 on 2016/08/10 by Daniel.Wright Copy - Scene capture alpha is now inverted to match DrawMaterialToRenderTarget, and to allow compositing with existing render target contents Added CompositeMode to SceneCapture2D, which can be used to addively accumulate or composite instead of the default overwrite behavior Added bCaptureOnMovement to SceneCapture, which can be disabled so the only source of scene capturing is a manual capture by calling CaptureScene() Change 3084783 on 2016/08/10 by Rolando.Caloca DR - Use the first targeted rhi shader platform as the initial RHI to load on Windows #jira UE-34510 Change 3084958 on 2016/08/10 by Daniel.Wright Copy - Reverted cl 2938543 "Lightmass now respects owner bHidden, and bCastHiddenShadow" because it did not have backwards compatibility so breaks content using hidden light cards Change 3086023 on 2016/08/11 by Marcus.Wassmer Merging //UE4/Dev-Main@3085468 to Dev-Rendering (//UE4/Dev-Rendering) #test none Change 3086778 on 2016/08/11 by Ben.Woodhouse Workaround for fortnite character rendering issue. Enable checkerboard rendering by default until we can fix properly #jira UE-34561 Change 3087404 on 2016/08/12 by Rolando.Caloca DR - Upgrade glslang to 1.0.21.1 - Added some more debug output Change 3087524 on 2016/08/12 by Rolando.Caloca DR - vk - Fixed StencilRef, fixed size of RHIReadSurfaceFloatData (but still returns dummy data) Change 3087663 on 2016/08/12 by Rolando.Caloca DR - vk - Fix for SRGB; support for mip texture views Change 3087735 on 2016/08/12 by Daniel.Wright TextureRenderTarget2D's can now be up to 8192^2. Anything over 2048 pops up an 'are you sure' dialog. Change 3087750 on 2016/08/12 by Rolando.Caloca DR - vk - Minor renaming in prep for merge Change 3087813 on 2016/08/12 by Rolando.Caloca DR - vk - More minor cleanup Change 3087819 on 2016/08/12 by Chris.Bunner Check material function input types directly, no need to traverse connected graph. #jira UE-32134 Change 3087901 on 2016/08/12 by Rolando.Caloca DR - vk - Fix RT view to use 1 mip Fix depth buffer component swizzle Change 3088193 on 2016/08/12 by Daniel.Wright DFAO and RTDF shadows are enabled in High and Epic scalability settings by default Change 3088988 on 2016/08/15 by Rolando.Caloca DR - Add Accessors Change 3089104 on 2016/08/15 by Olaf.Piesche #jira UE-34241 Sceneproxy can be nullptr in FDynamicMeshEmitterData::Init if the proxy is being recreated Change 3089208 on 2016/08/15 by Daniel.Wright Downsampled separate translucency uses a separate view uniform buffer with correct buffer sizes * Fixes WorldPosition in downsampled translucency * View uniform buffer parameters are now cached on the view, to allow recreating the uniform buffer without having to rebuild the entire struct. Currently used by global distance field, downsampled separate translucency. * Fixed the downsampled translucency depth buffer being full res used together with a smaller color target, now they are both the downsampled res Change 3089209 on 2016/08/15 by Daniel.Wright Fixed atmospheric fog on translucency Change 3089457 on 2016/08/15 by Daniel.Wright Fixed lighting build failure from UMaterialInstanceDynamic assigned to a mesh that's being exported to Lightmass. The Swarm cache entry is created using the parent's guid, causing multiple MID's with the same parent to acquire a file handle multiple times which fails after the first. Change 3089549 on 2016/08/15 by Daniel.Wright UMaterialInterface initializes LightingGuid to something valid - causes UMaterialInstanceDynamic to have a valid LightingGuid so they can be used in lighting builds Change 3089703 on 2016/08/15 by Daniel.Wright Custom expression fixup for View.RenderTargetSize Change 3090546 on 2016/08/16 by Daniel.Wright Hopeful fix for recycled snapshot view crash Change 3091202 on 2016/08/16 by Daniel.Wright Manually clear FViewInfo::CachedViewUniformShaderParameters on creating a snapshot, since memcpy is used to create the snapshot view [CL 3091931 by Gil Gribb in Main branch]
2016-08-17 11:38:13 -04:00
DynamicRHI = DynamicRHIModule->CreateRHI(RequestedFeatureLevel);
GLoadedRHIModuleName = LoadedRHIModuleName;
}
return DynamicRHI;
}
const TCHAR* GetSelectedDynamicRHIModuleName(bool bCleanup)
{
check(FApp::CanEverRender());
if (GDynamicRHI)
{
check(!!GLoadedRHIModuleName);
return GMaxRHIFeatureLevel == ERHIFeatureLevel::ES3_1 ? TEXT("ES31") : GLoadedRHIModuleName;
}
else
{
ERHIFeatureLevel::Type DesiredFeatureLevel;
const TCHAR* RHIModuleName;
IDynamicRHIModule* DynamicRHIModule = LoadDynamicRHIModule(DesiredFeatureLevel, RHIModuleName);
check(DynamicRHIModule);
check(RHIModuleName);
if (bCleanup)
{
FModuleManager::Get().UnloadModule(RHIModuleName);
}
return DesiredFeatureLevel == ERHIFeatureLevel::ES3_1 ? TEXT("ES31") : RHIModuleName;
}
}
#endif //WINDOWS_USE_FEATURE_DYNAMIC_RHI