init
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class DLSS : ModuleRules
|
||||
{
|
||||
@@ -38,9 +39,10 @@ public class DLSS : ModuleRules
|
||||
);
|
||||
|
||||
|
||||
// for ITemporalUpscaler in PostProcess/TemporalAA.h
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
EngineDirectory + "/Source/Runtime/Renderer/Private",
|
||||
Path.Combine(GetModuleDirectory("Renderer"), "Private"),
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
@@ -72,32 +74,7 @@ public class DLSS : ModuleRules
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
if (ReadOnlyBuildVersion.Current.MajorVersion == 5)
|
||||
{
|
||||
PrivateDependencyModuleNames.Add("RHICore");
|
||||
}
|
||||
|
||||
DynamicallyLoadedModuleNames.AddRange(SupportedDynamicallyLoadedNGXRHIModules(Target));
|
||||
|
||||
// We can't quite check whether we have CL 16848904 (in UE5-Main) so we do this in a round about way
|
||||
bool bSupportsPostProcessingScreenPercentage = (Target.Version.MajorVersion == 4) ||
|
||||
((Target.Version.MajorVersion == 5) && (Target.Version.BranchName == "++UE5+Release-5.0-EarlyAccess"))
|
||||
;
|
||||
PrivateDefinitions.Add(string.Format("SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE={0}", bSupportsPostProcessingScreenPercentage ? "1" : "0"));
|
||||
|
||||
// this is a public definition so the DLSSMoviePipelineSupport modules (if compiled against that branch) see it
|
||||
bool bSupportsCustomStaticScreenpercentageSetupViewFamily = ((Target.Version.MajorVersion == 4) && (Target.Version.MinorVersion >= 27)) || ((Target.Version.MajorVersion == 5) && (Target.Version.BranchName != "++UE5+Release-5.0-EarlyAccess"));
|
||||
PublicDefinitions.Add(string.Format("DLSS_ENGINE_SUPPORTS_CSSPD={0}", bSupportsCustomStaticScreenpercentageSetupViewFamily ? "1" : "0"));
|
||||
|
||||
// We can't quite check whether we have CL 16758229 so we do this in a round about way
|
||||
bool bEngineHasAAM_TSR = (Target.Version.MajorVersion == 5) && (Target.Version.BranchName != "++UE5+Release-5.0-EarlyAccess");
|
||||
PrivateDefinitions.Add(string.Format("DLSS_ENGINE_HAS_AAM_TSR={0}", bEngineHasAAM_TSR ? "1" : "0"));
|
||||
|
||||
// 4.x and early access 5.0 engines had GTemporalUpscaler interface
|
||||
bool bEngineHasGTemporalUpscaler = (Target.Version.MajorVersion == 4) || (Target.Version.BranchName == "++UE5+Release-5.0-EarlyAccess");
|
||||
PrivateDefinitions.Add(string.Format("DLSS_ENGINE_HAS_GTEMPORALUPSCALER={0}", bEngineHasGTemporalUpscaler ? "1" : "0"));
|
||||
|
||||
// 4.x and early access 5.0 engines, ITemporalUpscaler::AddPasses returns values through pointers passed into the function
|
||||
bool bEngineAddPassesReturnThroughParams = (Target.Version.MajorVersion == 4) || (Target.Version.BranchName == "++UE5+Release-5.0-EarlyAccess");
|
||||
PublicDefinitions.Add(string.Format("DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS={0}", bEngineAddPassesReturnThroughParams ? "1" : "0"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
@@ -46,7 +46,7 @@ static TAutoConsoleVariable<int32> CVarNGXEnable(
|
||||
TEXT("r.NGX.Enable"), 1,
|
||||
TEXT("Whether the NGX library should be loaded. This allow to have the DLSS plugin enabled but avoiding potential ")
|
||||
TEXT("incompatibilities by skipping the driver side NGX parts of DLSS. Can also be set on the command line via -ngxenable and -ngxdisable"),
|
||||
ECVF_Default);
|
||||
ECVF_ReadOnly);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSMinimumWindowsBuildVersion(
|
||||
TEXT("r.NGX.DLSS.MinimumWindowsBuildVersion"), 16299,
|
||||
@@ -102,8 +102,8 @@ public:
|
||||
virtual void SetupView(FSceneViewFamily& InViewFamily, FSceneView& InView) {}
|
||||
virtual void SetupViewPoint(APlayerController* Player, FMinimalViewInfo& InViewInfo) {}
|
||||
virtual void BeginRenderViewFamily(FSceneViewFamily& InViewFamily) {}
|
||||
virtual void PreRenderView_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneView& InView) final {}
|
||||
virtual void PreRenderViewFamily_RenderThread(FRHICommandListImmediate& RHICmdList, FSceneViewFamily& InViewFamily) final
|
||||
virtual void PreRenderView_RenderThread(FRDGBuilder& GraphBuilder, FSceneView& InView) final {}
|
||||
virtual void PreRenderViewFamily_RenderThread(FRDGBuilder& GraphBuilder, FSceneViewFamily& InViewFamily) final
|
||||
{
|
||||
int32 ViewIndex = CVarNGXAutomationViewIndex.GetValueOnRenderThread();
|
||||
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
View->ViewRotation.Pitch, View->ViewRotation.Roll, View->ViewRotation.Yaw);
|
||||
|
||||
static FColor ColorMarker = FColor::FromHex("0xA1A5E87");
|
||||
FRHICommandListImmediate& RHICmdList = GraphBuilder.RHICmdList;
|
||||
RHICmdList.PushEvent(*AiAgentMarker, ColorMarker);
|
||||
RHICmdList.PopEvent();
|
||||
}
|
||||
@@ -124,42 +125,18 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static bool IsCompatibleEngineVersion(FString& OutPluginVersion, FString& OutEngineVersion)
|
||||
{
|
||||
|
||||
// Binary incompatibility between 4.26.0 and 4.26.1, so check for the engine patch version at runtime here
|
||||
// Engine loading code already checks for compatibility for major/minor/changelist
|
||||
// Written so that no code change will be needed for future engine versions if compatibility isn't broken again
|
||||
FEngineVersion Version = FEngineVersion::Current();
|
||||
|
||||
OutEngineVersion = FString::Printf(TEXT("%u.%u.%u"), Version.GetMajor(), Version.GetMinor(), Version.GetPatch());
|
||||
OutPluginVersion = FString::Printf(TEXT("%u.%u.%u"), ENGINE_MAJOR_VERSION, ENGINE_MINOR_VERSION, ENGINE_PATCH_VERSION);
|
||||
#if ENGINE_MAJOR_VERSION == 4
|
||||
#if ENGINE_MINOR_VERSION == 26
|
||||
#if ENGINE_PATCH_VERSION == 0
|
||||
// 4.26.0
|
||||
return Version.GetPatch() == 0;
|
||||
#else
|
||||
// 4.26.x, x > 0
|
||||
return Version.GetPatch() >= 1;
|
||||
#endif
|
||||
#else
|
||||
// 4.x._, x > 26
|
||||
return true;
|
||||
#endif
|
||||
#elif ENGINE_MAJOR_VERSION == 5
|
||||
return true;
|
||||
#else
|
||||
#error "ENGINE_MAJOR_VERSION must be either 4 or 5"
|
||||
#endif
|
||||
}
|
||||
|
||||
void FDLSSModule::StartupModule()
|
||||
{
|
||||
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
if (!GDynamicRHI)
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS requires an RHI"));
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the base directory of this plugin
|
||||
const FString PluginBaseDir = IPluginManager::Get().FindPlugin(TEXT("DLSS"))->GetBaseDir();
|
||||
const FString NGXBinariesDir = FPaths::Combine(*PluginBaseDir, TEXT("Binaries/ThirdParty/Win64/"));
|
||||
@@ -181,36 +158,7 @@ void FDLSSModule::StartupModule()
|
||||
|
||||
const int32 NGXDLSSMinimumWindowsBuildVersion = CVarNGXDLSSMinimumWindowsBuildVersion.GetValueOnAnyThread();
|
||||
|
||||
|
||||
FString PluginVersion;
|
||||
FString EngineVersion;
|
||||
|
||||
if (!IsCompatibleEngineVersion(PluginVersion, EngineVersion))
|
||||
{
|
||||
FEngineVersion Version = FEngineVersion::Current();
|
||||
UE_LOG(LogDLSS, Error,
|
||||
TEXT("This prebuilt binary distribution version %s of the NVIDIA DLSS plugin is not compatible with the current engine version %s"),
|
||||
*PluginVersion, *EngineVersion);
|
||||
UE_LOG(LogDLSS, Error, TEXT("Build the DLSS plugin from source (e.g. via the Editor -> Plugins -> NVIDIA DLSS -> Package)"));
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
|
||||
// we don't want this ever show up in packaged builds
|
||||
#if WITH_EDITOR
|
||||
const bool IsUnattended = FApp::IsUnattended() || IsRunningCommandlet() || GIsRunningUnattendedScript;
|
||||
if (!IsUnattended )
|
||||
{
|
||||
const FText DialogTitle(LOCTEXT("DLSSIncompatibleEngineVersionTitle", "Error - DLSS plugin incompatible with engine"));
|
||||
|
||||
const FTextFormat Format(LOCTEXT("DLSSIncompatibleEngineVersion",
|
||||
"The binary version {0} of this DLSS Unreal Engine Plugin is not compatible with the binary version {1} of this Unreal Engine installation. \n\n"
|
||||
"Please build the DLSS plugin from source (e.g. via the Editor -> Plugins -> NVIDIA DLSS -> Package)"));
|
||||
const FText WarningMessage = FText::Format(Format, FText::FromString(PluginVersion), FText::FromString(EngineVersion));
|
||||
|
||||
FMessageDialog::Open(EAppMsgType::Ok,WarningMessage, &DialogTitle);
|
||||
}
|
||||
#endif //WITH_EDITOR
|
||||
}
|
||||
else if (!IsRHIDeviceNVIDIA())
|
||||
if (!IsRHIDeviceNVIDIA())
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS requires an NVIDIA RTX series graphics card"));
|
||||
DLSSSupport = EDLSSSupport::NotSupportedIncompatibleHardware;
|
||||
@@ -234,9 +182,11 @@ void FDLSSModule::StartupModule()
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool bIsDX12 = (RHIName == TEXT("D3D12")) && GetDefault<UDLSSSettings>()->bEnableDLSSD3D12;
|
||||
const bool bIsDX11 = (RHIName == TEXT("D3D11")) && GetDefault<UDLSSSettings>()->bEnableDLSSD3D11;
|
||||
const bool bIsVulkan = (RHIName == TEXT("Vulkan")) && GetDefault<UDLSSSettings>()->bEnableDLSSVulkan;
|
||||
const ERHIInterfaceType RHIType = RHIGetInterfaceType();
|
||||
|
||||
const bool bIsDX12 = (RHIType == ERHIInterfaceType::D3D12) && GetDefault<UDLSSSettings>()->bEnableDLSSD3D12;
|
||||
const bool bIsDX11 = (RHIType == ERHIInterfaceType::D3D11) && GetDefault<UDLSSSettings>()->bEnableDLSSD3D11;
|
||||
const bool bIsVulkan = (RHIType == ERHIInterfaceType::Vulkan) && GetDefault<UDLSSSettings>()->bEnableDLSSVulkan;
|
||||
const TCHAR* NGXRHIModuleName = nullptr;
|
||||
|
||||
DLSSSupport = (bIsDX11 || bIsDX12 || bIsVulkan) ? EDLSSSupport::Supported : EDLSSSupport::NotSupported;
|
||||
@@ -253,7 +203,6 @@ void FDLSSModule::StartupModule()
|
||||
}
|
||||
else if (bIsVulkan)
|
||||
{
|
||||
// TODO Vulkan (which might need a second, pre RHI init module to route the required vulkan extensions to the VulkanRHI, similar to the HMD stuff
|
||||
NGXRHIModuleName = TEXT("NGXVulkanRHI");
|
||||
}
|
||||
|
||||
@@ -352,6 +301,8 @@ void FDLSSModule::StartupModule()
|
||||
}
|
||||
|
||||
const FNGXDriverRequirements DriverRequirements = NGXRHIExtensions->GetDLSSDriverRequirements();
|
||||
MinDriverVersionMajor = DriverRequirements.MinDriverVersionMajor;
|
||||
MinDriverVersionMinor = DriverRequirements.MinDriverVersionMinor;
|
||||
if (DriverRequirements.DriverUpdateRequired)
|
||||
{
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
@@ -400,13 +351,6 @@ void FDLSSModule::StartupModule()
|
||||
DLSSUpscaler.Reset();
|
||||
NGXRHIExtensions.Reset();
|
||||
}
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
else
|
||||
{
|
||||
checkf(GTemporalUpscaler == ITemporalUpscaler::GetDefaultTemporalUpscaler(), TEXT("GTemporalUpscaler is not set to the default upscaler. Please check that only one upscaling plugin is active."));
|
||||
GTemporalUpscaler = DLSSUpscaler.Get();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,6 +360,11 @@ void FDLSSModule::StartupModule()
|
||||
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
{
|
||||
// set up the view extension for setting up the FDLSSUpscaler on FSceneViewFamily
|
||||
{
|
||||
DLSSUpscalerViewExtension = FSceneViewExtensions::NewExtension<FDLSSUpscalerViewExtension>();
|
||||
}
|
||||
|
||||
// set the denoiser
|
||||
{
|
||||
|
||||
@@ -429,12 +378,6 @@ void FDLSSModule::StartupModule()
|
||||
GScreenSpaceDenoiser = DLSSDenoiser.Get();
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s wrapping %s"), DLSSDenoiser->GetDebugName(), DLSSDenoiser->GetWrappedDenoiser()->GetDebugName());
|
||||
}
|
||||
|
||||
// set the screen percentage driver for game views
|
||||
{
|
||||
checkf(GCustomStaticScreenPercentage == nullptr, TEXT("GCustomStaticScreenPercentage is already in use. Please check that only one upscaling plugin is active."));
|
||||
GCustomStaticScreenPercentage = DLSSUpscaler.Get();
|
||||
}
|
||||
|
||||
// set the resource pool
|
||||
{
|
||||
@@ -462,17 +405,19 @@ void FDLSSModule::ShutdownModule()
|
||||
|
||||
if (QueryDLSSSupport() == EDLSSSupport::Supported)
|
||||
{
|
||||
// reset the view extension
|
||||
{
|
||||
DLSSUpscalerViewExtension = nullptr;
|
||||
}
|
||||
|
||||
// reset the resource pool
|
||||
if (GCustomResourcePool == DLSSUpscaler.Get())
|
||||
{
|
||||
GCustomResourcePool = nullptr;
|
||||
}
|
||||
|
||||
// reset the screen percentage driver for game views
|
||||
{
|
||||
GCustomStaticScreenPercentage = nullptr;
|
||||
}
|
||||
|
||||
// reset the denoiser
|
||||
if (GScreenSpaceDenoiser == DLSSDenoiser.Get())
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s unwrapping %s"), DLSSDenoiser->GetDebugName(), DLSSDenoiser->GetWrappedDenoiser()->GetDebugName());
|
||||
GScreenSpaceDenoiser = DLSSDenoiser->GetWrappedDenoiser();
|
||||
@@ -481,9 +426,6 @@ void FDLSSModule::ShutdownModule()
|
||||
|
||||
// reset the upscaler
|
||||
{
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
GTemporalUpscaler = ITemporalUpscaler::GetDefaultTemporalUpscaler();
|
||||
#endif
|
||||
FDLSSUpscaler::ReleaseStaticResources();
|
||||
DLSSUpscaler.Reset();
|
||||
}
|
||||
@@ -520,6 +462,11 @@ FDLSSUpscaler* FDLSSModule::GetDLSSUpscaler() const
|
||||
return DLSSUpscaler.Get();
|
||||
}
|
||||
|
||||
TSharedPtr< ISceneViewExtension, ESPMode::ThreadSafe> FDLSSModule::GetDLSSUpscalerViewExtension() const
|
||||
{
|
||||
return StaticCastSharedPtr<ISceneViewExtension>(DLSSUpscalerViewExtension);
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDLSSModule, DLSS)
|
||||
|
||||
@@ -31,15 +31,6 @@ static TAutoConsoleVariable<int32> CVarNGXDLSSWaterReflectionsTemporalAA(
|
||||
);
|
||||
|
||||
|
||||
// defined in Buid.cs since it depends on the branch and engine version
|
||||
#if !DLSS_ENGINE_HAS_AAM_TSR
|
||||
/** Returns whether the anti-aliasing method use a temporal accumulation */
|
||||
static inline bool IsTemporalAccumulationBasedMethod(EAntiAliasingMethod AntiAliasingMethod)
|
||||
{
|
||||
return AntiAliasingMethod == AAM_TemporalAA;
|
||||
}
|
||||
#endif
|
||||
|
||||
FDLSSDenoiser::FDLSSDenoiser(const IScreenSpaceDenoiser* InWrappedDenoiser, const FDLSSUpscaler* InUpscaler)
|
||||
: WrappedDenoiser(InWrappedDenoiser)
|
||||
, Upscaler(InUpscaler)
|
||||
@@ -54,14 +45,7 @@ const TCHAR* FDLSSDenoiser::GetDebugName() const
|
||||
{
|
||||
// we don't have the View here to check whether we have a valid GetTemporalUpscalerInterface, which we'll do when we actually get called to denoise/add TAA
|
||||
// and this is only for profilegpu anyways so OK if it's not 100% accurate
|
||||
if (Upscaler->IsAutoQualityMode())
|
||||
{
|
||||
return TEXT("FDLSSDenoiserWrapper(Auto)");
|
||||
}
|
||||
else
|
||||
{
|
||||
return TEXT("FDLSSDenoiserWrapper(Active)");
|
||||
}
|
||||
return TEXT("FDLSSDenoiserWrapper(Active)");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -87,7 +71,7 @@ IScreenSpaceDenoiser::FPolychromaticPenumbraOutputs FDLSSDenoiser::DenoisePolych
|
||||
IScreenSpaceDenoiser::FReflectionsOutputs FDLSSDenoiser::DenoiseReflections(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FReflectionsInputs& Inputs, const FReflectionsRayTracingConfig Config) const
|
||||
{
|
||||
FReflectionsOutputs Outputs = WrappedDenoiser->DenoiseReflections(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
const bool bIsDLSSActive = Upscaler->IsDLSSActive() && View.Family && Upscaler->IsValidUpscalerInstance(View.Family->GetTemporalUpscalerInterface());
|
||||
const bool bIsDLSSActive = View.Family && FDLSSSceneViewFamilyUpscaler::IsDLSSTemporalUpscaler(View.Family->GetTemporalUpscalerInterface());
|
||||
const bool bApplyTemporalAA = bIsDLSSActive && CVarNGXDLSSReflectionsTemporalAA.GetValueOnRenderThread() && View.ViewState && IsTemporalAccumulationBasedMethod(View.AntiAliasingMethod);
|
||||
if(bApplyTemporalAA)
|
||||
{
|
||||
@@ -116,7 +100,7 @@ IScreenSpaceDenoiser::FReflectionsOutputs FDLSSDenoiser::DenoiseReflections(FRDG
|
||||
IScreenSpaceDenoiser::FReflectionsOutputs FDLSSDenoiser::DenoiseWaterReflections(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FReflectionsInputs& Inputs, const FReflectionsRayTracingConfig Config) const
|
||||
{
|
||||
FReflectionsOutputs Outputs = WrappedDenoiser->DenoiseWaterReflections(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
const bool bIsDLSSActive = Upscaler->IsDLSSActive() && View.Family && Upscaler->IsValidUpscalerInstance(View.Family->GetTemporalUpscalerInterface());
|
||||
const bool bIsDLSSActive = View.Family && FDLSSSceneViewFamilyUpscaler::IsDLSSTemporalUpscaler(View.Family->GetTemporalUpscalerInterface());
|
||||
const bool bApplyTemporalAA = bIsDLSSActive && Upscaler->IsDLSSActive() && CVarNGXDLSSWaterReflectionsTemporalAA.GetValueOnRenderThread() && View.ViewState && IsTemporalAccumulationBasedMethod(View.AntiAliasingMethod);
|
||||
if (bApplyTemporalAA)
|
||||
{
|
||||
@@ -146,20 +130,6 @@ IScreenSpaceDenoiser::FAmbientOcclusionOutputs FDLSSDenoiser::DenoiseAmbientOccl
|
||||
{
|
||||
return WrappedDenoiser->DenoiseAmbientOcclusion(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
#if ENGINE_MAJOR_VERSION == 4
|
||||
IScreenSpaceDenoiser::FDiffuseIndirectOutputs FDLSSDenoiser::DenoiseDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
return WrappedDenoiser->DenoiseDiffuseIndirect(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
IScreenSpaceDenoiser::FDiffuseIndirectOutputs FDLSSDenoiser::DenoiseScreenSpaceDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
return WrappedDenoiser->DenoiseScreenSpaceDiffuseIndirect(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
IScreenSpaceDenoiser::FDiffuseIndirectHarmonic FDLSSDenoiser::DenoiseDiffuseIndirectHarmonic(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectHarmonic& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
return WrappedDenoiser->DenoiseDiffuseIndirectHarmonic(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
#elif ENGINE_MAJOR_VERSION == 5
|
||||
|
||||
FSSDSignalTextures FDLSSDenoiser::DenoiseDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
@@ -175,9 +145,6 @@ FSSDSignalTextures FDLSSDenoiser::DenoiseDiffuseIndirectHarmonic(FRDGBuilder& Gr
|
||||
{
|
||||
return WrappedDenoiser->DenoiseDiffuseIndirectHarmonic(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, CommonDiffuseParameters);
|
||||
}
|
||||
#else
|
||||
#error "ENGINE_MAJOR_VERSION must be either 4 or 5"
|
||||
#endif
|
||||
|
||||
IScreenSpaceDenoiser::FDiffuseIndirectOutputs FDLSSDenoiser::DenoiseSkyLight(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
|
||||
* rights in and to this software, related documentation and any modifications thereto.
|
||||
* Any use, reproduction, disclosure or distribution of this software and related
|
||||
* documentation without an express license agreement from NVIDIA Corporation is strictly
|
||||
* prohibited.
|
||||
*
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
|
||||
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
|
||||
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
|
||||
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGES.
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ScreenSpaceDenoise.h"
|
||||
// for ENGINE_MAJOR_VERSION
|
||||
#include "Launch/Resources/Version.h"
|
||||
class FDLSSUpscaler;
|
||||
|
||||
// wrapper for the default denoiser to add TAA after some passes
|
||||
@@ -41,17 +30,9 @@ public:
|
||||
virtual FReflectionsOutputs DenoiseReflections(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FReflectionsInputs& Inputs, const FReflectionsRayTracingConfig Config) const final;
|
||||
virtual FReflectionsOutputs DenoiseWaterReflections(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FReflectionsInputs& Inputs, const FReflectionsRayTracingConfig Config) const override;
|
||||
virtual FAmbientOcclusionOutputs DenoiseAmbientOcclusion(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FAmbientOcclusionInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
#if ENGINE_MAJOR_VERSION == 4
|
||||
virtual FDiffuseIndirectOutputs DenoiseDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
virtual FDiffuseIndirectHarmonic DenoiseDiffuseIndirectHarmonic(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectHarmonic& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
virtual FDiffuseIndirectOutputs DenoiseScreenSpaceDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
#elif ENGINE_MAJOR_VERSION == 5
|
||||
virtual FSSDSignalTextures DenoiseDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
virtual FSSDSignalTextures DenoiseScreenSpaceDiffuseIndirect(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
virtual FSSDSignalTextures DenoiseDiffuseIndirectHarmonic(FRDGBuilder& GraphBuilder,const FViewInfo& View,FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectHarmonic& Inputs, const HybridIndirectLighting::FCommonParameters& CommonDiffuseParameters) const final;
|
||||
#else
|
||||
#error "ENGINE_MAJOR_VERSION must be either 4 or 5"
|
||||
#endif
|
||||
virtual FDiffuseIndirectOutputs DenoiseSkyLight(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
virtual FDiffuseIndirectOutputs DenoiseReflectedSkyLight(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const final;
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
|
||||
* rights in and to this software, related documentation and any modifications thereto.
|
||||
* Any use, reproduction, disclosure or distribution of this software and related
|
||||
* documentation without an express license agreement from NVIDIA Corporation is strictly
|
||||
* prohibited.
|
||||
*
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
|
||||
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
|
||||
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
|
||||
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGES.
|
||||
*/
|
||||
|
||||
#include "DLSSSettings.h"
|
||||
#define LOCTEXT_NAMESPACE "FDLSSModule"
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "DLSSUpscaler.h"
|
||||
|
||||
|
||||
#include "DLSS.h"
|
||||
#include "DLSSUpscalerPrivate.h"
|
||||
#include "DLSSUpscalerHistory.h"
|
||||
#include "DLSSSettings.h"
|
||||
@@ -22,6 +23,7 @@
|
||||
#include "PostProcess/PostProcessing.h"
|
||||
#include "SceneTextureParameters.h"
|
||||
#include "ScreenPass.h"
|
||||
#include "DynamicResolutionState.h"
|
||||
|
||||
#include "RayTracing/RaytracingOptions.h"
|
||||
|
||||
@@ -30,10 +32,6 @@
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSModule"
|
||||
|
||||
#ifndef SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE
|
||||
#define SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE 1
|
||||
#endif
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSEnable(
|
||||
TEXT("r.NGX.DLSS.Enable"), 1,
|
||||
TEXT("Enable/Disable DLSS entirely."),
|
||||
@@ -69,7 +67,7 @@ static TAutoConsoleVariable<bool> CVarNGXDLSSAutoQualitySetting(
|
||||
static TAutoConsoleVariable<float> CVarNGXDLSSSharpness(
|
||||
TEXT("r.NGX.DLSS.Sharpness"),
|
||||
0.0f,
|
||||
TEXT("-1.0 to 1.0: Softening/sharpening to apply to the DLSS pass. Negative values soften the image, positive values sharpen. (default: 0.0f)"),
|
||||
TEXT("[deprecated] -1.0 to 1.0: Softening/sharpening to apply to the DLSS pass. Negative values soften the image, positive values sharpen. (default: 0.0f)"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSDilateMotionVectors(
|
||||
@@ -112,6 +110,8 @@ static TAutoConsoleVariable<int32> CVarNGXDLSSFeatureVisibilityMask(
|
||||
|
||||
DECLARE_GPU_STAT(DLSS)
|
||||
|
||||
static const float kDLSSResolutionFractionError = 0.01f;
|
||||
|
||||
BEGIN_SHADER_PARAMETER_STRUCT(FDLSSShaderParameters, )
|
||||
|
||||
// Input images
|
||||
@@ -126,6 +126,13 @@ RDG_TEXTURE_ACCESS(SceneColorOutput, ERHIAccess::UAVCompute)
|
||||
|
||||
END_SHADER_PARAMETER_STRUCT()
|
||||
|
||||
static FDLSSUpscaler* GetGlobalDLSSUpscaler()
|
||||
{
|
||||
IDLSSModuleInterface* DLSSModule = &FModuleManager::LoadModuleChecked<IDLSSModuleInterface>("DLSS");
|
||||
check(DLSSModule);
|
||||
|
||||
return DLSSModule->GetDLSSUpscaler();
|
||||
}
|
||||
|
||||
FIntPoint FDLSSPassParameters::GetOutputExtent() const
|
||||
{
|
||||
@@ -148,12 +155,6 @@ bool FDLSSPassParameters::Validate() const
|
||||
return true;
|
||||
}
|
||||
|
||||
const TCHAR* FDLSSUpscaler::GetDebugName() const
|
||||
{
|
||||
return TEXT("FDLSSUpscaler");
|
||||
}
|
||||
|
||||
|
||||
static NVSDK_NGX_PerfQuality_Value ToNGXQuality(EDLSSQualityMode Quality)
|
||||
{
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to handle the new EDLSSQualityMode enum values");
|
||||
@@ -179,48 +180,119 @@ static NVSDK_NGX_PerfQuality_Value ToNGXQuality(EDLSSQualityMode Quality)
|
||||
}
|
||||
|
||||
NGXRHI* FDLSSUpscaler::NGXRHIExtensions;
|
||||
TStaticArray <TSharedPtr<FDLSSUpscaler>, uint32(EDLSSQualityMode::NumValues)> FDLSSUpscaler::DLSSUpscalerInstancesPerViewFamily;
|
||||
float FDLSSUpscaler::MinResolutionFraction = TNumericLimits <float>::Max();
|
||||
float FDLSSUpscaler::MaxResolutionFraction = TNumericLimits <float>::Min();
|
||||
|
||||
|
||||
float FDLSSUpscaler::MinDynamicResolutionFraction = TNumericLimits <float>::Max();
|
||||
float FDLSSUpscaler::MaxDynamicResolutionFraction = TNumericLimits <float>::Min();
|
||||
uint32 FDLSSUpscaler::NumRuntimeQualityModes = 0;
|
||||
TArray<FDLSSOptimalSettings> FDLSSUpscaler::ResolutionSettings;
|
||||
|
||||
|
||||
FDLSSUpscaler* FDLSSUpscaler::GetUpscalerInstanceForViewFamily(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InQualityMode)
|
||||
bool FDLSSUpscalerViewExtension::IsActiveThisFrame_Internal(const FSceneViewExtensionContext& Context) const
|
||||
{
|
||||
uint32 ArrayIndex = (int32)ToNGXQuality(InQualityMode);
|
||||
if (!DLSSUpscalerInstancesPerViewFamily[ArrayIndex])
|
||||
{
|
||||
DLSSUpscalerInstancesPerViewFamily[ArrayIndex] = MakeShared<FDLSSUpscaler>(InUpscaler, InQualityMode);
|
||||
|
||||
}
|
||||
return DLSSUpscalerInstancesPerViewFamily[ArrayIndex].Get();
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsValidUpscalerInstance(const ITemporalUpscaler* InUpscaler)
|
||||
{
|
||||
// DLSSUpscalerInstancesPerViewFamily gets lazily initialized, but we don't want to accidentally treat nullptr as a valid
|
||||
// upscaler instance, when we want to check (e.g. in the denoiser) whether DLSS is actually active for the viewfamily
|
||||
if (InUpscaler == nullptr)
|
||||
// Verify this is for a viewport client
|
||||
if (Context.Viewport == nullptr || !GEngine)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto UpscalerInstance : DLSSUpscalerInstancesPerViewFamily)
|
||||
// Do not setup temporal upscaler in automated tests.
|
||||
const bool bDLSSActiveWithAutomation = !GIsAutomationTesting || (GIsAutomationTesting && (CVarNGXDLSSAutomationTesting.GetValueOnAnyThread() != 0));
|
||||
if (!bDLSSActiveWithAutomation)
|
||||
{
|
||||
if (UpscalerInstance.Get() == InUpscaler)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Do not setup if not available.
|
||||
if (!GetGlobalDLSSUpscaler()->IsDLSSActive())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GIsEditor)
|
||||
#if WITH_EDITOR
|
||||
{
|
||||
if (Context.Viewport->IsPlayInEditorViewport())
|
||||
{
|
||||
return true;
|
||||
bool bEnableDLSSInPlayInEditorViewports = false;
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableDLSSInPlayInEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
bEnableDLSSInPlayInEditorViewports = GetDefault<UDLSSSettings>()->bEnableDLSSInPlayInEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
bEnableDLSSInPlayInEditorViewports = GetDefault<UDLSSOverrideSettings>()->EnableDLSSInPlayInEditorViewportsOverride == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
#if !NO_LOGGING
|
||||
static bool bLoggedPIEWarning = false;
|
||||
if (!bLoggedPIEWarning && GIsPlayInEditorWorld && bEnableDLSSInPlayInEditorViewports)
|
||||
{
|
||||
if (FStaticResolutionFractionHeuristic::FUserSettings::EditorOverridePIESettings())
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("r.ScreenPercentage for DLSS quality mode will be ignored because overridden by editor settings (r.Editor.Viewport.OverridePIEScreenPercentage). Change this behavior in Edit -> Editor Preferences -> Performance"));
|
||||
bLoggedPIEWarning = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return GIsPlayInEditorWorld && bEnableDLSSInPlayInEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bEnableDLSSInEditorViewports = false;
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableDLSSInEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
bEnableDLSSInEditorViewports = GetDefault<UDLSSSettings>()->bEnableDLSSInEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
bEnableDLSSInEditorViewports = GetDefault<UDLSSOverrideSettings>()->EnableDLSSInEditorViewportsOverride == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
return bEnableDLSSInEditorViewports;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
const bool bIsGameViewport = Context.Viewport->GetClient() == GEngine->GameViewport;
|
||||
return bIsGameViewport;
|
||||
}
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsAutoQualityMode()
|
||||
void FDLSSUpscalerViewExtension::BeginRenderViewFamily(FSceneViewFamily& ViewFamily)
|
||||
{
|
||||
return CVarNGXDLSSAutoQualitySetting.GetValueOnAnyThread();
|
||||
if (ViewFamily.ViewMode != EViewModeIndex::VMI_Lit ||
|
||||
ViewFamily.Scene == nullptr ||
|
||||
ViewFamily.Scene->GetShadingPath() != EShadingPath::Deferred ||
|
||||
!ViewFamily.bRealtimeUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Early returns if none of the view have a view state.
|
||||
for (const FSceneView* View : ViewFamily.Views)
|
||||
{
|
||||
if (View->State == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Early returns if AA is disabled.
|
||||
if (!ViewFamily.EngineShowFlags.AntiAliasing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ViewFamily.GetTemporalUpscalerInterface())
|
||||
{
|
||||
GetGlobalDLSSUpscaler()->SetupViewFamily(ViewFamily);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSS, Error, TEXT("Another plugin already set FSceneViewFamily::SetTemporalUpscalerInterface()"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsDLAAMode()
|
||||
@@ -228,25 +300,9 @@ bool FDLSSUpscaler::IsDLAAMode()
|
||||
return CVarNGXDLAAEnable.GetValueOnAnyThread();
|
||||
}
|
||||
|
||||
void FDLSSUpscaler::SetAutoQualityMode(bool bAutoQualityMode)
|
||||
FDLSSUpscaler::FDLSSUpscaler(NGXRHI* InNGXRHIExtensions): PreviousResolutionFraction(-1.0f)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
CVarNGXDLSSAutoQualitySetting->Set(bAutoQualityMode, ECVF_SetByCommandline);
|
||||
}
|
||||
|
||||
// make copy & assign quality mode
|
||||
FDLSSUpscaler::FDLSSUpscaler(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InQualityMode)
|
||||
: FDLSSUpscaler(*InUpscaler)
|
||||
{
|
||||
DLSSQualityMode = InQualityMode;
|
||||
check(NGXRHIExtensions);
|
||||
}
|
||||
|
||||
|
||||
FDLSSUpscaler::FDLSSUpscaler(NGXRHI* InNGXRHIExtensions)
|
||||
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSS, VeryVerbose, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
|
||||
checkf(!NGXRHIExtensions, TEXT("static member NGXRHIExtensions should only be assigned once by this ctor when called during module startup") );
|
||||
@@ -267,9 +323,8 @@ FDLSSUpscaler::FDLSSUpscaler(NGXRHI* InNGXRHIExtensions)
|
||||
// we only consider non-fixed resolutions for the overall min / max resolution fraction
|
||||
if (OptimalSettings.bIsSupported && !OptimalSettings.IsFixedResolution())
|
||||
{
|
||||
// We use OptimalSettings.OptimalResolutionFraction to avoid getting to "floating point close" to OptimalSettings.{MinMax}ResolutionFraction)
|
||||
MinResolutionFraction = FMath::Min(MinResolutionFraction, OptimalSettings.OptimalResolutionFraction);
|
||||
MaxResolutionFraction = FMath::Max(MaxResolutionFraction, OptimalSettings.OptimalResolutionFraction);
|
||||
MinDynamicResolutionFraction = FMath::Min(MinDynamicResolutionFraction, OptimalSettings.MinResolutionFraction);
|
||||
MaxDynamicResolutionFraction = FMath::Max(MaxDynamicResolutionFraction, OptimalSettings.MaxResolutionFraction);
|
||||
++NumRuntimeQualityModes;
|
||||
}
|
||||
|
||||
@@ -278,7 +333,7 @@ FDLSSUpscaler::FDLSSUpscaler(NGXRHI* InNGXRHIExtensions)
|
||||
}
|
||||
|
||||
// the DLSS module will report DLSS as not supported if there are no supported quality modes at runtime
|
||||
UE_LOG(LogDLSS, Log, TEXT("NumRuntimeQualityModes=%u, MinResolutionFraction=%.4f, MaxResolutionFraction=%.4f"), NumRuntimeQualityModes, MinResolutionFraction, MaxResolutionFraction);
|
||||
UE_LOG(LogDLSS, Log, TEXT("NumRuntimeQualityModes=%u, MinDynamicResolutionFraction=%.4f, MaxDynamicResolutionFraction=%.4f"), NumRuntimeQualityModes, MinDynamicResolutionFraction, MaxDynamicResolutionFraction);
|
||||
|
||||
// Higher levels of the code (e.g. UI) should check whether each mode is actually supported
|
||||
// But for now verify early that the DLSS 2.0 modes are supported. Those checks could be removed in the future
|
||||
@@ -287,54 +342,53 @@ FDLSSUpscaler::FDLSSUpscaler(NGXRHI* InNGXRHIExtensions)
|
||||
check(IsQualityModeSupported(EDLSSQualityMode::Quality));
|
||||
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
FDLSSUpscaler::~FDLSSUpscaler()
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSS, VeryVerbose, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
// this gets explicitly called during module shutdown
|
||||
void FDLSSUpscaler::ReleaseStaticResources()
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSS, VeryVerbose, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
ResolutionSettings.Empty();
|
||||
for (auto& UpscalerInstance : DLSSUpscalerInstancesPerViewFamily)
|
||||
{
|
||||
UpscalerInstance.Reset();
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSS, VeryVerbose, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
void FDLSSUpscaler::AddPasses(
|
||||
#else
|
||||
ITemporalUpscaler::FOutputs FDLSSUpscaler::AddPasses(
|
||||
#endif
|
||||
static const TCHAR* const GDLSSSceneViewFamilyUpscalerDebugName = TEXT("FDLSSSceneViewFamilyUpscaler");
|
||||
|
||||
const TCHAR* FDLSSSceneViewFamilyUpscaler::GetDebugName() const
|
||||
{
|
||||
return GDLSSSceneViewFamilyUpscalerDebugName;
|
||||
}
|
||||
|
||||
// static
|
||||
bool FDLSSSceneViewFamilyUpscaler::IsDLSSTemporalUpscaler(const ITemporalUpscaler* TemporalUpscaler)
|
||||
{
|
||||
return TemporalUpscaler != nullptr && TemporalUpscaler->GetDebugName() == GDLSSSceneViewFamilyUpscalerDebugName;
|
||||
}
|
||||
|
||||
float FDLSSSceneViewFamilyUpscaler::GetMinUpsampleResolutionFraction() const
|
||||
{
|
||||
return Upscaler->GetMinResolutionFractionForQuality(DLSSQualityMode);
|
||||
}
|
||||
|
||||
float FDLSSSceneViewFamilyUpscaler::GetMaxUpsampleResolutionFraction() const
|
||||
{
|
||||
return Upscaler->GetMaxResolutionFractionForQuality(DLSSQualityMode);
|
||||
}
|
||||
|
||||
ITemporalUpscaler* FDLSSSceneViewFamilyUpscaler::Fork_GameThread(const class FSceneViewFamily& ViewFamily) const
|
||||
{
|
||||
return new FDLSSSceneViewFamilyUpscaler(Upscaler, DLSSQualityMode);
|
||||
}
|
||||
|
||||
ITemporalUpscaler::FOutputs FDLSSSceneViewFamilyUpscaler::AddPasses(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FPassInputs& PassInputs
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
, FRDGTextureRef* OutSceneColorTexture
|
||||
, FIntRect* OutSceneColorViewRect
|
||||
, FRDGTextureRef* OutSceneColorHalfResTexture
|
||||
, FIntRect* OutSceneColorHalfResViewRect
|
||||
#endif
|
||||
) const
|
||||
{
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
// For TAAU, this can happen with screen percentages larger than 100%, so not something that DLSS viewports are setup with
|
||||
checkf(!PassInputs.bAllowDownsampleSceneColor,TEXT("The DLSS plugin does not support downsampling the scenecolor. Please set r.TemporalAA.AllowDownsampling=0"));
|
||||
#endif
|
||||
checkf(View.PrimaryScreenPercentageMethod == EPrimaryScreenPercentageMethod::TemporalUpscale, TEXT("DLSS requires TemporalUpscale. If you hit this assert, please set r.TemporalAA.Upscale=1"));
|
||||
|
||||
|
||||
|
||||
|
||||
const FTemporalAAHistory& InputHistory = View.PrevViewInfo.TemporalAAHistory;
|
||||
const TRefCountPtr<ICustomTemporalAAHistory> InputCustomHistory = View.PrevViewInfo.CustomTemporalAAHistory;
|
||||
|
||||
@@ -344,9 +398,7 @@ ITemporalUpscaler::FOutputs FDLSSUpscaler::AddPasses(
|
||||
|
||||
FDLSSPassParameters DLSSParameters(View);
|
||||
const FIntRect SecondaryViewRect = DLSSParameters.OutputViewRect;
|
||||
#if !DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
ITemporalUpscaler::FOutputs Outputs;
|
||||
#endif
|
||||
{
|
||||
RDG_GPU_STAT_SCOPE(GraphBuilder, DLSS);
|
||||
RDG_EVENT_SCOPE(GraphBuilder, "DLSS");
|
||||
@@ -369,25 +421,13 @@ ITemporalUpscaler::FOutputs FDLSSUpscaler::AddPasses(
|
||||
OutputCustomHistory
|
||||
);
|
||||
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
FRDGTextureRef SceneColorTexture = DLSSOutputs.SceneColor;
|
||||
|
||||
*OutSceneColorTexture = SceneColorTexture;
|
||||
*OutSceneColorViewRect = SecondaryViewRect;
|
||||
|
||||
*OutSceneColorHalfResTexture = nullptr;
|
||||
*OutSceneColorHalfResViewRect = FIntRect(FIntPoint::ZeroValue, FIntPoint::ZeroValue);
|
||||
#else
|
||||
Outputs.FullRes.Texture = DLSSOutputs.SceneColor;
|
||||
Outputs.FullRes.ViewRect = SecondaryViewRect;
|
||||
#endif
|
||||
}
|
||||
#if !DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
return Outputs;
|
||||
#endif
|
||||
}
|
||||
|
||||
FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
FDLSSOutputs FDLSSSceneViewFamilyUpscaler::AddDLSSPass(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FDLSSPassParameters& Inputs,
|
||||
@@ -397,8 +437,8 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
TRefCountPtr<ICustomTemporalAAHistory>* OutputCustomHistoryInterface
|
||||
) const
|
||||
{
|
||||
check(IsValidUpscalerInstance(this));
|
||||
check(IsDLSSActive());
|
||||
check(IsInRenderingThread());
|
||||
check(Upscaler->IsDLSSActive());
|
||||
const FDLSSUpscalerHistory* InputCustomHistory = static_cast<const FDLSSUpscalerHistory*>(InputCustomHistoryInterface.GetReference());
|
||||
|
||||
const bool bCameraCut = !InputHistory.IsValid() || View.bCameraCut || !OutputHistory;
|
||||
@@ -414,13 +454,16 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
// set DLSSQualityMode by setting an FDLSSUpscaler on the ViewFamily (from the pool in DLSSUpscalerInstancesPerViewFamily)
|
||||
|
||||
checkf(DLSSQualityMode != EDLSSQualityMode::NumValues, TEXT("Invalid Quality mode, not initialized"));
|
||||
checkf(IsQualityModeSupported(DLSSQualityMode), TEXT("%u is not a valid Quality mode"), DLSSQualityMode);
|
||||
checkf(Upscaler->IsQualityModeSupported(DLSSQualityMode), TEXT("%u is not a valid Quality mode"), DLSSQualityMode);
|
||||
|
||||
// This assert can accidentally hit with small viewrect dimensions (e.g. when resizing an editor view) due to floating point rounding & quantization issues
|
||||
// e.g. with 33% screen percentage at 1000 DestRect dimension we get 333/1000 = 0.33 but at 10 DestRect dimension we get 3/10 0.3, thus the assert hits
|
||||
|
||||
checkf(DestRect.Width() < 100 || GetMinResolutionFractionForQuality(DLSSQualityMode) - 0.01f <= ScaleX && ScaleX <= GetMaxResolutionFractionForQuality(DLSSQualityMode) + 0.01f, TEXT("The current resolution fraction %f is out of the supported DLSS range [%f ... %f] for quality mode %d."), ScaleX, GetMinResolutionFractionForQuality(DLSSQualityMode), GetMaxResolutionFractionForQuality(DLSSQualityMode), DLSSQualityMode);
|
||||
checkf(DestRect.Height() < 100 || GetMinResolutionFractionForQuality(DLSSQualityMode) - 0.01f <= ScaleY && ScaleY <= GetMaxResolutionFractionForQuality(DLSSQualityMode) + 0.01f, TEXT("The current resolution fraction %f is out of the supported DLSS range [%f ... %f] for quality mode %d."), ScaleY, GetMinResolutionFractionForQuality(DLSSQualityMode), GetMaxResolutionFractionForQuality(DLSSQualityMode), DLSSQualityMode);
|
||||
checkf(DestRect.Width() < 100 || GetMinUpsampleResolutionFraction() - kDLSSResolutionFractionError <= ScaleX && ScaleX <= GetMaxUpsampleResolutionFraction() + kDLSSResolutionFractionError,
|
||||
TEXT("The current resolution fraction %f is out of the supported DLSS range [%f ... %f] for quality mode %d."),
|
||||
ScaleX, GetMinUpsampleResolutionFraction(), GetMaxUpsampleResolutionFraction(), DLSSQualityMode);
|
||||
checkf(DestRect.Height() < 100 || GetMinUpsampleResolutionFraction() - kDLSSResolutionFractionError <= ScaleY && ScaleY <= GetMaxUpsampleResolutionFraction() + kDLSSResolutionFractionError,
|
||||
TEXT("The current resolution fraction %f is out of the supported DLSS range [%f ... %f] for quality mode %d."),
|
||||
ScaleY, GetMinUpsampleResolutionFraction(), GetMaxUpsampleResolutionFraction(), DLSSQualityMode);
|
||||
|
||||
const TCHAR* PassName = TEXT("MainUpsampling");
|
||||
|
||||
@@ -463,19 +506,22 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
}
|
||||
|
||||
const FVector2D JitterOffset = View.TemporalJitterPixels;
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
const float DeltaWorldTime = View.Family->DeltaWorldTime;
|
||||
#else
|
||||
const float DeltaWorldTime = View.Family->Time.GetDeltaWorldTimeSeconds();
|
||||
#endif
|
||||
|
||||
const float PreExposure = View.PreExposure;
|
||||
const bool bUseAutoExposure = CVarNGXDLSSAutoExposure.GetValueOnRenderThread() != 0;
|
||||
|
||||
const bool bReleaseMemoryOnDelete = CVarNGXDLSSReleaseMemoryOnDelete.GetValueOnRenderThread() != 0;
|
||||
|
||||
const float Sharpness = FMath::Clamp(CVarNGXDLSSSharpness.GetValueOnRenderThread(), -1.0f, 1.0f);
|
||||
NGXRHI* LocalNGXRHIExtensions = this->NGXRHIExtensions;
|
||||
#if !NO_LOGGING
|
||||
static bool bLoggedSharpnessWarning = false;
|
||||
if (Sharpness != 0.0f && !bLoggedSharpnessWarning)
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("DLSS sharpening is deprecated, recommend using the NIS plugin for sharpening instead"));
|
||||
bLoggedSharpnessWarning = true;
|
||||
}
|
||||
#endif
|
||||
NGXRHI* LocalNGXRHIExtensions = Upscaler->NGXRHIExtensions;
|
||||
const int32 NGXPerfQuality = ToNGXQuality(DLSSQualityMode);
|
||||
GraphBuilder.AddPass(
|
||||
RDG_EVENT_NAME("DLSS %s%s %dx%d -> %dx%d",
|
||||
@@ -485,6 +531,7 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
DestRect.Width(), DestRect.Height()),
|
||||
PassParameters,
|
||||
ERDGPassFlags::Compute | ERDGPassFlags::Raster | ERDGPassFlags::SkipRenderPass,
|
||||
// FRHICommandListImmediate forces it to run on render thread, FRHICommandList doesn't
|
||||
[LocalNGXRHIExtensions, PassParameters, Inputs, bCameraCut, JitterOffset, DeltaWorldTime, PreExposure, Sharpness, NGXPerfQuality, DLSSState, bUseAutoExposure, bReleaseMemoryOnDelete](FRHICommandListImmediate& RHICmdList)
|
||||
{
|
||||
FRHIDLSSArguments DLSSArguments;
|
||||
@@ -497,16 +544,9 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
DLSSArguments.Sharpness = Sharpness;
|
||||
DLSSArguments.bReset = bCameraCut;
|
||||
|
||||
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
DLSSArguments.JitterOffset = JitterOffset;
|
||||
DLSSArguments.MotionVectorScale = FVector2D(1.0f, 1.0f);
|
||||
#else
|
||||
DLSSArguments.JitterOffset = FVector2f(JitterOffset); // LWC_TODO: Precision loss
|
||||
DLSSArguments.MotionVectorScale = FVector2f::UnitVector;
|
||||
|
||||
#endif ENGINE_MAJOR_VERSION
|
||||
|
||||
DLSSArguments.bHighResolutionMotionVectors = Inputs.bHighResolutionMotionVectors;
|
||||
DLSSArguments.DeltaTime = DeltaWorldTime;
|
||||
DLSSArguments.bReleaseMemoryOnDelete = bReleaseMemoryOnDelete;
|
||||
@@ -537,7 +577,7 @@ FDLSSOutputs FDLSSUpscaler::AddDLSSPass(
|
||||
PassParameters->SceneColorOutput->MarkResourceAsUsed();
|
||||
DLSSArguments.OutputColor = PassParameters->SceneColorOutput->GetRHI();
|
||||
|
||||
RHICmdList.TransitionResource(ERHIAccess::UAVMask, DLSSArguments.OutputColor);
|
||||
RHICmdList.Transition(FRHITransitionInfo(DLSSArguments.OutputColor, ERHIAccess::Unknown, ERHIAccess::UAVMask));
|
||||
RHICmdList.EnqueueLambda(
|
||||
[LocalNGXRHIExtensions, DLSSArguments, DLSSState](FRHICommandListImmediate& Cmd) mutable
|
||||
{
|
||||
@@ -593,127 +633,66 @@ bool FDLSSUpscaler::IsQualityModeSupported(EDLSSQualityMode InQualityMode) const
|
||||
bool FDLSSUpscaler::IsDLSSActive() const
|
||||
{
|
||||
static const auto CVarTemporalAAUpscaler = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAA.Upscaler"));
|
||||
static const IDLSSModuleInterface* DLSSModule = &FModuleManager::LoadModuleChecked<IDLSSModuleInterface>(TEXT("DLSS"));
|
||||
check(DLSSModule);
|
||||
check(CVarTemporalAAUpscaler);
|
||||
const bool bDLSSActive =
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
((GTemporalUpscaler == this) || IsValidUpscalerInstance(this)) &&
|
||||
#else
|
||||
((GCustomStaticScreenPercentage == this) || IsValidUpscalerInstance(this)) &&
|
||||
#endif
|
||||
DLSSModule->QueryDLSSSupport() == EDLSSSupport::Supported &&
|
||||
CVarTemporalAAUpscaler && (CVarTemporalAAUpscaler->GetInt() != 0) &&
|
||||
((CVarNGXDLSSEnable.GetValueOnAnyThread() != 0) || CVarNGXDLAAEnable.GetValueOnAnyThread());
|
||||
return bDLSSActive;
|
||||
}
|
||||
|
||||
|
||||
void FDLSSUpscaler::SetupMainGameViewFamily(FSceneViewFamily& ViewFamily)
|
||||
void FDLSSUpscaler::SetupViewFamily(FSceneViewFamily& ViewFamily)
|
||||
{
|
||||
const bool bDLSSActiveWithAutomation = !GIsAutomationTesting || (GIsAutomationTesting && (CVarNGXDLSSAutomationTesting.GetValueOnAnyThread() != 0));
|
||||
|
||||
if (IsDLSSActive() && bDLSSActiveWithAutomation)
|
||||
const ISceneViewFamilyScreenPercentage* ScreenPercentageInterface = ViewFamily.GetScreenPercentageInterface();
|
||||
float DesiredResolutionFraction = ScreenPercentageInterface->GetResolutionFractionsUpperBound()[GDynamicPrimaryResolutionFraction];
|
||||
|
||||
TOptional<EDLSSQualityMode> SelectedDLSSQualityMode;
|
||||
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to handle the new EDLSSQualityMode enum values");
|
||||
for (EDLSSQualityMode DLSSQualityMode : { EDLSSQualityMode::UltraPerformance, EDLSSQualityMode::Performance , EDLSSQualityMode::Balanced, EDLSSQualityMode::Quality, EDLSSQualityMode::UltraQuality })
|
||||
{
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
checkf(GTemporalUpscaler == this, TEXT("GTemporalUpscaler is not set to a DLSS upscaler . Please check that only one upscaling plugin is active."));
|
||||
#endif
|
||||
checkf(GCustomStaticScreenPercentage == this, TEXT("GCustomStaticScreenPercentage is not set to a DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
|
||||
if (!GIsEditor || (GIsEditor && GIsPlayInEditorWorld && EnableDLSSInPlayInEditorViewports()))
|
||||
bool bIsSupported = FDLSSUpscaler::IsQualityModeSupported(DLSSQualityMode);
|
||||
if (!bIsSupported)
|
||||
{
|
||||
bool bIsDLAAMode = IsDLAAMode();
|
||||
EDLSSQualityMode DLSSQuality;
|
||||
if (bIsDLAAMode)
|
||||
{
|
||||
DLSSQuality = EDLSSQualityMode::Quality;
|
||||
}
|
||||
else if (IsAutoQualityMode())
|
||||
{
|
||||
TOptional<EDLSSQualityMode> MaybeDLSSQuality = GetAutoQualityModeFromViewFamily(ViewFamily);
|
||||
if (!MaybeDLSSQuality.IsSet())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
DLSSQuality = MaybeDLSSQuality.GetValue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DLSSQuality = GetSupportedQualityModeFromCVarValue(CVarNGXDLSSPerfQualitySetting.GetValueOnGameThread());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
ViewFamily.SetTemporalUpscalerInterface(GetUpscalerInstanceForViewFamily(this, DLSSQuality));
|
||||
float MinResolutionFraction = FDLSSUpscaler::GetMinResolutionFractionForQuality(DLSSQualityMode);
|
||||
float MaxResolutionFraction = FDLSSUpscaler::GetMaxResolutionFractionForQuality(DLSSQualityMode);
|
||||
float TargetResolutionFraction = FDLSSUpscaler::GetOptimalResolutionFractionForQuality(DLSSQualityMode);
|
||||
|
||||
if (ViewFamily.EngineShowFlags.ScreenPercentage && !ViewFamily.GetScreenPercentageInterface())
|
||||
{
|
||||
// DLSS uses recommended resolution fraction, DLAA forces a 1.0 scale
|
||||
float ResolutionFraction = 1.0f;
|
||||
if (!bIsDLAAMode)
|
||||
{
|
||||
ResolutionFraction = GetOptimalResolutionFractionForQuality(DLSSQuality);
|
||||
}
|
||||
ViewFamily.SetScreenPercentageInterface(new FLegacyScreenPercentageDriver(
|
||||
ViewFamily, ResolutionFraction
|
||||
#if SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE
|
||||
/* AllowPostProcessSettingsScreenPercentage = */ , false
|
||||
#endif
|
||||
|
||||
));
|
||||
}
|
||||
bool bIsCompatible = DesiredResolutionFraction <= 1.0 &&
|
||||
DesiredResolutionFraction >= (MinResolutionFraction - kDLSSResolutionFractionError) &&
|
||||
DesiredResolutionFraction <= (MaxResolutionFraction + kDLSSResolutionFractionError);
|
||||
bool bIsClosestYet = false;
|
||||
if (SelectedDLSSQualityMode.IsSet())
|
||||
{
|
||||
float SelectedTargetResolutionFraction = FDLSSUpscaler::GetOptimalResolutionFractionForQuality(SelectedDLSSQualityMode.GetValue());
|
||||
bIsClosestYet = FMath::Abs(TargetResolutionFraction - DesiredResolutionFraction) < FMath::Abs(SelectedTargetResolutionFraction - DesiredResolutionFraction);
|
||||
}
|
||||
else if (bIsCompatible)
|
||||
{
|
||||
bIsClosestYet = true;
|
||||
}
|
||||
|
||||
if (bIsCompatible && bIsClosestYet)
|
||||
{
|
||||
SelectedDLSSQualityMode = DLSSQualityMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if DLSS_ENGINE_SUPPORTS_CSSPD
|
||||
void FDLSSUpscaler::SetupViewFamily(FSceneViewFamily& ViewFamily, TSharedPtr<ICustomStaticScreenPercentageData> InScreenPercentageDataInterface)
|
||||
{
|
||||
check(InScreenPercentageDataInterface.IsValid());
|
||||
TSharedPtr<FDLSSViewportQualitySetting> ScreenPercentageData = StaticCastSharedPtr<FDLSSViewportQualitySetting>(InScreenPercentageDataInterface);
|
||||
|
||||
EDLSSQualityMode Quality = static_cast<EDLSSQualityMode>(ScreenPercentageData->QualitySetting);
|
||||
const bool bIsDLAAMode = ScreenPercentageData->bDLAAEnabled;
|
||||
if (bIsDLAAMode)
|
||||
if (SelectedDLSSQualityMode.IsSet())
|
||||
{
|
||||
Quality = EDLSSQualityMode::Quality;
|
||||
ViewFamily.SetTemporalUpscalerInterface(new FDLSSSceneViewFamilyUpscaler(this, SelectedDLSSQualityMode.GetValue()));
|
||||
}
|
||||
if (!IsQualityModeSupported(Quality))
|
||||
else if (DesiredResolutionFraction != PreviousResolutionFraction)
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("DLSS Quality mode is not supported %d"), Quality);
|
||||
return;
|
||||
UE_LOG(LogDLSS, Warning, TEXT("Could not setup DLSS upscaler for screen percentage = %f"), DesiredResolutionFraction * 100.0f);
|
||||
}
|
||||
const bool bDLSSActiveWithAutomation = !GIsAutomationTesting || (GIsAutomationTesting && (CVarNGXDLSSAutomationTesting.GetValueOnAnyThread() != 0));
|
||||
if (IsDLSSActive() && bDLSSActiveWithAutomation)
|
||||
{
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
checkf(GTemporalUpscaler == this, TEXT("GTemporalUpscaler is not set to a DLSS upscaler . Please check that only one upscaling plugin is active."));
|
||||
#endif
|
||||
checkf(GCustomStaticScreenPercentage == this, TEXT("GCustomStaticScreenPercentage is not set to a DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
|
||||
ViewFamily.SetTemporalUpscalerInterface(GetUpscalerInstanceForViewFamily(this, Quality));
|
||||
|
||||
if (ViewFamily.EngineShowFlags.ScreenPercentage && !ViewFamily.GetScreenPercentageInterface())
|
||||
{
|
||||
const float ResolutionFraction = bIsDLAAMode ? 1.0f : GetOptimalResolutionFractionForQuality(Quality);
|
||||
ViewFamily.SetScreenPercentageInterface(new FLegacyScreenPercentageDriver(
|
||||
ViewFamily, ResolutionFraction
|
||||
#if SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE
|
||||
/* AllowPostProcessSettingsScreenPercentage = */ , false
|
||||
#endif
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
TOptional<EDLSSQualityMode> FDLSSUpscaler::GetAutoQualityModeFromViewFamily(const FSceneViewFamily& ViewFamily) const
|
||||
{
|
||||
if (ensure(ViewFamily.RenderTarget != nullptr))
|
||||
{
|
||||
FIntPoint ViewSize = ViewFamily.RenderTarget->GetSizeXY();
|
||||
int32 Pixels = ViewSize.X * ViewSize.Y;
|
||||
return GetAutoQualityModeFromPixels(Pixels);
|
||||
}
|
||||
|
||||
return TOptional<EDLSSQualityMode> {};
|
||||
PreviousResolutionFraction = DesiredResolutionFraction;
|
||||
}
|
||||
|
||||
TOptional<EDLSSQualityMode> FDLSSUpscaler::GetAutoQualityModeFromPixels(int PixelCount) const
|
||||
@@ -735,7 +714,7 @@ TOptional<EDLSSQualityMode> FDLSSUpscaler::GetAutoQualityModeFromPixels(int Pixe
|
||||
}
|
||||
|
||||
|
||||
bool FDLSSUpscaler::EnableDLSSInPlayInEditorViewports() const
|
||||
bool FDLSSUpscaler::EnableDLSSInPlayInEditorViewports() const
|
||||
{
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableDLSSInPlayInEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
@@ -747,16 +726,6 @@ bool FDLSSUpscaler::EnableDLSSInPlayInEditorViewports() const
|
||||
}
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetMinUpsampleResolutionFraction() const
|
||||
{
|
||||
return MinResolutionFraction;
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetMaxUpsampleResolutionFraction() const
|
||||
{
|
||||
return MaxResolutionFraction;
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetOptimalResolutionFractionForQuality(EDLSSQualityMode Quality) const
|
||||
{
|
||||
checkf(IsQualityModeSupported(Quality),TEXT("%u is not a valid Quality mode"), Quality);
|
||||
|
||||
@@ -12,13 +12,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SceneViewExtension.h"
|
||||
#include "RendererInterface.h"
|
||||
#include "PostProcess/TemporalAA.h"
|
||||
#include "ScreenPass.h"
|
||||
#include "NGXRHI.h"
|
||||
#include "DLSSSettings.h"
|
||||
|
||||
#include "CustomStaticScreenPercentage.h"
|
||||
#include "CustomResourcePool.h"
|
||||
|
||||
class FSceneTextureParameters;
|
||||
@@ -28,6 +27,8 @@ struct FTemporalAAHistory;
|
||||
class FRHITexture;
|
||||
class NGXRHI;
|
||||
struct FDLSSOptimalSettings;
|
||||
class FDLSSUpscaler;
|
||||
|
||||
struct FDLSSPassParameters
|
||||
{
|
||||
FIntRect InputViewRect;
|
||||
@@ -68,44 +69,61 @@ enum class EDLSSQualityMode
|
||||
NumValues = 5
|
||||
};
|
||||
|
||||
class DLSS_API FDLSSUpscaler final : public ITemporalUpscaler, public ICustomStaticScreenPercentage, public ICustomResourcePool
|
||||
class DLSS_API FDLSSUpscalerViewExtension final : public FSceneViewExtensionBase
|
||||
{
|
||||
public:
|
||||
FDLSSUpscalerViewExtension(const FAutoRegister& AutoRegister) : FSceneViewExtensionBase(AutoRegister)
|
||||
{ }
|
||||
|
||||
virtual void SetupViewFamily(FSceneViewFamily& InViewFamily) override {}
|
||||
virtual void SetupView(FSceneViewFamily& InViewFamily, FSceneView& InView) override {}
|
||||
virtual void BeginRenderViewFamily(FSceneViewFamily& InViewFamily) override;
|
||||
virtual void PreRenderView_RenderThread(FRDGBuilder& GraphBuilder, FSceneView& InView) final override {}
|
||||
virtual void PreRenderViewFamily_RenderThread(FRDGBuilder& GraphBuilder, FSceneViewFamily& InViewFamily) final override {}
|
||||
virtual bool IsActiveThisFrame_Internal(const FSceneViewExtensionContext& Context) const override;
|
||||
};
|
||||
|
||||
class DLSS_API FDLSSSceneViewFamilyUpscaler final : public ITemporalUpscaler
|
||||
{
|
||||
public:
|
||||
FDLSSSceneViewFamilyUpscaler(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InDLSSQualityMode)
|
||||
: Upscaler(InUpscaler)
|
||||
, DLSSQualityMode(InDLSSQualityMode)
|
||||
{ }
|
||||
|
||||
virtual const TCHAR* GetDebugName() const final override;
|
||||
virtual float GetMinUpsampleResolutionFraction() const final override;
|
||||
virtual float GetMaxUpsampleResolutionFraction() const final override;
|
||||
virtual ITemporalUpscaler* Fork_GameThread(const class FSceneViewFamily& ViewFamily) const final override;
|
||||
virtual ITemporalUpscaler::FOutputs AddPasses(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FPassInputs& PassInputs) const final override;
|
||||
|
||||
static bool IsDLSSTemporalUpscaler(const ITemporalUpscaler* TemporalUpscaler);
|
||||
|
||||
private:
|
||||
const FDLSSUpscaler* Upscaler;
|
||||
const EDLSSQualityMode DLSSQualityMode;
|
||||
|
||||
FDLSSOutputs AddDLSSPass(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FDLSSPassParameters& Inputs,
|
||||
const FTemporalAAHistory& InputHistory,
|
||||
FTemporalAAHistory* OutputHistory,
|
||||
const TRefCountPtr<ICustomTemporalAAHistory> InputCustomHistoryInterface,
|
||||
TRefCountPtr<ICustomTemporalAAHistory>* OutputCustomHistoryInterface
|
||||
) const;
|
||||
};
|
||||
|
||||
class DLSS_API FDLSSUpscaler final : public ICustomResourcePool
|
||||
{
|
||||
|
||||
friend class FDLSSModule;
|
||||
public:
|
||||
|
||||
|
||||
FDLSSUpscaler(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InQualityMode);
|
||||
virtual ~FDLSSUpscaler();
|
||||
// Inherited via ITemporalUpscaler
|
||||
virtual const TCHAR* GetDebugName() const final;
|
||||
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
virtual void AddPasses(
|
||||
#else
|
||||
virtual ITemporalUpscaler::FOutputs AddPasses(
|
||||
#endif
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FPassInputs& PassInputs
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
, FRDGTextureRef* OutSceneColorTexture
|
||||
, FIntRect* OutSceneColorViewRect
|
||||
, FRDGTextureRef* OutSceneColorHalfResTexture
|
||||
, FIntRect* OutSceneColorHalfResViewRect
|
||||
#endif
|
||||
) const final;
|
||||
|
||||
// Inherited via ICustomStaticScreenPercentage
|
||||
virtual void SetupMainGameViewFamily(FSceneViewFamily& ViewFamily) final;
|
||||
|
||||
#if DLSS_ENGINE_SUPPORTS_CSSPD
|
||||
/** Allows to setup View Family directly. To be used by modules that are aware of DLSS Plugin. */
|
||||
virtual void SetupViewFamily(FSceneViewFamily& ViewFamily, TSharedPtr<ICustomStaticScreenPercentageData> InScreenPercentageDataInterface) final;
|
||||
#endif
|
||||
|
||||
virtual float GetMinUpsampleResolutionFraction() const final;
|
||||
virtual float GetMaxUpsampleResolutionFraction() const final;
|
||||
void SetupViewFamily(FSceneViewFamily& ViewFamily);
|
||||
|
||||
float GetOptimalResolutionFractionForQuality(EDLSSQualityMode Quality) const;
|
||||
float GetOptimalSharpnessForQuality(EDLSSQualityMode Quality) const;
|
||||
@@ -129,61 +147,40 @@ public:
|
||||
|
||||
bool IsDLSSActive() const;
|
||||
|
||||
static FDLSSUpscaler* GetUpscalerInstanceForViewFamily(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InQualityMode);
|
||||
static bool IsValidUpscalerInstance(const ITemporalUpscaler* InUpscaler);
|
||||
|
||||
static bool IsDLAAMode();
|
||||
static bool IsAutoQualityMode();
|
||||
static void SetAutoQualityMode(bool bAutoQualityMode);
|
||||
|
||||
// Give the suggested EDLSSQualityMode if one is appropriate for the given pixel count, or nothing if DLSS should be disabled
|
||||
TOptional<EDLSSQualityMode> GetAutoQualityModeFromPixels(int PixelCount) const;
|
||||
|
||||
static void ReleaseStaticResources();
|
||||
|
||||
static float GetMinUpsampleResolutionFraction()
|
||||
{
|
||||
return MinDynamicResolutionFraction;
|
||||
}
|
||||
|
||||
static float GetMaxUpsampleResolutionFraction()
|
||||
{
|
||||
return MaxDynamicResolutionFraction;
|
||||
}
|
||||
|
||||
private:
|
||||
FDLSSUpscaler(NGXRHI* InNGXRHIExtensions);
|
||||
FDLSSUpscaler(const FDLSSUpscaler&) = default;
|
||||
|
||||
|
||||
EDLSSQualityMode GetSupportedQualityModeFromCVarValue(int32 InCVarValue) const
|
||||
{
|
||||
checkf(NumRuntimeQualityModes, TEXT("This should only be called from the higher level code when DLSS is supported") );
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to handle the new EDLSSQualityMode enum values");
|
||||
for (auto QualityMode : { EDLSSQualityMode::UltraPerformance, EDLSSQualityMode::Performance , EDLSSQualityMode::Balanced, EDLSSQualityMode::Quality, EDLSSQualityMode::UltraQuality })
|
||||
{
|
||||
if (InCVarValue == static_cast<int32>(QualityMode) && IsQualityModeSupported(QualityMode))
|
||||
{
|
||||
return QualityMode;
|
||||
}
|
||||
}
|
||||
return EDLSSQualityMode::Balanced;
|
||||
}
|
||||
|
||||
TOptional<EDLSSQualityMode> GetAutoQualityModeFromViewFamily(const FSceneViewFamily& ViewFamily) const;
|
||||
|
||||
bool EnableDLSSInPlayInEditorViewports() const;
|
||||
FDLSSOutputs AddDLSSPass(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FDLSSPassParameters& Inputs,
|
||||
const FTemporalAAHistory& InputHistory,
|
||||
FTemporalAAHistory* OutputHistory,
|
||||
const TRefCountPtr<ICustomTemporalAAHistory> InputCustomHistoryInterface,
|
||||
TRefCountPtr<ICustomTemporalAAHistory>* OutputCustomHistoryInterface
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
EDLSSQualityMode DLSSQualityMode = EDLSSQualityMode::NumValues;
|
||||
|
||||
// The FDLSSUpscaler(NGXRHI*) will update those once
|
||||
static NGXRHI* NGXRHIExtensions;
|
||||
static float MinResolutionFraction;
|
||||
static float MaxResolutionFraction;
|
||||
static float MinDynamicResolutionFraction;
|
||||
static float MaxDynamicResolutionFraction;
|
||||
|
||||
static uint32 NumRuntimeQualityModes;
|
||||
static TArray<FDLSSOptimalSettings> ResolutionSettings;
|
||||
float PreviousResolutionFraction;
|
||||
|
||||
static TStaticArray <TSharedPtr<FDLSSUpscaler>, uint32(EDLSSQualityMode::NumValues)> DLSSUpscalerInstancesPerViewFamily;
|
||||
friend class FDLSSUpscalerViewExtension;
|
||||
friend class FDLSSSceneViewFamilyUpscaler;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
|
||||
* rights in and to this software, related documentation and any modifications thereto.
|
||||
* Any use, reproduction, disclosure or distribution of this software and related
|
||||
* documentation without an express license agreement from NVIDIA Corporation is strictly
|
||||
* prohibited.
|
||||
*
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
|
||||
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
|
||||
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
|
||||
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGES.
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -26,7 +17,7 @@
|
||||
|
||||
class DLSS_API FDLSSUpscalerHistory final : public ICustomTemporalAAHistory, public FRefCountBase
|
||||
{
|
||||
friend class FDLSSUpscaler;
|
||||
friend class FDLSSSceneViewFamilyUpscaler;
|
||||
|
||||
FDLSSStateRef DLSSState;
|
||||
|
||||
|
||||
@@ -1,21 +1,12 @@
|
||||
/*
|
||||
* Copyright (c) 2020 NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
|
||||
* rights in and to this software, related documentation and any modifications thereto.
|
||||
* Any use, reproduction, disclosure or distribution of this software and related
|
||||
* documentation without an express license agreement from NVIDIA Corporation is strictly
|
||||
* prohibited.
|
||||
*
|
||||
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
|
||||
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
|
||||
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
|
||||
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
|
||||
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
|
||||
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGES.
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@@ -24,6 +15,8 @@
|
||||
|
||||
class FDLSSUpscaler;
|
||||
class FDLSSDenoiser;
|
||||
class ISceneViewExtension;
|
||||
class FDLSSUpscalerViewExtension;
|
||||
class FNGXAutomationViewExtension;
|
||||
class NGXRHI;
|
||||
|
||||
@@ -46,6 +39,7 @@ class IDLSSModuleInterface : public IModuleInterface
|
||||
virtual void GetDLSSMinDriverVersion(int32& MajorVersion, int32& MinorVersion) const = 0;
|
||||
virtual float GetResolutionFractionForQuality(int32 Quality) const = 0;
|
||||
virtual FDLSSUpscaler* GetDLSSUpscaler() const = 0;
|
||||
virtual TSharedPtr< ISceneViewExtension, ESPMode::ThreadSafe> GetDLSSUpscalerViewExtension() const = 0;
|
||||
};
|
||||
|
||||
class FDLSSModule final: public IDLSSModuleInterface
|
||||
@@ -60,13 +54,16 @@ public:
|
||||
virtual EDLSSSupport QueryDLSSSupport() const;
|
||||
virtual void GetDLSSMinDriverVersion(int32& MajorVersion, int32& MinorVersion) const;
|
||||
virtual float GetResolutionFractionForQuality(int32 Quality) const;
|
||||
virtual FDLSSUpscaler* GetDLSSUpscaler() const ;
|
||||
virtual FDLSSUpscaler* GetDLSSUpscaler() const;
|
||||
|
||||
virtual TSharedPtr< ISceneViewExtension, ESPMode::ThreadSafe> GetDLSSUpscalerViewExtension() const;
|
||||
|
||||
private:
|
||||
|
||||
TUniquePtr<FDLSSUpscaler> DLSSUpscaler;
|
||||
TUniquePtr<FDLSSDenoiser> DLSSDenoiser;
|
||||
TUniquePtr<NGXRHI> NGXRHIExtensions;
|
||||
TSharedPtr< FDLSSUpscalerViewExtension, ESPMode::ThreadSafe> DLSSUpscalerViewExtension;
|
||||
TSharedPtr< FNGXAutomationViewExtension, ESPMode::ThreadSafe> NGXAutomationViewExtension;
|
||||
EDLSSSupport DLSSSupport = EDLSSSupport::NotSupported;
|
||||
int32 MinDriverVersionMinor;
|
||||
|
||||
@@ -13,8 +13,7 @@
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Engine/DeveloperSettings.h"
|
||||
#include "CustomStaticScreenPercentage.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#include "SceneView.h"
|
||||
|
||||
#include "DLSSSettings.generated.h"
|
||||
|
||||
@@ -33,24 +32,20 @@ public:
|
||||
|
||||
GENERATED_BODY()
|
||||
|
||||
/** This enables DLSS in editor viewports. Saved to local user config only.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport (Local)", DisplayName = "Enable DLSS to be turned on in Editor viewports")
|
||||
/** This enables DLSS/DLAA in editor viewports. Saved to local user config only.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport (Local)", DisplayName = "Enable DLSS/DLAA to be turned on in Editor viewports")
|
||||
EDLSSSettingOverride EnableDLSSInEditorViewportsOverride = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
/** This setting enables adjusting the screenpercentage directly in the editor, outside of the optimized DLSS quality modes. Saved to local user config only.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport (Local)", DisplayName = "Enable Screenpercentage Manipulation in DLSS Editor Viewports")
|
||||
EDLSSSettingOverride EnableScreenpercentageManipulationInDLSSEditorViewportsOverride = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
/** This enables DLSS in play in editor viewports. Saved to local user config only. */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport (Local)", DisplayName = "Enable DLSS in Play In Editor viewports")
|
||||
/** This enables DLSS/DLAA in play in editor viewports. Saved to local user config only. */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport (Local)", DisplayName = "Enable DLSS/DLAA in Play In Editor viewports")
|
||||
EDLSSSettingOverride EnableDLSSInPlayInEditorViewportsOverride = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
/** This enables warnings about plugins & tools that are incompatible with DLSS in the editor. Saved to local user config only. */
|
||||
/** This enables warnings about plugins & tools that are incompatible with DLSS/DLAA in the editor. Saved to local user config only. */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Editor (Local)", DisplayName = "Warn about incompatible plugins and tools")
|
||||
bool bShowDLSSIncompatiblePluginsToolsWarnings = true;
|
||||
|
||||
/** This enables on screen warnings and errors about DLSS */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Editor (Local)", DisplayName = "Show various DLSS on screen debug messages")
|
||||
/** This enables on screen warnings and errors about DLSS/DLAA */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Editor (Local)", DisplayName = "Show various DLSS/DLAA on screen debug messages")
|
||||
EDLSSSettingOverride ShowDLSSSDebugOnScreenMessages = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
};
|
||||
@@ -64,32 +59,28 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
/** Enable DLSS for D3D12, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS for the D3D12RHI")
|
||||
/** Enable DLSS/DLAA for D3D12, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS/DLAA for the D3D12RHI")
|
||||
bool bEnableDLSSD3D12 = PLATFORM_WINDOWS;
|
||||
|
||||
/** Enable DLSS for D3D11, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS for the D3D11RHI")
|
||||
/** Enable DLSS/DLAA for D3D11, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS/DLAA for the D3D11RHI")
|
||||
bool bEnableDLSSD3D11 = PLATFORM_WINDOWS;
|
||||
|
||||
/** Enable DLSS for Vulkan, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS for the VulkanRHI")
|
||||
/** Enable DLSS/DLAA for Vulkan, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS/DLAA for the VulkanRHI")
|
||||
bool bEnableDLSSVulkan = PLATFORM_WINDOWS;
|
||||
|
||||
/** This enables DLSS in editor viewports. This project wide setting can be locally overridden in the NVIDIA DLSS (Local) settings.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Enable DLSS to be turned on in Editor viewports")
|
||||
bool bEnableDLSSInEditorViewports = true;
|
||||
/** This enables DLSS/DLAA in editor viewports. This project wide setting can be locally overridden in the NVIDIA DLSS (Local) settings.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Enable DLSS/DLAA to be turned on in Editor viewports")
|
||||
bool bEnableDLSSInEditorViewports = false;
|
||||
|
||||
/** This setting enables adjusting the screenpercentage directly in the editor, outside of the optimized DLSS quality modes. This project wide setting can be locally overridden in the NVIDIA DLSS (Local) settings.*/
|
||||
UPROPERTY(Config = Editor, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Enable Screenpercentage Manipulation in DLSS Editor Viewports")
|
||||
bool bEnableScreenpercentageManipulationInDLSSEditorViewports = false;
|
||||
|
||||
/** This enables DLSS in play in editor viewports. This project wide setting can be locally overridden in in the NVIDIA DLSS (Local) settings.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Enable DLSS in Play In Editor viewports")
|
||||
/** This enables DLSS/DLAA in play in editor viewports. This project wide setting can be locally overridden in in the NVIDIA DLSS (Local) settings.*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Enable DLSS/DLAA in Play In Editor viewports")
|
||||
bool bEnableDLSSInPlayInEditorViewports = true;
|
||||
|
||||
/** This enables on screen warnings and errors about DLSS. This project wide setting can be locally overridden in the NVIDIA DLSS (Local) settings. */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Show various DLSS on screen debug messages")
|
||||
/** This enables on screen warnings and errors about DLSS/DLAA. This project wide setting can be locally overridden in the NVIDIA DLSS (Local) settings. */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Level Editor - Viewport", DisplayName = "Show various DLSS/DLAA on screen debug messages")
|
||||
bool bShowDLSSSDebugOnScreenMessages = true;
|
||||
|
||||
/** This is part of the DLSS plugin and used by most projects*/
|
||||
@@ -99,7 +90,7 @@ public:
|
||||
UPROPERTY(VisibleAnywhere, Config, Category = "General Settings", DisplayName = "Exists")
|
||||
bool bGenericDLSSBinaryExists;
|
||||
|
||||
/** By default the DLSS plugin uses the UE Project ID to initalize DLSS. In some cases NVIDIA might provide a separate NVIDIA Application ID, which should be put here. Please refer to https://developer.nvidia.com/dlss for details*/
|
||||
/** By default the DLSS plugin uses the UE Project ID to initialize DLSS. In some cases NVIDIA might provide a separate NVIDIA Application ID, which should be put here. Please refer to https://developer.nvidia.com/dlss for details*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "General Settings", DisplayName = "NVIDIA NGX Application ID", AdvancedDisplay)
|
||||
uint32 NVIDIANGXApplicationId;
|
||||
|
||||
@@ -110,12 +101,3 @@ public:
|
||||
bool bCustomDLSSBinaryExists;
|
||||
};
|
||||
|
||||
// This is publically defined in the .Build.cs so it can key off branch names, which is not feasible to do with the preprocessor
|
||||
#if DLSS_ENGINE_SUPPORTS_CSSPD
|
||||
class FDLSSViewportQualitySetting final : public ICustomStaticScreenPercentageData
|
||||
{
|
||||
public:
|
||||
int32 QualitySetting = 0;
|
||||
bool bDLAAEnabled = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user