Adds everything
This commit is contained in:
12
Plugins/DLSS/Config/FilterPlugin.ini
Normal file
12
Plugins/DLSS/Config/FilterPlugin.ini
Normal file
@@ -0,0 +1,12 @@
|
||||
[FilterPlugin]
|
||||
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
|
||||
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
|
||||
;
|
||||
; Examples:
|
||||
; /README.txt
|
||||
; /Extras/...
|
||||
; /Binaries/ThirdParty/*.dll
|
||||
|
||||
|
||||
/Config/...
|
||||
|
||||
87
Plugins/DLSS/DLSS.uplugin
Normal file
87
Plugins/DLSS/DLSS.uplugin
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 12,
|
||||
"VersionName": "2.3.5",
|
||||
"FriendlyName": "NVIDIA DLSS",
|
||||
"Description": "NVIDIA Deep Learning Super Sampling",
|
||||
"Category": "Rendering",
|
||||
"CreatedBy": "NVIDIA",
|
||||
"CreatedByURL": "https://developer.nvidia.com/dlss",
|
||||
"DocsURL": "",
|
||||
"MarketplaceURL": "https://www.unrealengine.com/marketplace/en-US/product/nvidia-dlss",
|
||||
"SupportURL": "mailto:DLSS-Support@nvidia.com",
|
||||
"EngineVersion": "4.27.0",
|
||||
"CanContainContent": true,
|
||||
"Installed": true,
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "DLSSUtility",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostConfigInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "DLSS",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "DLSSBlueprint",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostConfigInit"
|
||||
},
|
||||
{
|
||||
"Name": "NGXRHI",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "NGXD3D11RHI",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "NGXD3D12RHI",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "NGXVulkanRHIPreInit",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostConfigInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "NGXVulkanRHI",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "DLSSEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [
|
||||
"Win64"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Plugins/DLSS/Resources/Icon128.png
(Stored with Git LFS)
Normal file
BIN
Plugins/DLSS/Resources/Icon128.png
(Stored with Git LFS)
Normal file
Binary file not shown.
199
Plugins/DLSS/Shaders/Private/VelocityCombine.usf
Normal file
199
Plugins/DLSS/Shaders/Private/VelocityCombine.usf
Normal file
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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 "/Engine/Private/Common.ush"
|
||||
#include "/Engine/Private/FastMath.ush"
|
||||
#include "/Engine/Private/ScreenPass.ush"
|
||||
|
||||
#ifndef THREADGROUP_SIZEX
|
||||
#define THREADGROUP_SIZEX 8
|
||||
#endif
|
||||
#ifndef THREADGROUP_SIZEY
|
||||
#define THREADGROUP_SIZEY 8
|
||||
#endif
|
||||
#define THREADGROUP_TOTALSIZE (THREADGROUP_SIZEX * THREADGROUP_SIZEY)
|
||||
|
||||
#ifndef DILATE_MOTION_VECTORS
|
||||
#define DILATE_MOTION_VECTORS 0
|
||||
#endif
|
||||
|
||||
#if DILATE_MOTION_VECTORS
|
||||
#define AA_CROSS 1
|
||||
float2 TemporalJitterPixels;
|
||||
#else
|
||||
#endif
|
||||
|
||||
Texture2D VelocityTexture;
|
||||
SamplerState VelocityTextureSampler;
|
||||
SCREEN_PASS_TEXTURE_VIEWPORT(Velocity)
|
||||
|
||||
Texture2D DepthTexture;
|
||||
SamplerState DepthTextureSampler;
|
||||
|
||||
RWTexture2D<float2> OutVelocityCombinedTexture;
|
||||
SCREEN_PASS_TEXTURE_VIEWPORT(CombinedVelocity)
|
||||
|
||||
|
||||
|
||||
|
||||
[numthreads(THREADGROUP_SIZEX, THREADGROUP_SIZEY, 1)]
|
||||
void VelocityCombineMain(
|
||||
uint2 GroupId : SV_GroupID,
|
||||
uint2 DispatchThreadId : SV_DispatchThreadID,
|
||||
uint2 GroupThreadId : SV_GroupThreadID,
|
||||
uint GroupIndex : SV_GroupIndex)
|
||||
{
|
||||
uint2 PixelPos = min(DispatchThreadId + Velocity_ViewportMin, Velocity_ViewportMax - 1);
|
||||
|
||||
// CombinedVelocity_ViewportMin is expected to be 0, but in case it is not
|
||||
uint2 OutputPixelPos = CombinedVelocity_ViewportMin + DispatchThreadId;
|
||||
const bool bInsideViewport = all(PixelPos.xy < Velocity_ViewportMax);
|
||||
|
||||
BRANCH
|
||||
if (!bInsideViewport)
|
||||
return;
|
||||
|
||||
#if DILATE_MOTION_VECTORS // TODO: 2x2.
|
||||
|
||||
// Screen position of minimum depth.
|
||||
float2 VelocityOffset = float2(0.0, 0.0);
|
||||
|
||||
float2 NearestBufferUV = (PixelPos + 0.5f) * Velocity_ViewportSizeInverse;
|
||||
|
||||
//float2 ViewportUV = NearestBufferUV;
|
||||
float2 ViewportUV = (float2(DispatchThreadId) + 0.5f) * CombinedVelocity_ViewportSizeInverse;
|
||||
|
||||
// Pixel coordinate of the center of output pixel O in the input viewport.
|
||||
float2 PPCo = ViewportUV * Velocity_ViewportSize + TemporalJitterPixels;
|
||||
|
||||
// Pixel coordinate of the center of the nearest input pixel K.
|
||||
float2 PPCk = floor(PPCo) + 0.5;
|
||||
|
||||
// Pixel coordinate of the center of the nearest top left input pixel T.
|
||||
float2 PPCt = floor(PPCo - 0.5) + 0.5;
|
||||
|
||||
NearestBufferUV = Velocity_ExtentInverse * (Velocity_ViewportMin + PPCk);
|
||||
|
||||
// FIND MOTION OF PIXEL AND NEAREST IN NEIGHBORHOOD
|
||||
// ------------------------------------------------
|
||||
float3 PosN; // Position of this pixel, possibly later nearest pixel in neighborhood.
|
||||
PosN.xy = ViewportUVToScreenPos(ViewportUV);
|
||||
PosN.z = DepthTexture.SampleLevel(DepthTextureSampler, NearestBufferUV, 0).x;
|
||||
|
||||
{
|
||||
// For motion vector, use camera/dynamic motion from min depth pixel in pattern around pixel.
|
||||
// This enables better quality outline on foreground against different motion background.
|
||||
// Larger 2 pixel distance "x" works best (because AA dilates surface).
|
||||
float4 Depths;
|
||||
Depths.x = DepthTexture.SampleLevel(DepthTextureSampler, NearestBufferUV, 0, int2(-AA_CROSS, -AA_CROSS)).x;
|
||||
Depths.y = DepthTexture.SampleLevel(DepthTextureSampler, NearestBufferUV, 0, int2(AA_CROSS, -AA_CROSS)).x;
|
||||
Depths.z = DepthTexture.SampleLevel(DepthTextureSampler, NearestBufferUV, 0, int2(-AA_CROSS, AA_CROSS)).x;
|
||||
Depths.w = DepthTexture.SampleLevel(DepthTextureSampler, NearestBufferUV, 0, int2(AA_CROSS, AA_CROSS)).x;
|
||||
|
||||
float2 DepthOffset = float2(AA_CROSS, AA_CROSS);
|
||||
float DepthOffsetXx = float(AA_CROSS);
|
||||
#if HAS_INVERTED_Z_BUFFER
|
||||
// Nearest depth is the largest depth (depth surface 0=far, 1=near).
|
||||
if (Depths.x > Depths.y)
|
||||
{
|
||||
DepthOffsetXx = -AA_CROSS;
|
||||
}
|
||||
if (Depths.z > Depths.w)
|
||||
{
|
||||
DepthOffset.x = -AA_CROSS;
|
||||
}
|
||||
float DepthsXY = max(Depths.x, Depths.y);
|
||||
float DepthsZW = max(Depths.z, Depths.w);
|
||||
if (DepthsXY > DepthsZW)
|
||||
{
|
||||
DepthOffset.y = -AA_CROSS;
|
||||
DepthOffset.x = DepthOffsetXx;
|
||||
}
|
||||
float DepthsXYZW = max(DepthsXY, DepthsZW);
|
||||
if (DepthsXYZW > PosN.z)
|
||||
{
|
||||
// This is offset for reading from velocity texture.
|
||||
// This supports half or fractional resolution velocity textures.
|
||||
// With the assumption that UV position scales between velocity and color.
|
||||
VelocityOffset = DepthOffset * Velocity_ExtentInverse;
|
||||
// This is [0 to 1] flipped in Y.
|
||||
//PosN.xy = ScreenPos + DepthOffset * ViewportSize.zw * 2.0;
|
||||
PosN.z = DepthsXYZW;
|
||||
}
|
||||
#else // !HAS_INVERTED_Z_BUFFER
|
||||
#error Fix me!
|
||||
#endif // !HAS_INVERTED_Z_BUFFER
|
||||
}
|
||||
// Camera motion for pixel or nearest pixel (in ScreenPos space).
|
||||
bool OffScreen = false;
|
||||
float Velocity = 0;
|
||||
float HistoryBlur = 0;
|
||||
|
||||
float4 ThisClip = float4(PosN.xy, PosN.z, 1);
|
||||
float4 PrevClip = mul(ThisClip, View.ClipToPrevClip);
|
||||
float2 PrevScreen = PrevClip.xy / PrevClip.w;
|
||||
float2 BackN = PosN.xy - PrevScreen;
|
||||
|
||||
float2 BackTemp = BackN * Velocity_ViewportSize;
|
||||
|
||||
float4 VelocityN = VelocityTexture.SampleLevel(VelocityTextureSampler, NearestBufferUV + VelocityOffset, 0);
|
||||
bool DynamicN = VelocityN.x > 0.0;
|
||||
if (DynamicN)
|
||||
{
|
||||
BackN = DecodeVelocityFromTexture(VelocityN).xy;
|
||||
}
|
||||
BackTemp = BackN * CombinedVelocity_ViewportSize;
|
||||
|
||||
OutVelocityCombinedTexture[OutputPixelPos].xy = -BackTemp * float2(0.5, -0.5);
|
||||
|
||||
#else
|
||||
float4 EncodedVelocity = VelocityTexture[PixelPos];
|
||||
float Depth = DepthTexture[PixelPos].x;
|
||||
|
||||
float2 Velocity;
|
||||
if (all(EncodedVelocity.xy > 0))
|
||||
{
|
||||
Velocity = DecodeVelocityFromTexture(EncodedVelocity).xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
float4 ClipPos;
|
||||
ClipPos.xy = SvPositionToScreenPosition(float4(PixelPos.xy, 0, 1)).xy;
|
||||
ClipPos.z = Depth;
|
||||
ClipPos.w = 1;
|
||||
|
||||
float4 PrevClipPos = mul(ClipPos, View.ClipToPrevClip);
|
||||
|
||||
if (PrevClipPos.w > 0)
|
||||
{
|
||||
float2 PrevScreen = PrevClipPos.xy / PrevClipPos.w;
|
||||
Velocity = ClipPos.xy - PrevScreen.xy;
|
||||
}
|
||||
else
|
||||
{
|
||||
Velocity = EncodedVelocity.xy;
|
||||
}
|
||||
}
|
||||
|
||||
float2 OutVelocity = Velocity * float2(0.5, -0.5) * View.ViewSizeAndInvSize.xy;
|
||||
|
||||
OutVelocityCombinedTexture[OutputPixelPos].xy = -OutVelocity;
|
||||
#endif
|
||||
}
|
||||
103
Plugins/DLSS/Source/DLSS/DLSS.Build.cs
Normal file
103
Plugins/DLSS/Source/DLSS/DLSS.Build.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class DLSS : ModuleRules
|
||||
{
|
||||
public virtual string [] SupportedDynamicallyLoadedNGXRHIModules(ReadOnlyTargetRules Target)
|
||||
{
|
||||
if(Target.Platform == UnrealTargetPlatform.Win64 )
|
||||
{
|
||||
return new string[]
|
||||
{
|
||||
"NGXD3D11RHI",
|
||||
"NGXD3D12RHI",
|
||||
"NGXVulkanRHI"
|
||||
};
|
||||
}
|
||||
return new string[] { "" };
|
||||
}
|
||||
|
||||
public DLSS(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
EngineDirectory + "/Source/Runtime/Renderer/Private",
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"EngineSettings",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"Renderer",
|
||||
"RHI",
|
||||
"NGX",
|
||||
"Projects",
|
||||
"DeveloperSettings",
|
||||
"DLSSUtility",
|
||||
"NGXRHI",
|
||||
// ... 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"));
|
||||
}
|
||||
}
|
||||
527
Plugins/DLSS/Source/DLSS/Private/DLSS.cpp
Normal file
527
Plugins/DLSS/Source/DLSS/Private/DLSS.cpp
Normal file
@@ -0,0 +1,527 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2022 NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "DLSS.h"
|
||||
#include "CoreMinimal.h"
|
||||
#include "DLSSUpscalerPrivate.h"
|
||||
|
||||
#include "DLSSUpscaler.h"
|
||||
#include "DLSSDenoiser.h"
|
||||
|
||||
#include "NGXRHI.h"
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
|
||||
#include "GeneralProjectSettings.h"
|
||||
#include "DLSSSettings.h"
|
||||
|
||||
#include "SceneViewExtension.h"
|
||||
#include "SceneView.h"
|
||||
#include "Misc/MessageDialog.h"
|
||||
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSModule"
|
||||
DEFINE_LOG_CATEGORY(LogDLSS);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXBinarySearchOrder(
|
||||
TEXT("r.NGX.BinarySearchOrder"),
|
||||
0,
|
||||
TEXT("0: automatic: (default)\n")
|
||||
TEXT(" use custom binaries from project and launch folder $(ProjectDir)/Binaries/ThirdParty/NVIDIA/NGX/$(Platform) if present\n")
|
||||
TEXT(" fallback to generic binaries from plugin folder\n")
|
||||
TEXT("1: force generic binaries from plugin folder, fail if not found\n")
|
||||
TEXT("2: force custom binaries from project or launch folder, fail if not found\n")
|
||||
TEXT("3: force generic development binaries from plugin folder, fail if not found. This is only supported in non-shipping build configurations\n"),
|
||||
ECVF_ReadOnly);
|
||||
|
||||
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);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSMinimumWindowsBuildVersion(
|
||||
TEXT("r.NGX.DLSS.MinimumWindowsBuildVersion"), 16299,
|
||||
TEXT("Sets the minimum Windows 10 build version required to enable DLSS. (default: 16299 for v1709, Windows 10 Fall 2017 Creators Update 64-bit)"),
|
||||
ECVF_Default
|
||||
);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXProjectIdentifier(
|
||||
TEXT("r.NGX.ProjectIdentifier"),
|
||||
0,
|
||||
TEXT("0: automatic: (default)\n")
|
||||
TEXT(" use NVIDIA NGX Application ID if non-zero, otherwise use UE Project ID)\n")
|
||||
TEXT("1: force UE Project ID\n")
|
||||
TEXT("2: force NVIDIA NGX Application ID (set via the Project Settings -> NVIDIA DLSS plugin)\n"),
|
||||
ECVF_ReadOnly);
|
||||
|
||||
|
||||
static TAutoConsoleVariable<bool> CVarNGXAutomationEnable(
|
||||
TEXT("r.NGX.Automation.Enable"),
|
||||
false,
|
||||
TEXT("Enable automation for NGX DLSS image quality and performance evaluation. (default = 0)\n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int> CVarNGXAutomationViewIndex(
|
||||
TEXT("r.NGX.Automation.ViewIndex"),
|
||||
0,
|
||||
TEXT("Select which view to use with NGX DLSS image quality and performance automation. (default = 0). \n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int> CVarNGXAutomationNonGameViews(
|
||||
TEXT("r.NGX.Automation.NonGameViews"),
|
||||
0,
|
||||
TEXT("Enable NGX DLSS image quality and performance automation for non-game views. (default = 0). \n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
|
||||
class FNGXAutomationViewExtension final : public FSceneViewExtensionBase
|
||||
{
|
||||
public:
|
||||
FNGXAutomationViewExtension(const FAutoRegister& AutoRegister): FSceneViewExtensionBase(AutoRegister)
|
||||
{
|
||||
FSceneViewExtensionIsActiveFunctor IsActiveFunctor;
|
||||
|
||||
IsActiveFunctor.IsActiveFunction = [](const ISceneViewExtension* SceneViewExtension, const FSceneViewExtensionContext& Context)
|
||||
{
|
||||
return CVarNGXAutomationEnable.GetValueOnAnyThread();
|
||||
};
|
||||
|
||||
IsActiveThisFrameFunctions.Add(IsActiveFunctor);
|
||||
}
|
||||
|
||||
virtual void SetupViewFamily(FSceneViewFamily& InViewFamily) {}
|
||||
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
|
||||
{
|
||||
int32 ViewIndex = CVarNGXAutomationViewIndex.GetValueOnRenderThread();
|
||||
|
||||
if (InViewFamily.Views.IsValidIndex(ViewIndex))
|
||||
{
|
||||
const FSceneView* View = InViewFamily.Views[ViewIndex];
|
||||
if (View->bIsGameView || CVarNGXAutomationNonGameViews.GetValueOnRenderThread())
|
||||
{
|
||||
const FString AiAgentMarker = FString::Printf(TEXT("{\"camera\":{\"position\":{\"x\": %f, \"y\": %f, \"z\": %f},\"rotation\":{\"pitch\": %f, \"roll\": %f, \"yaw\": %f}}}"),
|
||||
View->ViewLocation.X, View->ViewLocation.Y, View->ViewLocation.Z,
|
||||
View->ViewRotation.Pitch, View->ViewRotation.Roll, View->ViewRotation.Yaw);
|
||||
|
||||
static FColor ColorMarker = FColor::FromHex("0xA1A5E87");
|
||||
RHICmdList.PushEvent(*AiAgentMarker, ColorMarker);
|
||||
RHICmdList.PopEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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__));
|
||||
|
||||
// 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/"));
|
||||
const FString RHIName = GDynamicRHI->GetName();
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("PluginBaseDir %s"), *PluginBaseDir);
|
||||
UE_LOG(LogDLSS, Log, TEXT("NGXBinariesDir %s"), *NGXBinariesDir);
|
||||
UE_LOG(LogDLSS, Log, TEXT("GDynamicRHIName %s %s"), RHIVendorIdToString(), *RHIName );
|
||||
|
||||
bool bLoadLibraries = CVarNGXEnable.GetValueOnAnyThread() != 0;
|
||||
if (FParse::Param(FCommandLine::Get(), TEXT("ngxenable")))
|
||||
{
|
||||
bLoadLibraries = true;
|
||||
}
|
||||
else if (FParse::Param(FCommandLine::Get(), TEXT("ngxdisable")))
|
||||
{
|
||||
bLoadLibraries = false;
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS requires an NVIDIA RTX series graphics card"));
|
||||
DLSSSupport = EDLSSSupport::NotSupportedIncompatibleHardware;
|
||||
}
|
||||
#if PLATFORM_WINDOWS
|
||||
else if (NGXDLSSMinimumWindowsBuildVersion > 0 && !FPlatformMisc::VerifyWindowsVersion(10, 0
|
||||
#if PLATFORM_DESKTOP
|
||||
, NGXDLSSMinimumWindowsBuildVersion
|
||||
#endif
|
||||
))
|
||||
{
|
||||
// From https://docs.microsoft.com/en-us/windows/release-information/
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS requires at least Windows 10, build %u "), NGXDLSSMinimumWindowsBuildVersion);
|
||||
DLSSSupport = EDLSSSupport::NotSupportedOperatingSystemOutOfDate;
|
||||
}
|
||||
#endif
|
||||
else if (!bLoadLibraries)
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX library loading has been disabled with r.NGX.Enable=0"));
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
}
|
||||
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 TCHAR* NGXRHIModuleName = nullptr;
|
||||
|
||||
DLSSSupport = (bIsDX11 || bIsDX12 || bIsVulkan) ? EDLSSSupport::Supported : EDLSSSupport::NotSupported;
|
||||
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
{
|
||||
if (bIsDX11)
|
||||
{
|
||||
NGXRHIModuleName = TEXT("NGXD3D11RHI");
|
||||
}
|
||||
else if (bIsDX12)
|
||||
{
|
||||
NGXRHIModuleName = TEXT("NGXD3D12RHI");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
uint32 NGXAppID = GetDefault<UDLSSSettings>()->NVIDIANGXApplicationId;
|
||||
UE_LOG(LogDLSS, Log, TEXT("Plugin settings: NGXAppId = %u"), NGXAppID);
|
||||
|
||||
if (NGXAppID != 0)
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("NGX Application ID is specified, overriding the Project ID. Please refer to https://developer.nvidia.com/dlss."));
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("NGX Application ID not specified, using the Project ID by default."));
|
||||
}
|
||||
|
||||
FNGXRHICreateArguments Arguments;
|
||||
Arguments.PluginBaseDir = PluginBaseDir;
|
||||
Arguments.DynamicRHI = GDynamicRHI;
|
||||
Arguments.NGXBinariesSearchOrder = ENGXBinariesSearchOrder(FMath::Clamp(CVarNGXBinarySearchOrder.GetValueOnAnyThread(), int32(ENGXBinariesSearchOrder::MinValue), int32(ENGXBinariesSearchOrder::MaxValue)));
|
||||
|
||||
Arguments.ProjectIdentifier = ENGXProjectIdentifier(FMath::Clamp(CVarNGXProjectIdentifier.GetValueOnAnyThread(), int32(ENGXProjectIdentifier::MinValue), int32(ENGXProjectIdentifier::MaxValue)));
|
||||
Arguments.NGXAppId = NGXAppID;
|
||||
Arguments.UnrealEngineVersion = FString::Printf(TEXT("%u.%u"), FEngineVersion::Current().GetMajor(), FEngineVersion::Current().GetMinor());
|
||||
Arguments.UnrealProjectID = GetDefault<UGeneralProjectSettings>()->ProjectID.ToString();
|
||||
|
||||
INGXRHIModule* NGXRHIModule = &FModuleManager::LoadModuleChecked<INGXRHIModule>(NGXRHIModuleName);
|
||||
NGXRHIExtensions = NGXRHIModule->CreateNGXRHI(Arguments);
|
||||
|
||||
|
||||
const bool bRenderDocPluginFound = FModuleManager::Get().ModuleExists(TEXT("RenderDocPlugin"));
|
||||
const bool bDLSSUnavailable = (!NGXRHIExtensions || !NGXRHIExtensions->IsDLSSAvailable());
|
||||
const bool bIncompatibleAPICaptureToolActive = (bRenderDocPluginFound || NGXRHI::IsIncompatibleAPICaptureToolActive());
|
||||
if (bDLSSUnavailable && bIncompatibleAPICaptureToolActive)
|
||||
{
|
||||
if (bRenderDocPluginFound)
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("DLSS is not compatible with the RenderDoc plugin. To enable DLSS please disable the RenderDoc plugin."));
|
||||
}
|
||||
|
||||
if (NGXRHI::IsIncompatibleAPICaptureToolActive())
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("DLSS is not compatible with some API capture tools, such as RenderDoc. To enable DLSS please use an API capture tool such as NVIDIA NSIGHT graphics, which support the APIs required by DLSS."));
|
||||
}
|
||||
// we don't want this ever show up in packaged builds
|
||||
#if WITH_EDITOR
|
||||
const bool IsUnattended = FApp::IsUnattended() || IsRunningCommandlet() || GIsRunningUnattendedScript;
|
||||
auto LocalSettings = GetMutableDefault<UDLSSOverrideSettings>();
|
||||
if (!IsUnattended && LocalSettings->bShowDLSSIncompatiblePluginsToolsWarnings)
|
||||
{
|
||||
const FText DialogTitle(LOCTEXT("DLSSIncompatibleWithCaptureToolTitle", "Warning -- DLSS incompatible with plugins and/or API capture tools"));
|
||||
const FText WarningMessage(LOCTEXT("DLSSIncompatibleWithCaptureTool",
|
||||
"To enable DLSS, please disable the RenderDoc plugin and/or use an API capture tool such as NVIDIA NSIGHT graphics, which supports the APIs required by DLSS.\n\n"
|
||||
"Would you like to continue to see this message for this project? It can also be disabled in the NVIDIA DLSS Overrides (Local) plugin settings."));
|
||||
|
||||
EAppReturnType::Type YesNoCancelReply = FMessageDialog::Open(EAppMsgType::YesNoCancel, EAppReturnType::Yes, WarningMessage, &DialogTitle);
|
||||
|
||||
if(YesNoCancelReply == EAppReturnType::No)
|
||||
{
|
||||
LocalSettings->bShowDLSSIncompatiblePluginsToolsWarnings = false;
|
||||
}
|
||||
else if (YesNoCancelReply == EAppReturnType::Cancel)
|
||||
{
|
||||
FPlatformMisc::RequestExit(true);
|
||||
}
|
||||
}
|
||||
#endif //WITH_EDITOR
|
||||
}
|
||||
|
||||
if (NGXRHIExtensions)
|
||||
{
|
||||
if (NGXRHIExtensions->IsDLSSAvailable())
|
||||
{
|
||||
check(NVSDK_NGX_SUCCEED(NGXRHIExtensions->GetDLSSInitResult()));
|
||||
DLSSSupport = EDLSSSupport::Supported;
|
||||
}
|
||||
else
|
||||
{
|
||||
// map some of the NGX error codes to something that the UI/gameplay could suggest the end user to do something about
|
||||
if (bIncompatibleAPICaptureToolActive)
|
||||
{
|
||||
DLSSSupport = EDLSSSupport::NotSupportedIncompatibleAPICaptureToolActive;
|
||||
}
|
||||
else if (NVSDK_NGX_Result_FAIL_OutOfDate == NGXRHIExtensions->GetDLSSInitResult())
|
||||
{
|
||||
DLSSSupport = EDLSSSupport::NotSupportedDriverOutOfDate;
|
||||
}
|
||||
else if (NVSDK_NGX_Result_FAIL_FeatureNotSupported == NGXRHIExtensions->GetDLSSInitResult())
|
||||
{
|
||||
DLSSSupport = EDLSSSupport::NotSupportedIncompatibleHardware;
|
||||
}
|
||||
else
|
||||
{
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
}
|
||||
}
|
||||
|
||||
const FNGXDriverRequirements DriverRequirements = NGXRHIExtensions->GetDLSSDriverRequirements();
|
||||
if (DriverRequirements.DriverUpdateRequired)
|
||||
{
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS could be loaded properly. However it is recommended to update the version to at least: %u.%u"), DriverRequirements.MinDriverVersionMajor, DriverRequirements.MinDriverVersionMinor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS cannot be loaded properly. Please verify that at least this driver version is installed: %u.%u"), DriverRequirements.MinDriverVersionMajor, DriverRequirements.MinDriverVersionMinor);
|
||||
DLSSSupport = EDLSSSupport::NotSupportedDriverOutOfDate;
|
||||
MinDriverVersionMajor = DriverRequirements.MinDriverVersionMajor;
|
||||
MinDriverVersionMinor = DriverRequirements.MinDriverVersionMinor;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("Could not load %s module"), NGXRHIModuleName);
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
}
|
||||
|
||||
if (DLSSSupport != EDLSSSupport::Supported)
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("DLSS not supported by the %s %s RHI in the %s module at runtime"), RHIVendorIdToString(), *RHIName, NGXRHIModuleName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("DLSS not implemented for the %s RHI, or disabled in the project settings"), *RHIName);
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
{
|
||||
// set the upscaler
|
||||
{
|
||||
DLSSUpscaler.Reset(new FDLSSUpscaler(NGXRHIExtensions.Get()));
|
||||
check(DLSSUpscaler);
|
||||
if (DLSSUpscaler->GetNumRuntimeQualityModes() == 0)
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("DLSS not available due to not supporting any quality modes at runtime"));
|
||||
DLSSSupport = EDLSSSupport::NotSupported;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("NVIDIA NGX DLSS supported %u"), QueryDLSSSupport() == EDLSSSupport::Supported);
|
||||
|
||||
// and the other related interfaces
|
||||
|
||||
if (DLSSSupport == EDLSSSupport::Supported)
|
||||
{
|
||||
// set the denoiser
|
||||
{
|
||||
|
||||
static const auto CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Reflections.Denoiser"));
|
||||
if (CVar && (CVar->GetInt() != 2))
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("For optimal results NVIDIA NGX DLSS requires the use of a custom denoiser plugin, which currently is disabled. To enable, set r.Reflections.Denoiser=2"));
|
||||
}
|
||||
|
||||
DLSSDenoiser.Reset(new FDLSSDenoiser(GScreenSpaceDenoiser, DLSSUpscaler.Get()));
|
||||
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
|
||||
{
|
||||
checkf(GCustomResourcePool == nullptr, TEXT("GCustomResourcePool is already in use. Please check that only one upscaling plugin is active."));
|
||||
GCustomResourcePool = DLSSUpscaler.Get();
|
||||
}
|
||||
}
|
||||
|
||||
// setup DLSS image quality and performance automation hooks
|
||||
{
|
||||
NGXAutomationViewExtension = FSceneViewExtensions::NewExtension<FNGXAutomationViewExtension>();
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void FDLSSModule::ShutdownModule()
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
// reset DLSS image quality and performance automation hooks
|
||||
{
|
||||
NGXAutomationViewExtension = nullptr;
|
||||
}
|
||||
|
||||
if (QueryDLSSSupport() == EDLSSSupport::Supported)
|
||||
{
|
||||
// reset the resource pool
|
||||
{
|
||||
GCustomResourcePool = nullptr;
|
||||
}
|
||||
|
||||
// reset the screen percentage driver for game views
|
||||
{
|
||||
GCustomStaticScreenPercentage = nullptr;
|
||||
}
|
||||
|
||||
// reset the denoiser
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s unwrapping %s"), DLSSDenoiser->GetDebugName(), DLSSDenoiser->GetWrappedDenoiser()->GetDebugName());
|
||||
GScreenSpaceDenoiser = DLSSDenoiser->GetWrappedDenoiser();
|
||||
DLSSDenoiser.Reset();
|
||||
}
|
||||
|
||||
// reset the upscaler
|
||||
{
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
GTemporalUpscaler = ITemporalUpscaler::GetDefaultTemporalUpscaler();
|
||||
#endif
|
||||
FDLSSUpscaler::ReleaseStaticResources();
|
||||
DLSSUpscaler.Reset();
|
||||
}
|
||||
|
||||
NGXRHIExtensions.Reset();
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
|
||||
EDLSSSupport FDLSSModule::QueryDLSSSupport() const
|
||||
{
|
||||
return DLSSSupport;
|
||||
}
|
||||
|
||||
|
||||
void FDLSSModule::GetDLSSMinDriverVersion(int32& OutMajorVersion, int32& OutMinorVersion) const
|
||||
{
|
||||
OutMajorVersion = MinDriverVersionMajor;
|
||||
OutMinorVersion = MinDriverVersionMinor;
|
||||
}
|
||||
|
||||
|
||||
float FDLSSModule::GetResolutionFractionForQuality(int32 Quality) const
|
||||
{
|
||||
checkf(QueryDLSSSupport() == EDLSSSupport::Supported,TEXT("GetResolutionFractionForQuality should only be called when DLSS is supported"));
|
||||
checkf(Quality >= int32(EDLSSQualityMode::MinValue) && Quality <= int32(EDLSSQualityMode::MaxValue),TEXT("The Quality %d argument of GetResolutionFractionForQuality is out of range and/or an unsupported DLSS quality mode"), Quality);
|
||||
return DLSSUpscaler->GetOptimalResolutionFractionForQuality(EDLSSQualityMode(Quality));
|
||||
}
|
||||
|
||||
FDLSSUpscaler* FDLSSModule::GetDLSSUpscaler() const
|
||||
{
|
||||
return DLSSUpscaler.Get();
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDLSSModule, DLSS)
|
||||
|
||||
|
||||
201
Plugins/DLSS/Source/DLSS/Private/DLSSDenoiser.cpp
Normal file
201
Plugins/DLSS/Source/DLSS/Private/DLSSDenoiser.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "DLSSDenoiser.h"
|
||||
#include "DLSSUpscaler.h"
|
||||
#include "PostProcess/TemporalAA.h"
|
||||
#include "SceneTextureParameters.h"
|
||||
#include "ScenePrivate.h"
|
||||
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSReflectionsTemporalAA(
|
||||
TEXT("r.NGX.DLSS.Reflections.TemporalAA"),
|
||||
1,
|
||||
TEXT("Apply a temporal AA pass on the denoised reflections"),
|
||||
ECVF_RenderThreadSafe
|
||||
);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSWaterReflectionsTemporalAA(
|
||||
TEXT("r.NGX.DLSS.WaterReflections.TemporalAA"),
|
||||
1,
|
||||
TEXT("Apply a temporal AA pass on the denoised water reflections"),
|
||||
ECVF_RenderThreadSafe
|
||||
);
|
||||
|
||||
|
||||
// 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)
|
||||
{
|
||||
check(Upscaler);
|
||||
check(WrappedDenoiser);
|
||||
}
|
||||
|
||||
const TCHAR* FDLSSDenoiser::GetDebugName() const
|
||||
{
|
||||
if (Upscaler->IsDLSSActive())
|
||||
{
|
||||
// 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)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return TEXT("FDLSSDenoiserWrapper(Inactive)");
|
||||
}
|
||||
}
|
||||
|
||||
IScreenSpaceDenoiser::EShadowRequirements FDLSSDenoiser::GetShadowRequirements(const FViewInfo& View, const FLightSceneInfo& LightSceneInfo, const FShadowRayTracingConfig& RayTracingConfig) const
|
||||
{
|
||||
return WrappedDenoiser->GetShadowRequirements(View, LightSceneInfo, RayTracingConfig);
|
||||
}
|
||||
|
||||
void FDLSSDenoiser::DenoiseShadowVisibilityMasks(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const TStaticArray<FShadowVisibilityParameters, IScreenSpaceDenoiser::kMaxBatchSize>& InputParameters, const int32 InputParameterCount, TStaticArray<FShadowVisibilityOutputs, IScreenSpaceDenoiser::kMaxBatchSize>& Outputs) const
|
||||
{
|
||||
WrappedDenoiser->DenoiseShadowVisibilityMasks(GraphBuilder, View, PreviousViewInfos, SceneTextures, InputParameters, InputParameterCount, Outputs);
|
||||
}
|
||||
|
||||
IScreenSpaceDenoiser::FPolychromaticPenumbraOutputs FDLSSDenoiser::DenoisePolychromaticPenumbraHarmonics(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FPolychromaticPenumbraHarmonics& Inputs) const
|
||||
{
|
||||
return WrappedDenoiser->DenoisePolychromaticPenumbraHarmonics(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs);
|
||||
}
|
||||
|
||||
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 bApplyTemporalAA = bIsDLSSActive && CVarNGXDLSSReflectionsTemporalAA.GetValueOnRenderThread() && View.ViewState && IsTemporalAccumulationBasedMethod(View.AntiAliasingMethod);
|
||||
if(bApplyTemporalAA)
|
||||
{
|
||||
check(View.ViewState);
|
||||
|
||||
FTAAPassParameters TAASettings(View);
|
||||
TAASettings.Pass = ETAAPassConfig::ScreenSpaceReflections;
|
||||
TAASettings.SceneDepthTexture = SceneTextures.SceneDepthTexture;
|
||||
TAASettings.SceneVelocityTexture = SceneTextures.GBufferVelocityTexture;
|
||||
TAASettings.SceneColorInput = Outputs.Color;
|
||||
TAASettings.bOutputRenderTargetable = true;
|
||||
|
||||
FTAAOutputs TAAOutputs = AddTemporalAAPass(
|
||||
GraphBuilder,
|
||||
View,
|
||||
TAASettings,
|
||||
View.PrevViewInfo.SSRHistory,
|
||||
&View.ViewState->PrevFrameViewInfo.SSRHistory);
|
||||
|
||||
Outputs.Color = TAAOutputs.SceneColor;
|
||||
}
|
||||
|
||||
return Outputs;
|
||||
}
|
||||
|
||||
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 bApplyTemporalAA = bIsDLSSActive && Upscaler->IsDLSSActive() && CVarNGXDLSSWaterReflectionsTemporalAA.GetValueOnRenderThread() && View.ViewState && IsTemporalAccumulationBasedMethod(View.AntiAliasingMethod);
|
||||
if (bApplyTemporalAA)
|
||||
{
|
||||
check(View.ViewState);
|
||||
|
||||
FTAAPassParameters TAASettings(View);
|
||||
TAASettings.Pass = ETAAPassConfig::ScreenSpaceReflections;
|
||||
TAASettings.SceneDepthTexture = SceneTextures.SceneDepthTexture;
|
||||
TAASettings.SceneVelocityTexture = SceneTextures.GBufferVelocityTexture;
|
||||
TAASettings.SceneColorInput = Outputs.Color;
|
||||
TAASettings.bOutputRenderTargetable = true;
|
||||
|
||||
FTAAOutputs TAAOutputs = AddTemporalAAPass(
|
||||
GraphBuilder,
|
||||
View,
|
||||
TAASettings,
|
||||
View.PrevViewInfo.WaterSSRHistory,
|
||||
&View.ViewState->PrevFrameViewInfo.WaterSSRHistory);
|
||||
|
||||
Outputs.Color = TAAOutputs.SceneColor;
|
||||
}
|
||||
|
||||
return Outputs;
|
||||
}
|
||||
|
||||
IScreenSpaceDenoiser::FAmbientOcclusionOutputs FDLSSDenoiser::DenoiseAmbientOcclusion(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FAmbientOcclusionInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
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
|
||||
{
|
||||
return WrappedDenoiser->DenoiseDiffuseIndirect(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
|
||||
FSSDSignalTextures 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);
|
||||
}
|
||||
|
||||
FSSDSignalTextures FDLSSDenoiser::DenoiseDiffuseIndirectHarmonic(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectHarmonic& Inputs, const HybridIndirectLighting::FCommonParameters& CommonDiffuseParameters) const
|
||||
{
|
||||
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
|
||||
{
|
||||
return WrappedDenoiser->DenoiseSkyLight(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
|
||||
IScreenSpaceDenoiser::FDiffuseIndirectOutputs FDLSSDenoiser::DenoiseReflectedSkyLight(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FDiffuseIndirectInputs& Inputs, const FAmbientOcclusionRayTracingConfig Config) const
|
||||
{
|
||||
return WrappedDenoiser->DenoiseReflectedSkyLight(GraphBuilder, View, PreviousViewInfos, SceneTextures, Inputs, Config);
|
||||
}
|
||||
|
||||
|
||||
bool FDLSSDenoiser::SupportsScreenSpaceDiffuseIndirectDenoiser(EShaderPlatform Platform) const
|
||||
{
|
||||
return WrappedDenoiser->SupportsScreenSpaceDiffuseIndirectDenoiser(Platform);
|
||||
}
|
||||
|
||||
const IScreenSpaceDenoiser* FDLSSDenoiser::GetWrappedDenoiser() const
|
||||
{
|
||||
return WrappedDenoiser;
|
||||
}
|
||||
65
Plugins/DLSS/Source/DLSS/Private/DLSSDenoiser.h
Normal file
65
Plugins/DLSS/Source/DLSS/Private/DLSSDenoiser.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#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
|
||||
class DLSS_API FDLSSDenoiser final : public IScreenSpaceDenoiser
|
||||
{
|
||||
|
||||
public:
|
||||
FDLSSDenoiser(const IScreenSpaceDenoiser* InWrappedDenoiser, const FDLSSUpscaler* InUpscaler);
|
||||
|
||||
// Inherited via IScreenSpaceDenoiser
|
||||
virtual const TCHAR* GetDebugName() const final;
|
||||
virtual EShadowRequirements GetShadowRequirements(const FViewInfo& View, const FLightSceneInfo& LightSceneInfo, const FShadowRayTracingConfig& RayTracingConfig) const final;
|
||||
virtual void DenoiseShadowVisibilityMasks(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const TStaticArray<FShadowVisibilityParameters, IScreenSpaceDenoiser::kMaxBatchSize>& InputParameters, const int32 InputParameterCount, TStaticArray<FShadowVisibilityOutputs, IScreenSpaceDenoiser::kMaxBatchSize>& Outputs) const final;
|
||||
virtual FPolychromaticPenumbraOutputs DenoisePolychromaticPenumbraHarmonics(FRDGBuilder& GraphBuilder, const FViewInfo& View, FPreviousViewInfo* PreviousViewInfos, const FSceneTextureParameters& SceneTextures, const FPolychromaticPenumbraHarmonics& Inputs) const final;
|
||||
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;
|
||||
|
||||
|
||||
virtual bool SupportsScreenSpaceDiffuseIndirectDenoiser(EShaderPlatform Platform) const final;
|
||||
const IScreenSpaceDenoiser* GetWrappedDenoiser() const;
|
||||
private:
|
||||
|
||||
const IScreenSpaceDenoiser* WrappedDenoiser;
|
||||
const FDLSSUpscaler* Upscaler;
|
||||
};
|
||||
22
Plugins/DLSS/Source/DLSS/Private/DLSSSettings.cpp
Normal file
22
Plugins/DLSS/Source/DLSS/Private/DLSSSettings.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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"
|
||||
790
Plugins/DLSS/Source/DLSS/Private/DLSSUpscaler.cpp
Normal file
790
Plugins/DLSS/Source/DLSS/Private/DLSSUpscaler.cpp
Normal file
@@ -0,0 +1,790 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "DLSSUpscaler.h"
|
||||
|
||||
|
||||
#include "DLSSUpscalerPrivate.h"
|
||||
#include "DLSSUpscalerHistory.h"
|
||||
#include "DLSSSettings.h"
|
||||
|
||||
#include "VelocityCombinePass.h"
|
||||
|
||||
#include "PostProcess/SceneRenderTargets.h"
|
||||
#include "PostProcess/PostProcessing.h"
|
||||
#include "SceneTextureParameters.h"
|
||||
#include "ScreenPass.h"
|
||||
|
||||
#include "RayTracing/RaytracingOptions.h"
|
||||
|
||||
#include "LegacyScreenPercentageDriver.h"
|
||||
|
||||
|
||||
#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."),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<bool> CVarNGXDLAAEnable(
|
||||
TEXT("r.NGX.DLAA.Enable"), false,
|
||||
TEXT("Enable/Disable DLAA"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSAutomationTesting(
|
||||
TEXT("r.NGX.DLSS.AutomationTesting"), 0,
|
||||
TEXT("Whether the NGX library should be loaded when GIsAutomationTesting is true.(default is false)\n")
|
||||
TEXT("Must be set to true before startup. This can be enabled for cases where running automation testing with DLSS desired"),
|
||||
ECVF_ReadOnly);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSPerfQualitySetting(
|
||||
TEXT("r.NGX.DLSS.Quality"),
|
||||
-1,
|
||||
TEXT("DLSS Performance/Quality setting. Not all modes might be supported at runtime, in this case Balanced mode is used as a fallback\n")
|
||||
TEXT(" -2: Ultra Performance\n")
|
||||
TEXT(" -1: Performance (default)\n")
|
||||
TEXT(" 0: Balanced\n")
|
||||
TEXT(" 1: Quality\n")
|
||||
TEXT(" 2: Ultra Quality\n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<bool> CVarNGXDLSSAutoQualitySetting(
|
||||
TEXT("r.NGX.DLSS.Quality.Auto"), 0,
|
||||
TEXT("Enable/Disable DLSS automatically selecting the DLSS quality mode based on the render resolution"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
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)"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSDilateMotionVectors(
|
||||
TEXT("r.NGX.DLSS.DilateMotionVectors"),
|
||||
1,
|
||||
TEXT(" 0: pass low resolution motion vectors into DLSS\n")
|
||||
TEXT(" 1: pass dilated high resolution motion vectors into DLSS. This can help with improving image quality of thin details. (default)"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSAutoExposure(
|
||||
TEXT("r.NGX.DLSS.AutoExposure"), 1,
|
||||
TEXT("0: Use the engine-computed exposure value for input images to DLSS - in some cases this may reduce artifacts\n")
|
||||
TEXT("1: Enable DLSS internal auto-exposure instead of the application provided one (default)\n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSReleaseMemoryOnDelete(
|
||||
TEXT("r.NGX.DLSS.ReleaseMemoryOnDelete"),
|
||||
1,
|
||||
TEXT("Enabling/disable releasing DLSS related memory on the NGX side when DLSS features get released.(default=1)"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSFeatureCreationNode(
|
||||
TEXT("r.NGX.DLSS.FeatureCreationNode"), -1,
|
||||
TEXT("Determines which GPU the DLSS feature is getting created on\n")
|
||||
TEXT("-1: Create on the GPU the command list is getting executed on (default)\n")
|
||||
TEXT(" 0: Create on GPU node 0 \n")
|
||||
TEXT(" 1: Create on GPU node 1 \n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSFeatureVisibilityMask(
|
||||
TEXT("r.NGX.DLSS.FeatureVisibilityMask"), -1,
|
||||
TEXT("Determines which GPU the DLSS feature is visible to\n")
|
||||
TEXT("-1: Visible to the GPU the command list is getting executed on (default)\n")
|
||||
TEXT(" 1: visible to GPU node 0 \n")
|
||||
TEXT(" 2: visible to GPU node 1 \n")
|
||||
TEXT(" 3: visible to GPU node 0 and GPU node 1\n"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
DECLARE_GPU_STAT(DLSS)
|
||||
|
||||
BEGIN_SHADER_PARAMETER_STRUCT(FDLSSShaderParameters, )
|
||||
|
||||
// Input images
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneColorInput)
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneDepthInput)
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, EyeAdaptation)
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneVelocityInput)
|
||||
|
||||
|
||||
// Output images
|
||||
RDG_TEXTURE_ACCESS(SceneColorOutput, ERHIAccess::UAVCompute)
|
||||
|
||||
END_SHADER_PARAMETER_STRUCT()
|
||||
|
||||
|
||||
FIntPoint FDLSSPassParameters::GetOutputExtent() const
|
||||
{
|
||||
check(Validate());
|
||||
check(SceneColorInput);
|
||||
|
||||
FIntPoint InputExtent = SceneColorInput->Desc.Extent;
|
||||
|
||||
FIntPoint QuantizedPrimaryUpscaleViewSize;
|
||||
QuantizeSceneBufferSize(OutputViewRect.Size(), QuantizedPrimaryUpscaleViewSize);
|
||||
|
||||
return FIntPoint(
|
||||
FMath::Max(InputExtent.X, QuantizedPrimaryUpscaleViewSize.X),
|
||||
FMath::Max(InputExtent.Y, QuantizedPrimaryUpscaleViewSize.Y));
|
||||
}
|
||||
|
||||
bool FDLSSPassParameters::Validate() const
|
||||
{
|
||||
checkf(OutputViewRect.Min == FIntPoint::ZeroValue,TEXT("The DLSS OutputViewRect %dx%d must be non-zero"), OutputViewRect.Min.X, OutputViewRect.Min.Y);
|
||||
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");
|
||||
switch (Quality)
|
||||
{
|
||||
case EDLSSQualityMode::UltraPerformance:
|
||||
return NVSDK_NGX_PerfQuality_Value_UltraPerformance;
|
||||
|
||||
default:
|
||||
checkf(false, TEXT("ToNGXQuality should not be called with an out of range EDLSSQualityMode from the higher level code"));
|
||||
case EDLSSQualityMode::Performance:
|
||||
return NVSDK_NGX_PerfQuality_Value_MaxPerf;
|
||||
|
||||
case EDLSSQualityMode::Balanced:
|
||||
return NVSDK_NGX_PerfQuality_Value_Balanced;
|
||||
|
||||
case EDLSSQualityMode::Quality:
|
||||
return NVSDK_NGX_PerfQuality_Value_MaxQuality;
|
||||
|
||||
case EDLSSQualityMode::UltraQuality:
|
||||
return NVSDK_NGX_PerfQuality_Value_UltraQuality;
|
||||
}
|
||||
}
|
||||
|
||||
NGXRHI* FDLSSUpscaler::NGXRHIExtensions;
|
||||
TStaticArray <TSharedPtr<FDLSSUpscaler>, uint32(EDLSSQualityMode::NumValues)> FDLSSUpscaler::DLSSUpscalerInstancesPerViewFamily;
|
||||
float FDLSSUpscaler::MinResolutionFraction = TNumericLimits <float>::Max();
|
||||
float FDLSSUpscaler::MaxResolutionFraction = TNumericLimits <float>::Min();
|
||||
|
||||
|
||||
uint32 FDLSSUpscaler::NumRuntimeQualityModes = 0;
|
||||
TArray<FDLSSOptimalSettings> FDLSSUpscaler::ResolutionSettings;
|
||||
|
||||
|
||||
FDLSSUpscaler* FDLSSUpscaler::GetUpscalerInstanceForViewFamily(const FDLSSUpscaler* InUpscaler, EDLSSQualityMode InQualityMode)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto UpscalerInstance : DLSSUpscalerInstancesPerViewFamily)
|
||||
{
|
||||
if (UpscalerInstance.Get() == InUpscaler)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsAutoQualityMode()
|
||||
{
|
||||
return CVarNGXDLSSAutoQualitySetting.GetValueOnAnyThread();
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsDLAAMode()
|
||||
{
|
||||
return CVarNGXDLAAEnable.GetValueOnAnyThread();
|
||||
}
|
||||
|
||||
void FDLSSUpscaler::SetAutoQualityMode(bool bAutoQualityMode)
|
||||
{
|
||||
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__));
|
||||
|
||||
|
||||
checkf(!NGXRHIExtensions, TEXT("static member NGXRHIExtensions should only be assigned once by this ctor when called during module startup") );
|
||||
NGXRHIExtensions = InNGXRHIExtensions;
|
||||
|
||||
ResolutionSettings.Init(FDLSSOptimalSettings(), int32(EDLSSQualityMode::NumValues));
|
||||
|
||||
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 })
|
||||
{
|
||||
check(ToNGXQuality(QualityMode) < ResolutionSettings.Num());
|
||||
check(ToNGXQuality(QualityMode) >= 0);
|
||||
|
||||
FDLSSOptimalSettings OptimalSettings = NGXRHIExtensions->GetDLSSOptimalSettings(ToNGXQuality(QualityMode));
|
||||
|
||||
ResolutionSettings[ToNGXQuality(QualityMode)] = OptimalSettings;
|
||||
|
||||
// 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);
|
||||
++NumRuntimeQualityModes;
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSS, Log, TEXT("QualityMode %d: bSupported = %u, ResolutionFraction = %.4f. MinResolutionFraction=%.4f, MaxResolutionFraction %.4f"),
|
||||
QualityMode, OptimalSettings.bIsSupported, OptimalSettings.OptimalResolutionFraction, OptimalSettings.MinResolutionFraction, OptimalSettings.MaxResolutionFraction);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// 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
|
||||
check(IsQualityModeSupported(EDLSSQualityMode::Performance));
|
||||
check(IsQualityModeSupported(EDLSSQualityMode::Balanced));
|
||||
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__));
|
||||
}
|
||||
|
||||
// this gets explicitly called during module shutdown
|
||||
void FDLSSUpscaler::ReleaseStaticResources()
|
||||
{
|
||||
UE_LOG(LogDLSS, Log, 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__));
|
||||
}
|
||||
|
||||
#if DLSS_ENGINE_ADDPASSES_RETURN_THROUGH_PARAMS
|
||||
void FDLSSUpscaler::AddPasses(
|
||||
#else
|
||||
ITemporalUpscaler::FOutputs FDLSSUpscaler::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
|
||||
{
|
||||
#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;
|
||||
|
||||
FTemporalAAHistory* OutputHistory = View.ViewState ? &(View.ViewState->PrevFrameViewInfo.TemporalAAHistory) : nullptr;
|
||||
TRefCountPtr < ICustomTemporalAAHistory >* OutputCustomHistory = View.ViewState ? &(View.ViewState->PrevFrameViewInfo.CustomTemporalAAHistory) : nullptr;
|
||||
|
||||
|
||||
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");
|
||||
|
||||
const bool bDilateMotionVectors = CVarNGXDLSSDilateMotionVectors.GetValueOnRenderThread() != 0;
|
||||
|
||||
FRDGTextureRef CombinedVelocityTexture = AddVelocityCombinePass(GraphBuilder, View, PassInputs.SceneDepthTexture, PassInputs.SceneVelocityTexture, bDilateMotionVectors);
|
||||
|
||||
DLSSParameters.SceneColorInput = PassInputs.SceneColorTexture;
|
||||
DLSSParameters.SceneVelocityInput = CombinedVelocityTexture;
|
||||
DLSSParameters.SceneDepthInput = PassInputs.SceneDepthTexture;
|
||||
DLSSParameters.bHighResolutionMotionVectors = bDilateMotionVectors;
|
||||
const FDLSSOutputs DLSSOutputs = AddDLSSPass(
|
||||
GraphBuilder,
|
||||
View,
|
||||
DLSSParameters,
|
||||
InputHistory,
|
||||
OutputHistory,
|
||||
InputCustomHistory,
|
||||
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(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
const FDLSSPassParameters& Inputs,
|
||||
const FTemporalAAHistory& InputHistory,
|
||||
FTemporalAAHistory* OutputHistory,
|
||||
const TRefCountPtr<ICustomTemporalAAHistory> InputCustomHistoryInterface,
|
||||
TRefCountPtr<ICustomTemporalAAHistory>* OutputCustomHistoryInterface
|
||||
) const
|
||||
{
|
||||
check(IsValidUpscalerInstance(this));
|
||||
check(IsDLSSActive());
|
||||
const FDLSSUpscalerHistory* InputCustomHistory = static_cast<const FDLSSUpscalerHistory*>(InputCustomHistoryInterface.GetReference());
|
||||
|
||||
const bool bCameraCut = !InputHistory.IsValid() || View.bCameraCut || !OutputHistory;
|
||||
const FIntPoint OutputExtent = Inputs.GetOutputExtent();
|
||||
|
||||
const FIntRect SrcRect = Inputs.InputViewRect;
|
||||
const FIntRect DestRect = Inputs.OutputViewRect;
|
||||
|
||||
const float ScaleX = float(SrcRect.Width()) / float(DestRect.Width());
|
||||
const float ScaleY = float(SrcRect.Height()) / float(DestRect.Height());
|
||||
|
||||
// FDLSSUpscaler::SetupMainGameViewFamily or FDLSSUpscalerEditor::SetupEditorViewFamily
|
||||
// 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);
|
||||
|
||||
// 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);
|
||||
|
||||
const TCHAR* PassName = TEXT("MainUpsampling");
|
||||
|
||||
// Create outputs
|
||||
FDLSSOutputs Outputs;
|
||||
{
|
||||
FRDGTextureDesc SceneColorDesc = FRDGTextureDesc::Create2D(
|
||||
OutputExtent,
|
||||
PF_FloatRGBA,
|
||||
FClearValueBinding::Black,
|
||||
TexCreate_ShaderResource | TexCreate_UAV);
|
||||
|
||||
const TCHAR* OutputName = TEXT("DLSSOutputSceneColor");
|
||||
|
||||
Outputs.SceneColor = GraphBuilder.CreateTexture(
|
||||
SceneColorDesc,
|
||||
OutputName);
|
||||
}
|
||||
|
||||
FDLSSStateRef DLSSState = (InputCustomHistory && InputCustomHistory->DLSSState) ? InputCustomHistory->DLSSState : MakeShared<FDLSSState, ESPMode::ThreadSafe>();
|
||||
{
|
||||
FDLSSShaderParameters* PassParameters = GraphBuilder.AllocParameters<FDLSSShaderParameters>();
|
||||
|
||||
// Set up common shader parameters
|
||||
const FIntPoint InputExtent = Inputs.SceneColorInput->Desc.Extent;
|
||||
const FIntRect InputViewRect = Inputs.InputViewRect;
|
||||
const FIntRect OutputViewRect = Inputs.OutputViewRect;
|
||||
|
||||
// Input buffer shader parameters
|
||||
{
|
||||
PassParameters->SceneColorInput = Inputs.SceneColorInput;
|
||||
PassParameters->SceneDepthInput = Inputs.SceneDepthInput;
|
||||
PassParameters->SceneVelocityInput = Inputs.SceneVelocityInput;
|
||||
PassParameters->EyeAdaptation = GetEyeAdaptationTexture(GraphBuilder, View);
|
||||
}
|
||||
|
||||
// Outputs
|
||||
{
|
||||
PassParameters->SceneColorOutput = Outputs.SceneColor;
|
||||
}
|
||||
|
||||
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;
|
||||
const int32 NGXPerfQuality = ToNGXQuality(DLSSQualityMode);
|
||||
GraphBuilder.AddPass(
|
||||
RDG_EVENT_NAME("DLSS %s%s %dx%d -> %dx%d",
|
||||
PassName,
|
||||
Sharpness != 0.0f ? TEXT(" Sharpen") : TEXT(""),
|
||||
SrcRect.Width(), SrcRect.Height(),
|
||||
DestRect.Width(), DestRect.Height()),
|
||||
PassParameters,
|
||||
ERDGPassFlags::Compute | ERDGPassFlags::Raster | ERDGPassFlags::SkipRenderPass,
|
||||
[LocalNGXRHIExtensions, PassParameters, Inputs, bCameraCut, JitterOffset, DeltaWorldTime, PreExposure, Sharpness, NGXPerfQuality, DLSSState, bUseAutoExposure, bReleaseMemoryOnDelete](FRHICommandListImmediate& RHICmdList)
|
||||
{
|
||||
FRHIDLSSArguments DLSSArguments;
|
||||
FMemory::Memzero(&DLSSArguments, sizeof(DLSSArguments));
|
||||
|
||||
// input parameters
|
||||
DLSSArguments.SrcRect = Inputs.InputViewRect;
|
||||
DLSSArguments.DestRect = Inputs.OutputViewRect;
|
||||
|
||||
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;
|
||||
|
||||
DLSSArguments.PerfQuality = NGXPerfQuality;
|
||||
|
||||
check(PassParameters->SceneColorInput);
|
||||
PassParameters->SceneColorInput->MarkResourceAsUsed();
|
||||
DLSSArguments.InputColor = PassParameters->SceneColorInput->GetRHI();
|
||||
|
||||
|
||||
check(PassParameters->SceneVelocityInput);
|
||||
PassParameters->SceneVelocityInput->MarkResourceAsUsed();
|
||||
DLSSArguments.InputMotionVectors = PassParameters->SceneVelocityInput->GetRHI();
|
||||
|
||||
check(PassParameters->SceneDepthInput);
|
||||
PassParameters->SceneDepthInput->MarkResourceAsUsed();
|
||||
DLSSArguments.InputDepth = PassParameters->SceneDepthInput->GetRHI();
|
||||
|
||||
check(PassParameters->EyeAdaptation);
|
||||
PassParameters->EyeAdaptation->MarkResourceAsUsed();
|
||||
DLSSArguments.InputExposure = PassParameters->EyeAdaptation->GetRHI();
|
||||
DLSSArguments.PreExposure = PreExposure;
|
||||
DLSSArguments.bUseAutoExposure = bUseAutoExposure;
|
||||
|
||||
// output images
|
||||
check(PassParameters->SceneColorOutput);
|
||||
PassParameters->SceneColorOutput->MarkResourceAsUsed();
|
||||
DLSSArguments.OutputColor = PassParameters->SceneColorOutput->GetRHI();
|
||||
|
||||
RHICmdList.TransitionResource(ERHIAccess::UAVMask, DLSSArguments.OutputColor);
|
||||
RHICmdList.EnqueueLambda(
|
||||
[LocalNGXRHIExtensions, DLSSArguments, DLSSState](FRHICommandListImmediate& Cmd) mutable
|
||||
{
|
||||
const uint32 FeatureCreationNode = CVarNGXDLSSFeatureCreationNode.GetValueOnRenderThread();
|
||||
const uint32 FeatureVisibilityMask = CVarNGXDLSSFeatureVisibilityMask.GetValueOnRenderThread();
|
||||
|
||||
DLSSArguments.GPUNode = FeatureCreationNode == -1 ? Cmd.GetGPUMask().ToIndex() : FMath::Clamp(FeatureCreationNode, 0u, GNumExplicitGPUsForRendering - 1);
|
||||
DLSSArguments.GPUVisibility = FeatureVisibilityMask == -1 ? Cmd.GetGPUMask().GetNative() : (Cmd.GetGPUMask().All().GetNative() & FeatureVisibilityMask) ;
|
||||
|
||||
LocalNGXRHIExtensions->ExecuteDLSS(Cmd, DLSSArguments, DLSSState);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!View.bStatePrevViewInfoIsReadOnly && OutputHistory)
|
||||
{
|
||||
OutputHistory->SafeRelease();
|
||||
|
||||
GraphBuilder.QueueTextureExtraction(Outputs.SceneColor, &OutputHistory->RT[0]);
|
||||
|
||||
OutputHistory->ViewportRect = DestRect;
|
||||
OutputHistory->ReferenceBufferSize = OutputExtent;
|
||||
}
|
||||
|
||||
|
||||
if (!View.bStatePrevViewInfoIsReadOnly && OutputCustomHistoryInterface)
|
||||
{
|
||||
if (!OutputCustomHistoryInterface->GetReference())
|
||||
{
|
||||
(*OutputCustomHistoryInterface) = new FDLSSUpscalerHistory(DLSSState);
|
||||
}
|
||||
}
|
||||
return Outputs;
|
||||
}
|
||||
|
||||
void FDLSSUpscaler::Tick(FRHICommandListImmediate& RHICmdList)
|
||||
{
|
||||
check(NGXRHIExtensions);
|
||||
check(IsInRenderingThread());
|
||||
// Pass it over to the RHI thread which handles the lifetime of the NGX DLSS resources
|
||||
RHICmdList.EnqueueLambda(
|
||||
[this](FRHICommandListImmediate& Cmd)
|
||||
{
|
||||
NGXRHIExtensions->TickPoolElements();
|
||||
});
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsQualityModeSupported(EDLSSQualityMode InQualityMode) const
|
||||
{
|
||||
return ResolutionSettings[ToNGXQuality(InQualityMode)].bIsSupported;
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsDLSSActive() const
|
||||
{
|
||||
static const auto CVarTemporalAAUpscaler = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAA.Upscaler"));
|
||||
const bool bDLSSActive =
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
((GTemporalUpscaler == this) || IsValidUpscalerInstance(this)) &&
|
||||
#else
|
||||
((GCustomStaticScreenPercentage == this) || IsValidUpscalerInstance(this)) &&
|
||||
#endif
|
||||
CVarTemporalAAUpscaler && (CVarTemporalAAUpscaler->GetInt() != 0) &&
|
||||
((CVarNGXDLSSEnable.GetValueOnAnyThread() != 0) || CVarNGXDLAAEnable.GetValueOnAnyThread());
|
||||
return bDLSSActive;
|
||||
}
|
||||
|
||||
|
||||
void FDLSSUpscaler::SetupMainGameViewFamily(FSceneViewFamily& ViewFamily)
|
||||
{
|
||||
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."));
|
||||
|
||||
if (!GIsEditor || (GIsEditor && GIsPlayInEditorWorld && EnableDLSSInPlayInEditorViewports()))
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
ViewFamily.SetTemporalUpscalerInterface(GetUpscalerInstanceForViewFamily(this, DLSSQuality));
|
||||
|
||||
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
|
||||
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
Quality = EDLSSQualityMode::Quality;
|
||||
}
|
||||
if (!IsQualityModeSupported(Quality))
|
||||
{
|
||||
UE_LOG(LogDLSS, Warning, TEXT("DLSS Quality mode is not supported %d"), Quality);
|
||||
return;
|
||||
}
|
||||
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> {};
|
||||
}
|
||||
|
||||
TOptional<EDLSSQualityMode> FDLSSUpscaler::GetAutoQualityModeFromPixels(int PixelCount) const
|
||||
{
|
||||
if (PixelCount >= 8'300'000 && IsQualityModeSupported(EDLSSQualityMode::UltraPerformance))
|
||||
{
|
||||
return EDLSSQualityMode::UltraPerformance;
|
||||
}
|
||||
else if (PixelCount >= 3'690'000 && IsQualityModeSupported(EDLSSQualityMode::Performance))
|
||||
{
|
||||
return EDLSSQualityMode::Performance;
|
||||
}
|
||||
else if (PixelCount >= 2'030'000 && IsQualityModeSupported(EDLSSQualityMode::Quality))
|
||||
{
|
||||
return EDLSSQualityMode::Quality;
|
||||
}
|
||||
|
||||
return TOptional<EDLSSQualityMode> {};
|
||||
}
|
||||
|
||||
|
||||
bool FDLSSUpscaler::EnableDLSSInPlayInEditorViewports() const
|
||||
{
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableDLSSInPlayInEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
return GetDefault<UDLSSSettings>()->bEnableDLSSInPlayInEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetDefault<UDLSSOverrideSettings>()->EnableDLSSInPlayInEditorViewportsOverride == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
return ResolutionSettings[ToNGXQuality(Quality)].OptimalResolutionFraction;
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetOptimalSharpnessForQuality(EDLSSQualityMode Quality) const
|
||||
{
|
||||
checkf(IsQualityModeSupported(Quality), TEXT("%u is not a valid Quality mode"), Quality);
|
||||
return ResolutionSettings[ToNGXQuality(Quality)].Sharpness;
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetMinResolutionFractionForQuality(EDLSSQualityMode Quality) const
|
||||
{
|
||||
checkf(IsQualityModeSupported(Quality), TEXT("%u is not a valid Quality mode"), Quality);
|
||||
return ResolutionSettings[ToNGXQuality(Quality)].MinResolutionFraction;
|
||||
}
|
||||
|
||||
float FDLSSUpscaler::GetMaxResolutionFractionForQuality(EDLSSQualityMode Quality) const
|
||||
{
|
||||
checkf(IsQualityModeSupported(Quality), TEXT("%u is not a valid Quality mode"), Quality);
|
||||
return ResolutionSettings[ToNGXQuality(Quality)].MaxResolutionFraction;
|
||||
}
|
||||
|
||||
bool FDLSSUpscaler::IsFixedResolutionFraction(EDLSSQualityMode Quality) const
|
||||
{
|
||||
checkf(IsQualityModeSupported(Quality), TEXT("%u is not a valid Quality mode"), Quality);
|
||||
return ResolutionSettings[ToNGXQuality(Quality)].IsFixedResolution();
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
189
Plugins/DLSS/Source/DLSS/Private/DLSSUpscaler.h
Normal file
189
Plugins/DLSS/Source/DLSS/Private/DLSSUpscaler.h
Normal file
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 "RendererInterface.h"
|
||||
#include "PostProcess/TemporalAA.h"
|
||||
#include "ScreenPass.h"
|
||||
#include "NGXRHI.h"
|
||||
#include "DLSSSettings.h"
|
||||
|
||||
#include "CustomStaticScreenPercentage.h"
|
||||
#include "CustomResourcePool.h"
|
||||
|
||||
class FSceneTextureParameters;
|
||||
|
||||
struct FTemporalAAHistory;
|
||||
|
||||
class FRHITexture;
|
||||
class NGXRHI;
|
||||
struct FDLSSOptimalSettings;
|
||||
struct FDLSSPassParameters
|
||||
{
|
||||
FIntRect InputViewRect;
|
||||
FIntRect OutputViewRect;
|
||||
bool bHighResolutionMotionVectors = false;
|
||||
|
||||
FRDGTexture* SceneColorInput = nullptr;
|
||||
FRDGTexture* SceneVelocityInput = nullptr;
|
||||
FRDGTexture* SceneDepthInput = nullptr;
|
||||
|
||||
FDLSSPassParameters(const FViewInfo& View)
|
||||
: InputViewRect(View.ViewRect)
|
||||
, OutputViewRect(FIntPoint::ZeroValue, View.GetSecondaryViewRectSize())
|
||||
{
|
||||
}
|
||||
|
||||
/** Returns the texture resolution that will be output. */
|
||||
FIntPoint GetOutputExtent() const;
|
||||
|
||||
/** Validate the settings of TAA, to make sure there is no issue. */
|
||||
bool Validate() const;
|
||||
};
|
||||
|
||||
struct FDLSSOutputs
|
||||
{
|
||||
FRDGTexture* SceneColor = nullptr;
|
||||
};
|
||||
|
||||
enum class EDLSSQualityMode
|
||||
{
|
||||
MinValue = -2,
|
||||
UltraPerformance = -2,
|
||||
Performance = -1,
|
||||
Balanced = 0,
|
||||
Quality = 1,
|
||||
UltraQuality = 2,
|
||||
MaxValue = UltraQuality,
|
||||
NumValues = 5
|
||||
};
|
||||
|
||||
class DLSS_API FDLSSUpscaler final : public ITemporalUpscaler, public ICustomStaticScreenPercentage, 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;
|
||||
|
||||
float GetOptimalResolutionFractionForQuality(EDLSSQualityMode Quality) const;
|
||||
float GetOptimalSharpnessForQuality(EDLSSQualityMode Quality) const;
|
||||
float GetMinResolutionFractionForQuality(EDLSSQualityMode Quality) const;
|
||||
float GetMaxResolutionFractionForQuality(EDLSSQualityMode Quality) const;
|
||||
bool IsFixedResolutionFraction(EDLSSQualityMode Quality) const;
|
||||
|
||||
const NGXRHI* GetNGXRHI() const
|
||||
{
|
||||
return NGXRHIExtensions;
|
||||
}
|
||||
|
||||
// Inherited via ICustomResourcePool
|
||||
virtual void Tick(FRHICommandListImmediate& RHICmdList) override;
|
||||
|
||||
bool IsQualityModeSupported(EDLSSQualityMode InQualityMode) const;
|
||||
uint32 GetNumRuntimeQualityModes() const
|
||||
{
|
||||
return NumRuntimeQualityModes;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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 uint32 NumRuntimeQualityModes;
|
||||
static TArray<FDLSSOptimalSettings> ResolutionSettings;
|
||||
|
||||
static TStaticArray <TSharedPtr<FDLSSUpscaler>, uint32(EDLSSQualityMode::NumValues)> DLSSUpscalerInstancesPerViewFamily;
|
||||
};
|
||||
44
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerHistory.cpp
Normal file
44
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerHistory.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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 "DLSSUpscalerHistory.h"
|
||||
#include "DLSSUpscalerPrivate.h"
|
||||
#include "NGXRHI.h"
|
||||
|
||||
|
||||
#include "PostProcess/SceneRenderTargets.h"
|
||||
#include "PostProcess/PostProcessing.h"
|
||||
|
||||
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSModule"
|
||||
|
||||
|
||||
FDLSSUpscalerHistory::FDLSSUpscalerHistory(FDLSSStateRef InDLSSState)
|
||||
: DLSSState(InDLSSState)
|
||||
{
|
||||
}
|
||||
|
||||
FDLSSUpscalerHistory::~FDLSSUpscalerHistory()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
53
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerHistory.h
Normal file
53
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerHistory.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SceneRendering.h"
|
||||
#include "NGXRHI.h"
|
||||
|
||||
class DLSS_API FDLSSUpscalerHistory final : public ICustomTemporalAAHistory, public FRefCountBase
|
||||
{
|
||||
friend class FDLSSUpscaler;
|
||||
|
||||
FDLSSStateRef DLSSState;
|
||||
|
||||
|
||||
|
||||
virtual uint32 AddRef() const final
|
||||
{
|
||||
return FRefCountBase::AddRef();
|
||||
}
|
||||
|
||||
virtual uint32 Release() const final
|
||||
{
|
||||
return FRefCountBase::Release();
|
||||
}
|
||||
|
||||
virtual uint32 GetRefCount() const final
|
||||
{
|
||||
return FRefCountBase::GetRefCount();
|
||||
}
|
||||
|
||||
FDLSSUpscalerHistory(FDLSSStateRef InDLSSState);
|
||||
~FDLSSUpscalerHistory();
|
||||
|
||||
};
|
||||
26
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerPrivate.h
Normal file
26
Plugins/DLSS/Source/DLSS/Private/DLSSUpscalerPrivate.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogDLSS, Verbose, All);
|
||||
|
||||
74
Plugins/DLSS/Source/DLSS/Public/DLSS.h
Normal file
74
Plugins/DLSS/Source/DLSS/Public/DLSS.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FDLSSUpscaler;
|
||||
class FDLSSDenoiser;
|
||||
class FNGXAutomationViewExtension;
|
||||
class NGXRHI;
|
||||
|
||||
|
||||
enum class EDLSSSupport : uint8
|
||||
{
|
||||
Supported,
|
||||
NotSupported,
|
||||
NotSupportedIncompatibleHardware,
|
||||
NotSupportedDriverOutOfDate,
|
||||
NotSupportedOperatingSystemOutOfDate,
|
||||
NotSupportedIncompatibleAPICaptureToolActive,
|
||||
};
|
||||
|
||||
|
||||
class IDLSSModuleInterface : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual EDLSSSupport QueryDLSSSupport() const = 0;
|
||||
virtual void GetDLSSMinDriverVersion(int32& MajorVersion, int32& MinorVersion) const = 0;
|
||||
virtual float GetResolutionFractionForQuality(int32 Quality) const = 0;
|
||||
virtual FDLSSUpscaler* GetDLSSUpscaler() const = 0;
|
||||
};
|
||||
|
||||
class FDLSSModule final: public IDLSSModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
|
||||
// Inherited via IDLSSModuleInterface
|
||||
virtual EDLSSSupport QueryDLSSSupport() const;
|
||||
virtual void GetDLSSMinDriverVersion(int32& MajorVersion, int32& MinorVersion) const;
|
||||
virtual float GetResolutionFractionForQuality(int32 Quality) const;
|
||||
virtual FDLSSUpscaler* GetDLSSUpscaler() const ;
|
||||
|
||||
private:
|
||||
|
||||
TUniquePtr<FDLSSUpscaler> DLSSUpscaler;
|
||||
TUniquePtr<FDLSSDenoiser> DLSSDenoiser;
|
||||
TUniquePtr<NGXRHI> NGXRHIExtensions;
|
||||
TSharedPtr< FNGXAutomationViewExtension, ESPMode::ThreadSafe> NGXAutomationViewExtension;
|
||||
EDLSSSupport DLSSSupport = EDLSSSupport::NotSupported;
|
||||
int32 MinDriverVersionMinor;
|
||||
int32 MinDriverVersionMajor;
|
||||
};
|
||||
121
Plugins/DLSS/Source/DLSS/Public/DLSSSettings.h
Normal file
121
Plugins/DLSS/Source/DLSS/Public/DLSSSettings.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 "UObject/ObjectMacros.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Engine/DeveloperSettings.h"
|
||||
#include "CustomStaticScreenPercentage.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "DLSSSettings.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EDLSSSettingOverride : uint8
|
||||
{
|
||||
Enabled UMETA(DisplayName = "True"),
|
||||
Disabled UMETA(DisplayName = "False"),
|
||||
UseProjectSettings UMETA(DisplayName = "Use project settings"),
|
||||
};
|
||||
|
||||
UCLASS(Config = Engine, ProjectUserConfig)
|
||||
class DLSS_API UDLSSOverrideSettings : public UObject
|
||||
{
|
||||
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")
|
||||
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")
|
||||
EDLSSSettingOverride EnableDLSSInPlayInEditorViewportsOverride = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
/** This enables warnings about plugins & tools that are incompatible with DLSS 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")
|
||||
EDLSSSettingOverride ShowDLSSSDebugOnScreenMessages = EDLSSSettingOverride::UseProjectSettings;
|
||||
|
||||
};
|
||||
|
||||
UCLASS(Config = Engine, DefaultConfig, DisplayName="NVIDIA DLSS")
|
||||
class DLSS_API UDLSSSettings: public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
/** Enable DLSS for D3D12, if the driver supports it at runtime */
|
||||
UPROPERTY(Config, EditAnywhere, Category = "Platforms", DisplayName = "Enable DLSS 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")
|
||||
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")
|
||||
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 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")
|
||||
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")
|
||||
bool bShowDLSSSDebugOnScreenMessages = true;
|
||||
|
||||
/** This is part of the DLSS plugin and used by most projects*/
|
||||
UPROPERTY(VisibleAnywhere, Config, Category = "General Settings", DisplayName = "Generic DLSS Binary Path")
|
||||
FString GenericDLSSBinaryPath;
|
||||
|
||||
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*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "General Settings", DisplayName = "NVIDIA NGX Application ID", AdvancedDisplay)
|
||||
uint32 NVIDIANGXApplicationId;
|
||||
|
||||
/** In some cases NVIDIA might provide a project specific DLSS binary for your project. Please refer to https://developer.nvidia.com/dlss for details*/
|
||||
UPROPERTY(VisibleAnywhere, Config, Category = "General Settings", DisplayName = "Custom DLSS Binary Path", AdvancedDisplay)
|
||||
FString CustomDLSSBinaryPath;
|
||||
UPROPERTY(VisibleAnywhere, Config, Category = "General Settings", DisplayName = "Exists", AdvancedDisplay)
|
||||
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
|
||||
95
Plugins/DLSS/Source/DLSSBlueprint/DLSSBlueprint.Build.cs
Normal file
95
Plugins/DLSS/Source/DLSSBlueprint/DLSSBlueprint.Build.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class DLSSBlueprint : ModuleRules
|
||||
{
|
||||
protected virtual bool IsSupportedPlatform(ReadOnlyTargetRules Target)
|
||||
{
|
||||
return Target.Platform == UnrealTargetPlatform.Win64;
|
||||
}
|
||||
|
||||
public DLSSBlueprint(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"Renderer",
|
||||
"Projects",
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// for ITemporalUpscaler in PostProcess/TemporalAA.h
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
EngineDirectory + "/Source/Runtime/Renderer/Private",
|
||||
// ... add other private include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
bool bPlatformSupportsDLSS = IsSupportedPlatform(Target);
|
||||
|
||||
PublicDefinitions.Add("WITH_DLSS=" + (bPlatformSupportsDLSS ? '1' : '0'));
|
||||
|
||||
if (bPlatformSupportsDLSS)
|
||||
{
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
Path.Combine(ModuleDirectory, "../DLSS/Public"),
|
||||
}
|
||||
);
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[]
|
||||
{
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/Renderer/Private"),
|
||||
Path.Combine(ModuleDirectory, "../DLSS/Private")
|
||||
}
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"NGX",
|
||||
"NGXRHI",
|
||||
"DLSS",
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
725
Plugins/DLSS/Source/DLSSBlueprint/Private/DLSSLibrary.cpp
Normal file
725
Plugins/DLSS/Source/DLSSBlueprint/Private/DLSSLibrary.cpp
Normal file
@@ -0,0 +1,725 @@
|
||||
/*
|
||||
* 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 "DLSSLibrary.h"
|
||||
|
||||
#if WITH_DLSS
|
||||
#include "DLSS.h"
|
||||
#include "DLSSSettings.h"
|
||||
#include "DLSSUpscaler.h"
|
||||
#include "NGXRHI.h"
|
||||
#endif
|
||||
|
||||
#include "PostProcess/TemporalAA.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
#include "ShaderCore.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSBlueprintModule"
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSBlueprint, Log, All);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXDLSSPreferNISSharpen(
|
||||
TEXT("r.NGX.DLSS.PreferNISSharpen"),
|
||||
2,
|
||||
TEXT("Prefer sharpening with an extra NIS plugin sharpening pass instead of DLSS sharpening if the NIS plugin is also enabled for the project. (default: true)\n")
|
||||
TEXT("Requires UE4.27.1 and the NIS plugin to be enabled, DLSS sharpening will be used otherwise \n")
|
||||
TEXT(" 0: Softening/sharpening with the DLSS pass.\n")
|
||||
TEXT(" 1: Sharpen with the NIS plugin. Softening is not supported. Requires the NIS plugin to be enabled.\n")
|
||||
TEXT(" 2: Sharpen with the NIS plugin. Softening (i.e. negative sharpness)with the DLSS plugin. Requires the NIS plugin to be enabled.\n")
|
||||
TEXT("Note: This cvar is only evaluated when using the `SetDLSSSharpness` Blueprint function, from either C++ or a Blueprint event graph!"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static const FName SetDLSSModeInvalidEnumValueError= FName("SetDLSSModeInvalidEnumValueError");
|
||||
static const FName IsDLSSModeSupportedInvalidEnumValueError = FName("IsDLSSModeSupportedInvalidEnumValueError");
|
||||
|
||||
UDLSSSupport UDLSSLibrary::DLSSSupport = UDLSSSupport::NotSupportedByPlatformAtBuildTime;
|
||||
#if WITH_DLSS
|
||||
int32 UDLSSLibrary::MinDLSSDriverVersionMajor = 0;
|
||||
int32 UDLSSLibrary::MinDLSSDriverVersionMinor = 0;
|
||||
|
||||
FDLSSUpscaler* UDLSSLibrary::DLSSUpscaler = nullptr;
|
||||
bool UDLSSLibrary::bDLSSLibraryInitialized = false;
|
||||
|
||||
static bool ShowDLSSSDebugOnScreenMessages()
|
||||
{
|
||||
|
||||
if (GetDefault<UDLSSOverrideSettings>()->ShowDLSSSDebugOnScreenMessages == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
return GetDefault<UDLSSSettings>()->bShowDLSSSDebugOnScreenMessages;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetDefault<UDLSSOverrideSettings>()->ShowDLSSSDebugOnScreenMessages == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if !UE_BUILD_SHIPPING
|
||||
|
||||
UDLSSLibrary::FDLSSErrorState UDLSSLibrary::DLSSErrorState;
|
||||
FDelegateHandle UDLSSLibrary::DLSSOnScreenMessagesDelegateHandle;
|
||||
void UDLSSLibrary::GetDLSSOnScreenMessages(TMultiMap<FCoreDelegates::EOnScreenMessageSeverity, FText>& OutMessages)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
|
||||
// We need a valid DLSSSupport, so calling this here in case other UDLSSLibrary functions which call TryInitDLSSLibrary() haven't been called
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(ShowDLSSSDebugOnScreenMessages())
|
||||
{
|
||||
|
||||
if (DLSSErrorState.bIsDLSSModeUnsupported)
|
||||
{
|
||||
const FTextFormat Format(LOCTEXT("DLSSOnScreenDebugSetModeUnsupportedDLSSMode",
|
||||
"DLSS Error: The DLSS mode \"{0}\" is not supported. This error can be avoided by calling SetDLSSMode({0}) only if IsDLSSModeSupported({0}) returns true."));
|
||||
const FText Message = FText::Format(Format, StaticEnum<UDLSSMode>()->GetDisplayNameTextByValue(int64(DLSSErrorState.InvalidDLSSMode)));
|
||||
OutMessages.Add(FCoreDelegates::EOnScreenMessageSeverity::Error, Message);
|
||||
}
|
||||
|
||||
// Checking for "contains" in case virtualization is changing the GPU string
|
||||
const bool bIsNVIDIA = FWindowsPlatformMisc::GetPrimaryGPUBrand().Contains(TEXT("NVIDIA"));
|
||||
|
||||
bool bShowNotSupportedMessage = bIsNVIDIA && (UDLSSSupport::Supported != DLSSSupport);
|
||||
|
||||
if ((UDLSSSupport::NotSupportedIncompatibleAPICaptureToolActive == DLSSSupport) && !GetMutableDefault<UDLSSOverrideSettings>()->bShowDLSSIncompatiblePluginsToolsWarnings )
|
||||
{
|
||||
bShowNotSupportedMessage = false;
|
||||
}
|
||||
|
||||
if (bShowNotSupportedMessage)
|
||||
{
|
||||
const FTextFormat Format(LOCTEXT("DLSSOnScreenDebugDLSSNotSupported",
|
||||
"DLSS Information: DLSS is not supported due to {0}.Please see the various LogDLSS* categories in the Developer Tools -> Output Log for further detail."));
|
||||
const FText Message = FText::Format(Format, StaticEnum<UDLSSSupport>()->GetDisplayNameTextByValue(int64(DLSSSupport)));
|
||||
OutMessages.Add(FCoreDelegates::EOnScreenMessageSeverity::Warning, Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static EDLSSQualityMode ToEDLSSQualityMode(UDLSSMode InDLSSQualityMode)
|
||||
{
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to translate the new EDLSSQualityMode enum values to UDLSSMode");
|
||||
|
||||
switch (InDLSSQualityMode)
|
||||
{
|
||||
|
||||
case UDLSSMode::UltraPerformance:
|
||||
return EDLSSQualityMode::UltraPerformance;
|
||||
|
||||
// the higher level code should catch this...
|
||||
case UDLSSMode::Off:
|
||||
checkf(InDLSSQualityMode != UDLSSMode::Off, TEXT("ToEDLSSQualityMode should not be called with an InDLSSQualityMode of UDLSSMode::Off from the higher level code"));
|
||||
default:
|
||||
checkf(false, TEXT("ToEDLSSQualityMode should not be called with an out of range InDLSSQualityMode %d InDLSSQualityMode from the higher level code"), InDLSSQualityMode);
|
||||
|
||||
case UDLSSMode::Performance:
|
||||
return EDLSSQualityMode::Performance;
|
||||
|
||||
case UDLSSMode::Balanced:
|
||||
return EDLSSQualityMode::Balanced;
|
||||
|
||||
case UDLSSMode::Quality:
|
||||
return EDLSSQualityMode::Quality;
|
||||
|
||||
case UDLSSMode::UltraQuality:
|
||||
return EDLSSQualityMode::UltraQuality;
|
||||
}
|
||||
}
|
||||
|
||||
int32 UDLSSLibrary::ToDLSSQualityCVarValue(UDLSSMode DLSSMode)
|
||||
{
|
||||
return static_cast<int32>(ToEDLSSQualityMode(DLSSMode));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
bool UDLSSLibrary::IsDLSSModeSupported(UDLSSMode DLSSMode)
|
||||
{
|
||||
const UEnum* Enum = StaticEnum<UDLSSMode>();
|
||||
|
||||
// UEnums are strongly typed, but then one can also cast a byte to an UEnum ...
|
||||
if (Enum->IsValidEnumValue(int64(DLSSMode)) && (Enum->GetMaxEnumValue() != int64(DLSSMode)))
|
||||
{
|
||||
if (DLSSMode == UDLSSMode::Off)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("IsDLSSModeSupported should not be called before PostEngineInit"));
|
||||
return false;
|
||||
}
|
||||
if (!IsDLSSSupported())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (DLSSMode == UDLSSMode::Auto)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return DLSSUpscaler->IsQualityModeSupported(ToEDLSSQualityMode(DLSSMode));
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !UE_BUILD_SHIPPING
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(
|
||||
TEXT("IsDLSSModeSupported should not be called with an invalid DLSSMode enum value (%d) \"%s\""),
|
||||
int64(DLSSMode), *StaticEnum<UDLSSMode>()->GetDisplayNameTextByValue(int64(DLSSMode)).ToString()),
|
||||
ELogVerbosity::Error, IsDLSSModeSupportedInvalidEnumValueError);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void UDLSSLibrary::GetDLSSModeInformation(UDLSSMode DLSSMode, FVector2D ScreenResolution, bool& bIsSupported, float& OptimalScreenPercentage, bool& bIsFixedScreenPercentage, float& MinScreenPercentage, float& MaxScreenPercentage, float& OptimalSharpness)
|
||||
{
|
||||
// fall back to TAA for unsupported or DLSS off
|
||||
OptimalScreenPercentage = 0.0f;
|
||||
bIsFixedScreenPercentage = false;
|
||||
MinScreenPercentage = 100.0f * ITemporalUpscaler::GetDefaultTemporalUpscaler()->GetMinUpsampleResolutionFraction();
|
||||
MaxScreenPercentage = 100.0f * ITemporalUpscaler::GetDefaultTemporalUpscaler()->GetMaxUpsampleResolutionFraction();
|
||||
OptimalSharpness = 0.0f;
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDLSSModeInformation should not be called before PostEngineInit"));
|
||||
bIsSupported = false;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
bIsSupported = IsDLSSModeSupported(DLSSMode);
|
||||
|
||||
#if WITH_DLSS
|
||||
if ((DLSSMode != UDLSSMode::Off) && bIsSupported)
|
||||
{
|
||||
EDLSSQualityMode EDLSSMode;
|
||||
if (DLSSMode != UDLSSMode::Auto)
|
||||
{
|
||||
EDLSSMode = ToEDLSSQualityMode(DLSSMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Auto DLSS mode is based on total pixels
|
||||
float PixelsFloat = ScreenResolution.X * ScreenResolution.Y;
|
||||
int32 PixelsInt = (PixelsFloat < static_cast<float>(MAX_int32)) ? static_cast<int32>(PixelsFloat) : MAX_int32;
|
||||
TOptional<EDLSSQualityMode> MaybeDLSSMode = DLSSUpscaler->GetAutoQualityModeFromPixels(PixelsInt);
|
||||
if (!MaybeDLSSMode.IsSet())
|
||||
{
|
||||
// DLSS Off
|
||||
return;
|
||||
}
|
||||
EDLSSMode = MaybeDLSSMode.GetValue();
|
||||
}
|
||||
bIsFixedScreenPercentage = DLSSUpscaler->IsFixedResolutionFraction(EDLSSMode);
|
||||
|
||||
OptimalScreenPercentage = 100.0f * DLSSUpscaler->GetOptimalResolutionFractionForQuality(EDLSSMode);
|
||||
MinScreenPercentage = 100.0f * DLSSUpscaler->GetMinResolutionFractionForQuality(EDLSSMode);
|
||||
MaxScreenPercentage = 100.0f * DLSSUpscaler->GetMaxResolutionFractionForQuality(EDLSSMode);
|
||||
|
||||
OptimalSharpness = DLSSUpscaler->GetOptimalSharpnessForQuality(EDLSSMode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UDLSSLibrary::GetDLSSScreenPercentageRange(float& MinScreenPercentage, float& MaxScreenPercentage)
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDLSSScreenPercentageRange should not be called before PostEngineInit"));
|
||||
MinScreenPercentage = 100.0f;
|
||||
MaxScreenPercentage = 100.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsDLSSSupported())
|
||||
{
|
||||
MinScreenPercentage = 100.0f * DLSSUpscaler->GetMinUpsampleResolutionFraction();
|
||||
MaxScreenPercentage = 100.0f * DLSSUpscaler->GetMaxUpsampleResolutionFraction();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
MinScreenPercentage = 100.0f;
|
||||
MaxScreenPercentage = 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
TArray<UDLSSMode> UDLSSLibrary::GetSupportedDLSSModes()
|
||||
{
|
||||
TArray<UDLSSMode> SupportedQualityModes;
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetSupportedDLSSModes should not be called before PostEngineInit"));
|
||||
return SupportedQualityModes;
|
||||
}
|
||||
#endif
|
||||
{
|
||||
const UEnum* Enum = StaticEnum<UDLSSMode>();
|
||||
for (int32 EnumIndex = 0; EnumIndex < Enum->NumEnums(); ++EnumIndex)
|
||||
{
|
||||
const int64 EnumValue = Enum->GetValueByIndex(EnumIndex);
|
||||
if (EnumValue != Enum->GetMaxEnumValue())
|
||||
{
|
||||
const UDLSSMode QualityMode = UDLSSMode(EnumValue);
|
||||
if (IsDLSSModeSupported(QualityMode))
|
||||
{
|
||||
SupportedQualityModes.Add(QualityMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SupportedQualityModes;
|
||||
}
|
||||
|
||||
bool UDLSSLibrary::IsDLSSSupported()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("IsDLSSSupported should not be called before PostEngineInit"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return QueryDLSSSupport() == UDLSSSupport::Supported;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
UDLSSSupport UDLSSLibrary::QueryDLSSSupport()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("QueryDLSSSupport should not be called before PostEngineInit"));
|
||||
return UDLSSSupport::NotSupported;
|
||||
}
|
||||
#endif
|
||||
return DLSSSupport;
|
||||
}
|
||||
|
||||
void UDLSSLibrary::GetDLSSMinimumDriverVersion(int32& MinDriverVersionMajor, int32& MinDriverVersionMinor)
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDLSSMinimumDriverVersion should not be called before PostEngineInit"));
|
||||
}
|
||||
MinDriverVersionMajor = MinDLSSDriverVersionMajor;
|
||||
MinDriverVersionMinor = MinDLSSDriverVersionMinor;
|
||||
#else
|
||||
MinDriverVersionMajor = 0;
|
||||
MinDriverVersionMinor = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void UDLSSLibrary::EnableDLAA(bool bEnabled)
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("EnableDLAA should not be called before PostEngineInit"));
|
||||
return;
|
||||
}
|
||||
|
||||
static const auto CVarNGXEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.Enable"));
|
||||
bool bNGXEnabled = CVarNGXEnable && (CVarNGXEnable->GetInt() != 0);
|
||||
|
||||
static auto CVarDLAAEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLAA.Enable"));
|
||||
if (CVarDLAAEnable)
|
||||
{
|
||||
// r.NGX.Enable might be set to 0 via hotfix so disable DLAA too (in case it might come from saved settings)
|
||||
bool bDLAAEnabled = bNGXEnabled && bEnabled;
|
||||
CVarDLAAEnable->Set(bDLAAEnabled, ECVF_SetByCommandline);
|
||||
if (bDLAAEnabled)
|
||||
{
|
||||
// DLAA needs to override the temporal upscaler
|
||||
static const auto CVarUseTemporalAAUpscaler = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAA.Upscaler"));
|
||||
CVarUseTemporalAAUpscaler->SetWithCurrentPriority(1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool UDLSSLibrary::IsDLAAEnabled()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("IsDLAAEnabled should not be called before PostEngineInit"));
|
||||
return false;
|
||||
}
|
||||
|
||||
static const auto CVarNGXEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.Enable"));
|
||||
const bool bNGXEnabled = CVarNGXEnable && (CVarNGXEnable->GetInt() != 0);
|
||||
|
||||
const bool bDLAAEnabled = (DLSSUpscaler != nullptr) && DLSSUpscaler->IsDLAAMode();
|
||||
|
||||
return bNGXEnabled && bDLAAEnabled;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void UDLSSLibrary::SetDLSSMode(UDLSSMode DLSSMode)
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("SetDLSSMode should not be called before PostEngineInit"));
|
||||
return;
|
||||
}
|
||||
|
||||
const UEnum* Enum = StaticEnum<UDLSSMode>();
|
||||
|
||||
// UEnums are strongly typed, but then one can also cast a byte to an UEnum ...
|
||||
if(Enum->IsValidEnumValue(int64(DLSSMode)) && (Enum->GetMaxEnumValue() != int64(DLSSMode)))
|
||||
{
|
||||
static const auto CVarNGXEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.Enable"));
|
||||
const bool bNGXEnabled = CVarNGXEnable && CVarNGXEnable->GetInt();
|
||||
|
||||
static auto CVarDLSSEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Enable"));
|
||||
if (CVarDLSSEnable)
|
||||
{
|
||||
// r.NGX.Enable might be set to 0 via hotfix so set r.NGX.DLSS.Enable to 0 too (in case it might come from saved settings)
|
||||
const bool bDLSSEnabled = bNGXEnabled && (DLSSMode != UDLSSMode::Off);
|
||||
CVarDLSSEnable->Set(bDLSSEnabled ? 1 : 0, ECVF_SetByCommandline);
|
||||
|
||||
// Spatial upscalers such as NIS might set this to 0, but we need r.TemporalAA.Upscaler to be 1 for DLSS to work.
|
||||
// but we don't want to change the Cvar if DLSS is not active as to avoid impacting other code paths
|
||||
// we don't need to set r.TemporalAA.Upsampling since r.TemporalAA.Upscaler implies that
|
||||
if (bDLSSEnabled)
|
||||
{
|
||||
static const auto CVarTemporalAAUpscaler = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAA.Upscaler"));
|
||||
CVarTemporalAAUpscaler->Set(1, ECVF_SetByCommandline);
|
||||
}
|
||||
}
|
||||
|
||||
static auto CVarDLSSAutoQualityMode = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Quality.Auto"));
|
||||
if (CVarDLSSAutoQualityMode)
|
||||
{
|
||||
bool bIsAutoQualityMode = bNGXEnabled && (DLSSMode == UDLSSMode::Auto);
|
||||
CVarDLSSAutoQualityMode->Set(bIsAutoQualityMode, ECVF_SetByCommandline);
|
||||
}
|
||||
|
||||
static auto CVarDLSSQuality = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Quality"));
|
||||
|
||||
if (CVarDLSSQuality && (DLSSMode != UDLSSMode::Off) && (DLSSMode != UDLSSMode::Auto))
|
||||
{
|
||||
#if !UE_BUILD_SHIPPING
|
||||
check(IsInGameThread());
|
||||
DLSSErrorState.bIsDLSSModeUnsupported = !IsDLSSModeSupported(DLSSMode);
|
||||
DLSSErrorState.InvalidDLSSMode = DLSSMode;
|
||||
#endif
|
||||
CVarDLSSQuality->Set(ToDLSSQualityCVarValue(DLSSMode), ECVF_SetByCommandline);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !UE_BUILD_SHIPPING
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(
|
||||
TEXT("SetDLSSMode should not be called with an invalid DLSSMode enum value (%d) \"%s\""),
|
||||
int64(DLSSMode), *StaticEnum<UDLSSMode>()->GetDisplayNameTextByValue(int64(DLSSMode)).ToString()),
|
||||
ELogVerbosity::Error, SetDLSSModeInvalidEnumValueError);
|
||||
#endif
|
||||
}
|
||||
#endif // WITH_DLSS
|
||||
}
|
||||
|
||||
UDLSSMode UDLSSLibrary::GetDLSSMode()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDLSSMode should not be called before PostEngineInit"));
|
||||
return UDLSSMode::Off;
|
||||
}
|
||||
|
||||
static const auto CVarTemporalAAUpscaler = IConsoleManager::Get().FindConsoleVariable(TEXT("r.TemporalAA.Upscaler"));
|
||||
const bool bTemporalUpscalerActive = CVarTemporalAAUpscaler && CVarTemporalAAUpscaler->GetInt() != 0;
|
||||
|
||||
static const auto CVarNGXEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.Enable"));
|
||||
const bool bNGXEnabled = CVarNGXEnable && CVarNGXEnable->GetInt();
|
||||
|
||||
static const auto CVarDLSSEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Enable"));
|
||||
const bool bDLSSEnabled = CVarDLSSEnable && CVarDLSSEnable->GetInt();
|
||||
|
||||
static const auto CVarDLSSQuality = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Quality"));
|
||||
const int32 DLSSQuality = CVarDLSSQuality ? CVarDLSSQuality->GetInt() : 0;
|
||||
|
||||
static const auto CVarDLSSAutoQualityMode = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Quality.Auto"));
|
||||
const bool bIsAutoQualityMode = CVarDLSSAutoQualityMode ? CVarDLSSAutoQualityMode->GetBool() : false;
|
||||
const bool bDLAAEnabled = (DLSSUpscaler != nullptr) && DLSSUpscaler->IsDLAAMode();
|
||||
|
||||
if (bDLAAEnabled)
|
||||
{
|
||||
// DLSS is mutually exclusive with DLAA, DLAA wins
|
||||
return UDLSSMode::Off;
|
||||
}
|
||||
else if (bTemporalUpscalerActive && bNGXEnabled && bDLSSEnabled && bIsAutoQualityMode)
|
||||
{
|
||||
return UDLSSMode::Auto;
|
||||
}
|
||||
else if (bTemporalUpscalerActive && bNGXEnabled && bDLSSEnabled && CVarDLSSQuality)
|
||||
{
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to handle the new enum values");
|
||||
|
||||
switch (EDLSSQualityMode(DLSSQuality))
|
||||
{
|
||||
case EDLSSQualityMode::UltraPerformance:
|
||||
return UDLSSMode::UltraPerformance;
|
||||
|
||||
default:
|
||||
UE_LOG(LogDLSSBlueprint , Error, TEXT("r.NGX.DLSS.Quality is set to %d, which is outside of the valid range [%d, %d])"), DLSSQuality, EDLSSQualityMode::MinValue, EDLSSQualityMode::MaxValue);
|
||||
|
||||
case EDLSSQualityMode::Performance:
|
||||
return UDLSSMode::Performance;
|
||||
|
||||
case EDLSSQualityMode::Balanced:
|
||||
return UDLSSMode::Balanced;
|
||||
|
||||
case EDLSSQualityMode::Quality:
|
||||
return UDLSSMode::Quality;
|
||||
|
||||
case EDLSSQualityMode::UltraQuality:
|
||||
return UDLSSMode::UltraQuality;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
return UDLSSMode::Off;
|
||||
}
|
||||
|
||||
#ifndef ENGINE_CAN_SUPPORT_NIS_PLUGIN
|
||||
#define ENGINE_CAN_SUPPORT_NIS_PLUGIN (ENGINE_MAJOR_VERSION == 5 || (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION ==27 && ENGINE_PATCH_VERSION >=1 ))
|
||||
#endif
|
||||
|
||||
void UDLSSLibrary::SetDLSSSharpness(float Sharpness)
|
||||
{
|
||||
#if WITH_DLSS
|
||||
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("SetDLSSSharpness should not be called before PostEngineInit"));
|
||||
return;
|
||||
}
|
||||
static const auto CVarNGXDLSSharpness = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Sharpness"));
|
||||
if (CVarNGXDLSSharpness)
|
||||
{
|
||||
#if ENGINE_CAN_SUPPORT_NIS_PLUGIN
|
||||
static const auto CVarNISSharpness = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NIS.Sharpness"));
|
||||
static const auto CVarNISEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NIS.Enable"));
|
||||
const bool bHasNISPlugin = CVarNISSharpness != nullptr && CVarNISEnable != nullptr;
|
||||
const bool bIsNISEnabled = bHasNISPlugin && CVarNISEnable->GetBool();
|
||||
|
||||
if (bHasNISPlugin && bIsNISEnabled)
|
||||
{
|
||||
const int32 PreferNISSharpen = CVarNGXDLSSPreferNISSharpen.GetValueOnAnyThread();
|
||||
const bool bUseNISSharpen = PreferNISSharpen == 1 || (PreferNISSharpen == 2 && Sharpness > 0);
|
||||
if (bUseNISSharpen)
|
||||
{
|
||||
Sharpness = FMath::Clamp(Sharpness, 0.0f, 1.0f);
|
||||
}
|
||||
// Quantize here so we can have sharpness snap to 0, which downstream is used to turn off the NGX sharpening flag
|
||||
// CVarNGXDLSSharpness->Set(Sharpness, ECVF_SetByCommandline) internally uses Set(*FString::Printf(TEXT("%g"), InValue), SetBy);
|
||||
CVarNGXDLSSharpness->Set(*FString::Printf(TEXT("%2.2f"), bUseNISSharpen ? 0.0f : Sharpness), ECVF_SetByCommandline);
|
||||
CVarNISSharpness->Set( *FString::Printf(TEXT("%2.2f"), bUseNISSharpen ? Sharpness : 0.0f), ECVF_SetByCommandline);
|
||||
}
|
||||
else
|
||||
#endif // ENGINE_CAN_SUPPORT_NIS_PLUGIN
|
||||
{
|
||||
// Quantize here so we can have sharpness snap to 0, which downstream is used to turn off the NGX sharpening flag
|
||||
// CVarNGXDLSSharpness->Set(Sharpness, ECVF_SetByCommandline) internally uses Set(*FString::Printf(TEXT("%g"), InValue), SetBy);
|
||||
CVarNGXDLSSharpness->Set(*FString::Printf(TEXT("%2.2f"), Sharpness), ECVF_SetByCommandline);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
float UDLSSLibrary::GetDLSSSharpness()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDLSSSharpness should not be called before PostEngineInit"));
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
static const auto CVarNGXDLSSharpness = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Sharpness"));
|
||||
|
||||
if (CVarNGXDLSSharpness)
|
||||
{
|
||||
#if ENGINE_CAN_SUPPORT_NIS_PLUGIN
|
||||
static const auto CVarNISSharpness = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NIS.Sharpness"));
|
||||
static const auto CVarNISEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NIS.Enable"));
|
||||
const bool bHasNISPlugin = CVarNISSharpness != nullptr && CVarNISEnable != nullptr;
|
||||
const bool bIsNISEnabled = bHasNISPlugin && CVarNISEnable->GetBool();
|
||||
const int32 PreferNISSharpen = CVarNGXDLSSPreferNISSharpen.GetValueOnAnyThread();
|
||||
if (bHasNISPlugin && bIsNISEnabled && (PreferNISSharpen == 1))
|
||||
{
|
||||
return CVarNISSharpness->GetFloat();
|
||||
}
|
||||
else if (bHasNISPlugin && bIsNISEnabled && (PreferNISSharpen == 2))
|
||||
{
|
||||
const float DLSSSharpness = CVarNGXDLSSharpness->GetFloat();
|
||||
if (DLSSSharpness < 0)
|
||||
{
|
||||
return DLSSSharpness;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CVarNISSharpness->GetFloat();
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return CVarNGXDLSSharpness->GetFloat();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
UDLSSMode UDLSSLibrary::GetDefaultDLSSMode()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
if (!TryInitDLSSLibrary())
|
||||
{
|
||||
UE_LOG(LogDLSSBlueprint, Error, TEXT("GetDefaultDLSSMode should not be called before PostEngineInit"));
|
||||
return UDLSSMode::Off;
|
||||
}
|
||||
#endif
|
||||
if (UDLSSLibrary::IsDLSSSupported())
|
||||
{
|
||||
return UDLSSMode::Auto;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UDLSSMode::Off;
|
||||
}
|
||||
}
|
||||
|
||||
#if WITH_DLSS
|
||||
static UDLSSSupport ToUDLSSSupport(EDLSSSupport InDLSSSupport)
|
||||
{
|
||||
switch (InDLSSSupport)
|
||||
{
|
||||
|
||||
case EDLSSSupport::Supported:
|
||||
return UDLSSSupport::Supported;
|
||||
|
||||
// this should be resolved at development time
|
||||
default:
|
||||
checkf(false, TEXT("ToUDLSSSupport should not be called with an out of range InDLSSSupport from the higher level code"));
|
||||
case EDLSSSupport::NotSupported:
|
||||
return UDLSSSupport::NotSupported;
|
||||
|
||||
case EDLSSSupport::NotSupportedIncompatibleHardware:
|
||||
return UDLSSSupport::NotSupportedIncompatibleHardware;
|
||||
|
||||
|
||||
case EDLSSSupport::NotSupportedDriverOutOfDate:
|
||||
return UDLSSSupport::NotSupportedDriverOutOfDate;
|
||||
|
||||
case EDLSSSupport::NotSupportedOperatingSystemOutOfDate:
|
||||
return UDLSSSupport::NotSupportedOperatingSystemOutOfDate;
|
||||
|
||||
case EDLSSSupport::NotSupportedIncompatibleAPICaptureToolActive:
|
||||
return UDLSSSupport::NotSupportedIncompatibleAPICaptureToolActive;
|
||||
}
|
||||
}
|
||||
|
||||
// Delayed initialization, which allows this module to be available early so blueprints can be loaded before DLSS is available in PostEngineInit
|
||||
bool UDLSSLibrary::TryInitDLSSLibrary()
|
||||
{
|
||||
if (bDLSSLibraryInitialized)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Register this before we bail out so we can show error messages
|
||||
#if !UE_BUILD_SHIPPING
|
||||
if (!DLSSOnScreenMessagesDelegateHandle.IsValid())
|
||||
{
|
||||
DLSSOnScreenMessagesDelegateHandle = FCoreDelegates::OnGetOnScreenMessages.AddStatic(&GetDLSSOnScreenMessages);
|
||||
}
|
||||
#endif
|
||||
|
||||
IDLSSModuleInterface* DLSSModule = FModuleManager::GetModulePtr<IDLSSModuleInterface>(TEXT("DLSS"));
|
||||
if (DLSSModule == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DLSSUpscaler = DLSSModule->GetDLSSUpscaler();
|
||||
DLSSSupport = ToUDLSSSupport(DLSSModule->QueryDLSSSupport());
|
||||
DLSSModule->GetDLSSMinDriverVersion(MinDLSSDriverVersionMajor, MinDLSSDriverVersionMinor);
|
||||
|
||||
checkf((DLSSModule->GetDLSSUpscaler() != nullptr) || (DLSSModule->QueryDLSSSupport() != EDLSSSupport::Supported), TEXT("mismatch between not having a valid DLSSModule->GetDLSSUpscaler() while also reporting DLSS as being supported by DLSSModule->QueryDLSSSupport() %u "), DLSSModule->QueryDLSSSupport());
|
||||
|
||||
bDLSSLibraryInitialized = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // WITH_DLSS
|
||||
|
||||
void FDLSSBlueprintModule::StartupModule()
|
||||
{
|
||||
#if WITH_DLSS
|
||||
// This initialization will likely not succeed unless this module has been moved to PostEngineInit, and that's ok
|
||||
UDLSSLibrary::TryInitDLSSLibrary();
|
||||
#else
|
||||
UE_LOG(LogDLSSBlueprint, Log, TEXT("DLSS is not supported on this platform at build time. The DLSS Blueprint library however is supported and stubbed out to ignore any calls to enable DLSS and will always return UDLSSSupport::NotSupportedByPlatformAtBuildTime, regardless of the underlying hardware. This can be used to e.g. to turn off DLSS related UI elements."));
|
||||
UDLSSLibrary::DLSSSupport = UDLSSSupport::NotSupportedByPlatformAtBuildTime;
|
||||
#endif
|
||||
}
|
||||
|
||||
void FDLSSBlueprintModule::ShutdownModule()
|
||||
{
|
||||
#if WITH_DLSS && !UE_BUILD_SHIPPING
|
||||
if (UDLSSLibrary::DLSSOnScreenMessagesDelegateHandle.IsValid())
|
||||
{
|
||||
FCoreDelegates::OnGetOnScreenMessages.Remove(UDLSSLibrary::DLSSOnScreenMessagesDelegateHandle);
|
||||
UDLSSLibrary::DLSSOnScreenMessagesDelegateHandle.Reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDLSSBlueprintModule, DLSSBlueprint)
|
||||
|
||||
166
Plugins/DLSS/Source/DLSSBlueprint/Public/DLSSLibrary.h
Normal file
166
Plugins/DLSS/Source/DLSSBlueprint/Public/DLSSLibrary.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Misc/CoreDelegates.h"
|
||||
|
||||
#include "DLSSLibrary.generated.h"
|
||||
|
||||
class FDLSSUpscaler;
|
||||
class FDelegateHandle;
|
||||
|
||||
#ifndef WITH_DLSS
|
||||
#define WITH_DLSS 0
|
||||
#endif
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class UDLSSSupport : uint8
|
||||
{
|
||||
Supported UMETA(DisplayName = "Supported"),
|
||||
|
||||
NotSupported UMETA(DisplayName = "Not Supported"),
|
||||
NotSupportedIncompatibleHardware UMETA(DisplayName = "Incompatible Hardware", ToolTip = "DLSS requires an NVIDIA RTX GPU"),
|
||||
NotSupportedDriverOutOfDate UMETA(DisplayName = "Driver Out of Date", ToolTip = "The driver is outdated. Also see GetDLSSMinimumDriverVersion"),
|
||||
NotSupportedOperatingSystemOutOfDate UMETA(DisplayName = "Operating System Out of Date", ToolTip = "DLSS requires at least Windows 10 Fall 2017 Creators Update 64-bit, (v1709, build 16299)"),
|
||||
NotSupportedByPlatformAtBuildTime UMETA(DisplayName = "Platform Not Supported At Build Time", ToolTip = "This platform doesn't not support DLSS at build time. Currently DLSS is only supported on Windows 64"),
|
||||
NotSupportedIncompatibleAPICaptureToolActive UMETA(DisplayName = "Incompatible API Capture Tool Active", ToolTip = "DLSS is not compatible with an active API capture tool such as RenderDoc.")
|
||||
};
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class UDLSSMode : uint8
|
||||
{
|
||||
Off UMETA(DisplayName = "Off"),
|
||||
Auto UMETA(DisplayName = "Auto"),
|
||||
UltraQuality UMETA(DisplayName = "Ultra Quality"),
|
||||
Quality UMETA(DisplayName = "Quality"),
|
||||
Balanced UMETA(DisplayName = "Balanced"),
|
||||
Performance UMETA(DisplayName = "Performance"),
|
||||
UltraPerformance UMETA(DisplayName = "Ultra Performance")
|
||||
};
|
||||
|
||||
UCLASS(MinimalAPI)
|
||||
class UDLSSLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
friend class FDLSSBlueprintModule;
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
/** Checks whether DLSS/DLAA is supported by the current GPU. Further details can be retrieved via QueryDLSSSupport*/
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Is NVIDIA DLSS Supported"))
|
||||
static DLSSBLUEPRINT_API bool IsDLSSSupported();
|
||||
|
||||
/** Checks whether DLSS/DLAA is supported by the current GPU */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Query NVIDIA DLSS Support"))
|
||||
static DLSSBLUEPRINT_API UDLSSSupport QueryDLSSSupport();
|
||||
|
||||
/** If QueryDLSSSupport returns "NotSupportedDriverOutOfDate", then MinDriverVersionMajor and MinDriverVersionMinor contains the required driver version.*/
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get DLSS Minimum DriverVersion"))
|
||||
static DLSSBLUEPRINT_API void GetDLSSMinimumDriverVersion(int32& MinDriverVersionMajor, int32& MinDriverVersionMinor);
|
||||
|
||||
/** Enable/disable DLAA. Note that while DLAA is enabled, DLSS will be automatically disabled */
|
||||
UFUNCTION(BlueprintCallable, Category = "DLSS", meta = (DisplayName = "Enable DLAA"))
|
||||
static DLSSBLUEPRINT_API void EnableDLAA(bool bEnabled);
|
||||
|
||||
/** Checks whether DLAA is enabled */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Is DLAA Enabled"))
|
||||
static DLSSBLUEPRINT_API bool IsDLAAEnabled();
|
||||
|
||||
/** Checks whether a DLSS mode is supported */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Is DLSS Mode Supported"))
|
||||
static DLSSBLUEPRINT_API bool IsDLSSModeSupported(UDLSSMode DLSSMode);
|
||||
|
||||
/** Retrieves all supported DLSS modes. Can be used to populate UI */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get Supported DLSS Modes"))
|
||||
static DLSSBLUEPRINT_API TArray<UDLSSMode> GetSupportedDLSSModes();
|
||||
|
||||
/** Provides additional details (such as screen percentage ranges) about a DLSS mode. Screen Resolution is required for Auto mode */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get DLSS Mode Information"))
|
||||
static DLSSBLUEPRINT_API void GetDLSSModeInformation(UDLSSMode DLSSMode, FVector2D ScreenResolution, bool& bIsSupported, float& OptimalScreenPercentage, bool& bIsFixedScreenPercentage, float& MinScreenPercentage, float& MaxScreenPercentage, float& OptimalSharpness);
|
||||
|
||||
/** The global screen percentage range that DLSS supports. Excludes DLSS modes with fixed screen percentage. Also see GetDLSSModeInformation*/
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get DLSS Screenpercentage Range"))
|
||||
static DLSSBLUEPRINT_API void GetDLSSScreenPercentageRange(float& MinScreenPercentage, float& MaxScreenPercentage);
|
||||
|
||||
/** Sets the console variables to enable/disable DLSS (r.NGX.DLSS.Enable, r.NGX.DLSS.Quality)*/
|
||||
UFUNCTION(BlueprintCallable, Category = "DLSS", meta = (DisplayName = "Set DLSS Mode"))
|
||||
static DLSSBLUEPRINT_API void SetDLSSMode(UDLSSMode DLSSMode);
|
||||
|
||||
/* Reads the console variables to infer the current DLSS mode (r.NGX.DLSS.Enable, r.NGX.DLSS.Quality, r.TemporalAA.Upscaler)*/
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get DLSS Mode"))
|
||||
static DLSSBLUEPRINT_API UDLSSMode GetDLSSMode();
|
||||
|
||||
/* Sets the console variables to enable additional DLSS sharpening. Set to 0 to disable (r.NGX.DLSS.Sharpness) */
|
||||
UFUNCTION(BlueprintCallable, Category = "DLSS", meta = (DisplayName = "Set DLSS Sharpness"))
|
||||
static DLSSBLUEPRINT_API void SetDLSSSharpness(float Sharpness);
|
||||
|
||||
/*Reads the console variables to infer the current DLSS sharpness (r.NGX.DLSS.Sharpness) */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get DLSS Sharpness"))
|
||||
static DLSSBLUEPRINT_API float GetDLSSSharpness();
|
||||
|
||||
/* Find a reasonable default DLSS mode based on current hardware */
|
||||
UFUNCTION(BlueprintPure, Category = "DLSS", meta = (DisplayName = "Get Default DLSS Mode"))
|
||||
static DLSSBLUEPRINT_API UDLSSMode GetDefaultDLSSMode();
|
||||
|
||||
/* Allows conversion from BlueprintType enums. */
|
||||
static DLSSBLUEPRINT_API int32 ToDLSSQualityCVarValue(UDLSSMode InDLSSQualityMode);
|
||||
|
||||
private:
|
||||
static UDLSSSupport DLSSSupport;
|
||||
|
||||
#if WITH_DLSS
|
||||
static int32 MinDLSSDriverVersionMinor;
|
||||
static int32 MinDLSSDriverVersionMajor;
|
||||
static FDLSSUpscaler* DLSSUpscaler;
|
||||
static bool bDLSSLibraryInitialized;
|
||||
|
||||
static bool TryInitDLSSLibrary();
|
||||
|
||||
#if !UE_BUILD_SHIPPING
|
||||
struct FDLSSErrorState
|
||||
{
|
||||
bool bIsDLSSModeUnsupported = false;
|
||||
UDLSSMode InvalidDLSSMode = UDLSSMode::Off;
|
||||
};
|
||||
|
||||
static FDLSSErrorState DLSSErrorState;
|
||||
|
||||
static void GetDLSSOnScreenMessages(TMultiMap<FCoreDelegates::EOnScreenMessageSeverity, FText>& OutMessages);
|
||||
static FDelegateHandle DLSSOnScreenMessagesDelegateHandle;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
class FDLSSBlueprintModule final : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
};
|
||||
84
Plugins/DLSS/Source/DLSSEditor/DLSSEditor.Build.cs
Normal file
84
Plugins/DLSS/Source/DLSSEditor/DLSSEditor.Build.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class DLSSEditor : ModuleRules
|
||||
{
|
||||
public DLSSEditor(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/Renderer/Private"),
|
||||
Path.Combine(EngineDirectory,"Source/Editor/LevelEditor/Private"),
|
||||
|
||||
Path.Combine(ModuleDirectory, "../DLSS/Private")
|
||||
}
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"DLSS",
|
||||
}
|
||||
);
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"Renderer",
|
||||
"RHI",
|
||||
|
||||
"Settings",
|
||||
"LevelEditor",
|
||||
"ToolMenus",
|
||||
"Slate",
|
||||
"SlateCore",
|
||||
"EditorWidgets",
|
||||
"EditorStyle",
|
||||
"InputCore",
|
||||
"UnrealEd",
|
||||
"Projects",
|
||||
|
||||
"NGX",
|
||||
"DLSS",
|
||||
"NGXRHI",
|
||||
}
|
||||
);
|
||||
// We can't quite check whether we have CL 16509387 (in UE5-Release) so we do this in a round about way
|
||||
bool bUseSlotsArgumentsAPI = (Target.Version.MajorVersion == 5) && (Target.Version.BranchName != "++UE5+Release-5.0-EarlyAccess");
|
||||
PrivateDefinitions.Add(string.Format("USE_SLOT_SLOT_ARGUMENTS_API={0}", bUseSlotsArgumentsAPI ? "1" : "0"));
|
||||
|
||||
// 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"));
|
||||
|
||||
// 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"));
|
||||
}
|
||||
}
|
||||
124
Plugins/DLSS/Source/DLSSEditor/Private/DLSSEditor.cpp
Normal file
124
Plugins/DLSS/Source/DLSSEditor/Private/DLSSEditor.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* 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 "DLSSEditor.h"
|
||||
|
||||
#include "DLSSUpscaler.h"
|
||||
#include "DLSSUpscalerEditor.h"
|
||||
#include "DLSS.h"
|
||||
#include "DLSSSettings.h"
|
||||
#include "NGXRHI.h"
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ISettingsModule.h"
|
||||
#include "ISettingsSection.h"
|
||||
#include "UObject/Class.h"
|
||||
#include "UObject/WeakObjectPtr.h"
|
||||
|
||||
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSEditorModule"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogDLSSEditor);
|
||||
|
||||
void FDLSSEditorModule::StartupModule()
|
||||
{
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
check(GIsEditor);
|
||||
|
||||
// verify that the other DLSS modules are correctly hooked up
|
||||
{
|
||||
IDLSSModuleInterface* DLSSModule = &FModuleManager::LoadModuleChecked<IDLSSModuleInterface>(TEXT("DLSS"));
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("DLSS module %p, QueryDLSSSupport = %u DLSSUpscaler = %p"), DLSSModule, DLSSModule->QueryDLSSSupport(), DLSSModule->GetDLSSUpscaler());
|
||||
|
||||
bIsDLSSAvailable = DLSSModule->QueryDLSSSupport() == EDLSSSupport::Supported;
|
||||
if (bIsDLSSAvailable)
|
||||
{
|
||||
checkf(GCustomStaticScreenPercentage == DLSSModule->GetDLSSUpscaler(),TEXT("GCustomStaticScreenPercentage is not set to the DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
|
||||
DLSSUpscalerEditor = MakeShared<FDLSSUpscalerEditor>(DLSSModule->GetDLSSUpscaler());
|
||||
checkf(GCustomEditorStaticScreenPercentage == nullptr, TEXT("GCustomEditorStaticScreenPercentage is already in use. Please check that only one upscaling active is active."));
|
||||
GCustomEditorStaticScreenPercentage = DLSSUpscalerEditor.Get();
|
||||
}
|
||||
}
|
||||
|
||||
// register settings
|
||||
{
|
||||
ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>("Settings");
|
||||
if (SettingsModule != nullptr)
|
||||
{
|
||||
{
|
||||
auto Settings = GetMutableDefault<UDLSSSettings>();
|
||||
if(bIsDLSSAvailable)
|
||||
{
|
||||
IDLSSModuleInterface* DLSSModule = &FModuleManager::LoadModuleChecked<IDLSSModuleInterface>(TEXT("DLSS"));
|
||||
const NGXRHI* NGXRHIExtensions = DLSSModule->GetDLSSUpscaler()->GetNGXRHI();
|
||||
Settings->GenericDLSSBinaryPath = NGXRHIExtensions->GetDLSSGenericBinaryInfo().Get<0>();
|
||||
Settings->bGenericDLSSBinaryExists = NGXRHIExtensions->GetDLSSGenericBinaryInfo().Get<1>();
|
||||
|
||||
Settings->CustomDLSSBinaryPath = NGXRHIExtensions->GetDLSSCustomBinaryInfo().Get<0>();
|
||||
Settings->bCustomDLSSBinaryExists = NGXRHIExtensions->GetDLSSCustomBinaryInfo().Get<1>();
|
||||
}
|
||||
|
||||
ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "Plugins", "DLSS",
|
||||
LOCTEXT("DLSSSettingsName", "NVIDIA DLSS"),
|
||||
LOCTEXT("DLSSSettingsDescription", "Configure the NVIDIA DLSS plug-in."),
|
||||
Settings
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
auto Settings = GetMutableDefault<UDLSSOverrideSettings>();
|
||||
|
||||
ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings("Project", "Plugins", "DLSSOverride",
|
||||
LOCTEXT("DLSSOverrideSettingsName", "NVIDIA DLSS Overrides (Local)"),
|
||||
LOCTEXT("DLSSOverrideSettingsDescription", "Configure the local settings for the NVIDIA DLSS plug-in."),
|
||||
Settings
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void FDLSSEditorModule::ShutdownModule()
|
||||
{
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
if (bIsDLSSAvailable)
|
||||
{
|
||||
GCustomEditorStaticScreenPercentage = nullptr;
|
||||
DLSSUpscalerEditor = nullptr;
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
FDLSSUpscalerEditor* FDLSSEditorModule::GetDLSSUpscalerEditor() const
|
||||
{
|
||||
return DLSSUpscalerEditor.Get();
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDLSSEditorModule, DLSSEditor)
|
||||
|
||||
549
Plugins/DLSS/Source/DLSSEditor/Private/DLSSUpscalerEditor.cpp
Normal file
549
Plugins/DLSS/Source/DLSSEditor/Private/DLSSUpscalerEditor.cpp
Normal file
@@ -0,0 +1,549 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "DLSSUpscalerEditor.h"
|
||||
#include "DLSSUpscaler.h"
|
||||
|
||||
#include "LegacyScreenPercentageDriver.h"
|
||||
|
||||
#include "DLSSSettings.h"
|
||||
|
||||
#include "Editor.h"
|
||||
#include "SLevelViewportToolBar.h"
|
||||
#include "ToolMenus.h"
|
||||
#include "Widgets/Layout/SBox.h"
|
||||
#include "Widgets/Input/SSpinBox.h"
|
||||
#include "Framework/Commands/Commands.h"
|
||||
|
||||
#include "ISettingsModule.h"
|
||||
#include "ISettingsSection.h"
|
||||
#include "UObject/Class.h"
|
||||
#include "UObject/WeakObjectPtr.h"
|
||||
#include "Widgets/SBoxPanel.h"
|
||||
#include "Widgets/SNullWidget.h"
|
||||
#include "Styling/SlateTypes.h"
|
||||
#include "Widgets/Layout/SBorder.h"
|
||||
#include "Widgets/Text/STextBlock.h"
|
||||
#include "Widgets/Input/SButton.h"
|
||||
#include "Widgets/Input/SCheckBox.h"
|
||||
#include "Widgets/Input/SSlider.h"
|
||||
#include "Widgets/Layout/SGridPanel.h"
|
||||
|
||||
#include "EditorStyleSet.h"
|
||||
#include "Editor.h"
|
||||
#include "Settings/EditorSettings.h"
|
||||
#include "Editor/EditorPerformanceSettings.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSEditorModule"
|
||||
|
||||
|
||||
// We can't quite check whether we have CL 16509387 in UE5-Release-5.0 so we do this in a round about way by branch name
|
||||
// We also can't do a preprocessor string compare in C++ so we resolve this in DLSSEditor.Build.cs;
|
||||
#ifndef USE_SLOT_SLOT_ARGUMENTS_API
|
||||
#define USE_SLOT_SLOT_ARGUMENTS_API 1
|
||||
#endif
|
||||
|
||||
// We can't quite check whether we have CL 16848904 (in UE5-Main) so we do this in a round about way
|
||||
#ifndef SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE
|
||||
#define SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE 1
|
||||
#endif
|
||||
|
||||
// DLSS_TODO move the implementation of this to FDLSSUpscalerEditor?
|
||||
class DLSSEDITOR_API SDLSSSettings : public SCompoundWidget
|
||||
{
|
||||
public:
|
||||
|
||||
SLATE_BEGIN_ARGS(SDLSSSettings)
|
||||
{}
|
||||
SLATE_ARGUMENT(FDLSSUpscalerEditor*, UpscalerEditor)
|
||||
SLATE_ARGUMENT(ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments,ViewportMenuEntryArguments)
|
||||
|
||||
SLATE_END_ARGS()
|
||||
|
||||
// Widget construction
|
||||
void Construct(const FArguments& InArgs);
|
||||
|
||||
~SDLSSSettings();
|
||||
private:
|
||||
|
||||
// Makes a general quality level header button widget
|
||||
TSharedRef<SWidget> MakeHeaderButtonWidget(const FText& InName, EDLSSQualityMode InQualityLevel, const FText& InToolTip);
|
||||
|
||||
// Callback for when a quality level header button is pressed
|
||||
FReply OnHeaderClicked(EDLSSQualityMode InQualityLevel);
|
||||
|
||||
|
||||
// Create a gridslot for the group quality level with all the required formatting
|
||||
#if USE_SLOT_SLOT_ARGUMENTS_API
|
||||
SGridPanel::FSlot::FSlotArguments MakeGridSlot(int32 InCol, int32 InRow, int32 InColSpan = 1, int32 InRowSpan = 1);
|
||||
#else
|
||||
SGridPanel::FSlot& MakeGridSlot(int32 InCol, int32 InRow, int32 InColSpan = 1, int32 InRowSpan = 1);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
FDLSSUpscalerEditor* UpscalerEditor;
|
||||
ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments ViewportMenuEntryArguments;
|
||||
};
|
||||
|
||||
TSharedRef<SWidget> SDLSSSettings::MakeHeaderButtonWidget(const FText& InName, EDLSSQualityMode InQualityLevel, const FText& InToolTip)
|
||||
{
|
||||
return SNew(SButton)
|
||||
.OnClicked(this, &SDLSSSettings::OnHeaderClicked, InQualityLevel)
|
||||
.ToolTipText(InToolTip)
|
||||
.Content()
|
||||
[
|
||||
SNew(STextBlock)
|
||||
.Text(InName)
|
||||
];
|
||||
}
|
||||
|
||||
FReply SDLSSSettings::OnHeaderClicked(EDLSSQualityMode InQualityLevel)
|
||||
{
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s InQualityLevel = %d"), ANSI_TO_TCHAR(__FUNCTION__), InQualityLevel);
|
||||
if (InQualityLevel != EDLSSQualityMode::NumValues)
|
||||
{
|
||||
const int32 ScreenPercentage = UpscalerEditor->DLSSUpscaler->GetOptimalResolutionFractionForQuality(InQualityLevel) * 100.0f;
|
||||
|
||||
UpscalerEditor->OnQualityModeSelected(InQualityLevel, ViewportMenuEntryArguments);
|
||||
|
||||
UpscalerEditor->OnScreenPercentageValueChanged(ScreenPercentage, ViewportMenuEntryArguments);
|
||||
UpscalerEditor->OnSetPreviewCustomTemporalUpscaler(true, ViewportMenuEntryArguments);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
UpscalerEditor->OnSetPreviewCustomTemporalUpscaler(false, ViewportMenuEntryArguments);
|
||||
}
|
||||
|
||||
return FReply::Handled();
|
||||
}
|
||||
#if USE_SLOT_SLOT_ARGUMENTS_API
|
||||
SGridPanel::FSlot::FSlotArguments SDLSSSettings::MakeGridSlot(int32 InCol, int32 InRow, int32 InColSpan /*= 1*/, int32 InRowSpan /*= 1*/)
|
||||
{
|
||||
float PaddingH = 2.0f;
|
||||
float PaddingV = InRow == 0 ? 8.0f : 2.0f;
|
||||
return MoveTemp(SGridPanel::Slot(InCol, InRow)
|
||||
.Padding(PaddingH, PaddingV)
|
||||
.RowSpan(InRowSpan)
|
||||
.ColumnSpan(InColSpan));
|
||||
}
|
||||
#else
|
||||
SGridPanel::FSlot& SDLSSSettings::MakeGridSlot(int32 InCol, int32 InRow, int32 InColSpan /*= 1*/, int32 InRowSpan /*= 1*/)
|
||||
{
|
||||
float PaddingH = 2.0f;
|
||||
float PaddingV = InRow == 0 ? 8.0f : 2.0f;
|
||||
return SGridPanel::Slot(InCol, InRow)
|
||||
.Padding(PaddingH, PaddingV)
|
||||
.RowSpan(InRowSpan)
|
||||
.ColumnSpan(InColSpan);
|
||||
}
|
||||
#endif
|
||||
void SDLSSSettings::Construct(const FArguments& InArgs)
|
||||
{
|
||||
this->UpscalerEditor = InArgs._UpscalerEditor;
|
||||
this->ViewportMenuEntryArguments = InArgs._ViewportMenuEntryArguments;
|
||||
|
||||
auto TitleFont = FEditorStyle::GetFontStyle(TEXT("MenuItem.Font"));
|
||||
|
||||
static float QualityColumnCoeff = 1.0f;
|
||||
|
||||
static_assert(int32(EDLSSQualityMode::NumValues) == 5, "dear DLSS plugin NVIDIA developer, please update this code to handle the new enum values");
|
||||
|
||||
auto MakeWidget = [this](EDLSSQualityMode QualityMode, const FText& InName, const FText& InToolTip)
|
||||
{
|
||||
const bool bSupported = UpscalerEditor->DLSSUpscaler->IsQualityModeSupported(QualityMode);
|
||||
if (!bSupported)
|
||||
{
|
||||
return SNullWidget::NullWidget;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MakeHeaderButtonWidget(InName, QualityMode, InToolTip);
|
||||
}
|
||||
};
|
||||
|
||||
TSharedRef<SGridPanel> ButtonMatrix =
|
||||
SNew(SGridPanel)
|
||||
.FillColumn(0, QualityColumnCoeff)
|
||||
+ MakeGridSlot(0, 0).VAlign(VAlign_Center)[SNew(STextBlock).Text(LOCTEXT("DLSSModeLabel" , "DLSS Mode")).Font(TitleFont)]
|
||||
+ MakeGridSlot(1, 0)[MakeHeaderButtonWidget(LOCTEXT("DLSSModeOffLabel", "Off"), EDLSSQualityMode::NumValues, LOCTEXT("DLSSModeOff" , "Turn DLSS off and use built-in TAA"))]
|
||||
+ MakeGridSlot(2, 0)[MakeWidget(EDLSSQualityMode::UltraQuality, LOCTEXT("DLSSModeUltraQualityLabel", "Ultra Quality"), LOCTEXT("DLSSModeUltraQuality", "Set DLSS mode to Ultra Quality"))]
|
||||
+ MakeGridSlot(3, 0)[MakeWidget(EDLSSQualityMode::Quality, LOCTEXT("DLSSModeQualityLabel", "Quality"), LOCTEXT("DLSSModeQuality", "Set DLSS mode to Quality"))]
|
||||
+ MakeGridSlot(4, 0)[MakeWidget(EDLSSQualityMode::Balanced, LOCTEXT("DLSSModeBalancedLabel", "Balanced"), LOCTEXT("DLSSModeBalanced", "Set DLSS mode to Balanced"))]
|
||||
+ MakeGridSlot(5, 0)[MakeWidget(EDLSSQualityMode::Performance, LOCTEXT("DLSSModePerformanceLabel", "Performance"), LOCTEXT("DLSSModePerformance", "Set DLSS mode to Performance"))]
|
||||
+ MakeGridSlot(6, 0)[MakeWidget(EDLSSQualityMode::UltraPerformance, LOCTEXT("DLSSModeUltraPerformanceLabel", "Ultra Performance"), LOCTEXT("DLSSModeUltraPerformance", "Set DLSS mode to Ultra Performance"))];
|
||||
|
||||
this->ChildSlot
|
||||
.HAlign(EHorizontalAlignment::HAlign_Fill)
|
||||
[
|
||||
SNew(SVerticalBox)
|
||||
+ SVerticalBox::Slot()
|
||||
[
|
||||
ButtonMatrix
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
SDLSSSettings::~SDLSSSettings()
|
||||
{
|
||||
|
||||
}
|
||||
static void MakeDLSSQualitySettingsMenu(UToolMenu* InMenu, FDLSSUpscalerEditor* DLSSUpscalerEditor, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments)
|
||||
{
|
||||
{
|
||||
FToolMenuSection& Section = InMenu->AddSection("Section");
|
||||
Section.AddEntry(FToolMenuEntry::InitWidget("DLSSQualitySettings", SNew(SDLSSSettings).UpscalerEditor(DLSSUpscalerEditor).ViewportMenuEntryArguments(Arguments), FText(), true));
|
||||
}
|
||||
}
|
||||
|
||||
class DLSSEDITOR_API FFDLSSEditorViewportClientData final : public FEditorViewportClient::ICustomTemporalUpscalerData
|
||||
{
|
||||
public:
|
||||
|
||||
bool bIsDLSSEnabled;
|
||||
float ResolutionFraction;
|
||||
|
||||
EDLSSQualityMode DLSSQualityMode = EDLSSQualityMode::NumValues;
|
||||
float MinResolutionFraction = 0.0f;
|
||||
float MaxResolutionFraction = 1.0f;
|
||||
bool bIsFixedResolutionFraction = false;
|
||||
};
|
||||
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> FDLSSUpscalerEditor::GetOrCreateDLSSViewportData(FEditorViewportClient* ViewportClient)
|
||||
{
|
||||
check(ViewportClient);
|
||||
TSharedPtr<FEditorViewportClient::ICustomTemporalUpscalerData> CustomData = ViewportClient->GetCustomTemporalUpscalerData();
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData;
|
||||
|
||||
if (CustomData)
|
||||
{
|
||||
DLSSViewportData = StaticCastSharedPtr<FFDLSSEditorViewportClientData>(CustomData);
|
||||
check(DLSSViewportData);
|
||||
}
|
||||
else
|
||||
{
|
||||
DLSSViewportData = MakeShared< FFDLSSEditorViewportClientData>();
|
||||
ViewportClient->SetCustomTemporalUpscalerData(DLSSViewportData);
|
||||
}
|
||||
return DLSSViewportData;
|
||||
}
|
||||
|
||||
FDLSSUpscalerEditor::FDLSSUpscalerEditor(FDLSSUpscaler* InDLSSUpscaler)
|
||||
: DLSSUpscaler(InDLSSUpscaler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FDLSSUpscalerEditor::~FDLSSUpscalerEditor()
|
||||
{
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSSEditor, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
|
||||
void FDLSSUpscalerEditor::SetupEditorViewFamily(FSceneViewFamily& ViewFamily, FEditorViewportClient* ViewportClient)
|
||||
{
|
||||
|
||||
// this purpusefully does not check "r.TemporalAA.Upscaler", which is used at runtime since the enable/disable comes from DLSSViewportData->bIsDLSSEnabled
|
||||
// however make sure that the upscaler is "ours"
|
||||
static const auto CVarDLSSEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Enable"));
|
||||
const bool bDLSSActive = CVarDLSSEnable && (CVarDLSSEnable->GetInt() != 0);
|
||||
|
||||
static const auto CVarDLSSAutomationTesting = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.AutomationTesting"));
|
||||
const bool bDLSSActiveWithAutomation = !GIsAutomationTesting || (GIsAutomationTesting && CVarDLSSAutomationTesting && (CVarDLSSAutomationTesting->GetInt() != 0));
|
||||
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
if ((GTemporalUpscaler == DLSSUpscaler) && bDLSSActive && bDLSSActiveWithAutomation)
|
||||
#else
|
||||
if (bDLSSActive && bDLSSActiveWithAutomation)
|
||||
#endif
|
||||
{
|
||||
check(GIsEditor);
|
||||
checkf(GCustomStaticScreenPercentage == DLSSUpscaler, TEXT("GCustomStaticScreenPercentage is not set to the DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
checkf(GCustomEditorStaticScreenPercentage == this, TEXT("GCustomEditorStaticScreenPercentage is not set to the DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
check(ViewportClient);
|
||||
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(ViewportClient);
|
||||
|
||||
if(DLSSViewportData->bIsDLSSEnabled && EnableDLSSInEditorViewports())
|
||||
{
|
||||
ViewFamily.SetTemporalUpscalerInterface(DLSSUpscaler->GetUpscalerInstanceForViewFamily(DLSSUpscaler, DLSSViewportData->DLSSQualityMode));
|
||||
// DLSS_TODO figure out what to do, should this ever be the case
|
||||
checkf(ViewFamily.GetScreenPercentageInterface() == nullptr, TEXT("ViewFamily.GetScreenPercentageInterface() is already in use. Please check that only one upscaling plugin active is active."));
|
||||
|
||||
ViewFamily.EngineShowFlags.ScreenPercentage = true;
|
||||
|
||||
const float ResolutionFraction = DLSSViewportData->ResolutionFraction;
|
||||
ViewFamily.SetScreenPercentageInterface(new FLegacyScreenPercentageDriver(
|
||||
ViewFamily, ResolutionFraction
|
||||
#if SUPPORTS_POSTPROCESSING_SCREEN_PERCENTAGE
|
||||
/* AllowPostProcessSettingsScreenPercentage = */, false
|
||||
#endif
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool FDLSSUpscalerEditor::GenerateEditorViewportOptionsMenuEntry(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments& Arguments)
|
||||
{
|
||||
// this purpusefully does not check "r.TemporalAA.Upscaler", which is used at runtime since the enable/disable comes from DLSSViewportData->bIsDLSSEnabled
|
||||
// however make sure that the upscaler is "ours"
|
||||
|
||||
static const auto CVarDLSSEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.DLSS.Enable"));
|
||||
|
||||
#if DLSS_ENGINE_HAS_GTEMPORALUPSCALER
|
||||
if ((GTemporalUpscaler == DLSSUpscaler) && CVarDLSSEnable && (CVarDLSSEnable->GetInt() != 0))
|
||||
#else
|
||||
if (CVarDLSSEnable && (CVarDLSSEnable->GetInt() != 0))
|
||||
#endif
|
||||
{
|
||||
check(GIsEditor);
|
||||
checkf(GCustomStaticScreenPercentage == DLSSUpscaler, TEXT("GCustomStaticScreenPercentage is not set to the DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
checkf(GCustomEditorStaticScreenPercentage == this, TEXT("GCustomEditorStaticScreenPercentage is not set to the DLSS upscaler. Please check that only one upscaling plugin is active."));
|
||||
|
||||
FLevelEditorViewportClient& Levelviewport = Arguments.Viewport->GetLevelViewportClient();
|
||||
|
||||
FEngineShowFlags ShowFlags = Levelviewport.EngineShowFlags;
|
||||
|
||||
// DLSS_TODO is there a better way to detect whether TAA (and thus DLSS) is turned off?
|
||||
// maybe pass this in as a flag or have the callsite do this
|
||||
// FEditorViewportClient::Draw calls EngineShowFlagOrthographicOverride(IsPerspective(), ViewFamily.EngineShowFlags); which turns TAA off. And DLSS is a TAA flavor
|
||||
// EngineShowFlags.TemporalAA = 0;
|
||||
// EngineShowFlags.MotionBlur = 0;
|
||||
// but that well only be called later so emulate this here.
|
||||
|
||||
if (!ShowFlags.Lighting)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Levelviewport.IsPerspective())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnableDLSSInEditorViewports())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool bUseSubmenuForDLSSSettings = true;
|
||||
|
||||
if(bUseSubmenuForDLSSSettings)
|
||||
{
|
||||
Arguments.Section->AddSubMenu(
|
||||
"DLSSSettings",
|
||||
LOCTEXT("DLSSSettingsSubMenu", "DLSS Settings"),
|
||||
LOCTEXT("DLSSSettingsSubMenu_ToolTip", "Open the DLSS settings"),
|
||||
FNewToolMenuDelegate::CreateStatic(&MakeDLSSQualitySettingsMenu, this, Arguments));
|
||||
}
|
||||
else
|
||||
{
|
||||
Arguments.Section->AddEntry(FToolMenuEntry::InitWidget("DLSSSettings", SNew(SDLSSSettings).UpscalerEditor(this).ViewportMenuEntryArguments(Arguments), FText(), true));
|
||||
}
|
||||
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient());
|
||||
|
||||
if (DLSSViewportData->bIsDLSSEnabled)
|
||||
{
|
||||
Arguments.Section->AddEntry(FToolMenuEntry::InitWidget("DLSSScreenPercentage", GenerateScreenPercentageMenu(Arguments), LOCTEXT("DLSSScreenPercentage", "Screen Percentage (DLSS)")));
|
||||
|
||||
const int32 PreviewScreenPercentageMin = DLSSViewportData->MinResolutionFraction * 100.0f;
|
||||
const int32 PreviewScreenPercentageMax = DLSSViewportData->MaxResolutionFraction * 100.0f;
|
||||
|
||||
// clamp the current preview screen percentage (which might be 100%) to the supported DLSS range
|
||||
this->OnScreenPercentageValueChanged(FMath::Clamp(this->OnGetScreenPercentageValue(Arguments), PreviewScreenPercentageMin, PreviewScreenPercentageMax), Arguments);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TSharedRef<SWidget> FDLSSUpscalerEditor::GenerateScreenPercentageMenu(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments& Arguments) const
|
||||
{
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient());
|
||||
|
||||
const int32 PreviewScreenPercentageMin = DLSSViewportData->MinResolutionFraction * 100.0f;
|
||||
const int32 PreviewScreenPercentageMax = DLSSViewportData->MaxResolutionFraction * 100.0f;
|
||||
#if ENGINE_MAJOR_VERSION==4
|
||||
return
|
||||
SNew(SBox)
|
||||
.HAlign(HAlign_Right)
|
||||
.IsEnabled(this, &FDLSSUpscalerEditor::OnScreenPercentageIsEnabled, Arguments)
|
||||
[
|
||||
SNew(SBox)
|
||||
.Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f))
|
||||
.WidthOverride(100.0f)
|
||||
[
|
||||
SNew(SSpinBox<int32>)
|
||||
.Font(FEditorStyle::GetFontStyle(TEXT("MenuItem.Font")))
|
||||
.MinValue(PreviewScreenPercentageMin)
|
||||
.MaxValue(PreviewScreenPercentageMax)
|
||||
.Value(this, &FDLSSUpscalerEditor::OnGetScreenPercentageValue, Arguments)
|
||||
.OnValueChanged(this, &FDLSSUpscalerEditor::OnScreenPercentageValueChanged, Arguments)
|
||||
.ToolTipText(
|
||||
DLSSViewportData->bIsFixedResolutionFraction ?
|
||||
FText(LOCTEXT("DLSSScreenPercentageTooltipFixedResolution", "This DLSS quality mode has a fixed screen percentage and cannot be adjusted at runtime.")) :
|
||||
FText( LOCTEXT("DLSSScreenPercentageTooltip",
|
||||
"At runtime, the screen percentage is controlled by the r.NGX.DLSS.Quality cvar. To enable adjusting the screenpercentage directly in the editor, set the \"Enable Screenpercentage Manipulation In DLSS Editor Viewports\" setting under Editor Preferences -> Plugins -> NVIDIA DLSS"))
|
||||
)
|
||||
]
|
||||
];
|
||||
#elif ENGINE_MAJOR_VERSION==5
|
||||
return
|
||||
SNew(SBox)
|
||||
.HAlign(HAlign_Right)
|
||||
.IsEnabled(this, &FDLSSUpscalerEditor::OnScreenPercentageIsEnabled, Arguments)
|
||||
[
|
||||
SNew(SBox)
|
||||
.Padding(FMargin(4.0f, 0.0f, 0.0f, 0.0f))
|
||||
.WidthOverride(100.0f)
|
||||
[
|
||||
SNew(SBorder)
|
||||
.BorderImage(FAppStyle::Get().GetBrush("Menu.WidgetBorder"))
|
||||
.Padding(FMargin(1.0f))
|
||||
[
|
||||
SNew(SSpinBox<int32>)
|
||||
.Style(&FAppStyle::Get(), "Menu.SpinBox")
|
||||
.Font(FEditorStyle::GetFontStyle(TEXT("MenuItem.Font")))
|
||||
.MinValue(PreviewScreenPercentageMin)
|
||||
.MaxValue(PreviewScreenPercentageMax)
|
||||
.Value(this, &FDLSSUpscalerEditor::OnGetScreenPercentageValue, Arguments)
|
||||
.OnValueChanged(this, &FDLSSUpscalerEditor::OnScreenPercentageValueChanged, Arguments)
|
||||
.ToolTipText(
|
||||
DLSSViewportData->bIsFixedResolutionFraction ?
|
||||
FText(LOCTEXT("DLSSScreenPercentageTooltipFixedResolution", "This DLSS quality mode has a fixed screen percentage and cannot be adjusted at runtime.")) :
|
||||
FText(LOCTEXT("DLSSScreenPercentageTooltip",
|
||||
"At runtime, the screen percentage is controlled by the r.NGX.DLSS.Quality cvar. To enable adjusting the screenpercentage directly in the editor, set the \"Enable Screenpercentage Manipulation In DLSS Editor Viewports\" setting under Editor Preferences -> Plugins -> NVIDIA DLSS"))
|
||||
)
|
||||
]
|
||||
]
|
||||
];
|
||||
#else
|
||||
#error "ENGINE_MAJOR_VERSION must be either 4 or 5"
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FDLSSUpscalerEditor::EnableScreenpercentageInEditorViewports() const
|
||||
{
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableScreenpercentageManipulationInDLSSEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
return GetDefault<UDLSSSettings>()->bEnableScreenpercentageManipulationInDLSSEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetDefault<UDLSSOverrideSettings>()->EnableScreenpercentageManipulationInDLSSEditorViewportsOverride == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
bool FDLSSUpscalerEditor::EnableDLSSInEditorViewports() const
|
||||
{
|
||||
if (GetDefault<UDLSSOverrideSettings>()->EnableDLSSInEditorViewportsOverride == EDLSSSettingOverride::UseProjectSettings)
|
||||
{
|
||||
return GetDefault<UDLSSSettings>()->bEnableDLSSInEditorViewports;
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetDefault<UDLSSOverrideSettings>()->EnableDLSSInEditorViewportsOverride == EDLSSSettingOverride::Enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FDLSSUpscalerEditor::OnScreenPercentageIsEnabled(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
check(DLSSUpscaler);
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient());
|
||||
// adapted from SLevelViewportToolBar::OnScreenPercentageIsEnabled()
|
||||
|
||||
return EnableScreenpercentageInEditorViewports() && !DLSSViewportData->bIsFixedResolutionFraction && Arguments.Viewport->GetLevelViewportClient().SupportsPreviewResolutionFraction();
|
||||
}
|
||||
|
||||
int32 FDLSSUpscalerEditor::OnGetScreenPercentageValue(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
// adapted from SLevelViewportToolBar::OnGetScreenPercentageValue(), using DLSSViewportData->ResolutionFraction
|
||||
|
||||
// We expose the resolution fraction derived from DPI, to not lie to the artist when screen percentage = 100%.
|
||||
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient());
|
||||
|
||||
return FMath::RoundToInt(FMath::Clamp(
|
||||
DLSSViewportData->ResolutionFraction,
|
||||
DLSSViewportData->MinResolutionFraction,
|
||||
DLSSViewportData->MaxResolutionFraction) * 100.0f);
|
||||
}
|
||||
|
||||
void FDLSSUpscalerEditor::OnScreenPercentageValueChanged(int32 NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
// adapted from SLevelViewportToolBar::OnScreenPercentageValueChanged() and SetPreviewScreenPercentage()
|
||||
FLevelEditorViewportClient& ViewportClient = Arguments.Viewport->GetLevelViewportClient();
|
||||
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&ViewportClient);
|
||||
DLSSViewportData->ResolutionFraction = (NewValue / 100.0f);
|
||||
|
||||
ViewportClient.Invalidate();
|
||||
}
|
||||
|
||||
bool FDLSSUpscalerEditor::OnGetPreviewCustomTemporalUpscaler(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
return GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient())->bIsDLSSEnabled;
|
||||
}
|
||||
|
||||
void FDLSSUpscalerEditor::OnSetPreviewCustomTemporalUpscaler(bool NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
FLevelEditorViewportClient& ViewportClient = Arguments.Viewport->GetLevelViewportClient();
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&ViewportClient);
|
||||
DLSSViewportData->bIsDLSSEnabled = NewValue;
|
||||
ViewportClient.Invalidate();
|
||||
}
|
||||
|
||||
void FDLSSUpscalerEditor::OnPreviewCustomTemporalUpscalerChanged(bool NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const
|
||||
{
|
||||
FLevelEditorViewportClient& ViewportClient = Arguments.Viewport->GetLevelViewportClient();
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&ViewportClient);
|
||||
DLSSViewportData->bIsDLSSEnabled = NewValue;
|
||||
ViewportClient.Invalidate();
|
||||
}
|
||||
|
||||
void FDLSSUpscalerEditor::OnQualityModeSelected(EDLSSQualityMode InQualityLevel, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments)
|
||||
{
|
||||
TSharedPtr<FFDLSSEditorViewportClientData> DLSSViewportData = GetOrCreateDLSSViewportData(&Arguments.Viewport->GetLevelViewportClient());
|
||||
|
||||
DLSSViewportData->bIsFixedResolutionFraction = DLSSUpscaler->IsFixedResolutionFraction(InQualityLevel);
|
||||
DLSSViewportData->DLSSQualityMode = InQualityLevel;
|
||||
|
||||
if (DLSSViewportData->bIsFixedResolutionFraction)
|
||||
{
|
||||
DLSSViewportData->MinResolutionFraction = DLSSUpscaler->GetOptimalResolutionFractionForQuality(InQualityLevel);
|
||||
DLSSViewportData->MaxResolutionFraction = DLSSUpscaler->GetOptimalResolutionFractionForQuality(InQualityLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
DLSSViewportData->MinResolutionFraction = DLSSUpscaler->GetMinUpsampleResolutionFraction();
|
||||
DLSSViewportData->MaxResolutionFraction = DLSSUpscaler->GetMaxUpsampleResolutionFraction();
|
||||
}
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
|
||||
50
Plugins/DLSS/Source/DLSSEditor/Public/DLSSEditor.h
Normal file
50
Plugins/DLSS/Source/DLSSEditor/Public/DLSSEditor.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
|
||||
class FDLSSUpscalerEditor;
|
||||
|
||||
class IDLSSEditorModuleInterface : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual FDLSSUpscalerEditor* GetDLSSUpscalerEditor() const = 0;
|
||||
};
|
||||
|
||||
class FDLSSEditorModule final : public IDLSSEditorModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() final;
|
||||
virtual void ShutdownModule() final;
|
||||
|
||||
|
||||
// Inherited via IDLSSEditorModuleInterface
|
||||
virtual FDLSSUpscalerEditor* GetDLSSUpscalerEditor() const ;
|
||||
private:
|
||||
TSharedPtr<FDLSSUpscalerEditor> DLSSUpscalerEditor;
|
||||
bool bIsDLSSAvailable = false;
|
||||
};
|
||||
|
||||
|
||||
70
Plugins/DLSS/Source/DLSSEditor/Public/DLSSUpscalerEditor.h
Normal file
70
Plugins/DLSS/Source/DLSSEditor/Public/DLSSUpscalerEditor.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CustomEditorStaticScreenPercentage.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogDLSSEditor, Log, All);
|
||||
|
||||
class FDLSSUpscaler;
|
||||
enum class EDLSSQualityMode;
|
||||
class SWidget;
|
||||
class SLevelViewportToolBar;
|
||||
class SDLSSSettings;
|
||||
class FFDLSSEditorViewportClientData;
|
||||
class FEditorViewportClient;
|
||||
|
||||
class DLSSEDITOR_API FDLSSUpscalerEditor : public TSharedFromThis<FDLSSUpscalerEditor>, public ICustomEditorStaticScreenPercentage
|
||||
{
|
||||
friend class SDLSSSettings;
|
||||
public:
|
||||
FDLSSUpscalerEditor(FDLSSUpscaler* InDLSSUpscaler);
|
||||
virtual ~FDLSSUpscalerEditor();
|
||||
|
||||
// Inherited via ICustomEditorStaticScreenPercentage
|
||||
virtual bool GenerateEditorViewportOptionsMenuEntry(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments& Arguments) final;
|
||||
virtual void SetupEditorViewFamily(FSceneViewFamily& ViewFamily, FEditorViewportClient* ViewportClient) final;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
bool OnScreenPercentageIsEnabled(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
int32 OnGetScreenPercentageValue(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
void OnScreenPercentageValueChanged(int32 NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
|
||||
|
||||
bool OnGetPreviewCustomTemporalUpscaler(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
void OnSetPreviewCustomTemporalUpscaler(bool NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
void OnPreviewCustomTemporalUpscalerChanged(bool NewValue, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments) const;
|
||||
|
||||
|
||||
bool EnableScreenpercentageInEditorViewports() const;
|
||||
bool EnableDLSSInEditorViewports() const;
|
||||
TSharedRef<SWidget> GenerateScreenPercentageMenu(const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments& Arguments) const;
|
||||
|
||||
FDLSSUpscaler* DLSSUpscaler;
|
||||
|
||||
void OnQualityModeSelected(EDLSSQualityMode InQualityLevel, const ICustomEditorStaticScreenPercentage::FViewportMenuEntryArguments Arguments);
|
||||
|
||||
static TSharedPtr<FFDLSSEditorViewportClientData> GetOrCreateDLSSViewportData(FEditorViewportClient* ViewportClient);
|
||||
};
|
||||
|
||||
57
Plugins/DLSS/Source/DLSSUtility/DLSSUtility.Build.cs
Normal file
57
Plugins/DLSS/Source/DLSSUtility/DLSSUtility.Build.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class DLSSUtility : ModuleRules
|
||||
{
|
||||
public DLSSUtility(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/Renderer/Private"),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"RenderCore",
|
||||
"Renderer",
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Engine",
|
||||
"RHI",
|
||||
"Projects"
|
||||
}
|
||||
);
|
||||
|
||||
// 4.x and early access 5.0 engines used FVector2D type instead of FVector2f type for shader parameters
|
||||
bool bEngineUsesFVector2D = (Target.Version.MajorVersion == 4) || (Target.Version.BranchName == "++UE5+Release-5.0-EarlyAccess");
|
||||
PrivateDefinitions.Add(string.Format("DLSS_ENGINE_USES_FVECTOR2D={0}", bEngineUsesFVector2D ? "1" : "0"));
|
||||
}
|
||||
}
|
||||
42
Plugins/DLSS/Source/DLSSUtility/Private/DLSSUtility.cpp
Normal file
42
Plugins/DLSS/Source/DLSSUtility/Private/DLSSUtility.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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 "DLSSUtility.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
#include "ShaderCore.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FDLSSUtilityModule"
|
||||
|
||||
void FDLSSUtilityModule::StartupModule()
|
||||
{
|
||||
FString PluginShaderDir = FPaths::Combine(IPluginManager::Get().FindPlugin(TEXT("DLSS"))->GetBaseDir(), TEXT("Shaders"));
|
||||
AddShaderSourceDirectoryMapping(TEXT("/Plugin/DLSS"), PluginShaderDir);
|
||||
|
||||
}
|
||||
|
||||
void FDLSSUtilityModule::ShutdownModule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
IMPLEMENT_MODULE(FDLSSUtilityModule, DLSSUtility)
|
||||
153
Plugins/DLSS/Source/DLSSUtility/Private/VelocityCombinePass.cpp
Normal file
153
Plugins/DLSS/Source/DLSSUtility/Private/VelocityCombinePass.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "VelocityCombinePass.h"
|
||||
|
||||
|
||||
const int32 kVelocityCombineComputeTileSizeX = FComputeShaderUtils::kGolden2DGroupSize;
|
||||
const int32 kVelocityCombineComputeTileSizeY = FComputeShaderUtils::kGolden2DGroupSize;
|
||||
|
||||
|
||||
class FDilateMotionVectorsDim : SHADER_PERMUTATION_BOOL("DILATE_MOTION_VECTORS");
|
||||
|
||||
class FVelocityCombineCS : public FGlobalShader
|
||||
{
|
||||
public:
|
||||
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
||||
{
|
||||
// Only cook for the platforms/RHIs where DLSS is supported, which is DX11,DX12 and Vulkan [on Win64]
|
||||
return IsFeatureLevelSupported(Parameters.Platform, ERHIFeatureLevel::SM5) &&
|
||||
IsPCPlatform(Parameters.Platform) && (
|
||||
IsVulkanSM5Platform(Parameters.Platform) ||
|
||||
#if (ENGINE_MAJOR_VERSION == 4) && (ENGINE_MINOR_VERSION == 26)
|
||||
IsD3DPlatform(Parameters.Platform, false));
|
||||
#else
|
||||
IsD3DPlatform(Parameters.Platform));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
||||
{
|
||||
FGlobalShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
||||
OutEnvironment.SetDefine(TEXT("THREADGROUP_SIZEX"), kVelocityCombineComputeTileSizeX);
|
||||
OutEnvironment.SetDefine(TEXT("THREADGROUP_SIZEY"), kVelocityCombineComputeTileSizeY);
|
||||
}
|
||||
using FPermutationDomain = TShaderPermutationDomain<FDilateMotionVectorsDim>;
|
||||
|
||||
DECLARE_GLOBAL_SHADER(FVelocityCombineCS);
|
||||
SHADER_USE_PARAMETER_STRUCT(FVelocityCombineCS, FGlobalShader);
|
||||
|
||||
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
||||
// Input images
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, VelocityTexture)
|
||||
SHADER_PARAMETER_SAMPLER(SamplerState, VelocityTextureSampler)
|
||||
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, Velocity)
|
||||
|
||||
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, DepthTexture)
|
||||
SHADER_PARAMETER_SAMPLER(SamplerState, DepthTextureSampler)
|
||||
|
||||
#if DLSS_ENGINE_USES_FVECTOR2D
|
||||
SHADER_PARAMETER(FVector2D, TemporalJitterPixels)
|
||||
#else
|
||||
SHADER_PARAMETER(FVector2f, TemporalJitterPixels)
|
||||
#endif
|
||||
|
||||
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, View)
|
||||
|
||||
// Output images
|
||||
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, OutVelocityCombinedTexture)
|
||||
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, CombinedVelocity)
|
||||
|
||||
END_SHADER_PARAMETER_STRUCT()
|
||||
};
|
||||
|
||||
|
||||
IMPLEMENT_GLOBAL_SHADER(FVelocityCombineCS, "/Plugin/DLSS/Private/VelocityCombine.usf", "VelocityCombineMain", SF_Compute);
|
||||
|
||||
FRDGTextureRef AddVelocityCombinePass(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
FRDGTextureRef InSceneDepthTexture,
|
||||
FRDGTextureRef InVelocityTexture,
|
||||
bool bDilateMotionVectors
|
||||
)
|
||||
{
|
||||
const FIntRect InputViewRect = View.ViewRect;
|
||||
const FIntRect OutputViewRect = FIntRect( FIntPoint::ZeroValue, bDilateMotionVectors ? View.GetSecondaryViewRectSize() : View.ViewRect.Size());
|
||||
|
||||
FRDGTextureDesc CombinedVelocityDesc = FRDGTextureDesc::Create2D(
|
||||
OutputViewRect.Size(),
|
||||
PF_G16R16F,
|
||||
FClearValueBinding::Black,
|
||||
TexCreate_ShaderResource | TexCreate_UAV);
|
||||
const TCHAR* OutputName = TEXT("DLSSCombinedVelocity");
|
||||
|
||||
FRDGTextureRef CombinedVelocityTexture = GraphBuilder.CreateTexture(
|
||||
CombinedVelocityDesc,
|
||||
OutputName);
|
||||
|
||||
FVelocityCombineCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FVelocityCombineCS::FParameters>();
|
||||
|
||||
// input velocity
|
||||
{
|
||||
PassParameters->VelocityTexture = InVelocityTexture;
|
||||
PassParameters->VelocityTextureSampler = TStaticSamplerState<SF_Point>::GetRHI();
|
||||
|
||||
// we use InSceneDepthTexture here and not InVelocityTexture since the latter can be a 1x1 black texture
|
||||
check(InVelocityTexture->Desc.Extent == FIntPoint(1, 1) || InVelocityTexture->Desc.Extent == InSceneDepthTexture->Desc.Extent);
|
||||
FScreenPassTextureViewport velocityViewport(InSceneDepthTexture, InputViewRect);
|
||||
FScreenPassTextureViewportParameters velocityViewportParameters = GetScreenPassTextureViewportParameters(velocityViewport);
|
||||
PassParameters->Velocity = velocityViewportParameters;
|
||||
}
|
||||
// input depth
|
||||
{
|
||||
PassParameters->DepthTexture = InSceneDepthTexture;
|
||||
PassParameters->DepthTextureSampler = TStaticSamplerState<SF_Point>::GetRHI();
|
||||
}
|
||||
// output combined velocity
|
||||
{
|
||||
PassParameters->OutVelocityCombinedTexture = GraphBuilder.CreateUAV(CombinedVelocityTexture);
|
||||
|
||||
FScreenPassTextureViewport CombinedVelocityViewport(CombinedVelocityTexture, OutputViewRect);
|
||||
FScreenPassTextureViewportParameters CombinedVelocityViewportParameters = GetScreenPassTextureViewportParameters(CombinedVelocityViewport);
|
||||
PassParameters->CombinedVelocity = CombinedVelocityViewportParameters;
|
||||
}
|
||||
|
||||
// various state
|
||||
{
|
||||
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
PassParameters->TemporalJitterPixels = View.TemporalJitterPixels;
|
||||
#else
|
||||
PassParameters->TemporalJitterPixels = FVector2f(View.TemporalJitterPixels); // LWC_TODO: Precision loss
|
||||
#endif
|
||||
PassParameters->View = View.ViewUniformBuffer;
|
||||
}
|
||||
|
||||
FVelocityCombineCS::FPermutationDomain PermutationVector;
|
||||
PermutationVector.Set<FDilateMotionVectorsDim>(bDilateMotionVectors);
|
||||
|
||||
TShaderMapRef<FVelocityCombineCS> ComputeShader(View.ShaderMap, PermutationVector);
|
||||
|
||||
FComputeShaderUtils::AddPass(
|
||||
GraphBuilder,
|
||||
RDG_EVENT_NAME("Velocity Combine%s (%dx%d -> %dx%d)",
|
||||
bDilateMotionVectors ? TEXT(" Dilate") : TEXT(""),
|
||||
InputViewRect.Width(), InputViewRect.Height(),
|
||||
OutputViewRect.Width(), OutputViewRect.Height()
|
||||
),
|
||||
ComputeShader,
|
||||
PassParameters,
|
||||
FComputeShaderUtils::GetGroupCount(OutputViewRect.Size(), FComputeShaderUtils::kGolden2DGroupSize));
|
||||
|
||||
return CombinedVelocityTexture;
|
||||
}
|
||||
35
Plugins/DLSS/Source/DLSSUtility/Public/DLSSUtility.h
Normal file
35
Plugins/DLSS/Source/DLSSUtility/Public/DLSSUtility.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
|
||||
class FDLSSUtilityModule final : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
private:
|
||||
};
|
||||
34
Plugins/DLSS/Source/DLSSUtility/Public/VelocityCombinePass.h
Normal file
34
Plugins/DLSS/Source/DLSSUtility/Public/VelocityCombinePass.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "RendererInterface.h"
|
||||
#include "ScreenPass.h"
|
||||
|
||||
|
||||
extern DLSSUTILITY_API FRDGTextureRef AddVelocityCombinePass(
|
||||
FRDGBuilder& GraphBuilder,
|
||||
const FViewInfo& View,
|
||||
FRDGTextureRef InSceneDepthTexture,
|
||||
FRDGTextureRef InVelocityTexture,
|
||||
bool bDilateMotionVectors
|
||||
);
|
||||
79
Plugins/DLSS/Source/NGXD3D11RHI/NGXD3D11RHI.Build.cs
Normal file
79
Plugins/DLSS/Source/NGXD3D11RHI/NGXD3D11RHI.Build.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
using System.IO;
|
||||
|
||||
public class NGXD3D11RHI : ModuleRules
|
||||
{
|
||||
public NGXD3D11RHI(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/Windows/D3D11RHI/Private"),
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/Windows/D3D11RHI/Private/Windows"),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"RHI",
|
||||
"D3D11RHI",
|
||||
|
||||
"NGX",
|
||||
"NGXRHI",
|
||||
}
|
||||
);
|
||||
|
||||
if (ReadOnlyBuildVersion.Current.MajorVersion == 5)
|
||||
{
|
||||
PrivateDependencyModuleNames.Add("RHICore");
|
||||
}
|
||||
|
||||
// those come from the D3D11RHI
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "DX11");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "NVAPI");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "NVAftermath");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelMetricsDiscovery");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelExtensionsFramework");
|
||||
}
|
||||
}
|
||||
330
Plugins/DLSS/Source/NGXD3D11RHI/Private/NGXD3D11RHI.cpp
Normal file
330
Plugins/DLSS/Source/NGXD3D11RHI/Private/NGXD3D11RHI.cpp
Normal file
@@ -0,0 +1,330 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2021 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 "NGXD3D11RHI.h"
|
||||
|
||||
#include "nvsdk_ngx.h"
|
||||
#include "nvsdk_ngx_helpers.h"
|
||||
|
||||
#include "D3D11RHIPrivate.h"
|
||||
#include "D3D11Util.h"
|
||||
#include "D3D11State.h"
|
||||
#include "D3D11Resources.h"
|
||||
#include "D3D11Viewport.h"
|
||||
#include "D3D11ConstantBuffer.h"
|
||||
#include "D3D11StateCache.h"
|
||||
#include "RHIValidationCommon.h"
|
||||
|
||||
#include "GenericPlatform/GenericPlatformFile.h"
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGXD3D11RHI, Log, All);
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FNGXD3D11RHIModule"
|
||||
|
||||
class FD3D11NGXFeatureHandle final : public NGXDLSSFeature
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
using NGXDLSSFeature::NGXDLSSFeature;
|
||||
|
||||
virtual ~FD3D11NGXFeatureHandle()
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(NGXRHI::NGXInitialized());
|
||||
NVSDK_NGX_Result ResultReleaseFeature = NVSDK_NGX_D3D11_ReleaseFeature(Feature);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultReleaseFeature), TEXT("NVSDK_NGX_D3D11_ReleaseFeature failed! (%u %s), %s"), ResultReleaseFeature, GetNGXResultAsString(ResultReleaseFeature), *Desc.GetDebugDescription());
|
||||
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result ResultDestroyParameter = NVSDK_NGX_D3D11_DestroyParameters(Parameter);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultDestroyParameter), TEXT("NVSDK_NGX_D3D11_DestroyParameters failed! (%u %s), %s"), ResultDestroyParameter, GetNGXResultAsString(ResultDestroyParameter), *Desc.GetDebugDescription());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FNGXD3D11RHI final : public NGXRHI
|
||||
{
|
||||
public:
|
||||
FNGXD3D11RHI(const FNGXRHICreateArguments& Arguments);
|
||||
|
||||
virtual void ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState) final;
|
||||
virtual ~FNGXD3D11RHI();
|
||||
private:
|
||||
|
||||
FD3D11DynamicRHI* D3D11RHI = nullptr;
|
||||
ID3D11Device* Direct3DDevice = nullptr;
|
||||
ID3D11DeviceContext* Direct3DDeviceIMContext = nullptr;
|
||||
|
||||
NVSDK_NGX_Result Init_NGX_D3D11(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, ID3D11Device* InHandle, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
|
||||
static bool IsIncompatibleAPICaptureToolActive(ID3D11Device* InDirect3DDevice);
|
||||
|
||||
};
|
||||
|
||||
bool FNGXD3D11RHI::IsIncompatibleAPICaptureToolActive(ID3D11Device* InDirect3DDevice)
|
||||
{
|
||||
// RenderDoc
|
||||
{
|
||||
IID RenderDocID;
|
||||
if (SUCCEEDED(IIDFromString(L"{A7AA6116-9C8D-4BBA-9083-B4D816B71B78}", &RenderDocID)))
|
||||
{
|
||||
TRefCountPtr<IUnknown> RenderDoc;
|
||||
if (SUCCEEDED(InDirect3DDevice->QueryInterface(RenderDocID, (void**)RenderDoc.GetInitReference())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result FNGXD3D11RHI::Init_NGX_D3D11(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, ID3D11Device* InHandle, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_Result_Fail;
|
||||
int32 APIVersion = NVSDK_NGX_VERSION_API_MACRO;
|
||||
do
|
||||
{
|
||||
if (InArguments.InitializeNGXWithNGXApplicationID())
|
||||
{
|
||||
Result = NVSDK_NGX_D3D11_Init(InArguments.NGXAppId, InApplicationDataPath, InHandle, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_Init(AppID= %u, APIVersion = 0x%x) -> (%u %s)"), InArguments.NGXAppId, APIVersion, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = NVSDK_NGX_D3D11_Init_with_ProjectID(TCHAR_TO_UTF8(*InArguments.UnrealProjectID), NVSDK_NGX_ENGINE_TYPE_UNREAL, TCHAR_TO_UTF8(*InArguments.UnrealEngineVersion), InApplicationDataPath, InHandle, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_Init_with_ProjectID(ProjectID = %s, EngineVersion=%s, APIVersion = 0x%x) -> (%u %s)"), *InArguments.UnrealProjectID, *InArguments.UnrealEngineVersion, APIVersion, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(Result))
|
||||
{
|
||||
NVSDK_NGX_D3D11_Shutdown();
|
||||
}
|
||||
|
||||
--APIVersion;
|
||||
} while (NVSDK_NGX_FAILED(Result) && APIVersion >= NVSDK_NGX_VERSION_API_MACRO_BASE_LINE);
|
||||
|
||||
if (!NVSDK_NGX_FAILED(Result) && (APIVersion + 1 < NVSDK_NGX_VERSION_API_MACRO_WITH_LOGGING))
|
||||
{
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("Warning: NVSDK_NGX_D3D11_Init succeeded, but the driver installed on this system is too old the support the NGX logging API. The console variables r.NGX.LogLevel and r.NGX.EnableOtherLoggingSinks will have no effect and NGX logs will only show up in their own log files, and not in UE's log files."));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
FNGXD3D11RHI::FNGXD3D11RHI(const FNGXRHICreateArguments& Arguments)
|
||||
: NGXRHI(Arguments)
|
||||
, D3D11RHI(static_cast<FD3D11DynamicRHI*>(Arguments.DynamicRHI))
|
||||
, Direct3DDevice(D3D11RHI->GetDevice())
|
||||
, Direct3DDeviceIMContext(D3D11RHI->GetDeviceContext())
|
||||
{
|
||||
ensure(D3D11RHI);
|
||||
ensure(Direct3DDevice);
|
||||
|
||||
bIsIncompatibleAPICaptureToolActive = IsIncompatibleAPICaptureToolActive(Direct3DDevice);
|
||||
|
||||
const FString NGXLogDir = GetNGXLogDirectory();
|
||||
IPlatformFile::GetPlatformPhysical().CreateDirectoryTree(*NGXLogDir);
|
||||
|
||||
NVSDK_NGX_Result ResultInit = Init_NGX_D3D11(Arguments, *NGXLogDir, Direct3DDevice, CommonFeatureInfo());
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_Init (Log %s) -> (%u %s)"), *NGXLogDir, ResultInit, GetNGXResultAsString(ResultInit));
|
||||
|
||||
// store for the higher level code interpret
|
||||
DLSSQueryFeature.DLSSInitResult = ResultInit;
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultInit)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
else if (NVSDK_NGX_SUCCEED(ResultInit))
|
||||
{
|
||||
bNGXInitialized = true;
|
||||
|
||||
NVSDK_NGX_Result ResultGetParameters = NVSDK_NGX_D3D11_GetCapabilityParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_GetCapabilityParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultGetParameters)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(ResultGetParameters))
|
||||
{
|
||||
ResultGetParameters = NVSDK_NGX_D3D11_GetParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_GetParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
bSupportsAllocateParameters = false;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(ResultGetParameters))
|
||||
{
|
||||
DLSSQueryFeature.QueryDLSSSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FNGXD3D11RHI::~FNGXD3D11RHI()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
if(bNGXInitialized)
|
||||
{
|
||||
// Destroy the parameters and features before we call NVSDK_NGX_D3D11_Shutdown
|
||||
ReleaseAllocatedFeatures();
|
||||
|
||||
NVSDK_NGX_Result Result;
|
||||
if (bSupportsAllocateParameters && DLSSQueryFeature.CapabilityParameters)
|
||||
{
|
||||
Result = NVSDK_NGX_D3D11_DestroyParameters(DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_DestroyParameters -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
Result = NVSDK_NGX_D3D11_Shutdown();
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("NVSDK_NGX_D3D11_Shutdown -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
bNGXInitialized = false;
|
||||
}
|
||||
UE_LOG(LogDLSSNGXD3D11RHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
|
||||
void FNGXD3D11RHI::ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(IsDLSSAvailable());
|
||||
if (!IsDLSSAvailable())
|
||||
return;
|
||||
InArguments.Validate();
|
||||
|
||||
if (InDLSSState->RequiresFeatureRecreation(InArguments))
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature || InDLSSState->HasValidFeature());
|
||||
InDLSSState->DLSSFeature = nullptr;
|
||||
}
|
||||
|
||||
if (InArguments.bReset)
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature);
|
||||
InDLSSState->DLSSFeature = FindFreeFeature(InArguments);
|
||||
}
|
||||
|
||||
if (!InDLSSState->DLSSFeature)
|
||||
{
|
||||
NVSDK_NGX_Parameter* NewNGXParameterHandle = nullptr;
|
||||
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_D3D11_AllocateParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_D3D11_AllocateParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_D3D11_GetParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_D3D11_GetParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
ApplyCommonNGXParameterSettings(NewNGXParameterHandle, InArguments);
|
||||
|
||||
NVSDK_NGX_DLSS_Create_Params DlssCreateParams = InArguments.GetNGXDLSSCreateParams();
|
||||
NVSDK_NGX_Handle* NewNGXHandle = nullptr;
|
||||
NVSDK_NGX_Result ResultCreate = NGX_D3D11_CREATE_DLSS_EXT(
|
||||
Direct3DDeviceIMContext,
|
||||
&NewNGXHandle,
|
||||
NewNGXParameterHandle,
|
||||
&DlssCreateParams);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultCreate), TEXT("NGX_D3D11_CREATE_DLSS failed! (%u %s), %s"), ResultCreate, GetNGXResultAsString(ResultCreate), *InArguments.GetFeatureDesc().GetDebugDescription());
|
||||
|
||||
InDLSSState->DLSSFeature = MakeShared<FD3D11NGXFeatureHandle>(NewNGXHandle, NewNGXParameterHandle, InArguments.GetFeatureDesc(), FrameCounter);
|
||||
RegisterFeature(InDLSSState->DLSSFeature);
|
||||
}
|
||||
|
||||
check(InDLSSState->HasValidFeature());
|
||||
|
||||
// execute
|
||||
|
||||
D3D11RHI->RegisterGPUWork(1);
|
||||
|
||||
NVSDK_NGX_D3D11_DLSS_Eval_Params DlssEvalParams;
|
||||
FMemory::Memzero(DlssEvalParams);
|
||||
|
||||
DlssEvalParams.Feature.pInOutput = GetD3D11TextureFromRHITexture(InArguments.OutputColor)->GetResource();
|
||||
DlssEvalParams.InOutputSubrectBase.X = InArguments.DestRect.Min.X;
|
||||
DlssEvalParams.InOutputSubrectBase.Y = InArguments.DestRect.Min.Y;
|
||||
|
||||
DlssEvalParams.InRenderSubrectDimensions.Width = InArguments.SrcRect.Width();
|
||||
DlssEvalParams.InRenderSubrectDimensions.Height = InArguments.SrcRect.Height();
|
||||
|
||||
DlssEvalParams.Feature.pInColor = GetD3D11TextureFromRHITexture(InArguments.InputColor)->GetResource();
|
||||
DlssEvalParams.InColorSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InColorSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
DlssEvalParams.pInDepth = GetD3D11TextureFromRHITexture(InArguments.InputDepth)->GetResource();
|
||||
DlssEvalParams.InDepthSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InDepthSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
// The VelocityCombine pass puts the motion vectors into the top left corner
|
||||
DlssEvalParams.pInMotionVectors = GetD3D11TextureFromRHITexture(InArguments.InputMotionVectors)->GetResource();
|
||||
DlssEvalParams.InMVSubrectBase.X = 0;
|
||||
DlssEvalParams.InMVSubrectBase.Y = 0;
|
||||
|
||||
DlssEvalParams.pInExposureTexture = InArguments.bUseAutoExposure ? nullptr : GetD3D11TextureFromRHITexture(InArguments.InputExposure)->GetResource();
|
||||
DlssEvalParams.InPreExposure = InArguments.PreExposure;
|
||||
|
||||
DlssEvalParams.Feature.InSharpness = InArguments.Sharpness;
|
||||
DlssEvalParams.InJitterOffsetX = InArguments.JitterOffset.X;
|
||||
DlssEvalParams.InJitterOffsetY = InArguments.JitterOffset.Y;
|
||||
|
||||
DlssEvalParams.InMVScaleX = InArguments.MotionVectorScale.X;
|
||||
DlssEvalParams.InMVScaleY = InArguments.MotionVectorScale.Y;
|
||||
DlssEvalParams.InReset = InArguments.bReset;
|
||||
|
||||
DlssEvalParams.InFrameTimeDeltaInMsec = InArguments.DeltaTime;
|
||||
|
||||
|
||||
NVSDK_NGX_Result ResultEvaluate = NGX_D3D11_EVALUATE_DLSS_EXT(
|
||||
Direct3DDeviceIMContext,
|
||||
InDLSSState->DLSSFeature->Feature,
|
||||
InDLSSState->DLSSFeature->Parameter,
|
||||
&DlssEvalParams
|
||||
);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultEvaluate), TEXT("NGX_D3D11_EVALUATE_DLSS_EXT failed! (%u %s), %s"), ResultEvaluate, GetNGXResultAsString(ResultEvaluate), *InDLSSState->DLSSFeature->Desc.GetDebugDescription());
|
||||
|
||||
InDLSSState->DLSSFeature->Tick(FrameCounter);
|
||||
}
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
|
||||
void FNGXD3D11RHIModule::StartupModule()
|
||||
{
|
||||
// NGXRHI module should be loaded to ensure logging state is initialized
|
||||
FModuleManager::LoadModuleChecked<INGXRHIModule>(TEXT("NGXRHI"));
|
||||
}
|
||||
|
||||
void FNGXD3D11RHIModule::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
TUniquePtr<NGXRHI> FNGXD3D11RHIModule::CreateNGXRHI(const FNGXRHICreateArguments& Arguments)
|
||||
{
|
||||
TUniquePtr<NGXRHI> Result(new FNGXD3D11RHI(Arguments));
|
||||
return Result;
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(FNGXD3D11RHIModule, NGXD3D11RHI)
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
36
Plugins/DLSS/Source/NGXD3D11RHI/Public/NGXD3D11RHI.h
Normal file
36
Plugins/DLSS/Source/NGXD3D11RHI/Public/NGXD3D11RHI.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#include "NGXRHI.h"
|
||||
|
||||
class FNGXD3D11RHIModule final : public INGXRHIModule
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
|
||||
/** INGXRHIModule implementation */
|
||||
virtual TUniquePtr<NGXRHI> CreateNGXRHI(const FNGXRHICreateArguments& Arguments);
|
||||
};
|
||||
73
Plugins/DLSS/Source/NGXD3D12RHI/NGXD3D12RHI.Build.cs
Normal file
73
Plugins/DLSS/Source/NGXD3D12RHI/NGXD3D12RHI.Build.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
public class NGXD3D12RHI : ModuleRules
|
||||
{
|
||||
public NGXD3D12RHI(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/D3D12RHI/Private"),
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/D3D12RHI/Private/Windows"),
|
||||
}
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"RHI",
|
||||
"D3D12RHI",
|
||||
|
||||
"NGX",
|
||||
"NGXRHI",
|
||||
}
|
||||
);
|
||||
|
||||
if (ReadOnlyBuildVersion.Current.MajorVersion == 5)
|
||||
{
|
||||
PrivateDependencyModuleNames.Add("RHICore");
|
||||
}
|
||||
// those come from the D3D12RHI
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "DX12");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "NVAPI");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "NVAftermath");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelMetricsDiscovery");
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "IntelExtensionsFramework");
|
||||
}
|
||||
}
|
||||
343
Plugins/DLSS/Source/NGXD3D12RHI/Private/NGXD3D12RHI.cpp
Normal file
343
Plugins/DLSS/Source/NGXD3D12RHI/Private/NGXD3D12RHI.cpp
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2021 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 "NGXD3D12RHI.h"
|
||||
|
||||
#include "nvsdk_ngx.h"
|
||||
#include "nvsdk_ngx_helpers.h"
|
||||
|
||||
#include "D3D12RHIPrivate.h"
|
||||
#include "D3D12Util.h"
|
||||
#include "D3D12State.h"
|
||||
#include "D3D12Resources.h"
|
||||
#include "D3D12Viewport.h"
|
||||
#include "D3D12ConstantBuffer.h"
|
||||
|
||||
#include "RHIValidationCommon.h"
|
||||
#include "GenericPlatform/GenericPlatformFile.h"
|
||||
|
||||
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGXD3D12RHI, Log, All);
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FNGXD3D12RHIModule"
|
||||
|
||||
class FD3D12NGXDLSSFeature final : public NGXDLSSFeature
|
||||
{
|
||||
|
||||
public:
|
||||
using NGXDLSSFeature::NGXDLSSFeature;
|
||||
|
||||
virtual ~FD3D12NGXDLSSFeature()
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(NGXRHI::NGXInitialized());
|
||||
NVSDK_NGX_Result ResultReleaseFeature = NVSDK_NGX_D3D12_ReleaseFeature(Feature);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultReleaseFeature), TEXT("NVSDK_NGX_D3D12_ReleaseFeature failed! (%u %s), %s"), ResultReleaseFeature, GetNGXResultAsString(ResultReleaseFeature), *Desc.GetDebugDescription());
|
||||
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result ResultDestroyParameter = NVSDK_NGX_D3D12_DestroyParameters(Parameter);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultDestroyParameter), TEXT("NVSDK_NGX_D3D12_DestroyParameters failed! (%u %s), %s"), ResultDestroyParameter, GetNGXResultAsString(ResultDestroyParameter), *Desc.GetDebugDescription());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class FNGXD3D12RHI final : public NGXRHI
|
||||
{
|
||||
|
||||
public:
|
||||
FNGXD3D12RHI(const FNGXRHICreateArguments& Arguments);
|
||||
virtual void ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState) final;
|
||||
virtual ~FNGXD3D12RHI();
|
||||
private:
|
||||
NVSDK_NGX_Result Init_NGX_D3D12(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, ID3D12Device* InHandle, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
|
||||
static bool IsIncompatibleAPICaptureToolActive(ID3D12Device* InDirect3DDevice);
|
||||
|
||||
FD3D12DynamicRHI* D3D12RHI = nullptr;
|
||||
|
||||
|
||||
};
|
||||
|
||||
bool FNGXD3D12RHI::IsIncompatibleAPICaptureToolActive(ID3D12Device* InDirect3DDevice)
|
||||
{
|
||||
// RenderDoc
|
||||
{
|
||||
IID RenderDocID;
|
||||
if (SUCCEEDED(IIDFromString(L"{A7AA6116-9C8D-4BBA-9083-B4D816B71B78}", &RenderDocID)))
|
||||
{
|
||||
TRefCountPtr<IUnknown> RenderDoc;
|
||||
if (SUCCEEDED(InDirect3DDevice->QueryInterface(RenderDocID, (void**)RenderDoc.GetInitReference())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result FNGXD3D12RHI::Init_NGX_D3D12(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, ID3D12Device* InHandle, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_Result_Fail;
|
||||
int32 APIVersion = NVSDK_NGX_VERSION_API_MACRO;
|
||||
do
|
||||
{
|
||||
if (InArguments.InitializeNGXWithNGXApplicationID())
|
||||
{
|
||||
Result = NVSDK_NGX_D3D12_Init(InArguments.NGXAppId, InApplicationDataPath, InHandle, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_Init(AppID= %u, APIVersion = 0x%x, Device=%p) -> (%u %s)"), InArguments.NGXAppId, APIVersion, InHandle, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = NVSDK_NGX_D3D12_Init_with_ProjectID(TCHAR_TO_UTF8(*InArguments.UnrealProjectID), NVSDK_NGX_ENGINE_TYPE_UNREAL, TCHAR_TO_UTF8(*InArguments.UnrealEngineVersion), InApplicationDataPath, InHandle, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_Init_with_ProjectID(ProjectID = %s, EngineVersion=%s, APIVersion = 0x%x, Device=%p) -> (%u %s)"), *InArguments.UnrealProjectID, *InArguments.UnrealEngineVersion, APIVersion, InHandle, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(Result))
|
||||
{
|
||||
NVSDK_NGX_D3D12_Shutdown();
|
||||
}
|
||||
|
||||
--APIVersion;
|
||||
} while (NVSDK_NGX_FAILED(Result) && APIVersion >= NVSDK_NGX_VERSION_API_MACRO_BASE_LINE);
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(Result) && (APIVersion + 1 < NVSDK_NGX_VERSION_API_MACRO_WITH_LOGGING))
|
||||
{
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("Warning: NVSDK_NGX_D3D12_Init succeeded, but the driver installed on this system is too old the support the NGX logging API. The console variables r.NGX.LogLevel and r.NGX.EnableOtherLoggingSinks will have no effect and NGX logs will only show up in their own log files, and not in UE's log files."));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FNGXD3D12RHI::FNGXD3D12RHI(const FNGXRHICreateArguments& Arguments)
|
||||
: NGXRHI(Arguments)
|
||||
, D3D12RHI(static_cast<FD3D12DynamicRHI*>(Arguments.DynamicRHI))
|
||||
|
||||
{
|
||||
ID3D12Device* Direct3DDevice = D3D12RHI->GetAdapter().GetD3DDevice();
|
||||
|
||||
ensure(D3D12RHI);
|
||||
ensure(Direct3DDevice);
|
||||
bIsIncompatibleAPICaptureToolActive = IsIncompatibleAPICaptureToolActive(Direct3DDevice);
|
||||
|
||||
const FString NGXLogDir = GetNGXLogDirectory();
|
||||
IPlatformFile::GetPlatformPhysical().CreateDirectoryTree(*NGXLogDir);
|
||||
|
||||
NVSDK_NGX_Result ResultInit = Init_NGX_D3D12(Arguments, *NGXLogDir, Direct3DDevice, CommonFeatureInfo());
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_Init (Log %s) -> (%u %s)"), *NGXLogDir, ResultInit, GetNGXResultAsString(ResultInit));
|
||||
|
||||
// store for the higher level code interpret
|
||||
DLSSQueryFeature.DLSSInitResult = ResultInit;
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultInit)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
else if (NVSDK_NGX_SUCCEED(ResultInit))
|
||||
{
|
||||
bNGXInitialized = true;
|
||||
|
||||
NVSDK_NGX_Result ResultGetParameters = NVSDK_NGX_D3D12_GetCapabilityParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_GetCapabilityParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultGetParameters)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(ResultGetParameters))
|
||||
{
|
||||
ResultGetParameters = NVSDK_NGX_D3D12_GetParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_GetParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
bSupportsAllocateParameters = false;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(ResultGetParameters))
|
||||
{
|
||||
DLSSQueryFeature.QueryDLSSSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FNGXD3D12RHI::~FNGXD3D12RHI()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
if (bNGXInitialized)
|
||||
{
|
||||
// Destroy the parameters and features before we call NVSDK_NGX_D3D11_Shutdown
|
||||
ReleaseAllocatedFeatures();
|
||||
|
||||
NVSDK_NGX_Result Result;
|
||||
if (bSupportsAllocateParameters && DLSSQueryFeature.CapabilityParameters)
|
||||
{
|
||||
Result = NVSDK_NGX_D3D12_DestroyParameters(DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_DestroyParameters -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
Result = NVSDK_NGX_D3D12_Shutdown();
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("NVSDK_NGX_D3D12_Shutdown -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
bNGXInitialized = false;
|
||||
}
|
||||
UE_LOG(LogDLSSNGXD3D12RHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void FNGXD3D12RHI::ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(IsDLSSAvailable());
|
||||
if (!IsDLSSAvailable()) return;
|
||||
|
||||
InArguments.Validate();
|
||||
|
||||
FD3D12Device* Device = D3D12RHI->GetAdapter().GetDevice(CmdList.GetGPUMask().ToIndex());
|
||||
ID3D12GraphicsCommandList* D3DGraphicsCommandList = Device->GetCommandContext().CommandListHandle.GraphicsCommandList();
|
||||
if (InDLSSState->RequiresFeatureRecreation(InArguments))
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature || InDLSSState->HasValidFeature());
|
||||
InDLSSState->DLSSFeature = nullptr;
|
||||
}
|
||||
|
||||
if (InArguments.bReset)
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature);
|
||||
InDLSSState->DLSSFeature = FindFreeFeature(InArguments);
|
||||
}
|
||||
|
||||
if (!InDLSSState->DLSSFeature)
|
||||
{
|
||||
NVSDK_NGX_Parameter* NewNGXParameterHandle = nullptr;
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_AllocateParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_D3D12_AllocateParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_D3D12_GetParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_D3D12_GetParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
ApplyCommonNGXParameterSettings(NewNGXParameterHandle, InArguments);
|
||||
|
||||
NVSDK_NGX_DLSS_Create_Params DlssCreateParams = InArguments.GetNGXDLSSCreateParams();
|
||||
NVSDK_NGX_Handle* NewNGXFeatureHandle = nullptr;
|
||||
|
||||
const uint32 CreationNodeMask = 1 << InArguments.GPUNode;
|
||||
const uint32 VisibilityNodeMask = InArguments.GPUVisibility;
|
||||
|
||||
NVSDK_NGX_Result ResultCreate = NGX_D3D12_CREATE_DLSS_EXT(
|
||||
D3DGraphicsCommandList,
|
||||
CreationNodeMask,
|
||||
VisibilityNodeMask,
|
||||
&NewNGXFeatureHandle,
|
||||
NewNGXParameterHandle,
|
||||
&DlssCreateParams
|
||||
);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultCreate), TEXT("NGX_D3D12_CREATE_DLSS_EXT (CreationNodeMask=0x%x VisibilityNodeMask=0x%x) failed! (%u %s), %s"), CreationNodeMask, VisibilityNodeMask, ResultCreate, GetNGXResultAsString(ResultCreate), *InArguments.GetFeatureDesc().GetDebugDescription());
|
||||
InDLSSState->DLSSFeature = MakeShared<FD3D12NGXDLSSFeature>(NewNGXFeatureHandle, NewNGXParameterHandle, InArguments.GetFeatureDesc(), FrameCounter);
|
||||
RegisterFeature(InDLSSState->DLSSFeature);
|
||||
}
|
||||
|
||||
check(InDLSSState->HasValidFeature());
|
||||
|
||||
// execute
|
||||
if (Device->GetCommandContext().IsDefaultContext())
|
||||
{
|
||||
Device->RegisterGPUWork(1);
|
||||
}
|
||||
|
||||
NVSDK_NGX_D3D12_DLSS_Eval_Params DlssEvalParams;
|
||||
FMemory::Memzero(DlssEvalParams);
|
||||
|
||||
DlssEvalParams.Feature.pInOutput = GetD3D12TextureFromRHITexture(InArguments.OutputColor, InArguments.GPUNode)->GetResource()->GetResource();
|
||||
DlssEvalParams.InOutputSubrectBase.X = InArguments.DestRect.Min.X;
|
||||
DlssEvalParams.InOutputSubrectBase.Y = InArguments.DestRect.Min.Y;
|
||||
|
||||
DlssEvalParams.InRenderSubrectDimensions.Width = InArguments.SrcRect.Width();
|
||||
DlssEvalParams.InRenderSubrectDimensions.Height = InArguments.SrcRect.Height();
|
||||
|
||||
DlssEvalParams.Feature.pInColor = GetD3D12TextureFromRHITexture(InArguments.InputColor, InArguments.GPUNode)->GetResource()->GetResource();
|
||||
DlssEvalParams.InColorSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InColorSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
DlssEvalParams.pInDepth = GetD3D12TextureFromRHITexture(InArguments.InputDepth, InArguments.GPUNode)->GetResource()->GetResource();
|
||||
DlssEvalParams.InDepthSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InDepthSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
DlssEvalParams.pInMotionVectors = GetD3D12TextureFromRHITexture(InArguments.InputMotionVectors, InArguments.GPUNode)->GetResource()->GetResource();
|
||||
// The VelocityCombine pass puts the motion vectors into the top left corner
|
||||
DlssEvalParams.InMVSubrectBase.X = 0;
|
||||
DlssEvalParams.InMVSubrectBase.Y = 0;
|
||||
|
||||
DlssEvalParams.pInExposureTexture = InArguments.bUseAutoExposure ? nullptr : GetD3D12TextureFromRHITexture(InArguments.InputExposure, InArguments.GPUNode)->GetResource()->GetResource();
|
||||
DlssEvalParams.InPreExposure = InArguments.PreExposure;
|
||||
|
||||
DlssEvalParams.Feature.InSharpness = InArguments.Sharpness;
|
||||
DlssEvalParams.InJitterOffsetX = InArguments.JitterOffset.X;
|
||||
DlssEvalParams.InJitterOffsetY = InArguments.JitterOffset.Y;
|
||||
|
||||
DlssEvalParams.InMVScaleX = InArguments.MotionVectorScale.X;
|
||||
DlssEvalParams.InMVScaleY = InArguments.MotionVectorScale.Y;
|
||||
DlssEvalParams.InReset = InArguments.bReset;
|
||||
|
||||
DlssEvalParams.InFrameTimeDeltaInMsec = InArguments.DeltaTime;
|
||||
|
||||
NVSDK_NGX_Result ResultEvaluate = NGX_D3D12_EVALUATE_DLSS_EXT(
|
||||
D3DGraphicsCommandList,
|
||||
InDLSSState->DLSSFeature->Feature,
|
||||
InDLSSState->DLSSFeature->Parameter,
|
||||
&DlssEvalParams
|
||||
);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultEvaluate), TEXT("NGX_D3D12_EVALUATE_DLSS_EXT failed! (%u %s), %s"), ResultEvaluate, GetNGXResultAsString(ResultEvaluate), *InDLSSState->DLSSFeature->Desc.GetDebugDescription());
|
||||
InDLSSState->DLSSFeature->Tick(FrameCounter);
|
||||
|
||||
Device->GetCommandContext().StateCache.ForceSetComputeRootSignature();
|
||||
Device->GetCommandContext().StateCache.GetDescriptorCache()->SetCurrentCommandList(Device->GetCommandContext().CommandListHandle);
|
||||
|
||||
}
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
|
||||
void FNGXD3D12RHIModule::StartupModule()
|
||||
{
|
||||
// NGXRHI module should be loaded to ensure logging state is initialized
|
||||
FModuleManager::LoadModuleChecked<INGXRHIModule>(TEXT("NGXRHI"));
|
||||
}
|
||||
|
||||
void FNGXD3D12RHIModule::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
TUniquePtr<NGXRHI> FNGXD3D12RHIModule::CreateNGXRHI(const FNGXRHICreateArguments& Arguments)
|
||||
{
|
||||
TUniquePtr<NGXRHI> Result(new FNGXD3D12RHI(Arguments));
|
||||
return Result;
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(FNGXD3D12RHIModule, NGXD3D12RHI)
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
|
||||
|
||||
37
Plugins/DLSS/Source/NGXD3D12RHI/Public/NGXD3D12RHI.h
Normal file
37
Plugins/DLSS/Source/NGXD3D12RHI/Public/NGXD3D12RHI.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "NGXRHI.h"
|
||||
|
||||
class FNGXD3D12RHIModule final : public INGXRHIModule
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
|
||||
/** INGXRHIModule implementation */
|
||||
|
||||
virtual TUniquePtr<NGXRHI> CreateNGXRHI(const FNGXRHICreateArguments& Arguments);
|
||||
};
|
||||
68
Plugins/DLSS/Source/NGXRHI/NGXRHI.Build.cs
Normal file
68
Plugins/DLSS/Source/NGXRHI/NGXRHI.Build.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
public class NGXRHI : ModuleRules
|
||||
{
|
||||
public NGXRHI(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
|
||||
"Core",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"RHI",
|
||||
|
||||
"NGX",
|
||||
}
|
||||
);
|
||||
DynamicallyLoadedModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
530
Plugins/DLSS/Source/NGXRHI/Private/NGXRHI.cpp
Normal file
530
Plugins/DLSS/Source/NGXRHI/Private/NGXRHI.cpp
Normal file
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2021 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 "NGXRHI.h"
|
||||
|
||||
#include "Misc/Paths.h"
|
||||
#include "GenericPlatform/GenericPlatformFile.h"
|
||||
|
||||
#include "nvsdk_ngx.h"
|
||||
#include "nvsdk_ngx_params.h"
|
||||
#include "nvsdk_ngx_helpers.h"
|
||||
|
||||
// NGX software stack
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGX, Log, All);
|
||||
// The UE module
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGXRHI, Log, All);
|
||||
|
||||
|
||||
|
||||
DECLARE_STATS_GROUP(TEXT("DLSS"), STATGROUP_DLSS, STATCAT_Advanced);
|
||||
DECLARE_MEMORY_STAT_POOL(TEXT("DLSS: Video memory"), STAT_DLSSInternalGPUMemory, STATGROUP_DLSS, FPlatformMemory::MCR_GPU);
|
||||
DECLARE_DWORD_COUNTER_STAT(TEXT("DLSS: Num DLSS features"), STAT_DLSSNumFeatures, STATGROUP_DLSS);
|
||||
|
||||
#define LOCTEXT_NAMESPACE "NGXRHI"
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXLogLevel(
|
||||
TEXT("r.NGX.LogLevel"), 1,
|
||||
TEXT("Determines the minimal amount of logging the NGX implementation pipes into LogDLSSNGX. Can be overridden by the -NGXLogLevel= command line option\n")
|
||||
TEXT("Please refer to the DLSS plugin documentation on other ways to change the logging level.\n")
|
||||
TEXT("0: off \n")
|
||||
TEXT("1: on (default)\n")
|
||||
TEXT("2: verbose "),
|
||||
ECVF_ReadOnly);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXEnableOtherLoggingSinks(
|
||||
TEXT("r.NGX.EnableOtherLoggingSinks"), 0,
|
||||
TEXT("Determines whether the NGX implementation will write logs to files. Can also be set on the command line via -NGXLogFileEnable and -NGXLogFileDisable\n")
|
||||
TEXT("0: off (default)\n")
|
||||
TEXT("1: on \n"),
|
||||
ECVF_ReadOnly);
|
||||
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXFramesUntilFeatureDestruction(
|
||||
TEXT("r.NGX.FramesUntilFeatureDestruction"), 3,
|
||||
TEXT("Number of frames until an unused NGX feature gets destroyed. (default=3)"),
|
||||
ECVF_RenderThreadSafe);
|
||||
|
||||
static TAutoConsoleVariable<int32> CVarNGXRenameLogSeverities(
|
||||
TEXT("r.NGX.RenameNGXLogSeverities"), 1,
|
||||
TEXT("Renames 'error' and 'warning' in messages returned by the NGX log callback to 'e_rror' and 'w_arning' before passing them to the UE log system\n")
|
||||
TEXT("0: off \n")
|
||||
TEXT("1: on, for select messages during initalization (default)\n")
|
||||
TEXT("2: on, for all messages\n"),
|
||||
ECVF_Default);
|
||||
|
||||
void FRHIDLSSArguments::Validate() const
|
||||
{
|
||||
check(InputColor);
|
||||
check(InputDepth);
|
||||
check(InputMotionVectors);
|
||||
check(InputExposure);
|
||||
check(OutputColor);
|
||||
}
|
||||
|
||||
NGXDLSSFeature::~NGXDLSSFeature()
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Destroying NGX DLSS Feature %s "), *Desc.GetDebugDescription());
|
||||
}
|
||||
|
||||
void NVSDK_CONV NGXLogSink(const char* InNGXMessage, NVSDK_NGX_Logging_Level InLoggingLevel, NVSDK_NGX_Feature InSourceComponent)
|
||||
{
|
||||
FString Message(FString(UTF8_TO_TCHAR(InNGXMessage)).TrimEnd());
|
||||
const TCHAR* NGXComponent = TEXT("Unknown");
|
||||
|
||||
switch (InSourceComponent)
|
||||
{
|
||||
case NVSDK_NGX_Feature_SuperSampling: NGXComponent = TEXT("DLSS"); break;
|
||||
case NVSDK_NGX_Feature_Reserved_SDK : NGXComponent = TEXT("SDK"); break;
|
||||
case NVSDK_NGX_Feature_Reserved_Core: NGXComponent = TEXT("Core"); break;
|
||||
}
|
||||
|
||||
const bool bIsVerboseStartupMessage =
|
||||
(Message.Contains(TEXT(" doesn't exist in any of the search paths")) && !Message.Contains(TEXT("nvngx_dlss.dll"))) || // we want to know if the DLSS binary is missing
|
||||
Message.Contains(TEXT("warning: UWP compliant mode enabled"));
|
||||
|
||||
|
||||
|
||||
if ((CVarNGXRenameLogSeverities.GetValueOnAnyThread() == 2) || ((CVarNGXRenameLogSeverities.GetValueOnAnyThread() == 1) && bIsVerboseStartupMessage))
|
||||
{
|
||||
Message = Message.Replace(TEXT("error:"), TEXT("e_rror:"));
|
||||
Message = Message.Replace(TEXT("Warning:"), TEXT("w_arning:"));
|
||||
UE_LOG(LogDLSSNGX, Verbose, TEXT("[%s]: %s"), NGXComponent, *Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGX, Log, TEXT("[%s]: %s"), NGXComponent, *Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// the derived RHIs will set this to false based on runtime support
|
||||
bool NGXRHI::bSupportsAllocateParameters = true;
|
||||
|
||||
bool NGXRHI::bNGXInitialized = false;
|
||||
|
||||
// the derived RHIs will set this to true during their initialization
|
||||
bool NGXRHI::bIsIncompatibleAPICaptureToolActive = false;
|
||||
|
||||
NGXRHI::NGXRHI(const FNGXRHICreateArguments& Arguments)
|
||||
: DynamicRHI(Arguments.DynamicRHI)
|
||||
{
|
||||
FString PluginNGXProductionBinariesDir = FPaths::Combine(Arguments.PluginBaseDir, TEXT("Binaries/ThirdParty/Win64/"));
|
||||
FString PluginNGXDevelopmentBinariesDir = FPaths::Combine(Arguments.PluginBaseDir, TEXT("Binaries/ThirdParty/Win64/Development/"));
|
||||
FString PluginNGXBinariesDir = PluginNGXProductionBinariesDir;
|
||||
|
||||
// Thee paths can be different depending on the project type (source, no source) and how the project is packaged, thus we have both
|
||||
FString ProjectNGXBinariesDir = FPaths::Combine(FPaths::ProjectDir(), TEXT("Binaries/ThirdParty/NVIDIA/NGX/Win64/"));
|
||||
FString LaunchNGXBinariesDir = FPaths::Combine(FPaths::LaunchDir(), TEXT("Binaries/ThirdParty/NVIDIA/NGX/Win64/"));
|
||||
|
||||
switch (Arguments.NGXBinariesSearchOrder)
|
||||
{
|
||||
default:
|
||||
case ENGXBinariesSearchOrder::CustomThenGeneric:
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Searching for custom and generic DLSS binaries"));
|
||||
NGXDLLSearchPaths.Append({ ProjectNGXBinariesDir, LaunchNGXBinariesDir, PluginNGXProductionBinariesDir });
|
||||
break;
|
||||
}
|
||||
case ENGXBinariesSearchOrder::ForceGeneric:
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Searching only for generic binaries from the plugin folder"));
|
||||
NGXDLLSearchPaths.Append({ PluginNGXProductionBinariesDir });
|
||||
break;
|
||||
}
|
||||
case ENGXBinariesSearchOrder::ForceCustom:
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Searching only for custom DLSS binaries from the DLSS plugin"));
|
||||
NGXDLLSearchPaths.Append({ ProjectNGXBinariesDir, LaunchNGXBinariesDir });
|
||||
break;
|
||||
}
|
||||
case ENGXBinariesSearchOrder::ForceDevelopmentGeneric:
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Searching only for generic development DLSS binaries from the DLSS plugin. This binary is only packaged for non-shipping build configurations"));
|
||||
NGXDLLSearchPaths.Append({ PluginNGXDevelopmentBinariesDir });
|
||||
PluginNGXBinariesDir = PluginNGXDevelopmentBinariesDir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < NGXDLLSearchPaths.Num(); ++i)
|
||||
{
|
||||
NGXDLLSearchPaths[i] = FPaths::ConvertRelativePathToFull(NGXDLLSearchPaths[i]);
|
||||
FPaths::RemoveDuplicateSlashes(NGXDLLSearchPaths[i]);
|
||||
FPaths::MakePlatformFilename(NGXDLLSearchPaths[i]);
|
||||
|
||||
// After this we should not touch NGXDLLSearchPaths since that provides the backing store for NGXDLLSearchPathRawStrings
|
||||
NGXDLLSearchPathRawStrings.Add(*NGXDLLSearchPaths[i]);
|
||||
const bool bHasDLSSBinary = IPlatformFile::GetPlatformPhysical().FileExists(*FPaths::Combine(NGXDLLSearchPaths[i], NGX_DLSS_BINARY_NAME));
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NVIDIA NGX DLSS binary %s %s in search path %s"), NGX_DLSS_BINARY_NAME, bHasDLSSBinary ? TEXT("found") : TEXT("not found"), *NGXDLLSearchPaths[i]);
|
||||
}
|
||||
|
||||
// we do this separately here so we can show relative paths in the UI later
|
||||
DLSSGenericBinaryInfo.Get<0>() = FPaths::Combine(PluginNGXBinariesDir, NGX_DLSS_BINARY_NAME);
|
||||
DLSSGenericBinaryInfo.Get<1>() = IPlatformFile::GetPlatformPhysical().FileExists(*DLSSGenericBinaryInfo.Get<0>());
|
||||
|
||||
DLSSCustomBinaryInfo.Get<0>() = FPaths::Combine(ProjectNGXBinariesDir, NGX_DLSS_BINARY_NAME);
|
||||
DLSSCustomBinaryInfo.Get<1>() = IPlatformFile::GetPlatformPhysical().FileExists(*DLSSCustomBinaryInfo.Get<0>());
|
||||
|
||||
FeatureInfo.PathListInfo.Path = const_cast<wchar_t**>(NGXDLLSearchPathRawStrings.GetData());
|
||||
FeatureInfo.PathListInfo.Length = NGXDLLSearchPathRawStrings.Num();
|
||||
|
||||
// logging
|
||||
{
|
||||
FeatureInfo.LoggingInfo.DisableOtherLoggingSinks = 1 != CVarNGXEnableOtherLoggingSinks.GetValueOnAnyThread();
|
||||
FeatureInfo.LoggingInfo.LoggingCallback = &NGXLogSink;
|
||||
|
||||
switch (CVarNGXLogLevel.GetValueOnAnyThread())
|
||||
{
|
||||
case 0:
|
||||
FeatureInfo.LoggingInfo.MinimumLoggingLevel = NVSDK_NGX_LOGGING_LEVEL_OFF;
|
||||
break;
|
||||
// should match the CVarNGXLogLevel default value
|
||||
default:
|
||||
case 1:
|
||||
FeatureInfo.LoggingInfo.MinimumLoggingLevel = NVSDK_NGX_LOGGING_LEVEL_ON;
|
||||
break;
|
||||
case 2:
|
||||
FeatureInfo.LoggingInfo.MinimumLoggingLevel = NVSDK_NGX_LOGGING_LEVEL_VERBOSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TTuple<FString, bool> NGXRHI::GetDLSSGenericBinaryInfo() const
|
||||
{
|
||||
return DLSSGenericBinaryInfo;
|
||||
}
|
||||
|
||||
TTuple<FString, bool> NGXRHI::GetDLSSCustomBinaryInfo() const
|
||||
{
|
||||
return DLSSCustomBinaryInfo;
|
||||
}
|
||||
|
||||
NGXRHI::~NGXRHI()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
|
||||
void NGXRHI::FDLSSQueryFeature::QueryDLSSSupport()
|
||||
{
|
||||
int32 bNeedsUpdatedDriver = 0;
|
||||
int32 MinDriverVersionMajor = 0;
|
||||
int32 MinDriverVersionMinor = 0;
|
||||
|
||||
// Centralize this here instead during NGXRHI init. This should not happen but if we don't have a a valid CapabilityParameters, then we also don't have DLSS.
|
||||
if (!CapabilityParameters)
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NVIDIA NGX DLSS cannot be loaded possibly due to issues initializing NGX."));
|
||||
DLSSInitResult = NVSDK_NGX_Result_Fail;
|
||||
bIsAvailable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
check(CapabilityParameters);
|
||||
|
||||
NVSDK_NGX_Result ResultUpdatedDriver = CapabilityParameters->Get(NVSDK_NGX_Parameter_SuperSampling_NeedsUpdatedDriver, &bNeedsUpdatedDriver);
|
||||
NVSDK_NGX_Result ResultMinDriverVersionMajor = CapabilityParameters->Get(NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMajor, &MinDriverVersionMajor);
|
||||
NVSDK_NGX_Result ResultMinDriverVersionMinor = CapabilityParameters->Get(NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMinor, &MinDriverVersionMinor);
|
||||
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Get NVSDK_NGX_Parameter_SuperSampling_NeedsUpdatedDriver -> (%u %s), bNeedsUpdatedDriver = %d"), ResultUpdatedDriver, GetNGXResultAsString(ResultUpdatedDriver), bNeedsUpdatedDriver);
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Get NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMajor -> (%u %s), MinDriverVersionMajor = %d"), ResultMinDriverVersionMajor, GetNGXResultAsString(ResultMinDriverVersionMajor), MinDriverVersionMajor);
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Get NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMinor -> (%u %s), MinDriverVersionMinor = %d"), ResultMinDriverVersionMinor, GetNGXResultAsString(ResultMinDriverVersionMinor), MinDriverVersionMinor);
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(ResultUpdatedDriver) && NVSDK_NGX_SUCCEED(ResultMinDriverVersionMajor) && NVSDK_NGX_SUCCEED(ResultMinDriverVersionMinor))
|
||||
{
|
||||
DriverRequirements.DriverUpdateRequired = DriverRequirements.DriverUpdateRequired || bNeedsUpdatedDriver != 0;
|
||||
|
||||
// ignore 0.0 and fall back to the what's baked into FNGXDriverRequirements;
|
||||
if (MinDriverVersionMajor)
|
||||
{
|
||||
|
||||
DriverRequirements.MinDriverVersionMajor = MinDriverVersionMajor;
|
||||
}
|
||||
|
||||
if (MinDriverVersionMinor)
|
||||
{
|
||||
DriverRequirements.MinDriverVersionMinor = MinDriverVersionMinor;
|
||||
}
|
||||
|
||||
|
||||
if (bNeedsUpdatedDriver)
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NVIDIA NGX DLSS cannot be loaded due to an outdated driver. Minimum Driver Version required : %u.%u"), MinDriverVersionMajor, MinDriverVersionMinor);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NVIDIA NGX DLSS is supported by the currently installed driver. Minimum driver version was reported as: %u.%u"), MinDriverVersionMajor, MinDriverVersionMinor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NVIDIA NGX DLSS Minimum driver version was not reported"));
|
||||
}
|
||||
|
||||
// determine if DLSS is available
|
||||
int DlssAvailable = 0;
|
||||
NVSDK_NGX_Result ResultAvailable = CapabilityParameters->Get(NVSDK_NGX_EParameter_SuperSampling_Available, &DlssAvailable);
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Get NVSDK_NGX_EParameter_SuperSampling_Available -> (%u %s), DlssAvailable = %d"), ResultAvailable, GetNGXResultAsString(ResultAvailable), DlssAvailable);
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(ResultAvailable) && DlssAvailable)
|
||||
{
|
||||
bIsAvailable = true;
|
||||
|
||||
// store for the higher level code interpret
|
||||
DLSSInitResult = ResultAvailable;
|
||||
}
|
||||
|
||||
// DLSS_TODO verify this
|
||||
if(!DlssAvailable)
|
||||
{
|
||||
// and try to find out more details on why it might have failed
|
||||
NVSDK_NGX_Result DlssFeatureInitResult = NVSDK_NGX_Result_Fail;
|
||||
NVSDK_NGX_Result ResultDlssFeatureInitResult = CapabilityParameters->Get(NVSDK_NGX_Parameter_SuperSampling_FeatureInitResult, (int*)&DlssFeatureInitResult);
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Get NVSDK_NGX_Parameter_SuperSampling_FeatureInitResult -> (%u %s), NVSDK_NGX_Parameter_SuperSampling_FeatureInitResult = (%u %s)"), ResultDlssFeatureInitResult, GetNGXResultAsString(ResultDlssFeatureInitResult), DlssFeatureInitResult, GetNGXResultAsString(DlssFeatureInitResult));
|
||||
|
||||
// store for the higher level code interpret
|
||||
DLSSInitResult = NVSDK_NGX_SUCCEED(ResultDlssFeatureInitResult) ? DlssFeatureInitResult : NVSDK_NGX_Result_Fail;
|
||||
}
|
||||
}
|
||||
|
||||
FDLSSOptimalSettings NGXRHI::FDLSSQueryFeature::GetDLSSOptimalSettings(const FDLSSResolutionParameters& InResolution) const
|
||||
{
|
||||
check(CapabilityParameters);
|
||||
|
||||
FDLSSOptimalSettings OptimalSettings;
|
||||
|
||||
const NVSDK_NGX_Result ResultGetOptimalSettings = NGX_DLSS_GET_OPTIMAL_SETTINGS(
|
||||
CapabilityParameters,
|
||||
InResolution.Width,
|
||||
InResolution.Height,
|
||||
InResolution.PerfQuality,
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSize.X),
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSize.Y),
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSizeMax.X),
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSizeMax.Y),
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSizeMin.X),
|
||||
reinterpret_cast<unsigned int*>(&OptimalSettings.RenderSizeMin.Y),
|
||||
&OptimalSettings.Sharpness
|
||||
);
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("NGX_DLSS_GET_OPTIMAL_SETTINGS -> (%u %s)"), ResultGetOptimalSettings, GetNGXResultAsString(ResultGetOptimalSettings));
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultGetOptimalSettings), TEXT("failed to query supported DLSS modes"));
|
||||
|
||||
OptimalSettings.bIsSupported = (OptimalSettings.RenderSize.X > 0) && (OptimalSettings.RenderSize.Y > 0);
|
||||
auto ComputeResolutionFraction = [&InResolution](int32 RenderSizeX, int32 RenderSizeY)
|
||||
{
|
||||
float XScale = float(RenderSizeX) / float(InResolution.Width);
|
||||
float YScale = float(RenderSizeY) / float(InResolution.Height);
|
||||
return FMath::Min(XScale, YScale);
|
||||
};
|
||||
|
||||
|
||||
OptimalSettings.MinResolutionFraction = ComputeResolutionFraction(OptimalSettings.RenderSizeMin.X, OptimalSettings.RenderSizeMin.Y);
|
||||
OptimalSettings.MaxResolutionFraction = ComputeResolutionFraction(OptimalSettings.RenderSizeMax.X, OptimalSettings.RenderSizeMax.Y);
|
||||
|
||||
// restrict to range since floating point numbers are gonna floating point
|
||||
OptimalSettings.OptimalResolutionFraction = FMath::Clamp<float>(ComputeResolutionFraction(OptimalSettings.RenderSize.X, OptimalSettings.RenderSize.Y), OptimalSettings.MinResolutionFraction, OptimalSettings.MaxResolutionFraction);
|
||||
|
||||
|
||||
return OptimalSettings;
|
||||
}
|
||||
|
||||
FString NGXRHI::GetNGXLogDirectory()
|
||||
{
|
||||
// encode the time and instance id to handle cases like PIE standalone game where multiple processe are running at the same time.
|
||||
FString AbsoluteProjectLogDir = FPaths::ConvertRelativePathToFull(FPaths::ProjectLogDir());
|
||||
FString NGXLogDir = FPaths::Combine(AbsoluteProjectLogDir, TEXT("NGX"), FString::Printf(TEXT("NGX_%s_%s"), *FDateTime::Now().ToString(), *FApp::GetInstanceId().ToString()));
|
||||
return NGXLogDir;
|
||||
}
|
||||
|
||||
uint32 FRHIDLSSArguments::GetNGXCommonDLSSFeatureFlags() const
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
uint32 DLSSFeatureFlags = NVSDK_NGX_DLSS_Feature_Flags_None;
|
||||
DLSSFeatureFlags |= NVSDK_NGX_DLSS_Feature_Flags_IsHDR;
|
||||
DLSSFeatureFlags |= bool(ERHIZBuffer::IsInverted) ? NVSDK_NGX_DLSS_Feature_Flags_DepthInverted : 0;
|
||||
DLSSFeatureFlags |= !bHighResolutionMotionVectors ? NVSDK_NGX_DLSS_Feature_Flags_MVLowRes : 0;
|
||||
DLSSFeatureFlags |= Sharpness != 0.0f ? NVSDK_NGX_DLSS_Feature_Flags_DoSharpening : 0;
|
||||
DLSSFeatureFlags |= bUseAutoExposure ? NVSDK_NGX_DLSS_Feature_Flags_AutoExposure : 0;
|
||||
return DLSSFeatureFlags;
|
||||
}
|
||||
|
||||
NVSDK_NGX_DLSS_Create_Params FRHIDLSSArguments::GetNGXDLSSCreateParams() const
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
NVSDK_NGX_DLSS_Create_Params Result;
|
||||
FMemory::Memzero(Result);
|
||||
Result.Feature.InWidth = SrcRect.Width();
|
||||
Result.Feature.InHeight = SrcRect.Height();
|
||||
Result.Feature.InTargetWidth = DestRect.Width();
|
||||
Result.Feature.InTargetHeight = DestRect.Height();
|
||||
Result.Feature.InPerfQualityValue = static_cast<NVSDK_NGX_PerfQuality_Value>(PerfQuality);
|
||||
check((Result.Feature.InPerfQualityValue >= NVSDK_NGX_PerfQuality_Value_MaxPerf) && (Result.Feature.InPerfQualityValue <= NVSDK_NGX_PerfQuality_Value_UltraQuality));
|
||||
|
||||
Result.InFeatureCreateFlags = GetNGXCommonDLSSFeatureFlags();
|
||||
Result.InEnableOutputSubrects = OutputColor->GetTexture2D()->GetSizeXY() != DestRect.Size();
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this is used by the RHIs to see whether they need to recreate the NGX feature
|
||||
bool FDLSSState::RequiresFeatureRecreation(const FRHIDLSSArguments& InArguments)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
return !DLSSFeature || DLSSFeature->Desc != InArguments.GetFeatureDesc();
|
||||
}
|
||||
|
||||
void NGXRHI::RegisterFeature(TSharedPtr<NGXDLSSFeature> InFeature)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("Creating NGX DLSS Feature %s "), *InFeature->Desc.GetDebugDescription());
|
||||
AllocatedDLSSFeatures.Add(InFeature);
|
||||
}
|
||||
|
||||
TSharedPtr<NGXDLSSFeature> NGXRHI::FindFreeFeature(const FRHIDLSSArguments& InArguments)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
TSharedPtr<NGXDLSSFeature> OutFeature;
|
||||
for (int FeatureIndex = 0; FeatureIndex < AllocatedDLSSFeatures.Num(); ++FeatureIndex)
|
||||
{
|
||||
// another view already uses this (1 reference from AllocatedDLSSFeatures, another refernces held by FDLSState
|
||||
if (AllocatedDLSSFeatures[FeatureIndex].GetSharedReferenceCount() > 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (AllocatedDLSSFeatures[FeatureIndex]->Desc == InArguments.GetFeatureDesc())
|
||||
{
|
||||
OutFeature = AllocatedDLSSFeatures[FeatureIndex];
|
||||
OutFeature->LastUsedFrame = FrameCounter;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return OutFeature;
|
||||
}
|
||||
|
||||
void NGXRHI::ReleaseAllocatedFeatures()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
// There should be no FDLSSState::DLSSFeature anymore when we shut down
|
||||
for (int FeatureIndex = 0; FeatureIndex < AllocatedDLSSFeatures.Num(); ++FeatureIndex)
|
||||
{
|
||||
checkf(AllocatedDLSSFeatures[FeatureIndex].GetSharedReferenceCount() == 1,TEXT("There should be no FDLSSState::DLSSFeature references elsewhere."));
|
||||
}
|
||||
|
||||
AllocatedDLSSFeatures.Empty();
|
||||
SET_DWORD_STAT(STAT_DLSSNumFeatures, AllocatedDLSSFeatures.Num());
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void NGXRHI::ApplyCommonNGXParameterSettings(NVSDK_NGX_Parameter* InOutParameter, const FRHIDLSSArguments& InArguments)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetI(InOutParameter, NVSDK_NGX_Parameter_FreeMemOnReleaseFeature, InArguments.bReleaseMemoryOnDelete ? 1 : 0);
|
||||
}
|
||||
|
||||
void NGXRHI::TickPoolElements()
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
const uint32 kFramesUntilRelease = CVarNGXFramesUntilFeatureDestruction.GetValueOnAnyThread();
|
||||
|
||||
int32 FeatureIndex = 0;
|
||||
|
||||
while (FeatureIndex < AllocatedDLSSFeatures.Num())
|
||||
{
|
||||
TSharedPtr<NGXDLSSFeature>& Feature = AllocatedDLSSFeatures[FeatureIndex];
|
||||
|
||||
const bool bIsUnused = Feature.GetSharedReferenceCount() == 1;
|
||||
const bool bNotRequestedRecently = (FrameCounter - Feature->LastUsedFrame) > kFramesUntilRelease;
|
||||
|
||||
if (bIsUnused && bNotRequestedRecently)
|
||||
{
|
||||
Swap(Feature, AllocatedDLSSFeatures.Last());
|
||||
AllocatedDLSSFeatures.Pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
++FeatureIndex;
|
||||
}
|
||||
}
|
||||
|
||||
SET_DWORD_STAT(STAT_DLSSNumFeatures, AllocatedDLSSFeatures.Num());
|
||||
|
||||
|
||||
// if r.NGX.Enable is 0 then this should be nullptr
|
||||
if(DLSSQueryFeature.CapabilityParameters)
|
||||
{
|
||||
static const auto CVarNGXDLSSEnable = IConsoleManager::Get().FindConsoleVariable(TEXT("r.NGX.Enable"));
|
||||
check(CVarNGXDLSSEnable && CVarNGXDLSSEnable->GetInt() != 0);
|
||||
|
||||
unsigned long long VRAM = 0;
|
||||
|
||||
NVSDK_NGX_Result ResultGetStats = NGX_DLSS_GET_STATS(DLSSQueryFeature.CapabilityParameters, &VRAM);
|
||||
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultGetStats), TEXT("Failed to retrieve DLSS memory statistics via NGX_DLSS_GET_STATS -> (%u %s)"), ResultGetStats, GetNGXResultAsString(ResultGetStats));
|
||||
if (NVSDK_NGX_SUCCEED(ResultGetStats))
|
||||
{
|
||||
SET_DWORD_STAT(STAT_DLSSInternalGPUMemory, VRAM);
|
||||
}
|
||||
}
|
||||
|
||||
++FrameCounter;
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(FNGXRHIModule, NGXRHI)
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
|
||||
void FNGXRHIModule::StartupModule()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
int32 NGXLogLevel = CVarNGXLogLevel.GetValueOnAnyThread();
|
||||
if (FParse::Value(FCommandLine::Get(), TEXT("ngxloglevel="), NGXLogLevel))
|
||||
{
|
||||
CVarNGXLogLevel->Set(NGXLogLevel, ECVF_SetByCommandline);
|
||||
}
|
||||
|
||||
if (FParse::Param(FCommandLine::Get(), TEXT("ngxlogfileenable")))
|
||||
{
|
||||
CVarNGXEnableOtherLoggingSinks->Set(1, ECVF_SetByCommandline);
|
||||
}
|
||||
else if (FParse::Param(FCommandLine::Get(), TEXT("ngxlogfiledisable")))
|
||||
{
|
||||
CVarNGXEnableOtherLoggingSinks->Set(0, ECVF_SetByCommandline);
|
||||
}
|
||||
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void FNGXRHIModule::ShutdownModule()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSSNGXRHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
409
Plugins/DLSS/Source/NGXRHI/Public/NGXRHI.h
Normal file
409
Plugins/DLSS/Source/NGXRHI/Public/NGXRHI.h
Normal file
@@ -0,0 +1,409 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "RendererInterface.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "nvsdk_ngx_params.h"
|
||||
|
||||
#define NVSDK_NGX_VERSION_API_MACRO_BASE_LINE (0x0000013)
|
||||
#define NVSDK_NGX_VERSION_API_MACRO_WITH_LOGGING (0x0000014)
|
||||
|
||||
struct FDLSSState;
|
||||
|
||||
struct FDLSSFeatureDesc
|
||||
{
|
||||
bool operator != (const FDLSSFeatureDesc& Other) const
|
||||
{
|
||||
return DestRect.Size() != Other.DestRect.Size()
|
||||
|| PerfQuality != Other.PerfQuality
|
||||
|| bHighResolutionMotionVectors != Other.bHighResolutionMotionVectors
|
||||
|| bNonZeroSharpness != Other.bNonZeroSharpness
|
||||
|| bUseAutoExposure != Other.bUseAutoExposure
|
||||
|| bReleaseMemoryOnDelete != Other.bReleaseMemoryOnDelete
|
||||
|| GPUNode != Other.GPUNode
|
||||
|| GPUVisibility != Other.GPUVisibility;
|
||||
}
|
||||
|
||||
bool operator == (const FDLSSFeatureDesc& Other) const
|
||||
{
|
||||
return !operator !=(Other);
|
||||
}
|
||||
|
||||
FIntRect SrcRect = FIntRect(FIntPoint::NoneValue, FIntPoint::NoneValue);
|
||||
FIntRect DestRect = FIntRect(FIntPoint::NoneValue, FIntPoint::NoneValue);
|
||||
int32 PerfQuality = -1;
|
||||
bool bHighResolutionMotionVectors = false;
|
||||
bool bNonZeroSharpness = false;
|
||||
bool bUseAutoExposure = false;
|
||||
bool bReleaseMemoryOnDelete = false;
|
||||
uint32 GPUNode = 0;
|
||||
uint32 GPUVisibility = 0;
|
||||
FString GetDebugDescription() const
|
||||
{
|
||||
auto NGXPerfQualityString = [] (int NGXPerfQuality)
|
||||
{
|
||||
switch (NGXPerfQuality)
|
||||
{
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxPerf:return TEXT("MaxPerf");
|
||||
case NVSDK_NGX_PerfQuality_Value_Balanced:return TEXT("Balanced");
|
||||
case NVSDK_NGX_PerfQuality_Value_MaxQuality:return TEXT("MaxQuality");
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraPerformance:return TEXT("UltraPerformance");
|
||||
case NVSDK_NGX_PerfQuality_Value_UltraQuality:return TEXT("UltraQuality");
|
||||
default:return TEXT("Invalid NVSDK_NGX_PerfQuality_Value");
|
||||
}
|
||||
};
|
||||
return FString::Printf(TEXT("SrcRect=[%dx%d->%dx%d], DestRect=[%dx%d->%dx%d], ScaleX=%f, ScaleY=%f, NGXPerfQuality=%s(%d), bHighResolutionMotionVectors=%d, bNonZeroSharpness=%d, bUseAutoExposure=%d, bReleaseMemoryOnDelete=%d, GPUNode=%u, GPUVisibility=0x%x"),
|
||||
SrcRect.Min.X, SrcRect.Min.Y, SrcRect.Max.X, SrcRect.Max.Y,
|
||||
DestRect.Min.X, DestRect.Min.Y, DestRect.Max.X, DestRect.Max.Y,
|
||||
float(SrcRect.Width()) / float(DestRect.Width()),
|
||||
float(SrcRect.Height()) / float(DestRect.Height()),
|
||||
NGXPerfQualityString(PerfQuality),
|
||||
PerfQuality,
|
||||
bHighResolutionMotionVectors,
|
||||
bNonZeroSharpness,
|
||||
bUseAutoExposure,
|
||||
bReleaseMemoryOnDelete,
|
||||
GPUNode,
|
||||
GPUVisibility);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
struct NGXRHI_API FRHIDLSSArguments
|
||||
{
|
||||
FRHITexture* InputColor = nullptr;
|
||||
FRHITexture* InputDepth = nullptr;
|
||||
FRHITexture* InputMotionVectors = nullptr;
|
||||
FRHITexture* InputExposure = nullptr;
|
||||
|
||||
FRHITexture* OutputColor = nullptr;
|
||||
|
||||
FIntRect SrcRect = FIntRect(FIntPoint::ZeroValue, FIntPoint::ZeroValue);
|
||||
FIntRect DestRect = FIntRect(FIntPoint::ZeroValue, FIntPoint::ZeroValue);
|
||||
#if ENGINE_MAJOR_VERSION < 5
|
||||
FVector2D JitterOffset= FVector2D::ZeroVector;
|
||||
FVector2D MotionVectorScale{ 1.0f,1.0f };
|
||||
#else
|
||||
FVector2f JitterOffset = FVector2f::ZeroVector;
|
||||
FVector2f MotionVectorScale = FVector2f::UnitVector;
|
||||
#endif
|
||||
bool bHighResolutionMotionVectors = false;
|
||||
|
||||
float Sharpness = 0.0f;
|
||||
bool bReset = false;
|
||||
|
||||
int32 PerfQuality = 0;
|
||||
float DeltaTime = 0.0f;
|
||||
|
||||
float PreExposure = 1.0f;
|
||||
bool bUseAutoExposure = false;
|
||||
|
||||
|
||||
bool bReleaseMemoryOnDelete = false;
|
||||
uint32 GPUNode = 0;
|
||||
uint32 GPUVisibility = 0;
|
||||
void Validate() const;
|
||||
|
||||
inline FDLSSFeatureDesc GetFeatureDesc() const
|
||||
{
|
||||
return FDLSSFeatureDesc{ SrcRect, DestRect, PerfQuality, bHighResolutionMotionVectors, Sharpness != 0.0f, bUseAutoExposure, bReleaseMemoryOnDelete, GPUNode, GPUVisibility};
|
||||
}
|
||||
|
||||
uint32 GetNGXCommonDLSSFeatureFlags() const;
|
||||
NVSDK_NGX_DLSS_Create_Params GetNGXDLSSCreateParams() const;
|
||||
};
|
||||
|
||||
struct FNGXDriverRequirements
|
||||
{
|
||||
bool DriverUpdateRequired = false;
|
||||
int32 MinDriverVersionMajor = 470;
|
||||
int32 MinDriverVersionMinor = 0;
|
||||
};
|
||||
|
||||
// the API specic RHI extensions derive from this to handle the lifetime
|
||||
class NGXRHI_API NGXDLSSFeature
|
||||
{
|
||||
public:
|
||||
virtual ~NGXDLSSFeature() = 0;
|
||||
|
||||
FDLSSFeatureDesc Desc;
|
||||
NVSDK_NGX_Handle* Feature = nullptr;
|
||||
NVSDK_NGX_Parameter* Parameter = nullptr;
|
||||
uint32 LastUsedFrame = 0;
|
||||
|
||||
void Tick(uint32 InFrameNumber)
|
||||
{
|
||||
check(Feature);
|
||||
check(Parameter);
|
||||
LastUsedFrame = InFrameNumber;
|
||||
}
|
||||
|
||||
NGXDLSSFeature(NVSDK_NGX_Handle* InFeature, NVSDK_NGX_Parameter* InParameter, const FDLSSFeatureDesc& InFeatureDesc, uint32 InLastUsedEvaluation)
|
||||
: Desc(InFeatureDesc)
|
||||
, Feature(InFeature)
|
||||
, Parameter(InParameter)
|
||||
, LastUsedFrame(InLastUsedEvaluation)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(Feature);
|
||||
check(Parameter);
|
||||
}
|
||||
bool IsValid() const
|
||||
{
|
||||
return Feature && Parameter;
|
||||
}
|
||||
};
|
||||
|
||||
struct NGXRHI_API FDLSSState
|
||||
{
|
||||
// this is used by the RHIs to see whether they need to recreate the NGX feature
|
||||
|
||||
bool RequiresFeatureRecreation(const FRHIDLSSArguments& InArguments);
|
||||
|
||||
bool HasValidFeature() const
|
||||
{
|
||||
return DLSSFeature && DLSSFeature->IsValid();
|
||||
}
|
||||
|
||||
// this is stored via pointer to allow the NGXRHIs use the API specific functions to create & release
|
||||
TSharedPtr<NGXDLSSFeature> DLSSFeature;
|
||||
};
|
||||
|
||||
using FDLSSStateRef = TSharedPtr<FDLSSState, ESPMode::ThreadSafe>;
|
||||
|
||||
enum class ENGXBinariesSearchOrder
|
||||
{
|
||||
MinValue = 0,
|
||||
CustomThenGeneric = 0,
|
||||
ForceGeneric = 1,
|
||||
ForceCustom = 2,
|
||||
ForceDevelopmentGeneric = 3,
|
||||
MaxValue = ForceDevelopmentGeneric
|
||||
};
|
||||
|
||||
enum class ENGXProjectIdentifier
|
||||
{
|
||||
MinValue = 0,
|
||||
NGXApplicationIDThenUEProjectID = 0,
|
||||
ForceUEProjectID = 1,
|
||||
ForceNGXApplicationID = 2,
|
||||
MaxValue = ForceNGXApplicationID
|
||||
};
|
||||
|
||||
struct FNGXRHICreateArguments
|
||||
{
|
||||
FString PluginBaseDir;
|
||||
FDynamicRHI* DynamicRHI = nullptr;
|
||||
ENGXBinariesSearchOrder NGXBinariesSearchOrder = ENGXBinariesSearchOrder::CustomThenGeneric;
|
||||
|
||||
ENGXProjectIdentifier ProjectIdentifier = ENGXProjectIdentifier::NGXApplicationIDThenUEProjectID;
|
||||
uint32 NGXAppId = 0;
|
||||
FString UnrealEngineVersion;
|
||||
FString UnrealProjectID;
|
||||
|
||||
// centralize that logic here for the derived NGXRHIs
|
||||
bool InitializeNGXWithNGXApplicationID() const
|
||||
{
|
||||
if ((ProjectIdentifier == ENGXProjectIdentifier::NGXApplicationIDThenUEProjectID) && (NGXAppId != 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (ProjectIdentifier == ENGXProjectIdentifier::ForceNGXApplicationID)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct FDLSSOptimalSettings
|
||||
{
|
||||
FIntPoint RenderSize;
|
||||
|
||||
FIntPoint RenderSizeMin;
|
||||
FIntPoint RenderSizeMax;
|
||||
float Sharpness;
|
||||
|
||||
bool bIsSupported;
|
||||
float OptimalResolutionFraction;
|
||||
|
||||
float MinResolutionFraction;
|
||||
float MaxResolutionFraction;
|
||||
|
||||
bool IsFixedResolution() const
|
||||
{
|
||||
return MinResolutionFraction == MaxResolutionFraction;
|
||||
}
|
||||
};
|
||||
|
||||
class NGXRHI_API NGXRHI
|
||||
{
|
||||
struct NGXRHI_API FDLSSQueryFeature
|
||||
{
|
||||
struct FDLSSResolutionParameters
|
||||
{
|
||||
uint32 Width = 0;
|
||||
uint32 Height = 0;
|
||||
NVSDK_NGX_PerfQuality_Value PerfQuality = NVSDK_NGX_PerfQuality_Value_MaxPerf;
|
||||
|
||||
|
||||
FDLSSResolutionParameters(uint32 InWidth, uint32 InHeight, NVSDK_NGX_PerfQuality_Value InPerfQuality)
|
||||
: Width(InWidth)
|
||||
, Height(InHeight)
|
||||
, PerfQuality(InPerfQuality)
|
||||
{}
|
||||
};
|
||||
|
||||
void QueryDLSSSupport();
|
||||
FDLSSOptimalSettings GetDLSSOptimalSettings(const FDLSSResolutionParameters& InResolution) const;
|
||||
|
||||
// the lifetime of this is managed directly by the encompassing derived RHI
|
||||
NVSDK_NGX_Parameter* CapabilityParameters = nullptr;
|
||||
|
||||
bool bIsAvailable = false;
|
||||
FNGXDriverRequirements DriverRequirements;
|
||||
|
||||
NVSDK_NGX_Result DLSSInitResult = NVSDK_NGX_Result_Fail;
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
virtual ~NGXRHI();
|
||||
|
||||
virtual void ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState) = 0;
|
||||
|
||||
bool IsDLSSAvailable() const
|
||||
{
|
||||
return DLSSQueryFeature.bIsAvailable;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result GetDLSSInitResult() const
|
||||
{
|
||||
return DLSSQueryFeature.DLSSInitResult;
|
||||
}
|
||||
|
||||
const FNGXDriverRequirements& GetDLSSDriverRequirements() const
|
||||
{
|
||||
return DLSSQueryFeature.DriverRequirements;
|
||||
}
|
||||
|
||||
FDLSSOptimalSettings GetDLSSOptimalSettings(const FDLSSQueryFeature::FDLSSResolutionParameters& InResolution) const
|
||||
{
|
||||
return DLSSQueryFeature.GetDLSSOptimalSettings(InResolution);
|
||||
}
|
||||
|
||||
FDLSSOptimalSettings GetDLSSOptimalSettings(NVSDK_NGX_PerfQuality_Value QualityLevel) const
|
||||
{
|
||||
return DLSSQueryFeature.GetDLSSOptimalSettings(FDLSSQueryFeature::FDLSSResolutionParameters(1000, 1000, QualityLevel));
|
||||
}
|
||||
|
||||
float GetDLSSResolutionFraction(NVSDK_NGX_PerfQuality_Value QualityLevel) const
|
||||
{
|
||||
return GetDLSSOptimalSettings(QualityLevel).OptimalResolutionFraction;
|
||||
}
|
||||
|
||||
TPair<FString, bool> GetDLSSGenericBinaryInfo() const;
|
||||
TPair<FString, bool> GetDLSSCustomBinaryInfo() const;
|
||||
|
||||
void TickPoolElements();
|
||||
|
||||
static bool SupportsAllocateParameters()
|
||||
{
|
||||
return bSupportsAllocateParameters;
|
||||
}
|
||||
|
||||
static bool NGXInitialized()
|
||||
{
|
||||
return bNGXInitialized;
|
||||
}
|
||||
|
||||
static bool IsIncompatibleAPICaptureToolActive()
|
||||
{
|
||||
return bIsIncompatibleAPICaptureToolActive;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
NGXRHI(const FNGXRHICreateArguments& Arguments);
|
||||
|
||||
const NVSDK_NGX_FeatureCommonInfo* CommonFeatureInfo() const
|
||||
{
|
||||
return &FeatureInfo;
|
||||
}
|
||||
|
||||
void RegisterFeature(TSharedPtr<NGXDLSSFeature> InFeature);
|
||||
TSharedPtr<NGXDLSSFeature> FindFreeFeature(const FRHIDLSSArguments& InArguments);
|
||||
|
||||
void ReleaseAllocatedFeatures();
|
||||
void ApplyCommonNGXParameterSettings(NVSDK_NGX_Parameter* Parameter, const FRHIDLSSArguments& InArguments);
|
||||
static FString GetNGXLogDirectory();
|
||||
|
||||
|
||||
|
||||
|
||||
FDynamicRHI* DynamicRHI = nullptr;
|
||||
|
||||
FDLSSQueryFeature DLSSQueryFeature;
|
||||
|
||||
uint32 FrameCounter = 1;
|
||||
|
||||
static bool bNGXInitialized;
|
||||
static bool bSupportsAllocateParameters;
|
||||
static bool bIsIncompatibleAPICaptureToolActive;
|
||||
private:
|
||||
TArray< TSharedPtr<NGXDLSSFeature>> AllocatedDLSSFeatures;
|
||||
|
||||
TTuple<FString, bool> DLSSGenericBinaryInfo;
|
||||
TTuple<FString, bool> DLSSCustomBinaryInfo;
|
||||
|
||||
TArray<FString> NGXDLLSearchPaths;
|
||||
TArray<const wchar_t*> NGXDLLSearchPathRawStrings;
|
||||
|
||||
NVSDK_NGX_FeatureCommonInfo FeatureInfo = {{0}};
|
||||
};
|
||||
|
||||
|
||||
// Implemented by the API specific modules
|
||||
class INGXRHIModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
virtual TUniquePtr<NGXRHI> CreateNGXRHI(const FNGXRHICreateArguments& Arguments) = 0;
|
||||
};
|
||||
|
||||
class FNGXRHIModule final : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
};
|
||||
75
Plugins/DLSS/Source/NGXVulkanRHI/NGXVulkanRHI.Build.cs
Normal file
75
Plugins/DLSS/Source/NGXVulkanRHI/NGXVulkanRHI.Build.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class NGXVulkanRHI : ModuleRules
|
||||
{
|
||||
public NGXVulkanRHI(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/VulkanRHI/Private"),
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/VulkanRHI/Private/Windows"),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"RHI",
|
||||
"VulkanRHI",
|
||||
|
||||
"NGX",
|
||||
"NGXRHI",
|
||||
}
|
||||
);
|
||||
|
||||
if (ReadOnlyBuildVersion.Current.MajorVersion == 5)
|
||||
{
|
||||
PrivateDependencyModuleNames.Add("RHICore");
|
||||
}
|
||||
|
||||
// those come from the VulkanRHI
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "Vulkan");
|
||||
|
||||
}
|
||||
}
|
||||
371
Plugins/DLSS/Source/NGXVulkanRHI/Private/NGXVulkanRHI.cpp
Normal file
371
Plugins/DLSS/Source/NGXVulkanRHI/Private/NGXVulkanRHI.cpp
Normal file
@@ -0,0 +1,371 @@
|
||||
/*
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "NGXVulkanRHI.h"
|
||||
|
||||
#include "VulkanRHIPrivate.h"
|
||||
#include "VulkanPendingState.h"
|
||||
#include "VulkanRHIBridge.h"
|
||||
#include "VulkanContext.h"
|
||||
|
||||
#include "nvsdk_ngx_vk.h"
|
||||
#include "nvsdk_ngx_helpers_vk.h"
|
||||
|
||||
#include "GenericPlatform/GenericPlatformFile.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGXVulkanRHI, Log, All);
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FNGXVulkanRHIModule"
|
||||
|
||||
class FVulkanNGXDLSSFeature final : public NGXDLSSFeature
|
||||
{
|
||||
|
||||
public:
|
||||
using NGXDLSSFeature::NGXDLSSFeature;
|
||||
|
||||
virtual ~FVulkanNGXDLSSFeature()
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(NGXRHI::NGXInitialized());
|
||||
NVSDK_NGX_Result ResultReleaseFeature = NVSDK_NGX_VULKAN_ReleaseFeature(Feature);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultReleaseFeature), TEXT("NVSDK_NGX_VULKAN_ReleaseFeature failed! (%u %s), %s"), ResultReleaseFeature, GetNGXResultAsString(ResultReleaseFeature), *Desc.GetDebugDescription());
|
||||
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result ResultDestroyParameter = NVSDK_NGX_VULKAN_DestroyParameters(Parameter);
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultDestroyParameter), TEXT("NVSDK_NGX_VULKAN_DestroyParameters failed! (%u %s), %s"), ResultDestroyParameter, GetNGXResultAsString(ResultDestroyParameter), *Desc.GetDebugDescription());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class FNGXVulkanRHI final : public NGXRHI
|
||||
{
|
||||
|
||||
public:
|
||||
FNGXVulkanRHI(const FNGXRHICreateArguments& Arguments);
|
||||
virtual void ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState) final;
|
||||
virtual ~FNGXVulkanRHI();
|
||||
private:
|
||||
|
||||
FVulkanDynamicRHI* VulkanRHI = nullptr;
|
||||
FVulkanDevice* VulkanDevice = nullptr;
|
||||
|
||||
NVSDK_NGX_Result Init_NGX_VK(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo);
|
||||
static bool IsIncompatibleAPICaptureToolActive();
|
||||
};
|
||||
|
||||
|
||||
bool FNGXVulkanRHI::IsIncompatibleAPICaptureToolActive()
|
||||
{
|
||||
// TODO figure out whether the renderdoc layer is active, either here or in the PreInit module
|
||||
return false;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result FNGXVulkanRHI::Init_NGX_VK(const FNGXRHICreateArguments& InArguments, const wchar_t* InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo* InFeatureInfo)
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_Result_Fail;
|
||||
int32 APIVersion = NVSDK_NGX_VERSION_API_MACRO;
|
||||
do
|
||||
{
|
||||
if (InArguments.InitializeNGXWithNGXApplicationID())
|
||||
{
|
||||
Result = NVSDK_NGX_VULKAN_Init(InArguments.NGXAppId, InApplicationDataPath, InInstance, InPD, InDevice, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_Init(AppID= %u, APIVersion = 0x%x) -> (%u %s)"), InArguments.NGXAppId, APIVersion, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = NVSDK_NGX_VULKAN_Init_with_ProjectID(TCHAR_TO_UTF8(*InArguments.UnrealProjectID), NVSDK_NGX_ENGINE_TYPE_UNREAL, TCHAR_TO_UTF8(*InArguments.UnrealEngineVersion), InApplicationDataPath, InInstance, InPD, InDevice, InFeatureInfo, static_cast<NVSDK_NGX_Version>(APIVersion));
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_Init(ProjectID = %s, EngineVersion=%s, APIVersion = 0x%x) -> (%u %s)"), *InArguments.UnrealProjectID, *InArguments.UnrealEngineVersion, APIVersion, Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(Result))
|
||||
{
|
||||
NVSDK_NGX_VULKAN_Shutdown();
|
||||
}
|
||||
|
||||
--APIVersion;
|
||||
} while (NVSDK_NGX_FAILED(Result) && APIVersion >= NVSDK_NGX_VERSION_API_MACRO_BASE_LINE);
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(Result) && (APIVersion + 1 < NVSDK_NGX_VERSION_API_MACRO_WITH_LOGGING))
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("Warning: NVSDK_NGX_VULKAN_Init succeeded, but the driver installed on this system is too old the support the NGX logging API. The console variables r.NGX.LogLevel and r.NGX.EnableOtherLoggingSinks will have no effect and NGX logs will only show up in their own log files, and not in UE's log files."));
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
|
||||
FNGXVulkanRHI::FNGXVulkanRHI(const FNGXRHICreateArguments& Arguments)
|
||||
: NGXRHI(Arguments)
|
||||
, VulkanRHI(static_cast<FVulkanDynamicRHI*>(Arguments.DynamicRHI))
|
||||
, VulkanDevice(VulkanRHIBridge::GetDevice(VulkanRHI)
|
||||
)
|
||||
{
|
||||
ensure(VulkanRHI);
|
||||
|
||||
const FString NGXLogDir = GetNGXLogDirectory();
|
||||
IPlatformFile::GetPlatformPhysical().CreateDirectoryTree(*NGXLogDir);
|
||||
|
||||
bIsIncompatibleAPICaptureToolActive = IsIncompatibleAPICaptureToolActive();
|
||||
|
||||
VkInstance VulkanInstance = reinterpret_cast<VkInstance>(VulkanRHIBridge::GetInstance(VulkanRHI));
|
||||
VkPhysicalDevice VulkanPhysicalDevice = reinterpret_cast<VkPhysicalDevice>(VulkanRHIBridge::GetPhysicalDevice(VulkanDevice));
|
||||
VkDevice VulkanLogicalDevice = reinterpret_cast<VkDevice>(VulkanRHIBridge::GetLogicalDevice(VulkanDevice));
|
||||
|
||||
NVSDK_NGX_Result ResultInit = Init_NGX_VK(Arguments, *NGXLogDir, VulkanInstance, VulkanPhysicalDevice, VulkanLogicalDevice, CommonFeatureInfo());
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_Init (Log %s) -> (%u %s)"), *NGXLogDir, ResultInit, GetNGXResultAsString(ResultInit));
|
||||
|
||||
// store for the higher level code interpret
|
||||
DLSSQueryFeature.DLSSInitResult = ResultInit;
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultInit)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
else if (NVSDK_NGX_SUCCEED(ResultInit))
|
||||
{
|
||||
bNGXInitialized = true;
|
||||
|
||||
NVSDK_NGX_Result ResultGetParameters = NVSDK_NGX_VULKAN_GetCapabilityParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_GetCapabilityParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
if (NVSDK_NGX_Result_FAIL_OutOfDate == ResultGetParameters)
|
||||
{
|
||||
DLSSQueryFeature.DriverRequirements.DriverUpdateRequired = true;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_FAILED(ResultGetParameters))
|
||||
{
|
||||
ResultGetParameters = NVSDK_NGX_VULKAN_GetParameters(&DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_GetParameters -> (%u %s)"), ResultGetParameters, GetNGXResultAsString(ResultGetParameters));
|
||||
|
||||
bSupportsAllocateParameters = false;
|
||||
}
|
||||
|
||||
if (NVSDK_NGX_SUCCEED(ResultGetParameters))
|
||||
{
|
||||
DLSSQueryFeature.QueryDLSSSupport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FNGXVulkanRHI::~FNGXVulkanRHI()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
if (bNGXInitialized)
|
||||
{
|
||||
// Destroy the parameters and features before we call NVSDK_NGX_D3D11_Shutdown
|
||||
ReleaseAllocatedFeatures();
|
||||
|
||||
NVSDK_NGX_Result Result;
|
||||
if (bSupportsAllocateParameters && DLSSQueryFeature.CapabilityParameters)
|
||||
{
|
||||
Result = NVSDK_NGX_VULKAN_DestroyParameters(DLSSQueryFeature.CapabilityParameters);
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_DestroyParameters -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
Result = NVSDK_NGX_VULKAN_Shutdown();
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("NVSDK_NGX_VULKAN_Shutdown -> (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
bNGXInitialized = false;
|
||||
}
|
||||
UE_LOG(LogDLSSNGXVulkanRHI, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
void FNGXVulkanRHI::ExecuteDLSS(FRHICommandList& CmdList, const FRHIDLSSArguments& InArguments, FDLSSStateRef InDLSSState)
|
||||
{
|
||||
check(!IsRunningRHIInSeparateThread() || IsInRHIThread());
|
||||
check(IsDLSSAvailable());
|
||||
if (!IsDLSSAvailable()) return;
|
||||
|
||||
InArguments.Validate();
|
||||
|
||||
FVulkanCommandListContextImmediate& ImmediateContext = VulkanDevice->GetImmediateContext();
|
||||
VkCommandBuffer VulkanCommandBuffer = ImmediateContext.GetCommandBufferManager()->GetActiveCmdBuffer()->GetHandle();
|
||||
|
||||
if (InDLSSState->RequiresFeatureRecreation(InArguments))
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature || InDLSSState->HasValidFeature());
|
||||
InDLSSState->DLSSFeature = nullptr;
|
||||
}
|
||||
|
||||
if (InArguments.bReset)
|
||||
{
|
||||
check(!InDLSSState->DLSSFeature);
|
||||
InDLSSState->DLSSFeature = FindFreeFeature(InArguments);
|
||||
}
|
||||
|
||||
if (!InDLSSState->DLSSFeature)
|
||||
{
|
||||
NVSDK_NGX_Parameter* NewNGXParameterHandle = nullptr;
|
||||
if (NGXRHI::SupportsAllocateParameters())
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_VULKAN_AllocateParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_VULKAN_AllocateParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
else
|
||||
{
|
||||
NVSDK_NGX_Result Result = NVSDK_NGX_VULKAN_GetParameters(&NewNGXParameterHandle);
|
||||
checkf(NVSDK_NGX_SUCCEED(Result), TEXT("NVSDK_NGX_VULKAN_GetParameters failed! (%u %s)"), Result, GetNGXResultAsString(Result));
|
||||
}
|
||||
|
||||
ApplyCommonNGXParameterSettings(NewNGXParameterHandle, InArguments);
|
||||
|
||||
NVSDK_NGX_DLSS_Create_Params DlssCreateParams = InArguments.GetNGXDLSSCreateParams();
|
||||
NVSDK_NGX_Handle* NewNGXHandle = nullptr;
|
||||
|
||||
const uint32 CreationNodeMask = 1 << InArguments.GPUNode;
|
||||
const uint32 VisibilityNodeMask = InArguments.GPUVisibility;
|
||||
|
||||
NVSDK_NGX_Result ResultCreate = NGX_VULKAN_CREATE_DLSS_EXT(
|
||||
VulkanCommandBuffer,
|
||||
CreationNodeMask,
|
||||
VisibilityNodeMask,
|
||||
&NewNGXHandle,
|
||||
NewNGXParameterHandle,
|
||||
&DlssCreateParams);
|
||||
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultCreate), TEXT("NGX_VULKAN_CREATE_DLSS failed! (CreationNodeMask=0x%x VisibilityNodeMask=0x%x) (%u %s), %s"), CreationNodeMask, VisibilityNodeMask, ResultCreate, GetNGXResultAsString(ResultCreate), *InArguments.GetFeatureDesc().GetDebugDescription());
|
||||
InDLSSState->DLSSFeature = MakeShared<FVulkanNGXDLSSFeature>(NewNGXHandle, NewNGXParameterHandle, InArguments.GetFeatureDesc(), FrameCounter);
|
||||
RegisterFeature(InDLSSState->DLSSFeature);
|
||||
}
|
||||
|
||||
check(InDLSSState->HasValidFeature());
|
||||
|
||||
// execute
|
||||
NVSDK_NGX_VK_DLSS_Eval_Params DlssEvalParams;
|
||||
FMemory::Memzero(DlssEvalParams);
|
||||
auto NGXVulkanResourceFromRHITexture = [](FRHITexture* InRHITexture)
|
||||
{
|
||||
check(InRHITexture);
|
||||
if (FRHITextureReference* TexRef = InRHITexture->GetTextureReference())
|
||||
{
|
||||
InRHITexture = TexRef->GetReferencedTexture();
|
||||
check(InRHITexture);
|
||||
}
|
||||
|
||||
FVulkanTextureBase* VulkanTexture = static_cast<FVulkanTextureBase*>(InRHITexture->GetTextureBaseRHI());
|
||||
|
||||
NVSDK_NGX_Resource_VK NGXTexture;
|
||||
FMemory::Memzero(NGXTexture);
|
||||
|
||||
NGXTexture.Type = NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW;
|
||||
|
||||
// Check for VK_IMAGE_USAGE_STORAGE_BIT. Those are not directly stored but FVulkanSurface::GenerateImageCreateInfo sets the VK flag based on those UEFlags
|
||||
NGXTexture.ReadWrite = EnumHasAnyFlags(VulkanTexture->Surface.UEFlags, TexCreate_Presentable | TexCreate_UAV);
|
||||
|
||||
NGXTexture.Resource.ImageViewInfo.ImageView = VulkanTexture->DefaultView.View;
|
||||
NGXTexture.Resource.ImageViewInfo.Image = VulkanTexture->DefaultView.Image;
|
||||
NGXTexture.Resource.ImageViewInfo.Format = VulkanTexture->Surface.ViewFormat;
|
||||
|
||||
NGXTexture.Resource.ImageViewInfo.Width = VulkanTexture->Surface.Width;
|
||||
NGXTexture.Resource.ImageViewInfo.Height = VulkanTexture->Surface.Height;
|
||||
check(VulkanTexture->Surface.Depth == 1);
|
||||
|
||||
NGXTexture.Resource.ImageViewInfo.SubresourceRange.aspectMask = VulkanTexture->Surface.GetFullAspectMask();
|
||||
|
||||
NGXTexture.Resource.ImageViewInfo.SubresourceRange.layerCount = VulkanTexture->Surface.GetNumberOfArrayLevels();
|
||||
NGXTexture.Resource.ImageViewInfo.SubresourceRange.levelCount = VulkanTexture->Surface.GetNumMips();
|
||||
|
||||
// DLSS_TODO Figure out where to get those from if the textures are arrayed or mipped.
|
||||
check(VulkanTexture->Surface.GetNumberOfArrayLevels() == 1);
|
||||
check(VulkanTexture->Surface.GetNumMips() == 1);
|
||||
NGXTexture.Resource.ImageViewInfo.SubresourceRange.baseMipLevel = 0;
|
||||
NGXTexture.Resource.ImageViewInfo.SubresourceRange.baseArrayLayer = 0;
|
||||
|
||||
return NGXTexture;
|
||||
};
|
||||
|
||||
NVSDK_NGX_Resource_VK InOutput = NGXVulkanResourceFromRHITexture(InArguments.OutputColor);
|
||||
DlssEvalParams.Feature.pInOutput = &InOutput;
|
||||
check(InArguments.OutputColor->GetFlags() & ( TexCreate_UAV | TexCreate_Presentable));
|
||||
check(InOutput.ReadWrite == true);
|
||||
DlssEvalParams.InOutputSubrectBase.X = InArguments.DestRect.Min.X;
|
||||
DlssEvalParams.InOutputSubrectBase.Y = InArguments.DestRect.Min.Y;
|
||||
|
||||
DlssEvalParams.InRenderSubrectDimensions.Width = InArguments.SrcRect.Width();
|
||||
DlssEvalParams.InRenderSubrectDimensions.Height = InArguments.SrcRect.Height();
|
||||
|
||||
NVSDK_NGX_Resource_VK InColor = NGXVulkanResourceFromRHITexture(InArguments.InputColor);
|
||||
DlssEvalParams.Feature.pInColor = &InColor;
|
||||
DlssEvalParams.InColorSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InColorSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
NVSDK_NGX_Resource_VK InDepth = NGXVulkanResourceFromRHITexture(InArguments.InputDepth);
|
||||
DlssEvalParams.pInDepth = &InDepth;
|
||||
DlssEvalParams.InDepthSubrectBase.X = InArguments.SrcRect.Min.X;
|
||||
DlssEvalParams.InDepthSubrectBase.Y = InArguments.SrcRect.Min.Y;
|
||||
|
||||
NVSDK_NGX_Resource_VK InMotionVectors = NGXVulkanResourceFromRHITexture(InArguments.InputMotionVectors);
|
||||
DlssEvalParams.pInMotionVectors = &InMotionVectors;
|
||||
// The VelocityCombine pass puts the motion vectors into the top left corner
|
||||
DlssEvalParams.InMVSubrectBase.X = 0;
|
||||
DlssEvalParams.InMVSubrectBase.Y = 0;
|
||||
|
||||
NVSDK_NGX_Resource_VK InExposureTexture = NGXVulkanResourceFromRHITexture(InArguments.InputExposure);
|
||||
DlssEvalParams.pInExposureTexture = InArguments.bUseAutoExposure ? nullptr : &InExposureTexture;
|
||||
DlssEvalParams.InPreExposure = InArguments.PreExposure;
|
||||
|
||||
DlssEvalParams.Feature.InSharpness = InArguments.Sharpness;
|
||||
DlssEvalParams.InJitterOffsetX = InArguments.JitterOffset.X;
|
||||
DlssEvalParams.InJitterOffsetY = InArguments.JitterOffset.Y;
|
||||
|
||||
DlssEvalParams.InMVScaleX = InArguments.MotionVectorScale.X;
|
||||
DlssEvalParams.InMVScaleY = InArguments.MotionVectorScale.Y;
|
||||
DlssEvalParams.InReset = InArguments.bReset;
|
||||
|
||||
|
||||
DlssEvalParams.InFrameTimeDeltaInMsec = InArguments.DeltaTime;
|
||||
|
||||
NVSDK_NGX_Result ResultEvaluate = NGX_VULKAN_EVALUATE_DLSS_EXT(
|
||||
VulkanCommandBuffer,
|
||||
InDLSSState->DLSSFeature->Feature,
|
||||
InDLSSState->DLSSFeature->Parameter,
|
||||
&DlssEvalParams
|
||||
);
|
||||
|
||||
checkf(NVSDK_NGX_SUCCEED(ResultEvaluate), TEXT("NGX_Vulkan_EVALUATE_DLSS_EXT failed! (%u %s), %s"), ResultEvaluate, GetNGXResultAsString(ResultEvaluate), *InDLSSState->DLSSFeature->Desc.GetDebugDescription());
|
||||
InDLSSState->DLSSFeature->Tick(FrameCounter);
|
||||
|
||||
if (FVulkanPlatform::RegisterGPUWork() && ImmediateContext.IsImmediate())
|
||||
{
|
||||
ImmediateContext.GetGPUProfiler().RegisterGPUWork(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImmediateContext.GetPendingComputeState()->Reset();
|
||||
ImmediateContext.GetPendingGfxState()->Reset();
|
||||
}
|
||||
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
|
||||
void FNGXVulkanRHIModule::StartupModule()
|
||||
{
|
||||
// NGXRHI module should be loaded to ensure logging state is initialized
|
||||
FModuleManager::LoadModuleChecked<INGXRHIModule>(TEXT("NGXRHI"));
|
||||
}
|
||||
|
||||
void FNGXVulkanRHIModule::ShutdownModule()
|
||||
{
|
||||
}
|
||||
|
||||
TUniquePtr<NGXRHI> FNGXVulkanRHIModule::CreateNGXRHI(const FNGXRHICreateArguments& Arguments)
|
||||
{
|
||||
TUniquePtr<NGXRHI> Result(new FNGXVulkanRHI(Arguments));
|
||||
return Result;
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(FNGXVulkanRHIModule, NGXVulkanRHI)
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
36
Plugins/DLSS/Source/NGXVulkanRHI/Public/NGXVulkanRHI.h
Normal file
36
Plugins/DLSS/Source/NGXVulkanRHI/Public/NGXVulkanRHI.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
#include "NGXRHI.h"
|
||||
|
||||
class FNGXVulkanRHIModule final : public INGXRHIModule
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
|
||||
/** INGXRHIModule implementation */
|
||||
virtual TUniquePtr<NGXRHI> CreateNGXRHI(const FNGXRHICreateArguments& Arguments);
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class NGXVulkanRHIPreInit : ModuleRules
|
||||
{
|
||||
public NGXVulkanRHIPreInit(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicIncludePaths.AddRange(
|
||||
new string[] {
|
||||
// ... add public include paths required here ...
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
new string[] {
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/VulkanRHI/Private"),
|
||||
Path.Combine(EngineDirectory,"Source/Runtime/VulkanRHI/Private/Windows"),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"Engine",
|
||||
"RenderCore",
|
||||
"RHI",
|
||||
|
||||
"VulkanRHI",
|
||||
"NGX",
|
||||
}
|
||||
);
|
||||
if (ReadOnlyBuildVersion.Current.MajorVersion == 5)
|
||||
{
|
||||
PrivateDependencyModuleNames.Add("RHICore");
|
||||
}
|
||||
// those come from the VulkanRHI
|
||||
AddEngineThirdPartyPrivateStaticDependencies(Target, "Vulkan");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2020 - 2021 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 "NGXVulkanRHIPreInit.h"
|
||||
|
||||
#include "VulkanRHIPrivate.h"
|
||||
#include "VulkanRHIBridge.h"
|
||||
|
||||
#include "DynamicRHI.h"
|
||||
|
||||
#include "nvsdk_ngx_vk.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogDLSSNGXVulkanRHIPreInit, Log, All);
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FNGXVulkanRHIPreInitModule"
|
||||
|
||||
|
||||
void FNGXVulkanRHIPreInitModule::StartupModule()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
if(FApp::CanEverRender())
|
||||
{
|
||||
const TCHAR* VulkanRHIModuleName = TEXT("VulkanRHI");
|
||||
|
||||
// don't cleanup since the same module gets loaded shortly thereafter anyways
|
||||
const TCHAR* DynamicRHIModuleName = GetSelectedDynamicRHIModuleName(false);
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("GetSelectedDynamicRHIModuleName = %s"), DynamicRHIModuleName);
|
||||
|
||||
if(FString(VulkanRHIModuleName) == FString(DynamicRHIModuleName))
|
||||
{
|
||||
IDynamicRHIModule* VulkanRHIModule = FModuleManager::GetModulePtr<IDynamicRHIModule>(VulkanRHIModuleName);
|
||||
|
||||
if(VulkanRHIModule && VulkanRHIModule->IsSupported())
|
||||
{
|
||||
unsigned int NumInstanceExtensions = 0 ;
|
||||
const char** InstanceExtensions = nullptr;
|
||||
unsigned int NumDeviceExtensions = 0;
|
||||
const char** DeviceExtensions = nullptr;
|
||||
|
||||
const NVSDK_NGX_Result ResultRequiredExtensions = NVSDK_NGX_VULKAN_RequiredExtensions(&NumInstanceExtensions, &InstanceExtensions, &NumDeviceExtensions, &DeviceExtensions);
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("NVSDK_NGX_VULKAN_RequiredExtensions -> (%u %s)"), ResultRequiredExtensions, GetNGXResultAsString(ResultRequiredExtensions));
|
||||
|
||||
const TArray<const ANSICHAR*> RHIBridgeInstanceExtensions(InstanceExtensions, NumInstanceExtensions);
|
||||
VulkanRHIBridge::AddEnabledInstanceExtensionsAndLayers(RHIBridgeInstanceExtensions, TArray<const ANSICHAR*>());
|
||||
|
||||
const TArray<const ANSICHAR*> RHIBridgeDeviceExtensions(DeviceExtensions, NumDeviceExtensions);
|
||||
VulkanRHIBridge::AddEnabledDeviceExtensionsAndLayers(RHIBridgeDeviceExtensions, TArray<const ANSICHAR*>());
|
||||
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("Preregistered the required NGX DLSS Vulkan device extensions (%u) and instance extensions (%u) via the VulkanRHIBridge"), NumDeviceExtensions, NumInstanceExtensions);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("Failed to load the VulkanRHI module and/or Vulkan is not supported; skipping of pregistering the required NGX DLSS Vulkan device and instance extensions via the VulkanRHIBridge"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("VulkanRHI is not the active DynamicRHI; skipping of pregistering the required NGX DLSS Vulkan device and instance extensions via the VulkanRHIBridge"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("This UE instance does not render; skipping of pregistering the required NGX DLSS Vulkan device and instance extensions via the VulkanRHIBridge"));
|
||||
}
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
|
||||
}
|
||||
|
||||
void FNGXVulkanRHIPreInitModule::ShutdownModule()
|
||||
{
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("%s Enter"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
UE_LOG(LogDLSSNGXVulkanRHIPreInit, Log, TEXT("%s Leave"), ANSI_TO_TCHAR(__FUNCTION__));
|
||||
}
|
||||
|
||||
IMPLEMENT_MODULE(FNGXVulkanRHIPreInitModule, NGXVulkanRHIPreInit)
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FNGXVulkanRHIPreInitModule final : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule();
|
||||
virtual void ShutdownModule();
|
||||
};
|
||||
437
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx.h
vendored
Normal file
437
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx.h
vendored
Normal file
@@ -0,0 +1,437 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* HOW TO USE:
|
||||
*
|
||||
* IMPORTANT: FOR DLSS/DLISP PLEASE SEE THE PROGRAMMING GUIDE
|
||||
*
|
||||
* IMPORTANT: Methods in this library are NOT thread safe. It is up to the
|
||||
* client to ensure that thread safety is enforced as needed.
|
||||
*
|
||||
* 1) Call NVSDK_CONV NVSDK_NGX_D3D11/D3D12/CUDA_Init and pass your app Id
|
||||
* and other parameters. This will initialize SDK or return an error code
|
||||
* if SDK cannot run on target machine. Depending on error user might
|
||||
* need to update drivers. Please note that application Id is provided
|
||||
* by NVIDIA so if you do not have one please contact us.
|
||||
*
|
||||
* 2) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetParameters to obtain pointer to
|
||||
* interface used to pass parameters to SDK. Interface instance is
|
||||
* allocated and released by SDK so there is no need to do any memory
|
||||
* management on client side.
|
||||
*
|
||||
* 3) Set key parameters for the feature you want to use. For example,
|
||||
* width and height are required for all features and they can be
|
||||
* set like this:
|
||||
* Params->Set(NVSDK_NGX_Parameter_Width,MY_WIDTH);
|
||||
* Params->Set(NVSDK_NGX_Parameter_Height,MY_HEIGHT);
|
||||
*
|
||||
* You can also provide hints like NVSDK_NGX_Parameter_Hint_HDR to tell
|
||||
* SDK that it should expect HDR color space is needed. Please refer to
|
||||
* samples since different features need different parameters and hints.
|
||||
*
|
||||
* 4) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetScratchBufferSize to obtain size of
|
||||
* the scratch buffer needed by specific feature. This D3D or CUDA buffer
|
||||
* should be allocated by client and passed as:
|
||||
* Params->Set(NVSDK_NGX_Parameter_Scratch,MY_SCRATCH_POINTER)
|
||||
* Params->Set(NVSDK_NGX_Parameter_Scratch_SizeInBytes,MY_SCRATCH_SIZE_IN_BYTES)
|
||||
* NOTE: Returned size can be 0 if feature does not use any scratch buffer.
|
||||
* It is OK to use bigger buffer or reuse buffers across features as long
|
||||
* as minimum size requirement is met.
|
||||
*
|
||||
* 5) Call NVSDK_NGX_D3D11/D3D12/CUDA_CreateFeature to create feature you need.
|
||||
* On success SDK will return a handle which must be used in any successive
|
||||
* calls to SDK which require feature handle. SDK will use all parameters
|
||||
* and hints provided by client to generate feature. If feature with the same
|
||||
* parameters already exists and error code will be returned.
|
||||
*
|
||||
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_EvaluateFeature to invoke execution of
|
||||
* specific feature. Before feature can be evaluated input parameters must
|
||||
* be specified (like for example color/albedo buffer, motion vectors etc)
|
||||
*
|
||||
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_ReleaseFeature when feature is no longer
|
||||
* needed. After this call feature handle becomes invalid and cannot be used.
|
||||
*
|
||||
* 7) Call NVSDK_NGX_D3D11/D3D12/CUDA_Shutdown when SDK is no longer needed to
|
||||
* release all resources.
|
||||
|
||||
* Contact: ngxsupport@nvidia.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NVSDK_NGX_H
|
||||
#define NVSDK_NGX_H
|
||||
|
||||
#include <stddef.h> // For size_t
|
||||
|
||||
#include "nvsdk_ngx_defs.h"
|
||||
#include "nvsdk_ngx_params.h"
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct IUnknown IUnknown;
|
||||
|
||||
typedef struct ID3D11Device ID3D11Device;
|
||||
typedef struct ID3D11Resource ID3D11Resource;
|
||||
typedef struct ID3D11DeviceContext ID3D11DeviceContext;
|
||||
typedef struct D3D11_TEXTURE2D_DESC D3D11_TEXTURE2D_DESC;
|
||||
typedef struct D3D11_BUFFER_DESC D3D11_BUFFER_DESC;
|
||||
typedef struct ID3D11Buffer ID3D11Buffer;
|
||||
typedef struct ID3D11Texture2D ID3D11Texture2D;
|
||||
|
||||
typedef struct ID3D12Device ID3D12Device;
|
||||
typedef struct ID3D12Resource ID3D12Resource;
|
||||
typedef struct ID3D12GraphicsCommandList ID3D12GraphicsCommandList;
|
||||
typedef struct D3D12_RESOURCE_DESC D3D12_RESOURCE_DESC;
|
||||
typedef struct CD3DX12_HEAP_PROPERTIES CD3DX12_HEAP_PROPERTIES;
|
||||
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D12_ResourceAllocCallback)(D3D12_RESOURCE_DESC *InDesc, int InState, CD3DX12_HEAP_PROPERTIES *InHeap, ID3D12Resource **OutResource);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_BufferAllocCallback)(D3D11_BUFFER_DESC *InDesc, ID3D11Buffer **OutResource);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_D3D11_Tex2DAllocCallback)(D3D11_TEXTURE2D_DESC *InDesc, ID3D11Texture2D **OutResource);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ResourceReleaseCallback)(IUnknown *InResource);
|
||||
|
||||
typedef unsigned long long CUtexObject;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Init
|
||||
// -------------------------------------
|
||||
//
|
||||
// InApplicationId:
|
||||
// Unique Id provided by NVIDIA
|
||||
//
|
||||
// InApplicationDataPath:
|
||||
// Folder to store logs and other temporary files (write access required),
|
||||
// Normally this would be a location in Documents or ProgramData.
|
||||
//
|
||||
// InDevice: [d3d11/12 only]
|
||||
// DirectX device to use
|
||||
//
|
||||
// InFeatureInfo:
|
||||
// Contains information common to all features, presently only a list of all paths
|
||||
// feature dlls can be located in, other than the default path - application directory.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Initializes new SDK instance.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
#else
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Init_with_ProjectID
|
||||
// -------------------------------------
|
||||
//
|
||||
// InProjectId:
|
||||
// Unique Id provided by the rendering engine used
|
||||
//
|
||||
// InEngineType:
|
||||
// Rendering engine used by the application / plugin.
|
||||
// Use NVSDK_NGX_ENGINE_TYPE_CUSTOM if the specific engine type is not supported explicitly
|
||||
//
|
||||
// InEngineVersion:
|
||||
// Version number of the rendering engine used by the application / plugin.
|
||||
//
|
||||
// InApplicationDataPath:
|
||||
// Folder to store logs and other temporary files (write access required),
|
||||
// Normally this would be a location in Documents or ProgramData.
|
||||
//
|
||||
// InDevice: [d3d11/12 only]
|
||||
// DirectX device to use
|
||||
//
|
||||
// InFeatureInfo:
|
||||
// Contains information common to all features, presently only a list of all paths
|
||||
// feature dlls can be located in, other than the default path - application directory.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Initializes new SDK instance.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
#else
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D11Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, ID3D12Device *InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Shutdown
|
||||
// -------------------------------------
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Shuts down the current SDK instance and releases all resources.
|
||||
// Shutdown1(Device) only affects specified device
|
||||
// Shutdown1(nullptr) = Shutdown() and shuts down all devices
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown(void);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_Shutdown1(ID3D11Device *InDevice);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown(void);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_Shutdown1(ID3D12Device *InDevice);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_Shutdown(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// Parameters interface used to set any parameter needed by the SDK
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows simple parameter setup using named fields.
|
||||
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
|
||||
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
|
||||
// For more details please see sample code. Please note that allocated memory
|
||||
// will be freed by NGX so free/delete operator should NOT be called.
|
||||
// Parameter maps output by NVSDK_NGX_GetParameters are also pre-populated
|
||||
// with NGX capabilities and available features.
|
||||
// Unlike with NVSDK_NGX_AllocateParameters, parameter maps output by NVSDK_NGX_GetParameters
|
||||
// have their lifetimes managed by NGX, and must not
|
||||
// be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// NVSDK_NGX_GetParameters is soon to be deprecated and apps should move to using
|
||||
// NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters when possible.
|
||||
// Nevertheless, due to the possibility that the user will be using an older driver version,
|
||||
// NVSDK_NGX_GetParameters should still be used as a fallback if NVSDK_NGX_AllocateParameters
|
||||
// or NVSDK_NGX_GetCapabilityParameters return NVSDK_NGX_Result_FAIL_OutOfDate.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetParameters(NVSDK_NGX_Parameter **OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetParameters(NVSDK_NGX_Parameter **OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetParameters(NVSDK_NGX_Parameter **OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_AllocateParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// Parameters interface used to set any parameter needed by the SDK
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows allocating a simple parameter setup using named fields, whose
|
||||
// lifetime the app must manage.
|
||||
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
|
||||
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
|
||||
// For more details please see sample code.
|
||||
// Parameter maps output by NVSDK_NGX_AllocateParameters must NOT be freed using
|
||||
// the free/delete operator; to free a parameter map
|
||||
// output by NVSDK_NGX_AllocateParameters, NVSDK_NGX_DestroyParameters should be used.
|
||||
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_AllocateParameters
|
||||
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// Also unlike with NVSDK_NGX_GetParameters, parameter maps output by NVSDK_NGX_AllocateParameters
|
||||
// do not come pre-populated with NGX capabilities and available features.
|
||||
// To create a new parameter map pre-populated with such information, NVSDK_NGX_GetCapabilityParameters
|
||||
// should be used.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. In such a case, NVSDK_NGX_GetParameters
|
||||
// may be used as a fallback.
|
||||
// This function may only be called after a successful call into NVSDK_NGX_Init.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetCapabilityParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// The parameters interface populated with NGX and feature capabilities
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows the app to create a new parameter map
|
||||
// pre-populated with NGX capabilities and available features.
|
||||
// The output parameter map can also be used for any purpose
|
||||
// parameter maps output by NVSDK_NGX_AllocateParameters can be used for
|
||||
// but it is not recommended to use NVSDK_NGX_GetCapabilityParameters
|
||||
// unless querying NGX capabilities and available features
|
||||
// due to the overhead associated with pre-populating the parameter map.
|
||||
// Parameter maps output by NVSDK_NGX_GetCapabilityParameters must NOT be freed using
|
||||
// the free/delete operator; to free a parameter map
|
||||
// output by NVSDK_NGX_GetCapabilityParameters, NVSDK_NGX_DestroyParameters should be used.
|
||||
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_GetCapabilityParameters
|
||||
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. This function may only be called
|
||||
// after a successful call into NVSDK_NGX_Init.
|
||||
// If NVSDK_NGX_GetCapabilityParameters fails with NVSDK_NGX_Result_FAIL_OutOfDate,
|
||||
// NVSDK_NGX_GetParameters may be used as a fallback, to get a parameter map pre-populated
|
||||
// with NGX capabilities and available features.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_DestroyParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// InParameters:
|
||||
// The parameters interface to be destroyed
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows the app to destroy the parameter map passed in. Once
|
||||
// NVSDK_NGX_DestroyParameters is called on a parameter map, it
|
||||
// must not be used again.
|
||||
// NVSDK_NGX_DestroyParameters must not be called on any parameter map returned
|
||||
// by NVSDK_NGX_GetParameters; NGX will manage the lifetime of those
|
||||
// parameter maps.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. This function may only be called
|
||||
// after a successful call into NVSDK_NGX_Init.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetScratchBufferSize
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// InFeatureId:
|
||||
// AI feature in question
|
||||
//
|
||||
// InParameters:
|
||||
// Parameters used by the feature to help estimate scratch buffer size
|
||||
//
|
||||
// OutSizeInBytes:
|
||||
// Number of bytes needed for the scratch buffer for the specified feature.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// SDK needs a buffer of a certain size provided by the client in
|
||||
// order to initialize AI feature. Once feature is no longer
|
||||
// needed buffer can be released. It is safe to reuse the same
|
||||
// scratch buffer for different features as long as minimum size
|
||||
// requirement is met for all features. Please note that some
|
||||
// features might not need a scratch buffer so return size of 0
|
||||
// is completely valid.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_CreateFeature
|
||||
// -------------------------------------
|
||||
//
|
||||
// InCmdList:[d3d12 only]
|
||||
// Command list to use to execute GPU commands. Must be:
|
||||
// - Open and recording
|
||||
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
|
||||
// - Execute on non-copy command queue.
|
||||
// InDevCtx: [d3d11 only]
|
||||
// Device context to use to execute GPU commands
|
||||
//
|
||||
// InFeatureID:
|
||||
// AI feature to initialize
|
||||
//
|
||||
// InParameters:
|
||||
// List of parameters
|
||||
//
|
||||
// OutHandle:
|
||||
// Handle which uniquely identifies the feature. If feature with
|
||||
// provided parameters already exists the "already exists" error code is returned.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Each feature needs to be created before it can be used.
|
||||
// Refer to the sample code to find out which input parameters
|
||||
// are needed to create specific feature.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_CreateFeature(ID3D11DeviceContext *InDevCtx, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_CreateFeature(ID3D12GraphicsCommandList *InCmdList, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_CreateFeature(NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Release
|
||||
// -------------------------------------
|
||||
//
|
||||
// InHandle:
|
||||
// Handle to feature to be released
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Releases feature with a given handle.
|
||||
// Handles are not reference counted so
|
||||
// after this call it is invalid to use provided handle.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_EvaluateFeature
|
||||
// -------------------------------------
|
||||
//
|
||||
// InCmdList:[d3d12 only]
|
||||
// Command list to use to execute GPU commands. Must be:
|
||||
// - Open and recording
|
||||
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
|
||||
// - Execute on non-copy command queue.
|
||||
// InDevCtx: [d3d11 only]
|
||||
// Device context to use to execute GPU commands
|
||||
//
|
||||
// InFeatureHandle:
|
||||
// Handle representing feature to be evaluated
|
||||
//
|
||||
// InParameters:
|
||||
// List of parameters required to evaluate feature
|
||||
//
|
||||
// InCallback:
|
||||
// Optional callback for features which might take longer
|
||||
// to execture. If specified SDK will call it with progress
|
||||
// values in range 0.0f - 1.0f
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Evaluates given feature using the provided parameters and
|
||||
// pre-trained NN. Please note that for most features
|
||||
// it can be benefitials to pass as many input buffers and parameters
|
||||
// as possible (for example provide all render targets like color, albedo, normals, depth etc)
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback)(float InCurrentProgress, bool &OutShouldCancel);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_EvaluateFeature(ID3D11DeviceContext *InDevCtx, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_EvaluateFeature(ID3D12GraphicsCommandList *InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_EvaluateFeature(const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
|
||||
#endif
|
||||
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback_C)(float InCurrentProgress, bool *OutShouldCancel);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D11_EvaluateFeature_C(ID3D11DeviceContext *InDevCtx, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_D3D12_EvaluateFeature_C(ID3D12GraphicsCommandList *InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_CUDA_EvaluateFeature_C(const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
|
||||
|
||||
// NGX return-code conversion-to-string utility only as a helper for debugging/logging - not for official use.
|
||||
const wchar_t* NVSDK_CONV GetNGXResultAsString(NVSDK_NGX_Result InNGXResult);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // #define NVSDK_NGX_H
|
||||
597
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_defs.h
vendored
Normal file
597
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_defs.h
vendored
Normal file
@@ -0,0 +1,597 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
#ifndef NVSDK_NGX_DEFS_H
|
||||
#define NVSDK_NGX_DEFS_H
|
||||
#pragma once
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stddef.h> // For size_t
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(NVSDK_NGX) && defined(NV_WINDOWS)
|
||||
#define NVSDK_NGX_API extern "C" __declspec(dllexport)
|
||||
#else
|
||||
#define NVSDK_NGX_API extern "C"
|
||||
#endif
|
||||
#else
|
||||
#if defined(NVSDK_NGX) && defined(NV_WINDOWS)
|
||||
#define NVSDK_NGX_API __declspec(dllexport)
|
||||
#else
|
||||
#define NVSDK_NGX_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define NVSDK_CONV
|
||||
#else
|
||||
#define NVSDK_CONV __cdecl
|
||||
#endif
|
||||
|
||||
#define NVSDK_NGX_ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
// Version Notes:
|
||||
// Version 0x0000014:
|
||||
// * Added a logging callback that the app may pass in on init
|
||||
// * Added ability for the app to override the logging level
|
||||
// Version 0x0000015:
|
||||
// * Support multiple GPUs (bug 3270533)
|
||||
#define NVSDK_NGX_VERSION_API_MACRO 0x0000014 // NGX_VERSION_DOT 1.4.0
|
||||
|
||||
typedef struct NVSDK_NGX_FeatureCommonInfo_Internal NVSDK_NGX_FeatureCommonInfo_Internal;
|
||||
|
||||
typedef enum NVSDK_NGX_Version { NVSDK_NGX_Version_API = NVSDK_NGX_VERSION_API_MACRO } NVSDK_NGX_Version;
|
||||
|
||||
typedef enum NVSDK_NGX_Result
|
||||
{
|
||||
NVSDK_NGX_Result_Success = 0x1,
|
||||
|
||||
NVSDK_NGX_Result_Fail = 0xBAD00000,
|
||||
|
||||
// Feature is not supported on current hardware
|
||||
NVSDK_NGX_Result_FAIL_FeatureNotSupported = NVSDK_NGX_Result_Fail | 1,
|
||||
|
||||
// Platform error - for example - check d3d12 debug layer log for more information
|
||||
NVSDK_NGX_Result_FAIL_PlatformError = NVSDK_NGX_Result_Fail | 2,
|
||||
|
||||
// Feature with given parameters already exists
|
||||
NVSDK_NGX_Result_FAIL_FeatureAlreadyExists = NVSDK_NGX_Result_Fail | 3,
|
||||
|
||||
// Feature with provided handle does not exist
|
||||
NVSDK_NGX_Result_FAIL_FeatureNotFound = NVSDK_NGX_Result_Fail | 4,
|
||||
|
||||
// Invalid parameter was provided
|
||||
NVSDK_NGX_Result_FAIL_InvalidParameter = NVSDK_NGX_Result_Fail | 5,
|
||||
|
||||
// Provided buffer is too small, please use size provided by NVSDK_NGX_GetScratchBufferSize
|
||||
NVSDK_NGX_Result_FAIL_ScratchBufferTooSmall = NVSDK_NGX_Result_Fail | 6,
|
||||
|
||||
// SDK was not initialized properly
|
||||
NVSDK_NGX_Result_FAIL_NotInitialized = NVSDK_NGX_Result_Fail | 7,
|
||||
|
||||
// Unsupported format used for input/output buffers
|
||||
NVSDK_NGX_Result_FAIL_UnsupportedInputFormat = NVSDK_NGX_Result_Fail | 8,
|
||||
|
||||
// Feature input/output needs RW access (UAV) (d3d11/d3d12 specific)
|
||||
NVSDK_NGX_Result_FAIL_RWFlagMissing = NVSDK_NGX_Result_Fail | 9,
|
||||
|
||||
// Feature was created with specific input but none is provided at evaluation
|
||||
NVSDK_NGX_Result_FAIL_MissingInput = NVSDK_NGX_Result_Fail | 10,
|
||||
|
||||
// Feature is not available on the system
|
||||
NVSDK_NGX_Result_FAIL_UnableToInitializeFeature = NVSDK_NGX_Result_Fail | 11,
|
||||
|
||||
// NGX system libraries are old and need an update
|
||||
NVSDK_NGX_Result_FAIL_OutOfDate = NVSDK_NGX_Result_Fail | 12,
|
||||
|
||||
// Feature requires more GPU memory than it is available on system
|
||||
NVSDK_NGX_Result_FAIL_OutOfGPUMemory = NVSDK_NGX_Result_Fail | 13,
|
||||
|
||||
// Format used in input buffer(s) is not supported by feature
|
||||
NVSDK_NGX_Result_FAIL_UnsupportedFormat = NVSDK_NGX_Result_Fail | 14,
|
||||
|
||||
// Path provided in InApplicationDataPath cannot be written to
|
||||
NVSDK_NGX_Result_FAIL_UnableToWriteToAppDataPath = NVSDK_NGX_Result_Fail | 15,
|
||||
|
||||
// Unsupported parameter was provided (e.g. specific scaling factor is unsupported)
|
||||
NVSDK_NGX_Result_FAIL_UnsupportedParameter = NVSDK_NGX_Result_Fail | 16,
|
||||
|
||||
// The feature or application was denied (contact NVIDIA for further details)
|
||||
NVSDK_NGX_Result_FAIL_Denied = NVSDK_NGX_Result_Fail | 17
|
||||
} NVSDK_NGX_Result;
|
||||
|
||||
#define NVSDK_NGX_SUCCEED(value) (((value) & 0xFFF00000) != NVSDK_NGX_Result_Fail)
|
||||
#define NVSDK_NGX_FAILED(value) (((value) & 0xFFF00000) == NVSDK_NGX_Result_Fail)
|
||||
|
||||
typedef enum NVSDK_NGX_Feature
|
||||
{
|
||||
NVSDK_NGX_Feature_Reserved0,
|
||||
|
||||
NVSDK_NGX_Feature_SuperSampling,
|
||||
|
||||
NVSDK_NGX_Feature_InPainting,
|
||||
|
||||
NVSDK_NGX_Feature_ImageSuperResolution,
|
||||
|
||||
NVSDK_NGX_Feature_SlowMotion,
|
||||
|
||||
NVSDK_NGX_Feature_VideoSuperResolution,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved1,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved2,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved3,
|
||||
|
||||
NVSDK_NGX_Feature_ImageSignalProcessing,
|
||||
|
||||
NVSDK_NGX_Feature_DeepResolve,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved4,
|
||||
|
||||
// New features go here
|
||||
NVSDK_NGX_Feature_Count,
|
||||
|
||||
// These members are not strictly NGX features, but are
|
||||
// components of the NGX system, and it may sometimes
|
||||
// be useful to identify them using the same enum
|
||||
NVSDK_NGX_Feature_Reserved_SDK = 32764,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved_Core,
|
||||
|
||||
NVSDK_NGX_Feature_Reserved_Unknown
|
||||
} NVSDK_NGX_Feature;
|
||||
|
||||
//TODO create grayscale format (R32F?)
|
||||
typedef enum NVSDK_NGX_Buffer_Format
|
||||
{
|
||||
NVSDK_NGX_Buffer_Format_Unknown,
|
||||
NVSDK_NGX_Buffer_Format_RGB8UI,
|
||||
NVSDK_NGX_Buffer_Format_RGB16F,
|
||||
NVSDK_NGX_Buffer_Format_RGB32F,
|
||||
NVSDK_NGX_Buffer_Format_RGBA8UI,
|
||||
NVSDK_NGX_Buffer_Format_RGBA16F,
|
||||
NVSDK_NGX_Buffer_Format_RGBA32F,
|
||||
} NVSDK_NGX_Buffer_Format;
|
||||
|
||||
typedef enum NVSDK_NGX_PerfQuality_Value
|
||||
{
|
||||
NVSDK_NGX_PerfQuality_Value_MaxPerf,
|
||||
NVSDK_NGX_PerfQuality_Value_Balanced,
|
||||
NVSDK_NGX_PerfQuality_Value_MaxQuality,
|
||||
// Extended PerfQuality modes
|
||||
NVSDK_NGX_PerfQuality_Value_UltraPerformance,
|
||||
NVSDK_NGX_PerfQuality_Value_UltraQuality,
|
||||
} NVSDK_NGX_PerfQuality_Value;
|
||||
|
||||
typedef enum NVSDK_NGX_RTX_Value
|
||||
{
|
||||
NVSDK_NGX_RTX_Value_Off,
|
||||
NVSDK_NGX_RTX_Value_On,
|
||||
} NVSDK_NGX_RTX_Value;
|
||||
|
||||
typedef enum NVSDK_NGX_DLSS_Mode
|
||||
{
|
||||
NVSDK_NGX_DLSS_Mode_Off, // use existing in-engine AA + upscale solution
|
||||
NVSDK_NGX_DLSS_Mode_DLSS_DLISP,
|
||||
NVSDK_NGX_DLSS_Mode_DLISP_Only, // use existing in-engine AA solution
|
||||
NVSDK_NGX_DLSS_Mode_DLSS, // DLSS will apply AA and upsample at the same time
|
||||
} NVSDK_NGX_DLSS_Mode;
|
||||
|
||||
typedef struct NVSDK_NGX_Handle { unsigned int Id; } NVSDK_NGX_Handle;
|
||||
|
||||
typedef enum NSDK_NGX_GPU_Arch
|
||||
{
|
||||
NVSDK_NGX_GPU_Arch_NotSupported = 0,
|
||||
|
||||
// Match NvAPI's NV_GPU_ARCHITECTURE_ID values for GV100 and TU100 for
|
||||
// backwards compatibility with snippets built against NvAPI
|
||||
NVSDK_NGX_GPU_Arch_Volta = 0x0140,
|
||||
NVSDK_NGX_GPU_Arch_Turing = 0x0160,
|
||||
|
||||
// Presumably something newer
|
||||
NVSDK_NGX_GPU_Arch_Unknown = 0x7FFFFFF
|
||||
} NVSDK_NGX_GPU_Arch;
|
||||
|
||||
|
||||
typedef enum NVSDK_NGX_DLSS_Feature_Flags
|
||||
{
|
||||
NVSDK_NGX_DLSS_Feature_Flags_IsInvalid = 1 << 31,
|
||||
|
||||
NVSDK_NGX_DLSS_Feature_Flags_None = 0,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_IsHDR = 1 << 0,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_MVLowRes = 1 << 1,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_MVJittered = 1 << 2,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_DepthInverted = 1 << 3,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_Reserved_0 = 1 << 4,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_DoSharpening = 1 << 5,
|
||||
NVSDK_NGX_DLSS_Feature_Flags_AutoExposure = 1 << 6,
|
||||
} NVSDK_NGX_DLSS_Feature_Flags;
|
||||
|
||||
typedef enum NVSDK_NGX_ToneMapperType
|
||||
{
|
||||
NVSDK_NGX_TONEMAPPER_STRING = 0,
|
||||
NVSDK_NGX_TONEMAPPER_REINHARD,
|
||||
NVSDK_NGX_TONEMAPPER_ONEOVERLUMA,
|
||||
NVSDK_NGX_TONEMAPPER_ACES,
|
||||
NVSDK_NGX_TONEMAPPERTYPE_NUM
|
||||
} NVSDK_NGX_ToneMapperType;
|
||||
|
||||
typedef enum NVSDK_NGX_GBufferType
|
||||
{
|
||||
NVSDK_NGX_GBUFFER_ALBEDO = 0,
|
||||
NVSDK_NGX_GBUFFER_ROUGHNESS,
|
||||
NVSDK_NGX_GBUFFER_METALLIC,
|
||||
NVSDK_NGX_GBUFFER_SPECULAR,
|
||||
NVSDK_NGX_GBUFFER_SUBSURFACE,
|
||||
NVSDK_NGX_GBUFFER_NORMALS,
|
||||
NVSDK_NGX_GBUFFER_SHADINGMODELID, /* unique identifier for drawn object or how the object is drawn */
|
||||
NVSDK_NGX_GBUFFER_MATERIALID, /* unique identifier for material */
|
||||
NVSDK_NGX_GBUFFERTYPE_NUM = 16
|
||||
} NVSDK_NGX_GBufferType;
|
||||
|
||||
typedef struct NVSDK_NGX_Coordinates
|
||||
{
|
||||
unsigned int X;
|
||||
unsigned int Y;
|
||||
} NVSDK_NGX_Coordinates;
|
||||
|
||||
typedef struct NVSDK_NGX_Dimensions
|
||||
{
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
} NVSDK_NGX_Dimensions;
|
||||
|
||||
typedef struct NVSDK_NGX_PathListInfo
|
||||
{
|
||||
wchar_t **Path;
|
||||
// Path-list length
|
||||
unsigned int Length;
|
||||
} NVSDK_NGX_PathListInfo;
|
||||
|
||||
typedef enum NVSDK_NGX_Logging_Level
|
||||
{
|
||||
NVSDK_NGX_LOGGING_LEVEL_OFF = 0,
|
||||
NVSDK_NGX_LOGGING_LEVEL_ON,
|
||||
NVSDK_NGX_LOGGING_LEVEL_VERBOSE,
|
||||
NVSDK_NGX_LOGGING_LEVEL_NUM
|
||||
} NVSDK_NGX_Logging_Level;
|
||||
|
||||
// A logging callback provided by the app to allow piping log lines back to the app.
|
||||
// Please take careful note of the signature and calling convention.
|
||||
// The callback must be able to be called from any thread.
|
||||
// It must also be fully thread-safe and any number of threads may call into it concurrently.
|
||||
// It must fully process message by the time it returns, and there is no guarantee that
|
||||
// message will still be valid or allocated after it returns.
|
||||
// message will be a null-terminated string and may contain multibyte characters.
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
typedef void NVSDK_CONV(*NVSDK_NGX_AppLogCallback)(const char* message, NVSDK_NGX_Logging_Level loggingLevel, NVSDK_NGX_Feature sourceComponent);
|
||||
#else
|
||||
typedef void(NVSDK_CONV* NVSDK_NGX_AppLogCallback)(const char* message, NVSDK_NGX_Logging_Level loggingLevel, NVSDK_NGX_Feature sourceComponent);
|
||||
#endif
|
||||
|
||||
typedef struct NGSDK_NGX_LoggingInfo
|
||||
{
|
||||
// Fields below were introduced in SDK version 0x0000014
|
||||
|
||||
// App-provided logging callback
|
||||
NVSDK_NGX_AppLogCallback LoggingCallback;
|
||||
|
||||
// The minimum logging level to use. If this is higher
|
||||
// than the logging level otherwise configured, this will override
|
||||
// that logging level. Otherwise, that logging level will be used.
|
||||
NVSDK_NGX_Logging_Level MinimumLoggingLevel;
|
||||
|
||||
// Whether or not to disable writing log lines to sinks other than the app log callback. This
|
||||
// may be useful if the app provides a logging callback. LoggingCallback must be non-null and point
|
||||
// to a valid logging callback if this is set to true.
|
||||
bool DisableOtherLoggingSinks;
|
||||
|
||||
} NGSDK_NGX_LoggingInfo;
|
||||
|
||||
typedef struct NVSDK_NGX_FeatureCommonInfo
|
||||
{
|
||||
// List of all paths in descending order of search sequence to locate a feature dll in, other than the default path - application folder.
|
||||
NVSDK_NGX_PathListInfo PathListInfo;
|
||||
// Used internally by NGX
|
||||
NVSDK_NGX_FeatureCommonInfo_Internal* InternalData; // Introduced in SDK version 0x0000013
|
||||
|
||||
// Fields below were introduced in SDK version 0x0000014
|
||||
|
||||
NGSDK_NGX_LoggingInfo LoggingInfo;
|
||||
} NVSDK_NGX_FeatureCommonInfo;
|
||||
|
||||
typedef enum NVSDK_NGX_Resource_VK_Type
|
||||
{
|
||||
NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW,
|
||||
NVSDK_NGX_RESOURCE_VK_TYPE_VK_BUFFER
|
||||
} NVSDK_NGX_Resource_VK_Type;
|
||||
|
||||
typedef enum NVSDK_NGX_Opt_Level
|
||||
{
|
||||
NVSDK_NGX_OPT_LEVEL_UNDEFINED = 0,
|
||||
NVSDK_NGX_OPT_LEVEL_DEBUG = 20,
|
||||
NVSDK_NGX_OPT_LEVEL_DEVELOP = 30,
|
||||
NVSDK_NGX_OPT_LEVEL_RELEASE = 40
|
||||
} NVSDK_NGX_Opt_Level;
|
||||
|
||||
typedef enum NVSDK_NGX_EngineType
|
||||
{
|
||||
NVSDK_NGX_ENGINE_TYPE_CUSTOM = 0,
|
||||
NVSDK_NGX_ENGINE_TYPE_UNREAL,
|
||||
NVSDK_NGX_ENGINE_TYPE_UNITY,
|
||||
NVSDK_NGX_ENGINE_TYPE_OMNIVERSE,
|
||||
NVSDK_NGX_ENGINE_COUNT
|
||||
} NVSDK_NGX_EngineType;
|
||||
|
||||
// Read-only parameters provided by NGX
|
||||
#define NVSDK_NGX_EParameter_Reserved00 "#\x00"
|
||||
#define NVSDK_NGX_EParameter_SuperSampling_Available "#\x01"
|
||||
#define NVSDK_NGX_EParameter_InPainting_Available "#\x02"
|
||||
#define NVSDK_NGX_EParameter_ImageSuperResolution_Available "#\x03"
|
||||
#define NVSDK_NGX_EParameter_SlowMotion_Available "#\x04"
|
||||
#define NVSDK_NGX_EParameter_VideoSuperResolution_Available "#\x05"
|
||||
#define NVSDK_NGX_EParameter_Reserved06 "#\x06"
|
||||
#define NVSDK_NGX_EParameter_Reserved07 "#\x07"
|
||||
#define NVSDK_NGX_EParameter_Reserved08 "#\x08"
|
||||
#define NVSDK_NGX_EParameter_ImageSignalProcessing_Available "#\x09"
|
||||
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_2_1 "#\x0a"
|
||||
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_3_1 "#\x0b"
|
||||
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_3_2 "#\x0c"
|
||||
#define NVSDK_NGX_EParameter_ImageSuperResolution_ScaleFactor_4_3 "#\x0d"
|
||||
#define NVSDK_NGX_EParameter_NumFrames "#\x0e"
|
||||
#define NVSDK_NGX_EParameter_Scale "#\x0f"
|
||||
#define NVSDK_NGX_EParameter_Width "#\x10"
|
||||
#define NVSDK_NGX_EParameter_Height "#\x11"
|
||||
#define NVSDK_NGX_EParameter_OutWidth "#\x12"
|
||||
#define NVSDK_NGX_EParameter_OutHeight "#\x13"
|
||||
#define NVSDK_NGX_EParameter_Sharpness "#\x14"
|
||||
#define NVSDK_NGX_EParameter_Scratch "#\x15"
|
||||
#define NVSDK_NGX_EParameter_Scratch_SizeInBytes "#\x16"
|
||||
#define NVSDK_NGX_EParameter_Deprecated_17 "#\x17"
|
||||
#define NVSDK_NGX_EParameter_Input1 "#\x18"
|
||||
#define NVSDK_NGX_EParameter_Input1_Format "#\x19"
|
||||
#define NVSDK_NGX_EParameter_Input1_SizeInBytes "#\x1a"
|
||||
#define NVSDK_NGX_EParameter_Input2 "#\x1b"
|
||||
#define NVSDK_NGX_EParameter_Input2_Format "#\x1c"
|
||||
#define NVSDK_NGX_EParameter_Input2_SizeInBytes "#\x1d"
|
||||
#define NVSDK_NGX_EParameter_Color "#\x1e"
|
||||
#define NVSDK_NGX_EParameter_Color_Format "#\x1f"
|
||||
#define NVSDK_NGX_EParameter_Color_SizeInBytes "#\x20"
|
||||
#define NVSDK_NGX_EParameter_Albedo "#\x21"
|
||||
#define NVSDK_NGX_EParameter_Output "#\x22"
|
||||
#define NVSDK_NGX_EParameter_Output_Format "#\x23"
|
||||
#define NVSDK_NGX_EParameter_Output_SizeInBytes "#\x24"
|
||||
#define NVSDK_NGX_EParameter_Reset "#\x25"
|
||||
#define NVSDK_NGX_EParameter_BlendFactor "#\x26"
|
||||
#define NVSDK_NGX_EParameter_MotionVectors "#\x27"
|
||||
#define NVSDK_NGX_EParameter_Rect_X "#\x28"
|
||||
#define NVSDK_NGX_EParameter_Rect_Y "#\x29"
|
||||
#define NVSDK_NGX_EParameter_Rect_W "#\x2a"
|
||||
#define NVSDK_NGX_EParameter_Rect_H "#\x2b"
|
||||
#define NVSDK_NGX_EParameter_MV_Scale_X "#\x2c"
|
||||
#define NVSDK_NGX_EParameter_MV_Scale_Y "#\x2d"
|
||||
#define NVSDK_NGX_EParameter_Model "#\x2e"
|
||||
#define NVSDK_NGX_EParameter_Format "#\x2f"
|
||||
#define NVSDK_NGX_EParameter_SizeInBytes "#\x30"
|
||||
#define NVSDK_NGX_EParameter_ResourceAllocCallback "#\x31"
|
||||
#define NVSDK_NGX_EParameter_BufferAllocCallback "#\x32"
|
||||
#define NVSDK_NGX_EParameter_Tex2DAllocCallback "#\x33"
|
||||
#define NVSDK_NGX_EParameter_ResourceReleaseCallback "#\x34"
|
||||
#define NVSDK_NGX_EParameter_CreationNodeMask "#\x35"
|
||||
#define NVSDK_NGX_EParameter_VisibilityNodeMask "#\x36"
|
||||
#define NVSDK_NGX_EParameter_PreviousOutput "#\x37"
|
||||
#define NVSDK_NGX_EParameter_MV_Offset_X "#\x38"
|
||||
#define NVSDK_NGX_EParameter_MV_Offset_Y "#\x39"
|
||||
#define NVSDK_NGX_EParameter_Hint_UseFireflySwatter "#\x3a"
|
||||
#define NVSDK_NGX_EParameter_Resource_Width "#\x3b"
|
||||
#define NVSDK_NGX_EParameter_Resource_Height "#\x3c"
|
||||
#define NVSDK_NGX_EParameter_Depth "#\x3d"
|
||||
#define NVSDK_NGX_EParameter_DLSSOptimalSettingsCallback "#\x3e"
|
||||
#define NVSDK_NGX_EParameter_PerfQualityValue "#\x3f"
|
||||
#define NVSDK_NGX_EParameter_RTXValue "#\x40"
|
||||
#define NVSDK_NGX_EParameter_DLSSMode "#\x41"
|
||||
#define NVSDK_NGX_EParameter_DeepResolve_Available "#\x42"
|
||||
#define NVSDK_NGX_EParameter_Deprecated_43 "#\x43"
|
||||
#define NVSDK_NGX_EParameter_OptLevel "#\x44"
|
||||
#define NVSDK_NGX_EParameter_IsDevSnippetBranch "#\x45"
|
||||
|
||||
#define NVSDK_NGX_Parameter_OptLevel "Snippet.OptLevel"
|
||||
#define NVSDK_NGX_Parameter_IsDevSnippetBranch "Snippet.IsDevBranch"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_ScaleFactor "SuperSampling.ScaleFactor"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_ScaleFactor "ImageSignalProcessing.ScaleFactor"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_Available "SuperSampling.Available"
|
||||
#define NVSDK_NGX_Parameter_InPainting_Available "InPainting.Available"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_Available "ImageSuperResolution.Available"
|
||||
#define NVSDK_NGX_Parameter_SlowMotion_Available "SlowMotion.Available"
|
||||
#define NVSDK_NGX_Parameter_VideoSuperResolution_Available "VideoSuperResolution.Available"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_Available "ImageSignalProcessing.Available"
|
||||
#define NVSDK_NGX_Parameter_DeepResolve_Available "DeepResolve.Available"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_NeedsUpdatedDriver "SuperSampling.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_InPainting_NeedsUpdatedDriver "InPainting.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_NeedsUpdatedDriver "ImageSuperResolution.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_SlowMotion_NeedsUpdatedDriver "SlowMotion.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_VideoSuperResolution_NeedsUpdatedDriver "VideoSuperResolution.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_NeedsUpdatedDriver "ImageSignalProcessing.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_DeepResolve_NeedsUpdatedDriver "DeepResolve.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_FrameInterpolation_NeedsUpdatedDriver "FrameInterpolation.NeedsUpdatedDriver"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMajor "SuperSampling.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_InPainting_MinDriverVersionMajor "InPainting.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_MinDriverVersionMajor "ImageSuperResolution.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_SlowMotion_MinDriverVersionMajor "SlowMotion.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_VideoSuperResolution_MinDriverVersionMajor "VideoSuperResolution.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_MinDriverVersionMajor "ImageSignalProcessing.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_DeepResolve_MinDriverVersionMajor "DeepResolve.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_FrameInterpolation_MinDriverVersionMajor "FrameInterpolation.MinDriverVersionMajor"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_MinDriverVersionMinor "SuperSampling.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_InPainting_MinDriverVersionMinor "InPainting.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_MinDriverVersionMinor "ImageSuperResolution.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_SlowMotion_MinDriverVersionMinor "SlowMotion.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_VideoSuperResolution_MinDriverVersionMinor "VideoSuperResolution.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_MinDriverVersionMinor "ImageSignalProcessing.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_DeepResolve_MinDriverVersionMinor "DeepResolve.MinDriverVersionMinor"
|
||||
#define NVSDK_NGX_Parameter_SuperSampling_FeatureInitResult "SuperSampling.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_InPainting_FeatureInitResult "InPainting.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_FeatureInitResult "ImageSuperResolution.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_SlowMotion_FeatureInitResult "SlowMotion.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_VideoSuperResolution_FeatureInitResult "VideoSuperResolution.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_ImageSignalProcessing_FeatureInitResult "ImageSignalProcessing.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_DeepResolve_FeatureInitResult "DeepResolve.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_FrameInterpolation_FeatureInitResult "FrameInterpolation.FeatureInitResult"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_2_1 "ImageSuperResolution.ScaleFactor.2.1"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_3_1 "ImageSuperResolution.ScaleFactor.3.1"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_3_2 "ImageSuperResolution.ScaleFactor.3.2"
|
||||
#define NVSDK_NGX_Parameter_ImageSuperResolution_ScaleFactor_4_3 "ImageSuperResolution.ScaleFactor.4.3"
|
||||
#define NVSDK_NGX_Parameter_NumFrames "NumFrames"
|
||||
#define NVSDK_NGX_Parameter_Scale "Scale"
|
||||
#define NVSDK_NGX_Parameter_Width "Width"
|
||||
#define NVSDK_NGX_Parameter_Height "Height"
|
||||
#define NVSDK_NGX_Parameter_OutWidth "OutWidth"
|
||||
#define NVSDK_NGX_Parameter_OutHeight "OutHeight"
|
||||
#define NVSDK_NGX_Parameter_Sharpness "Sharpness"
|
||||
#define NVSDK_NGX_Parameter_Scratch "Scratch"
|
||||
#define NVSDK_NGX_Parameter_Scratch_SizeInBytes "Scratch.SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_Input1 "Input1"
|
||||
#define NVSDK_NGX_Parameter_Input1_Format "Input1.Format"
|
||||
#define NVSDK_NGX_Parameter_Input1_SizeInBytes "Input1.SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_Input2 "Input2"
|
||||
#define NVSDK_NGX_Parameter_Input2_Format "Input2.Format"
|
||||
#define NVSDK_NGX_Parameter_Input2_SizeInBytes "Input2.SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_Color "Color"
|
||||
#define NVSDK_NGX_Parameter_Color_Format "Color.Format"
|
||||
#define NVSDK_NGX_Parameter_Color_SizeInBytes "Color.SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_FI_Color1 "Color1"
|
||||
#define NVSDK_NGX_Parameter_FI_Color2 "Color2"
|
||||
#define NVSDK_NGX_Parameter_Albedo "Albedo"
|
||||
#define NVSDK_NGX_Parameter_Output "Output"
|
||||
#define NVSDK_NGX_Parameter_Output_SizeInBytes "Output.SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_FI_Output1 "Output1"
|
||||
#define NVSDK_NGX_Parameter_FI_Output2 "Output2"
|
||||
#define NVSDK_NGX_Parameter_FI_Output3 "Output3"
|
||||
#define NVSDK_NGX_Parameter_Reset "Reset"
|
||||
#define NVSDK_NGX_Parameter_BlendFactor "BlendFactor"
|
||||
#define NVSDK_NGX_Parameter_MotionVectors "MotionVectors"
|
||||
#define NVSDK_NGX_Parameter_FI_MotionVectors1 "MotionVectors1"
|
||||
#define NVSDK_NGX_Parameter_FI_MotionVectors2 "MotionVectors2"
|
||||
#define NVSDK_NGX_Parameter_Rect_X "Rect.X"
|
||||
#define NVSDK_NGX_Parameter_Rect_Y "Rect.Y"
|
||||
#define NVSDK_NGX_Parameter_Rect_W "Rect.W"
|
||||
#define NVSDK_NGX_Parameter_Rect_H "Rect.H"
|
||||
#define NVSDK_NGX_Parameter_MV_Scale_X "MV.Scale.X"
|
||||
#define NVSDK_NGX_Parameter_MV_Scale_Y "MV.Scale.Y"
|
||||
#define NVSDK_NGX_Parameter_Model "Model"
|
||||
#define NVSDK_NGX_Parameter_Format "Format"
|
||||
#define NVSDK_NGX_Parameter_SizeInBytes "SizeInBytes"
|
||||
#define NVSDK_NGX_Parameter_ResourceAllocCallback "ResourceAllocCallback"
|
||||
#define NVSDK_NGX_Parameter_BufferAllocCallback "BufferAllocCallback"
|
||||
#define NVSDK_NGX_Parameter_Tex2DAllocCallback "Tex2DAllocCallback"
|
||||
#define NVSDK_NGX_Parameter_ResourceReleaseCallback "ResourceReleaseCallback"
|
||||
#define NVSDK_NGX_Parameter_CreationNodeMask "CreationNodeMask"
|
||||
#define NVSDK_NGX_Parameter_VisibilityNodeMask "VisibilityNodeMask"
|
||||
#define NVSDK_NGX_Parameter_MV_Offset_X "MV.Offset.X"
|
||||
#define NVSDK_NGX_Parameter_MV_Offset_Y "MV.Offset.Y"
|
||||
#define NVSDK_NGX_Parameter_Hint_UseFireflySwatter "Hint.UseFireflySwatter"
|
||||
#define NVSDK_NGX_Parameter_Resource_Width "ResourceWidth"
|
||||
#define NVSDK_NGX_Parameter_Resource_Height "ResourceHeight"
|
||||
#define NVSDK_NGX_Parameter_Resource_OutWidth "ResourceOutWidth"
|
||||
#define NVSDK_NGX_Parameter_Resource_OutHeight "ResourceOutHeight"
|
||||
#define NVSDK_NGX_Parameter_Depth "Depth"
|
||||
#define NVSDK_NGX_Parameter_FI_Depth1 "Depth1"
|
||||
#define NVSDK_NGX_Parameter_FI_Depth2 "Depth2"
|
||||
#define NVSDK_NGX_Parameter_DLSSOptimalSettingsCallback "DLSSOptimalSettingsCallback"
|
||||
#define NVSDK_NGX_Parameter_DLSSGetStatsCallback "DLSSGetStatsCallback"
|
||||
#define NVSDK_NGX_Parameter_PerfQualityValue "PerfQualityValue"
|
||||
#define NVSDK_NGX_Parameter_RTXValue "RTXValue"
|
||||
#define NVSDK_NGX_Parameter_DLSSMode "DLSSMode"
|
||||
#define NVSDK_NGX_Parameter_FI_Mode "FIMode"
|
||||
#define NVSDK_NGX_Parameter_FI_OF_Preset "FIOFPreset"
|
||||
#define NVSDK_NGX_Parameter_FI_OF_GridSize "FIOFGridSize"
|
||||
#define NVSDK_NGX_Parameter_Jitter_Offset_X "Jitter.Offset.X"
|
||||
#define NVSDK_NGX_Parameter_Jitter_Offset_Y "Jitter.Offset.Y"
|
||||
#define NVSDK_NGX_Parameter_Denoise "Denoise"
|
||||
#define NVSDK_NGX_Parameter_TransparencyMask "TransparencyMask"
|
||||
#define NVSDK_NGX_Parameter_ExposureTexture "ExposureTexture" // a 1x1 texture containing the final exposure scale
|
||||
#define NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags "DLSS.Feature.Create.Flags"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Checkerboard_Jitter_Hack "DLSS.Checkerboard.Jitter.Hack"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Albedo "GBuffer.Albedo"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Roughness "GBuffer.Roughness"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Metallic "GBuffer.Metallic"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Specular "GBuffer.Specular"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Subsurface "GBuffer.Subsurface"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Normals "GBuffer.Normals"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_ShadingModelId "GBuffer.ShadingModelId"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_MaterialId "GBuffer.MaterialId"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_8 "GBuffer.Attrib.8"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_9 "GBuffer.Attrib.9"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_10 "GBuffer.Attrib.10"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_11 "GBuffer.Attrib.11"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_12 "GBuffer.Attrib.12"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_13 "GBuffer.Attrib.13"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_14 "GBuffer.Attrib.14"
|
||||
#define NVSDK_NGX_Parameter_GBuffer_Atrrib_15 "GBuffer.Attrib.15"
|
||||
#define NVSDK_NGX_Parameter_TonemapperType "TonemapperType"
|
||||
#define NVSDK_NGX_Parameter_FreeMemOnReleaseFeature "FreeMemOnReleaseFeature"
|
||||
#define NVSDK_NGX_Parameter_MotionVectors3D "MotionVectors3D"
|
||||
#define NVSDK_NGX_Parameter_IsParticleMask "IsParticleMask"
|
||||
#define NVSDK_NGX_Parameter_AnimatedTextureMask "AnimatedTextureMask"
|
||||
#define NVSDK_NGX_Parameter_DepthHighRes "DepthHighRes"
|
||||
#define NVSDK_NGX_Parameter_Position_ViewSpace "Position.ViewSpace"
|
||||
#define NVSDK_NGX_Parameter_FrameTimeDeltaInMsec "FrameTimeDeltaInMsec"
|
||||
#define NVSDK_NGX_Parameter_RayTracingHitDistance "RayTracingHitDistance"
|
||||
#define NVSDK_NGX_Parameter_MotionVectorsReflection "MotionVectorsReflection"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects "DLSS.Enable.Output.Subrects"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X "DLSS.Input.Color.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y "DLSS.Input.Color.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X "DLSS.Input.Depth.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y "DLSS.Input.Depth.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X "DLSS.Input.MV.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y "DLSS.Input.MV.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X "DLSS.Input.Translucency.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y "DLSS.Input.Translucency.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X "DLSS.Output.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y "DLSS.Output.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width "DLSS.Render.Subrect.Dimensions.Width"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height "DLSS.Render.Subrect.Dimensions.Height"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Pre_Exposure "DLSS.Pre.Exposure"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Exposure_Scale "DLSS.Exposure.Scale"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask "DLSS.Input.Bias.Current.Color.Mask"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X "DLSS.Input.Bias.Current.Color.Subrect.Base.X"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y "DLSS.Input.Bias.Current.Color.Subrect.Base.Y"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis "DLSS.Indicator.Invert.Y.Axis"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis "DLSS.Indicator.Invert.X.Axis"
|
||||
|
||||
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Width "DLSS.Get.Dynamic.Max.Render.Width"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Height "DLSS.Get.Dynamic.Max.Render.Height"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width "DLSS.Get.Dynamic.Min.Render.Width"
|
||||
#define NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height "DLSS.Get.Dynamic.Min.Render.Height"
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
629
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_helpers.h
vendored
Normal file
629
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_helpers.h
vendored
Normal file
@@ -0,0 +1,629 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
#ifndef NVSDK_NGX_HELPERS_H
|
||||
#define NVSDK_NGX_HELPERS_H
|
||||
#pragma once
|
||||
|
||||
#include "nvsdk_ngx.h"
|
||||
#include "nvsdk_ngx_defs.h"
|
||||
|
||||
typedef NVSDK_NGX_Result(NVSDK_CONV *PFN_NVSDK_NGX_DLSS_GetStatsCallback)(NVSDK_NGX_Parameter *InParams);
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS_2(
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
unsigned long long *pVRAMAllocatedBytes,
|
||||
unsigned int *pOptLevel, unsigned int *IsDevSnippetBranch)
|
||||
{
|
||||
void *Callback = NULL;
|
||||
NVSDK_NGX_Parameter_GetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSSGetStatsCallback, &Callback);
|
||||
if (!Callback)
|
||||
{
|
||||
// Possible reasons for this:
|
||||
// - Installed DLSS is out of date and does not support the feature we need
|
||||
// - You used NVSDK_NGX_AllocateParameters() for creating InParams. Try using NVSDK_NGX_GetCapabilityParameters() instead
|
||||
return NVSDK_NGX_Result_FAIL_OutOfDate;
|
||||
}
|
||||
|
||||
NVSDK_NGX_Result Res = NVSDK_NGX_Result_Success;
|
||||
PFN_NVSDK_NGX_DLSS_GetStatsCallback PFNCallback = (PFN_NVSDK_NGX_DLSS_GetStatsCallback)Callback;
|
||||
Res = PFNCallback(pInParams);
|
||||
if (NVSDK_NGX_FAILED(Res))
|
||||
{
|
||||
return Res;
|
||||
}
|
||||
NVSDK_NGX_Parameter_GetULL(pInParams, NVSDK_NGX_Parameter_SizeInBytes, pVRAMAllocatedBytes);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_EParameter_OptLevel, pOptLevel);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_EParameter_IsDevSnippetBranch, IsDevSnippetBranch);
|
||||
return Res;
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS_1(
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
unsigned long long *pVRAMAllocatedBytes,
|
||||
unsigned int *pOptLevel)
|
||||
{
|
||||
unsigned int dummy = 0;
|
||||
return NGX_DLSS_GET_STATS_2(pInParams, pVRAMAllocatedBytes, pOptLevel, &dummy);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_DLSS_GET_STATS(
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
unsigned long long *pVRAMAllocatedBytes)
|
||||
{
|
||||
unsigned int dummy = 0;
|
||||
return NGX_DLSS_GET_STATS_2(pInParams, pVRAMAllocatedBytes, &dummy, &dummy);
|
||||
}
|
||||
|
||||
typedef NVSDK_NGX_Result(NVSDK_CONV *PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback)(NVSDK_NGX_Parameter *InParams);
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_DLSS_GET_OPTIMAL_SETTINGS(
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
unsigned int InUserSelectedWidth,
|
||||
unsigned int InUserSelectedHeight,
|
||||
NVSDK_NGX_PerfQuality_Value InPerfQualityValue,
|
||||
unsigned int *pOutRenderOptimalWidth,
|
||||
unsigned int *pOutRenderOptimalHeight,
|
||||
unsigned int *pOutRenderMaxWidth,
|
||||
unsigned int *pOutRenderMaxHeight,
|
||||
unsigned int *pOutRenderMinWidth,
|
||||
unsigned int *pOutRenderMinHeight,
|
||||
float *pOutSharpness)
|
||||
{
|
||||
void *Callback = NULL;
|
||||
NVSDK_NGX_Parameter_GetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSSOptimalSettingsCallback, &Callback);
|
||||
if (!Callback)
|
||||
{
|
||||
// Possible reasons for this:
|
||||
// - Installed DLSS is out of date and does not support the feature we need
|
||||
// - You used NVSDK_NGX_AllocateParameters() for creating InParams. Try using NVSDK_NGX_GetCapabilityParameters() instead
|
||||
return NVSDK_NGX_Result_FAIL_OutOfDate;
|
||||
}
|
||||
|
||||
// These are selections made by user in UI
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, InUserSelectedWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, InUserSelectedHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, InPerfQualityValue);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_RTXValue, false); // Some older DLSS dlls still expect this value to be set
|
||||
|
||||
NVSDK_NGX_Result Res = NVSDK_NGX_Result_Success;
|
||||
PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback PFNCallback = (PFN_NVSDK_NGX_DLSS_GetOptimalSettingsCallback)Callback;
|
||||
Res = PFNCallback(pInParams);
|
||||
if (NVSDK_NGX_FAILED(Res))
|
||||
{
|
||||
return Res;
|
||||
}
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pOutRenderOptimalWidth);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pOutRenderOptimalHeight);
|
||||
// If we have an older DLSS Dll those might need to be set to the optimal dimensions instead
|
||||
*pOutRenderMaxWidth = *pOutRenderOptimalWidth;
|
||||
*pOutRenderMaxHeight = *pOutRenderOptimalHeight;
|
||||
*pOutRenderMinWidth = *pOutRenderOptimalWidth;
|
||||
*pOutRenderMinHeight = *pOutRenderOptimalHeight;
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Width, pOutRenderMaxWidth);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Max_Render_Height, pOutRenderMaxHeight);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Width, pOutRenderMinWidth);
|
||||
NVSDK_NGX_Parameter_GetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Get_Dynamic_Min_Render_Height, pOutRenderMinHeight);
|
||||
NVSDK_NGX_Parameter_GetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pOutSharpness);
|
||||
return Res;
|
||||
}
|
||||
|
||||
/*** D3D11 ***/
|
||||
typedef struct NVSDK_NGX_D3D11_Feature_Eval_Params
|
||||
{
|
||||
ID3D11Resource* pInColor;
|
||||
ID3D11Resource* pInOutput;
|
||||
/*** OPTIONAL for DLSS ***/
|
||||
float InSharpness;
|
||||
} NVSDK_NGX_D3D11_Feature_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_CUDA_Feature_Eval_Params
|
||||
{
|
||||
CUtexObject* pInColor;
|
||||
CUtexObject* pInOutput;
|
||||
/*** OPTIONAL for DLSS ***/
|
||||
float InSharpness;
|
||||
} NVSDK_NGX_CUDA_Feature_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D11_GBuffer
|
||||
{
|
||||
ID3D11Resource* pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
|
||||
} NVSDK_NGX_D3D11_GBuffer;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D11_DLSS_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_D3D11_Feature_Eval_Params Feature;
|
||||
ID3D11Resource* pInDepth;
|
||||
ID3D11Resource* pInMotionVectors;
|
||||
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
|
||||
float InJitterOffsetY;
|
||||
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
int InReset; /* Set to 1 when scene changes completely (new level etc) */
|
||||
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
|
||||
float InMVScaleY;
|
||||
ID3D11Resource* pInTransparencyMask; /* Unused/Reserved for future use */
|
||||
ID3D11Resource* pInExposureTexture;
|
||||
ID3D11Resource* pInBiasCurrentColorMask;
|
||||
NVSDK_NGX_Coordinates InColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InDepthSubrectBase;
|
||||
NVSDK_NGX_Coordinates InMVSubrectBase;
|
||||
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
|
||||
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InOutputSubrectBase;
|
||||
float InPreExposure;
|
||||
int InIndicatorInvertXAxis;
|
||||
int InIndicatorInvertYAxis;
|
||||
/*** OPTIONAL - only for research purposes ***/
|
||||
NVSDK_NGX_D3D11_GBuffer GBufferSurface;
|
||||
NVSDK_NGX_ToneMapperType InToneMapperType;
|
||||
ID3D11Resource* pInMotionVectors3D;
|
||||
ID3D11Resource* pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
|
||||
ID3D11Resource* pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
|
||||
ID3D11Resource* pInDepthHighRes;
|
||||
ID3D11Resource* pInPositionViewSpace;
|
||||
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
|
||||
ID3D11Resource* pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
|
||||
ID3D11Resource* pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
|
||||
} NVSDK_NGX_D3D11_DLSS_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D11_DLISP_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_D3D11_Feature_Eval_Params Feature;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
unsigned int InRectX;
|
||||
unsigned int InRectY;
|
||||
unsigned int InRectW;
|
||||
unsigned int InRectH;
|
||||
float InDenoise;
|
||||
} NVSDK_NGX_D3D11_DLISP_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_CUDA_DLISP_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_CUDA_Feature_Eval_Params Feature;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
unsigned int InRectX;
|
||||
unsigned int InRectY;
|
||||
unsigned int InRectW;
|
||||
unsigned int InRectH;
|
||||
float InDenoise;
|
||||
} NVSDK_NGX_CUDA_DLISP_Eval_Params;
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLSS_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
|
||||
|
||||
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLSS_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D11_DLSS_Eval_Params *pInDlssEvalParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
|
||||
|
||||
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLISP_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pDlispCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
|
||||
|
||||
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_CUDA_CREATE_DLISP_EXT(
|
||||
NVSDK_NGX_Handle** ppOutHandle,
|
||||
NVSDK_NGX_Parameter* pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params* pDlispCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
|
||||
|
||||
return NVSDK_NGX_CUDA_CreateFeature(NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLISP_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D11_DLISP_Eval_Params *pDlispEvalParams)
|
||||
{
|
||||
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
|
||||
{
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
|
||||
// Both sharpness and denoise in range [0.0f,1.0f]
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
|
||||
// If input is atlas - use RECT to upscale only the required area
|
||||
if (pDlispEvalParams->InRectW)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
|
||||
}
|
||||
|
||||
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_CUDA_EVALUATE_DLISP_EXT(
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_CUDA_DLISP_Eval_Params *pDlispEvalParams)
|
||||
{
|
||||
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
|
||||
{
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
|
||||
// Both sharpness and denoise in range [0.0f,1.0f]
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
|
||||
// If input is atlas - use RECT to upscale only the required area
|
||||
if (pDlispEvalParams->InRectW)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
|
||||
}
|
||||
|
||||
return NVSDK_NGX_CUDA_EvaluateFeature_C(pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_CREATE_DLRESOLVE_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pDlresolveCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlresolveCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlresolveCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlresolveCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlresolveCreateParams->InTargetHeight);
|
||||
|
||||
return NVSDK_NGX_D3D11_CreateFeature(pInCtx, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D11_EVALUATE_DLRESOLVE_EXT(
|
||||
ID3D11DeviceContext *pInCtx,
|
||||
NVSDK_NGX_Handle *InHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D11_Feature_Eval_Params *pDlresolveEvalParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlresolveEvalParams->pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d11Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlresolveEvalParams->pInOutput);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlresolveEvalParams->InSharpness);
|
||||
|
||||
return NVSDK_NGX_D3D11_EvaluateFeature_C(pInCtx, InHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
/*** D3D12 ***/
|
||||
typedef struct NVSDK_NGX_D3D12_Feature_Eval_Params
|
||||
{
|
||||
ID3D12Resource* pInColor;
|
||||
ID3D12Resource* pInOutput;
|
||||
/*** OPTIONAL for DLSS ***/
|
||||
float InSharpness;
|
||||
} NVSDK_NGX_D3D12_Feature_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D12_GBuffer
|
||||
{
|
||||
ID3D12Resource* pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
|
||||
} NVSDK_NGX_D3D12_GBuffer;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D12_DLSS_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_D3D12_Feature_Eval_Params Feature;
|
||||
ID3D12Resource* pInDepth;
|
||||
ID3D12Resource* pInMotionVectors;
|
||||
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
|
||||
float InJitterOffsetY;
|
||||
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
int InReset; /* Set to 1 when scene changes completely (new level etc) */
|
||||
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
|
||||
float InMVScaleY;
|
||||
ID3D12Resource* pInTransparencyMask; /* Unused/Reserved for future use */
|
||||
ID3D12Resource* pInExposureTexture;
|
||||
ID3D12Resource* pInBiasCurrentColorMask;
|
||||
NVSDK_NGX_Coordinates InColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InDepthSubrectBase;
|
||||
NVSDK_NGX_Coordinates InMVSubrectBase;
|
||||
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
|
||||
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InOutputSubrectBase;
|
||||
float InPreExposure;
|
||||
int InIndicatorInvertXAxis;
|
||||
int InIndicatorInvertYAxis;
|
||||
/*** OPTIONAL - only for research purposes ***/
|
||||
NVSDK_NGX_D3D12_GBuffer GBufferSurface;
|
||||
NVSDK_NGX_ToneMapperType InToneMapperType;
|
||||
ID3D12Resource* pInMotionVectors3D;
|
||||
ID3D12Resource* pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
|
||||
ID3D12Resource* pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
|
||||
ID3D12Resource* pInDepthHighRes;
|
||||
ID3D12Resource* pInPositionViewSpace;
|
||||
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
|
||||
ID3D12Resource* pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
|
||||
ID3D12Resource* pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
|
||||
} NVSDK_NGX_D3D12_DLSS_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_D3D12_DLISP_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_D3D12_Feature_Eval_Params Feature;
|
||||
/*** OPTIONAL ***/
|
||||
unsigned int InRectX;
|
||||
unsigned int InRectY;
|
||||
unsigned int InRectW;
|
||||
unsigned int InRectH;
|
||||
float InDenoise;
|
||||
} NVSDK_NGX_D3D12_DLISP_Eval_Params;
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLSS_EXT(
|
||||
ID3D12GraphicsCommandList *pInCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
|
||||
|
||||
return NVSDK_NGX_D3D12_CreateFeature(pInCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLSS_EXT(
|
||||
ID3D12GraphicsCommandList *pInCmdList,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D12_DLSS_Eval_Params *pInDlssEvalParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
|
||||
|
||||
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLISP_EXT(
|
||||
ID3D12GraphicsCommandList *InCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pDlispCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlispCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlispCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlispCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlispCreateParams->InTargetHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pDlispCreateParams->InPerfQualityValue);
|
||||
|
||||
return NVSDK_NGX_D3D12_CreateFeature(InCmdList, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLISP_EXT(
|
||||
ID3D12GraphicsCommandList *pInCmdList,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D12_DLISP_Eval_Params *pDlispEvalParams)
|
||||
{
|
||||
if (pDlispEvalParams->Feature.InSharpness < 0.0f || pDlispEvalParams->Feature.InSharpness > 1.0f || pDlispEvalParams->InDenoise < 0.0f || pDlispEvalParams->InDenoise > 1.0f)
|
||||
{
|
||||
return NVSDK_NGX_Result_FAIL_InvalidParameter;
|
||||
}
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlispEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlispEvalParams->Feature.pInOutput);
|
||||
// Both sharpness and denoise in range [0.0f,1.0f]
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlispEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pDlispEvalParams->InDenoise);
|
||||
// If input is atlas - use RECT to upscale only the required area
|
||||
if (pDlispEvalParams->InRectW)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pDlispEvalParams->InRectX);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pDlispEvalParams->InRectY);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pDlispEvalParams->InRectW);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pDlispEvalParams->InRectH);
|
||||
}
|
||||
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_CREATE_DLRESOLVE_EXT(
|
||||
ID3D12GraphicsCommandList *pInCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pDlresolveCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pDlresolveCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pDlresolveCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pDlresolveCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pDlresolveCreateParams->InTargetHeight);
|
||||
|
||||
return NVSDK_NGX_D3D12_CreateFeature(pInCmdList, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_D3D12_EVALUATE_DLRESOLVE_EXT(
|
||||
ID3D12GraphicsCommandList *pInCmdList,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_D3D12_Feature_Eval_Params *pDlresolveEvalParams)
|
||||
{
|
||||
// This call to NVSDK_NGX_Parameter_SetXXX() is equivalent to the Params->Set below functionally
|
||||
// but to work around the lack of virtual functions and polymorphism in a C only project
|
||||
// we introduced this new way to set params.
|
||||
// The test should enforce that both paths work.
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Color, pDlresolveEvalParams->pInColor);
|
||||
NVSDK_NGX_Parameter_SetD3d12Resource(pInParams, NVSDK_NGX_Parameter_Output, pDlresolveEvalParams->pInOutput);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pDlresolveEvalParams->InSharpness);
|
||||
|
||||
return NVSDK_NGX_D3D12_EvaluateFeature_C(pInCmdList, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
318
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_helpers_vk.h
vendored
Normal file
318
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_helpers_vk.h
vendored
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
#ifndef NVSDK_NGX_HELPERS_VK_H
|
||||
#define NVSDK_NGX_HELPERS_VK_H
|
||||
#pragma once
|
||||
|
||||
#include "nvsdk_ngx_vk.h"
|
||||
|
||||
#define NVSDK_NGX_ENSURE_VK_IMAGEVIEW(InResource) if ((InResource) && (InResource)->Type != NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW) { return NVSDK_NGX_Result_FAIL_InvalidParameter; }
|
||||
|
||||
static inline NVSDK_NGX_Resource_VK NVSDK_NGX_Create_ImageView_Resource_VK(VkImageView imageView, VkImage image, VkImageSubresourceRange subresourceRange, VkFormat format, unsigned int width, unsigned int height, bool readWrite)
|
||||
{
|
||||
NVSDK_NGX_Resource_VK resourceVK = {0};
|
||||
resourceVK.Type = NVSDK_NGX_RESOURCE_VK_TYPE_VK_IMAGEVIEW;
|
||||
resourceVK.Resource.ImageViewInfo.ImageView = imageView;
|
||||
resourceVK.Resource.ImageViewInfo.Image = image;
|
||||
resourceVK.Resource.ImageViewInfo.SubresourceRange = subresourceRange;
|
||||
resourceVK.Resource.ImageViewInfo.Height = height;
|
||||
resourceVK.Resource.ImageViewInfo.Width = width;
|
||||
resourceVK.Resource.ImageViewInfo.Format = format;
|
||||
resourceVK.ReadWrite = readWrite;
|
||||
return resourceVK;
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Resource_VK NVSDK_NGX_Create_Buffer_Resource_VK(VkBuffer buffer, unsigned int sizeInBytes, bool readWrite)
|
||||
{
|
||||
NVSDK_NGX_Resource_VK resourceVK = {0};
|
||||
resourceVK.Type = NVSDK_NGX_RESOURCE_VK_TYPE_VK_BUFFER;
|
||||
resourceVK.Resource.BufferInfo.Buffer = buffer;
|
||||
resourceVK.Resource.BufferInfo.SizeInBytes = sizeInBytes;
|
||||
resourceVK.ReadWrite = readWrite;
|
||||
return resourceVK;
|
||||
}
|
||||
|
||||
typedef struct NVSDK_NGX_VK_Feature_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_Resource_VK *pInColor;
|
||||
NVSDK_NGX_Resource_VK *pInOutput;
|
||||
/*** OPTIONAL for DLSS ***/
|
||||
float InSharpness;
|
||||
} NVSDK_NGX_VK_Feature_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_VK_GBuffer
|
||||
{
|
||||
NVSDK_NGX_Resource_VK *pInAttrib[NVSDK_NGX_GBUFFERTYPE_NUM];
|
||||
} NVSDK_NGX_VK_GBuffer;
|
||||
|
||||
typedef struct NVSDK_NGX_Coordinates_VK
|
||||
{
|
||||
unsigned int X;
|
||||
unsigned int Y;
|
||||
} NVSDK_NGX_Coordinates_VK;
|
||||
|
||||
typedef struct NVSDK_NGX_VK_DLSS_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_VK_Feature_Eval_Params Feature;
|
||||
NVSDK_NGX_Resource_VK * pInDepth;
|
||||
NVSDK_NGX_Resource_VK * pInMotionVectors;
|
||||
float InJitterOffsetX; /* Jitter offset must be in input/render pixel space */
|
||||
float InJitterOffsetY;
|
||||
NVSDK_NGX_Dimensions InRenderSubrectDimensions;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
int InReset; /* Set to 1 when scene changes completely (new level etc) */
|
||||
float InMVScaleX; /* If MVs need custom scaling to convert to pixel space */
|
||||
float InMVScaleY;
|
||||
NVSDK_NGX_Resource_VK * pInTransparencyMask; /* Unused/Reserved for future use */
|
||||
NVSDK_NGX_Resource_VK * pInExposureTexture;
|
||||
NVSDK_NGX_Resource_VK * pInBiasCurrentColorMask;
|
||||
NVSDK_NGX_Coordinates InColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InDepthSubrectBase;
|
||||
NVSDK_NGX_Coordinates InMVSubrectBase;
|
||||
NVSDK_NGX_Coordinates InTranslucencySubrectBase;
|
||||
NVSDK_NGX_Coordinates InBiasCurrentColorSubrectBase;
|
||||
NVSDK_NGX_Coordinates InOutputSubrectBase;
|
||||
float InPreExposure;
|
||||
int InIndicatorInvertXAxis;
|
||||
int InIndicatorInvertYAxis;
|
||||
/*** OPTIONAL - only for research purposes ***/
|
||||
NVSDK_NGX_VK_GBuffer GBufferSurface;
|
||||
NVSDK_NGX_ToneMapperType InToneMapperType;
|
||||
NVSDK_NGX_Resource_VK * pInMotionVectors3D;
|
||||
NVSDK_NGX_Resource_VK * pInIsParticleMask; /* to identify which pixels contains particles, essentially that are not drawn as part of base pass */
|
||||
NVSDK_NGX_Resource_VK * pInAnimatedTextureMask; /* a binary mask covering pixels occupied by animated textures */
|
||||
NVSDK_NGX_Resource_VK * pInDepthHighRes;
|
||||
NVSDK_NGX_Resource_VK * pInPositionViewSpace;
|
||||
float InFrameTimeDeltaInMsec; /* helps in determining the amount to denoise or anti-alias based on the speed of the object from motion vector magnitudes and fps as determined by this delta */
|
||||
NVSDK_NGX_Resource_VK * pInRayTracingHitDistance; /* for each effect - approximation to the amount of noise in a ray-traced color */
|
||||
NVSDK_NGX_Resource_VK * pInMotionVectorsReflections; /* motion vectors of reflected objects like for mirrored surfaces */
|
||||
} NVSDK_NGX_VK_DLSS_Eval_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_VK_DLISP_Eval_Params
|
||||
{
|
||||
NVSDK_NGX_VK_Feature_Eval_Params Feature;
|
||||
/*** OPTIONAL - leave to 0/0.0f if unused ***/
|
||||
unsigned int InRectX;
|
||||
unsigned int InRectY;
|
||||
unsigned int InRectW;
|
||||
unsigned int InRectH;
|
||||
float InDenoise;
|
||||
} NVSDK_NGX_VK_DLISP_Eval_Params;
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLSS_EXT1(
|
||||
VkDevice InDevice,
|
||||
VkCommandBuffer InCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlssCreateParams->Feature.InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlssCreateParams->Feature.InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlssCreateParams->Feature.InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlssCreateParams->Feature.InTargetHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlssCreateParams->Feature.InPerfQualityValue);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Feature_Create_Flags, pInDlssCreateParams->InFeatureCreateFlags);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Enable_Output_Subrects, pInDlssCreateParams->InEnableOutputSubrects ? 1 : 0);
|
||||
|
||||
if (InDevice) return NVSDK_NGX_VULKAN_CreateFeature1(InDevice, InCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
|
||||
else return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_SuperSampling, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLSS_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_DLSS_Create_Params *pInDlssCreateParams)
|
||||
{
|
||||
return NGX_VULKAN_CREATE_DLSS_EXT1(NULL, InCmdList, InCreationNodeMask, InVisibilityNodeMask, ppOutHandle, pInParams, pInDlssCreateParams);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLSS_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_VK_DLSS_Eval_Params *pInDlssEvalParams)
|
||||
{
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectors);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->Feature.pInOutput);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInDepth);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInTransparencyMask);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInExposureTexture);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInBiasCurrentColorMask);
|
||||
for (size_t i = 0; i <= 15; i++)
|
||||
{
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->GBufferSurface.pInAttrib[i]);
|
||||
}
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectors3D);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInIsParticleMask);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInAnimatedTextureMask);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInDepthHighRes);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInPositionViewSpace);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInRayTracingHitDistance);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlssEvalParams->pInMotionVectorsReflections);
|
||||
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlssEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlssEvalParams->Feature.pInOutput);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Depth, pInDlssEvalParams->pInDepth);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectors, pInDlssEvalParams->pInMotionVectors);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_X, pInDlssEvalParams->InJitterOffsetX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Jitter_Offset_Y, pInDlssEvalParams->InJitterOffsetY);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlssEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_Reset, pInDlssEvalParams->InReset);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_X, pInDlssEvalParams->InMVScaleX == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleX);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_MV_Scale_Y, pInDlssEvalParams->InMVScaleY == 0.0f ? 1.0f : pInDlssEvalParams->InMVScaleY);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_TransparencyMask, pInDlssEvalParams->pInTransparencyMask);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_ExposureTexture, pInDlssEvalParams->pInExposureTexture);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_Mask, pInDlssEvalParams->pInBiasCurrentColorMask);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Albedo, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ALBEDO]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Roughness, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_ROUGHNESS]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Metallic, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_METALLIC]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Specular, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SPECULAR]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Subsurface, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SUBSURFACE]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Normals, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_NORMALS]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_ShadingModelId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_SHADINGMODELID]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_MaterialId, pInDlssEvalParams->GBufferSurface.pInAttrib[NVSDK_NGX_GBUFFER_MATERIALID]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_8, pInDlssEvalParams->GBufferSurface.pInAttrib[8]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_9, pInDlssEvalParams->GBufferSurface.pInAttrib[9]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_10, pInDlssEvalParams->GBufferSurface.pInAttrib[10]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_11, pInDlssEvalParams->GBufferSurface.pInAttrib[11]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_12, pInDlssEvalParams->GBufferSurface.pInAttrib[12]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_13, pInDlssEvalParams->GBufferSurface.pInAttrib[13]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_14, pInDlssEvalParams->GBufferSurface.pInAttrib[14]);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_GBuffer_Atrrib_15, pInDlssEvalParams->GBufferSurface.pInAttrib[15]);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_TonemapperType, pInDlssEvalParams->InToneMapperType);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectors3D, pInDlssEvalParams->pInMotionVectors3D);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_IsParticleMask, pInDlssEvalParams->pInIsParticleMask);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_AnimatedTextureMask, pInDlssEvalParams->pInAnimatedTextureMask);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_DepthHighRes, pInDlssEvalParams->pInDepthHighRes);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Position_ViewSpace, pInDlssEvalParams->pInPositionViewSpace);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_FrameTimeDeltaInMsec, pInDlssEvalParams->InFrameTimeDeltaInMsec);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_RayTracingHitDistance, pInDlssEvalParams->pInRayTracingHitDistance);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_MotionVectorsReflection, pInDlssEvalParams->pInMotionVectorsReflections);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_X, pInDlssEvalParams->InColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Color_Subrect_Base_Y, pInDlssEvalParams->InColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_X, pInDlssEvalParams->InDepthSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Depth_Subrect_Base_Y, pInDlssEvalParams->InDepthSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_X, pInDlssEvalParams->InMVSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_MV_SubrectBase_Y, pInDlssEvalParams->InMVSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_X, pInDlssEvalParams->InTranslucencySubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Translucency_SubrectBase_Y, pInDlssEvalParams->InTranslucencySubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_X, pInDlssEvalParams->InBiasCurrentColorSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Input_Bias_Current_Color_SubrectBase_Y, pInDlssEvalParams->InBiasCurrentColorSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_X, pInDlssEvalParams->InOutputSubrectBase.X);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Output_Subrect_Base_Y, pInDlssEvalParams->InOutputSubrectBase.Y);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Width , pInDlssEvalParams->InRenderSubrectDimensions.Width);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_DLSS_Render_Subrect_Dimensions_Height, pInDlssEvalParams->InRenderSubrectDimensions.Height);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_DLSS_Pre_Exposure, pInDlssEvalParams->InPreExposure == 0.0f ? 1.0f : pInDlssEvalParams->InPreExposure);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_X_Axis, pInDlssEvalParams->InIndicatorInvertXAxis);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_DLSS_Indicator_Invert_Y_Axis, pInDlssEvalParams->InIndicatorInvertYAxis);
|
||||
|
||||
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLISP_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pInDlispCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlispCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlispCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlispCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlispCreateParams->InTargetHeight);
|
||||
NVSDK_NGX_Parameter_SetI(pInParams, NVSDK_NGX_Parameter_PerfQualityValue, pInDlispCreateParams->InPerfQualityValue);
|
||||
|
||||
return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_ImageSignalProcessing, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLISP_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
NVSDK_NGX_Handle *InHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_VK_DLISP_Eval_Params *pInDlispEvalParams)
|
||||
{
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlispEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlispEvalParams->Feature.pInOutput);
|
||||
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlispEvalParams->Feature.pInColor);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlispEvalParams->Feature.pInOutput);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlispEvalParams->Feature.InSharpness);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Denoise, pInDlispEvalParams->InDenoise);
|
||||
// If input is atlas - use RECT to upscale only the required area
|
||||
if (pInDlispEvalParams->InRectW)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_X, pInDlispEvalParams->InRectX);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_Y, pInDlispEvalParams->InRectY);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_W, pInDlispEvalParams->InRectW);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Rect_H, pInDlispEvalParams->InRectH);
|
||||
}
|
||||
|
||||
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, InHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_CREATE_DLRESOLVE_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
unsigned int InCreationNodeMask,
|
||||
unsigned int InVisibilityNodeMask,
|
||||
NVSDK_NGX_Handle **ppOutHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_Feature_Create_Params *pInDlresolveCreateParams)
|
||||
{
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_CreationNodeMask, InCreationNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_VisibilityNodeMask, InVisibilityNodeMask);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Width, pInDlresolveCreateParams->InWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_Height, pInDlresolveCreateParams->InHeight);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutWidth, pInDlresolveCreateParams->InTargetWidth);
|
||||
NVSDK_NGX_Parameter_SetUI(pInParams, NVSDK_NGX_Parameter_OutHeight, pInDlresolveCreateParams->InTargetHeight);
|
||||
|
||||
return NVSDK_NGX_VULKAN_CreateFeature(InCmdList, NVSDK_NGX_Feature_DeepResolve, pInParams, ppOutHandle);
|
||||
}
|
||||
|
||||
static inline NVSDK_NGX_Result NGX_VULKAN_EVALUATE_DLRESOLVE_EXT(
|
||||
VkCommandBuffer InCmdList,
|
||||
NVSDK_NGX_Handle *pInHandle,
|
||||
NVSDK_NGX_Parameter *pInParams,
|
||||
NVSDK_NGX_VK_Feature_Eval_Params *pInDlresolveEvalParams)
|
||||
{
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlresolveEvalParams->pInColor);
|
||||
NVSDK_NGX_ENSURE_VK_IMAGEVIEW(pInDlresolveEvalParams->pInOutput);
|
||||
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Color, pInDlresolveEvalParams->pInColor);
|
||||
NVSDK_NGX_Parameter_SetVoidPointer(pInParams, NVSDK_NGX_Parameter_Output, pInDlresolveEvalParams->pInOutput);
|
||||
NVSDK_NGX_Parameter_SetF(pInParams, NVSDK_NGX_Parameter_Sharpness, pInDlresolveEvalParams->InSharpness);
|
||||
|
||||
return NVSDK_NGX_VULKAN_EvaluateFeature_C(InCmdList, pInHandle, pInParams, NULL);
|
||||
}
|
||||
|
||||
#endif // NVSDK_NGX_HELPERS_VK_H
|
||||
117
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_params.h
vendored
Normal file
117
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_params.h
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NVSDK_NGX_PARAMS_H
|
||||
#define NVSDK_NGX_PARAMS_H
|
||||
|
||||
#include "nvsdk_ngx_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct ID3D11Resource ID3D11Resource;
|
||||
typedef struct ID3D12Resource ID3D12Resource;
|
||||
|
||||
typedef struct NVSDK_NGX_Feature_Create_Params
|
||||
{
|
||||
unsigned int InWidth;
|
||||
unsigned int InHeight;
|
||||
unsigned int InTargetWidth;
|
||||
unsigned int InTargetHeight;
|
||||
/*** OPTIONAL ***/
|
||||
NVSDK_NGX_PerfQuality_Value InPerfQualityValue;
|
||||
} NVSDK_NGX_Feature_Create_Params;
|
||||
|
||||
typedef struct NVSDK_NGX_DLSS_Create_Params
|
||||
{
|
||||
NVSDK_NGX_Feature_Create_Params Feature;
|
||||
/*** OPTIONAL ***/
|
||||
int InFeatureCreateFlags;
|
||||
bool InEnableOutputSubrects;
|
||||
} NVSDK_NGX_DLSS_Create_Params;
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef struct NVSDK_NGX_Parameter
|
||||
{
|
||||
virtual void Set(const char * InName, unsigned long long InValue) = 0;
|
||||
virtual void Set(const char * InName, float InValue) = 0;
|
||||
virtual void Set(const char * InName, double InValue) = 0;
|
||||
virtual void Set(const char * InName, unsigned int InValue) = 0;
|
||||
virtual void Set(const char * InName, int InValue) = 0;
|
||||
virtual void Set(const char * InName, ID3D11Resource *InValue) = 0;
|
||||
virtual void Set(const char * InName, ID3D12Resource *InValue) = 0;
|
||||
virtual void Set(const char * InName, void *InValue) = 0;
|
||||
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, unsigned long long *OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, float *OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, double *OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, unsigned int *OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, int *OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, ID3D11Resource **OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, ID3D12Resource **OutValue) const = 0;
|
||||
virtual NVSDK_NGX_Result Get(const char * InName, void **OutValue) const = 0;
|
||||
|
||||
virtual void Reset() = 0;
|
||||
} NVSDK_NGX_Parameter;
|
||||
#else
|
||||
typedef struct NVSDK_NGX_Parameter NVSDK_NGX_Parameter;
|
||||
#endif // _cplusplus
|
||||
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetULL)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetULL(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetF)(NVSDK_NGX_Parameter *InParameter, const char * InName, float InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetF(NVSDK_NGX_Parameter *InParameter, const char * InName, float InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD)(NVSDK_NGX_Parameter *InParameter, const char * InName, double InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD(NVSDK_NGX_Parameter *InParameter, const char * InName, double InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetUI)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetUI(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetI)(NVSDK_NGX_Parameter *InParameter, const char * InName, int InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetI(NVSDK_NGX_Parameter *InParameter, const char * InName, int InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD3d11Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource *InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD3d11Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource *InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetD3d12Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource *InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetD3d12Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource *InValue);
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_SetVoidPointer)(NVSDK_NGX_Parameter *InParameter, const char * InName, void *InValue);
|
||||
NVSDK_NGX_API void NVSDK_CONV NVSDK_NGX_Parameter_SetVoidPointer(NVSDK_NGX_Parameter *InParameter, const char * InName, void *InValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetULL)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long *OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetULL(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned long long *OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetF)(NVSDK_NGX_Parameter *InParameter, const char * InName, float *OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetF(NVSDK_NGX_Parameter *InParameter, const char * InName, float *OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD)(NVSDK_NGX_Parameter *InParameter, const char * InName, double *OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD(NVSDK_NGX_Parameter *InParameter, const char * InName, double *OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetUI)(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int *OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetUI(NVSDK_NGX_Parameter *InParameter, const char * InName, unsigned int *OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetI)(NVSDK_NGX_Parameter *InParameter, const char * InName, int *OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetI(NVSDK_NGX_Parameter *InParameter, const char * InName, int *OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD3d11Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource **OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD3d11Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D11Resource **OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetD3d12Resource)(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource **OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetD3d12Resource(NVSDK_NGX_Parameter *InParameter, const char * InName, ID3D12Resource **OutValue);
|
||||
typedef NVSDK_NGX_Result (NVSDK_CONV *PFN_NVSDK_NGX_Parameter_GetVoidPointer)(NVSDK_NGX_Parameter *InParameter, const char * InName, void **OutValue);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_Parameter_GetVoidPointer(NVSDK_NGX_Parameter *InParameter, const char * InName, void **OutValue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // #define NVSDK_NGX_PARAMS_H
|
||||
462
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_vk.h
vendored
Normal file
462
Plugins/DLSS/Source/ThirdParty/NGX/Include/nvsdk_ngx_vk.h
vendored
Normal file
@@ -0,0 +1,462 @@
|
||||
/*
|
||||
* Copyright (c) 2018 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* HOW TO USE:
|
||||
*
|
||||
* IMPORTANT: Methods in this library are NOT thread safe. It is up to the
|
||||
* client to ensure that thread safety is enforced as needed.
|
||||
*
|
||||
* 1) Call NVSDK_CONV NVSDK_NGX_D3D11/D3D12/CUDA_Init and pass your app Id
|
||||
* and other parameters. This will initialize SDK or return an error code
|
||||
* if SDK cannot run on target machine. Depending on error user might
|
||||
* need to update drivers. Please note that application Id is provided
|
||||
* by NVIDIA so if you do not have one please contact us.
|
||||
*
|
||||
* 2) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetParameters to obtain pointer to
|
||||
* interface used to pass parameters to SDK. Interface instance is
|
||||
* allocated and released by SDK so there is no need to do any memory
|
||||
* management on client side.
|
||||
*
|
||||
* 3) Set key parameters for the feature you want to use. For example,
|
||||
* width and height are required for all features and they can be
|
||||
* set like this:
|
||||
* Params->Set(NVSDK_NGX_Parameter_Width,MY_WIDTH);
|
||||
* Params->Set(NVSDK_NGX_Parameter_Height,MY_HEIGHT);
|
||||
*
|
||||
* You can also provide hints like NVSDK_NGX_Parameter_Hint_HDR to tell
|
||||
* SDK that it should expect HDR color space is needed. Please refer to
|
||||
* samples since different features need different parameters and hints.
|
||||
*
|
||||
* 4) Call NVSDK_NGX_D3D11/D3D12/CUDA_GetScratchBufferSize to obtain size of
|
||||
* the scratch buffer needed by specific feature. This D3D or CUDA buffer
|
||||
* should be allocated by client and passed as:
|
||||
* Params->Set(NVSDK_NGX_Parameter_Scratch,MY_SCRATCH_POINTER)
|
||||
* Params->Set(NVSDK_NGX_Parameter_Scratch_SizeInBytes,MY_SCRATCH_SIZE_IN_BYTES)
|
||||
* NOTE: Returned size can be 0 if feature does not use any scratch buffer.
|
||||
* It is OK to use bigger buffer or reuse buffers across features as long
|
||||
* as minimum size requirement is met.
|
||||
*
|
||||
* 5) Call NVSDK_NGX_D3D11/D3D12/CUDA_CreateFeature to create feature you need.
|
||||
* On success SDK will return a handle which must be used in any successive
|
||||
* calls to SDK which require feature handle. SDK will use all parameters
|
||||
* and hints provided by client to generate feature. If feature with the same
|
||||
* parameters already exists and error code will be returned.
|
||||
*
|
||||
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_EvaluateFeature to invoke execution of
|
||||
* specific feature. Before feature can be evaluated input parameters must
|
||||
* be specified (like for example color/albedo buffer, motion vectors etc)
|
||||
*
|
||||
* 6) Call NVSDK_NGX_D3D11/D3D12/CUDA_ReleaseFeature when feature is no longer
|
||||
* needed. After this call feature handle becomes invalid and cannot be used.
|
||||
*
|
||||
* 7) Call NVSDK_NGX_D3D11/D3D12/CUDA_Shutdown when SDK is no longer needed to
|
||||
* release all resources.
|
||||
|
||||
* Contact: ngxsupport@nvidia.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef NVSDK_NGX_VK_H
|
||||
#define NVSDK_NGX_VK_H
|
||||
|
||||
#include "nvsdk_ngx_defs.h"
|
||||
#include "nvsdk_ngx_params.h"
|
||||
#ifndef __cplusplus
|
||||
#include <stdbool.h>
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_ImageViewInfo_VK [Vulkan only]
|
||||
// Contains ImageView-specific metadata.
|
||||
// ImageView:
|
||||
// The VkImageView resource.
|
||||
//
|
||||
// Image:
|
||||
// The VkImage associated to this VkImageView.
|
||||
//
|
||||
// SubresourceRange:
|
||||
// The VkImageSubresourceRange associated to this VkImageView.
|
||||
//
|
||||
// Format:
|
||||
// The format of the resource.
|
||||
//
|
||||
// Width:
|
||||
// The width of the resource.
|
||||
//
|
||||
// Height:
|
||||
// The height of the resource.
|
||||
//
|
||||
typedef struct NVSDK_NGX_ImageViewInfo_VK {
|
||||
VkImageView ImageView;
|
||||
VkImage Image;
|
||||
VkImageSubresourceRange SubresourceRange;
|
||||
VkFormat Format;
|
||||
unsigned int Width;
|
||||
unsigned int Height;
|
||||
} NVSDK_NGX_ImageViewInfo_VK;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_BufferInfo_VK [Vulkan only]
|
||||
// Contains Buffer-specific metadata.
|
||||
// Buffer
|
||||
// The VkBuffer resource.
|
||||
//
|
||||
// SizeInBytes:
|
||||
// The size of the resource (in bytes).
|
||||
//
|
||||
typedef struct NVSDK_NGX_BufferInfo_VK {
|
||||
VkBuffer Buffer;
|
||||
unsigned int SizeInBytes;
|
||||
} NVSDK_NGX_BufferInfo_VK;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Resource_VK [Vulkan only]
|
||||
//
|
||||
// ImageViewInfo:
|
||||
// The VkImageView resource, and VkImageView-specific metadata. A NVSDK_NGX_Resource_VK can only have one of ImageViewInfo or BufferInfo.
|
||||
//
|
||||
// BufferInfo:
|
||||
// The VkBuffer Resource, and VkBuffer-specific metadata. A NVSDK_NGX_Resource_VK can only have one of ImageViewInfo or BufferInfo.
|
||||
//
|
||||
// Type:
|
||||
// Whether or this resource is a VkImageView or a VkBuffer.
|
||||
//
|
||||
// ReadWrite:
|
||||
// True if the resource is available for read and write access.
|
||||
// For VkBuffer resources: VkBufferUsageFlags includes VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT or VK_BUFFER_USAGE_STORAGE_BUFFER_BIT
|
||||
// For VkImage resources: VkImageUsageFlags for associated VkImage includes VK_IMAGE_USAGE_STORAGE_BIT
|
||||
//
|
||||
typedef struct NVSDK_NGX_Resource_VK {
|
||||
union {
|
||||
NVSDK_NGX_ImageViewInfo_VK ImageViewInfo;
|
||||
NVSDK_NGX_BufferInfo_VK BufferInfo;
|
||||
} Resource;
|
||||
NVSDK_NGX_Resource_VK_Type Type;
|
||||
bool ReadWrite;
|
||||
} NVSDK_NGX_Resource_VK;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_RequiredExtensions [Vulkan only]
|
||||
//
|
||||
// OutInstanceExtCount:
|
||||
// Returns the number of instance extensions NGX requires
|
||||
//
|
||||
// OutInstanceExts:
|
||||
// Returns a pointer to *OutInstanceExtCount strings of instance extensions
|
||||
//
|
||||
// OutDeviceExtCount:
|
||||
// Returns the number of device extensions NGX requires
|
||||
//
|
||||
// OutDeviceExts:
|
||||
// Returns a pointer to *OutDeviceExtCount strings of device extensions
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_RequiredExtensions(unsigned int *OutInstanceExtCount, const char *** OutInstanceExts, unsigned int *OutDeviceExtCount, const char *** OutDeviceExts);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Init
|
||||
// -------------------------------------
|
||||
//
|
||||
// InApplicationId:
|
||||
// Unique Id provided by NVIDIA
|
||||
//
|
||||
// InApplicationDataPath:
|
||||
// Folder to store logs and other temporary files (write access required),
|
||||
// Normally this would be a location in Documents or ProgramData.
|
||||
//
|
||||
// InDevice: [d3d11/12 only]
|
||||
// DirectX device to use
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Initializes new SDK instance.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
#else
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init(unsigned long long InApplicationId, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Init_with_ProjectID
|
||||
// -------------------------------------
|
||||
//
|
||||
// InParojectId:
|
||||
// Unique Id provided by the rendering engine used
|
||||
//
|
||||
// InEngineType:
|
||||
// Rendering engine used by the application / plugin.
|
||||
// Use NVSDK_NGX_ENGINE_TYPE_CUSTOM if the specific engine type is not supported explicitly
|
||||
//
|
||||
// InEngineVersion:
|
||||
// Version number of the rendering engine used by the application / plugin.
|
||||
//
|
||||
// InApplicationDataPath:
|
||||
// Folder to store logs and other temporary files (write access required),
|
||||
// Normally this would be a location in Documents or ProgramData.
|
||||
//
|
||||
// InDevice: [d3d11/12 only]
|
||||
// DirectX device to use
|
||||
//
|
||||
// InFeatureInfo:
|
||||
// Contains information common to all features, presently only a list of all paths
|
||||
// feature dlls can be located in, other than the default path - application directory.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Initializes new SDK instance.
|
||||
//
|
||||
#ifdef __cplusplus
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo = nullptr, NVSDK_NGX_Version InSDKVersion = NVSDK_NGX_Version_API);
|
||||
#else
|
||||
NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Init_with_ProjectID(const char *InProjectId, NVSDK_NGX_EngineType InEngineType, const char *InEngineVersion, const wchar_t *InApplicationDataPath, VkInstance InInstance, VkPhysicalDevice InPD, VkDevice InDevice, const NVSDK_NGX_FeatureCommonInfo *InFeatureInfo, NVSDK_NGX_Version InSDKVersion);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Shutdown
|
||||
// -------------------------------------
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Shuts down the current SDK instance and releases all resources.
|
||||
// Shutdown1(Device) only affects specified device
|
||||
// Shutdown1(nullptr) = Shutdown() and shuts down all devices
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown(void);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_Shutdown1(VkDevice InDevice);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// Parameters interface used to set any parameter needed by the SDK
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows simple parameter setup using named fields.
|
||||
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
|
||||
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
|
||||
// For more details please see sample code. Please note that allocated memory
|
||||
// will be freed by NGX so free/delete operator should NOT be called.
|
||||
// Parameter maps output by NVSDK_NGX_GetParameters are also pre-populated
|
||||
// with NGX capabilities and available features.
|
||||
// Unlike with NVSDK_NGX_AllocateParameters, parameter maps output by NVSDK_NGX_GetParameters
|
||||
// have their lifetimes managed by NGX, and must not
|
||||
// be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// NVSDK_NGX_GetParameters is soon to be deprecated and apps should move to using
|
||||
// NVSDK_NGX_AllocateParameters and NVSDK_NGX_GetCapabilityParameters when possible.
|
||||
// Nevertheless, due to the possibility that the user will be using an older driver version,
|
||||
// NVSDK_NGX_GetParameters should still be used as a fallback if NVSDK_NGX_AllocateParameters
|
||||
// or NVSDK_NGX_GetCapabilityParameters return NVSDK_NGX_Result_FAIL_OutOfDate.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetParameters(NVSDK_NGX_Parameter **OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_AllocateParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// Parameters interface used to set any parameter needed by the SDK
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows allocating a simple parameter setup using named fields, whose
|
||||
// lifetime the app must manage.
|
||||
// For example one can set width by calling Set(NVSDK_NGX_Parameter_Denoiser_Width,100) or
|
||||
// provide CUDA buffer pointer by calling Set(NVSDK_NGX_Parameter_Denoiser_Color,cudaBuffer)
|
||||
// For more details please see sample code.
|
||||
// Parameter maps output by NVSDK_NGX_AllocateParameters must NOT be freed using
|
||||
// the free/delete operator; to free a parameter map
|
||||
// output by NVSDK_NGX_AllocateParameters, NVSDK_NGX_DestroyParameters should be used.
|
||||
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_AllocateParameters
|
||||
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// Also unlike with NVSDK_NGX_GetParameters, parameter maps output by NVSDK_NGX_AllocateParameters
|
||||
// do not come pre-populated with NGX capabilities and available features.
|
||||
// To create a new parameter map pre-populated with such information, NVSDK_NGX_GetCapabilityParameters
|
||||
// should be used.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. In such a case, NVSDK_NGX_GetParameters
|
||||
// may be used as a fallback.
|
||||
// This function may only be called after a successful call into NVSDK_NGX_Init.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_AllocateParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetCapabilityParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// OutParameters:
|
||||
// The parameters interface populated with NGX and feature capabilities
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows the app to create a new parameter map
|
||||
// pre-populated with NGX capabilities and available features.
|
||||
// The output parameter map can also be used for any purpose
|
||||
// parameter maps output by NVSDK_NGX_AllocateParameters can be used for
|
||||
// but it is not recommended to use NVSDK_NGX_GetCapabilityParameters
|
||||
// unless querying NGX capabilities and available features
|
||||
// due to the overhead associated with pre-populating the parameter map.
|
||||
// Parameter maps output by NVSDK_NGX_GetCapabilityParameters must NOT be freed using
|
||||
// the free/delete operator; to free a parameter map
|
||||
// output by NVSDK_NGX_GetCapabilityParameters, NVSDK_NGX_DestroyParameters should be used.
|
||||
// Unlike with NVSDK_NGX_GetParameters, parameter maps allocated with NVSDK_NGX_GetCapabilityParameters
|
||||
// must be destroyed by the app using NVSDK_NGX_DestroyParameters.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. This function may only be called
|
||||
// after a successful call into NVSDK_NGX_Init.
|
||||
// If NVSDK_NGX_GetCapabilityParameters fails with NVSDK_NGX_Result_FAIL_OutOfDate,
|
||||
// NVSDK_NGX_GetParameters may be used as a fallback, to get a parameter map pre-populated
|
||||
// with NGX capabilities and available features.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetCapabilityParameters(NVSDK_NGX_Parameter** OutParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_DestroyParameters
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// InParameters:
|
||||
// The parameters interface to be destroyed
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// This interface allows the app to destroy the parameter map passed in. Once
|
||||
// NVSDK_NGX_DestroyParameters is called on a parameter map, it
|
||||
// must not be used again.
|
||||
// NVSDK_NGX_DestroyParameters must not be called on any parameter map returned
|
||||
// by NVSDK_NGX_GetParameters; NGX will manage the lifetime of those
|
||||
// parameter maps.
|
||||
// This function may return NVSDK_NGX_Result_FAIL_OutOfDate if an older driver, which
|
||||
// does not support this API call is being used. This function may only be called
|
||||
// after a successful call into NVSDK_NGX_Init.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_DestroyParameters(NVSDK_NGX_Parameter* InParameters);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_GetScratchBufferSize
|
||||
// ----------------------------------------------------------
|
||||
//
|
||||
// InFeatureId:
|
||||
// AI feature in question
|
||||
//
|
||||
// InParameters:
|
||||
// Parameters used by the feature to help estimate scratch buffer size
|
||||
//
|
||||
// OutSizeInBytes:
|
||||
// Number of bytes needed for the scratch buffer for the specified feature.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// SDK needs a buffer of a certain size provided by the client in
|
||||
// order to initialize AI feature. Once feature is no longer
|
||||
// needed buffer can be released. It is safe to reuse the same
|
||||
// scratch buffer for different features as long as minimum size
|
||||
// requirement is met for all features. Please note that some
|
||||
// features might not need a scratch buffer so return size of 0
|
||||
// is completely valid.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_GetScratchBufferSize(NVSDK_NGX_Feature InFeatureId, const NVSDK_NGX_Parameter *InParameters, size_t *OutSizeInBytes);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_CreateFeature
|
||||
// -------------------------------------
|
||||
//
|
||||
// InCmdBuffer:
|
||||
// Command buffer to use to execute GPU commands. Must be:
|
||||
// - Open and recording
|
||||
|
||||
// InFeatureID:
|
||||
// AI feature to initialize
|
||||
//
|
||||
// InParameters:
|
||||
// List of parameters
|
||||
//
|
||||
// OutHandle:
|
||||
// Handle which uniquely identifies the feature. If feature with
|
||||
// provided parameters already exists the "already exists" error code is returned.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Each feature needs to be created before it can be used.
|
||||
// Refer to the sample code to find out which input parameters
|
||||
// are needed to create specific feature.
|
||||
// CreateFeature() creates feature on single existing Device
|
||||
// CreateFeature1() creates feature on the specified Device
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature(VkCommandBuffer InCmdBuffer, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_CreateFeature1(VkDevice InDevice, VkCommandBuffer InCmdList, NVSDK_NGX_Feature InFeatureID, const NVSDK_NGX_Parameter *InParameters, NVSDK_NGX_Handle **OutHandle);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_Release
|
||||
// -------------------------------------
|
||||
//
|
||||
// InHandle:
|
||||
// Handle to feature to be released
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Releases feature with a given handle.
|
||||
// Handles are not reference counted so
|
||||
// after this call it is invalid to use provided handle.
|
||||
//
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_ReleaseFeature(NVSDK_NGX_Handle *InHandle);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// NVSDK_NGX_EvaluateFeature
|
||||
// -------------------------------------
|
||||
//
|
||||
// InCmdList:[d3d12 only]
|
||||
// Command list to use to execute GPU commands. Must be:
|
||||
// - Open and recording
|
||||
// - With node mask including the device provided in NVSDK_NGX_D3D12_Init
|
||||
// - Execute on non-copy command queue.
|
||||
// InDevCtx: [d3d11 only]
|
||||
// Device context to use to execute GPU commands
|
||||
//
|
||||
// InFeatureHandle:
|
||||
// Handle representing feature to be evaluated
|
||||
//
|
||||
// InParameters:
|
||||
// List of parameters required to evaluate feature
|
||||
//
|
||||
// InCallback:
|
||||
// Optional callback for features which might take longer
|
||||
// to execture. If specified SDK will call it with progress
|
||||
// values in range 0.0f - 1.0f
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Evaluates given feature using the provided parameters and
|
||||
// pre-trained NN. Please note that for most features
|
||||
// it can be benefitials to pass as many input buffers and parameters
|
||||
// as possible (for example provide all render targets like color, albedo, normals, depth etc)
|
||||
//
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback)(float InCurrentProgress, bool &OutShouldCancel);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_EvaluateFeature(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback InCallback = NULL);
|
||||
#endif
|
||||
typedef void (NVSDK_CONV *PFN_NVSDK_NGX_ProgressCallback_C)(float InCurrentProgress, bool *OutShouldCancel);
|
||||
NVSDK_NGX_API NVSDK_NGX_Result NVSDK_CONV NVSDK_NGX_VULKAN_EvaluateFeature_C(VkCommandBuffer InCmdList, const NVSDK_NGX_Handle *InFeatureHandle, const NVSDK_NGX_Parameter *InParameters, PFN_NVSDK_NGX_ProgressCallback_C InCallback);
|
||||
|
||||
// NGX return-code conversion-to-string utility only as a helper for debugging/logging - not for official use.
|
||||
const wchar_t* NVSDK_CONV GetNGXResultAsString(NVSDK_NGX_Result InNGXResult);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // #define NVSDK_NGX_VK_H
|
||||
408
Plugins/DLSS/Source/ThirdParty/NGX/LICENSE.txt
vendored
Normal file
408
Plugins/DLSS/Source/ThirdParty/NGX/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
NVIDIA RTX SDKs LICENSE
|
||||
|
||||
This license is a legal agreement between you and NVIDIA Corporation ("NVIDIA")
|
||||
and governs the use of the NVIDIA RTX software development kits, including the
|
||||
DLSS SDK, NGX SDK, RTXGI SDK, RTXDI SDK and/or NRD SDK, if and when made
|
||||
available to you under this license (in each case, the "SDK"). This license can
|
||||
be accepted only by an adult of legal age of majority in the country in which
|
||||
the SDK is used. If you are under the legal age of majority, you must ask your
|
||||
parent or legal guardian to consent to this license. If you are entering this
|
||||
license on behalf of a company or other legal entity, you represent that you
|
||||
have legal authority and "you" will mean the entity you represent. By using the
|
||||
SDK, you affirm that you have reached the legal age of majority, you accept the
|
||||
terms of this license, and you take legal and financial responsibility for the
|
||||
actions of your permitted users.
|
||||
|
||||
You agree to use the SDK only for purposes that are permitted by (a) this
|
||||
license, and (b) any applicable law, regulation or generally accepted practices
|
||||
or guidelines in the relevant jurisdictions.
|
||||
|
||||
1. LICENSE. Subject to the terms of this license and the terms in the supplement
|
||||
attached, NVIDIA hereby grants you a non-exclusive, non-transferable license,
|
||||
without the right to sublicense (except as expressly provided in this license)
|
||||
to:
|
||||
|
||||
(a) Install and use the SDK,
|
||||
|
||||
(b) Modify and create derivative works of sample source code delivered in the
|
||||
SDK, and
|
||||
|
||||
(c) Distribute any software and materials within the SDK, other than developer
|
||||
tools provided for your internal use, as incorporated in object code format into
|
||||
a software application subject to the distribution requirements indicated in
|
||||
this license.
|
||||
|
||||
2. DISTRIBUTION REQUIREMENTS. These are the distribution requirements for you to
|
||||
exercise the grants above:
|
||||
|
||||
(a) An application must have material additional functionality, beyond the
|
||||
included portions of the SDK.
|
||||
|
||||
(b) The following notice shall be included in modifications and derivative works
|
||||
of source code distributed: "This software contains source code provided by
|
||||
NVIDIA Corporation."
|
||||
|
||||
(c) You agree to distribute the SDK subject to the terms at least as protective
|
||||
as the terms of this license, including (without limitation) terms relating to
|
||||
the license grant, license restrictions and protection of NVIDIA's intellectual
|
||||
property rights. Additionally, you agree that you will protect the privacy,
|
||||
security and legal rights of your application users.
|
||||
|
||||
(d) You agree to notify NVIDIA in writing of any known or suspected distribution
|
||||
or use of the SDK not in compliance with the requirements of this license, and
|
||||
to enforce the terms of your agreements with respect to the distributed portions
|
||||
of the SDK.
|
||||
|
||||
3. AUTHORIZED USERS. You may allow employees and contractors of your entity or
|
||||
of your subsidiary(ies) to access and use the SDK from your secure network to
|
||||
perform work on your behalf. If you are an academic institution you may allow
|
||||
users enrolled or employed by the academic institution to access and use the SDK
|
||||
from your secure network. You are responsible for the compliance with the terms
|
||||
of this license by your authorized users.
|
||||
|
||||
4. LIMITATIONS. Your license to use the SDK is restricted as follows:
|
||||
|
||||
(a) You may not reverse engineer, decompile or disassemble, or remove copyright
|
||||
or other proprietary notices from any portion of the SDK or copies of the SDK.
|
||||
|
||||
(b) Except as expressly provided in this license, you may not copy, sell, rent,
|
||||
sublicense, transfer, distribute, modify, or create derivative works of any
|
||||
portion of the SDK. For clarity, you may not distribute or sublicense the SDK as
|
||||
a stand-alone product.
|
||||
|
||||
(c) Unless you have an agreement with NVIDIA for this purpose, you may not
|
||||
indicate that an application created with the SDK is sponsored or endorsed by
|
||||
NVIDIA.
|
||||
|
||||
(d) You may not bypass, disable, or circumvent any technical limitation,
|
||||
encryption, security, digital rights management or authentication mechanism in
|
||||
the SDK.
|
||||
|
||||
(e) You may not use the SDK in any manner that would cause it to become subject
|
||||
to an open source software license. As examples, licenses that require as a
|
||||
condition of use, modification, and/or distribution that the SDK be: (i)
|
||||
disclosed or distributed in source code form; (ii) licensed for the purpose of
|
||||
making derivative works; or (iii) redistributable at no charge.
|
||||
|
||||
(f) Unless you have an agreement with NVIDIA for this purpose, you may not use
|
||||
the SDK with any system or application where the use or failure of the system or
|
||||
application can reasonably be expected to threaten or result in personal injury,
|
||||
death, or catastrophic loss. Examples include use in avionics, navigation,
|
||||
military, medical, life support or other life critical applications. NVIDIA does
|
||||
not design, test or manufacture the SDK for these critical uses and NVIDIA shall
|
||||
not be liable to you or any third party, in whole or in part, for any claims or
|
||||
damages arising from such uses.
|
||||
|
||||
(g) You agree to defend, indemnify and hold harmless NVIDIA and its affiliates,
|
||||
and their respective employees, contractors, agents, officers and directors,
|
||||
from and against any and all claims, damages, obligations, losses, liabilities,
|
||||
costs or debt, fines, restitutions and expenses (including but not limited to
|
||||
attorney's fees and costs incident to establishing the right of indemnification)
|
||||
arising out of or related to your use of the SDK outside of the scope of this
|
||||
license, or not in compliance with its terms.
|
||||
|
||||
5. UPDATES. NVIDIA may, at its option, make available patches, workarounds or
|
||||
other updates to this SDK. Unless the updates are provided with their separate
|
||||
governing terms, they are deemed part of the SDK licensed to you as provided in
|
||||
this license. You agree that the form and content of the SDK that NVIDIA
|
||||
provides may change without prior notice to you. While NVIDIA generally
|
||||
maintains compatibility between versions, NVIDIA may in some cases make changes
|
||||
that introduce incompatibilities in future versions of the SDK.
|
||||
|
||||
6. PRE-RELEASE VERSIONS. SDK versions identified as alpha, beta, preview, early
|
||||
access or otherwise as pre-release may not be fully functional, may contain
|
||||
errors or design flaws, and may have reduced or different security, privacy,
|
||||
availability, and reliability standards relative to commercial versions of
|
||||
NVIDIA software and materials. You may use a pre-release SDK version at your own
|
||||
risk, understanding that these versions are not intended for use in production
|
||||
or business-critical systems. NVIDIA may choose not to make available a
|
||||
commercial version of any pre-release SDK. NVIDIA may also choose to abandon
|
||||
development and terminate the availability of a pre-release SDK at any time
|
||||
without liability.
|
||||
|
||||
7. THIRD-PARTY COMPONENTS. The SDK may include third-party components with
|
||||
separate legal notices or terms as may be described in proprietary notices
|
||||
accompanying the SDK. If and to the extent there is a conflict between the terms
|
||||
in this license and the third-party license terms, the third-party terms control
|
||||
only to the extent necessary to resolve the conflict.
|
||||
|
||||
8. OWNERSHIP.
|
||||
|
||||
8.1 NVIDIA reserves all rights, title and interest in and to the SDK not
|
||||
expressly granted to you under this license. NVIDIA and its suppliers hold all
|
||||
rights, title and interest in and to the SDK, including their respective
|
||||
intellectual property rights. The SDK is copyrighted and protected by the laws
|
||||
of the United States and other countries, and international treaty provisions.
|
||||
|
||||
8.2 Subject to the rights of NVIDIA and its suppliers in the SDK, you hold all
|
||||
rights, title and interest in and to your applications and your derivative works
|
||||
of the sample source code delivered in the SDK including their respective
|
||||
intellectual property rights.
|
||||
|
||||
9. FEEDBACK. You may, but are not obligated to, provide Feedback to NVIDIA.
|
||||
"Feedback" means all suggestions, fixes, modifications, feature requests or
|
||||
other feedback regarding the SDK. Feedback, even if designated as confidential
|
||||
by you, shall not create any confidentiality obligation for NVIDIA. NVIDIA and
|
||||
its designees have a perpetual, non-exclusive, worldwide, irrevocable license to
|
||||
use, reproduce, publicly display, modify, create derivative works of, license,
|
||||
sublicense, and otherwise distribute and exploit Feedback as NVIDIA sees fit
|
||||
without payment and without obligation or restriction of any kind on account of
|
||||
intellectual property rights or otherwise.
|
||||
|
||||
10. NO WARRANTIES. THE SDK IS PROVIDED AS-IS. TO THE MAXIMUM EXTENT PERMITTED BY
|
||||
APPLICABLE LAW NVIDIA AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF
|
||||
ANY KIND OR NATURE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT
|
||||
LIMITED TO, WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE. NVIDIA DOES NOT WARRANT THAT THE SDK WILL MEET YOUR
|
||||
REQUIREMENTS OR THAT THE OPERATION THEREOF WILL BE UNINTERRUPTED OR ERROR-FREE,
|
||||
OR THAT ALL ERRORS WILL BE CORRECTED.
|
||||
|
||||
11. LIMITATIONS OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW
|
||||
NVIDIA AND ITS AFFILIATES SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
|
||||
PUNITIVE OR CONSEQUENTIAL DAMAGES, OR FOR ANY LOST PROFITS, PROJECT DELAYS, LOSS
|
||||
OF USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE
|
||||
PRODUCTS, ARISING OUT OF OR IN CONNECTION WITH THIS LICENSE OR THE USE OR
|
||||
PERFORMANCE OF THE SDK, WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON
|
||||
BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT
|
||||
LIABILITY OR ANY OTHER CAUSE OF ACTION OR THEORY OF LIABILITY, EVEN IF NVIDIA
|
||||
HAS PREVIOUSLY BEEN ADVISED OF, OR COULD REASONABLY HAVE FORESEEN, THE
|
||||
POSSIBILITY OF SUCH DAMAGES. IN NO EVENT WILL NVIDIA'S AND ITS AFFILIATES TOTAL
|
||||
CUMULATIVE LIABILITY UNDER OR ARISING OUT OF THIS LICENSE EXCEED US$10.00. THE
|
||||
NATURE OF THE LIABILITY OR THE NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR
|
||||
EXTEND THIS LIMIT.
|
||||
|
||||
12. TERMINATION. Your rights under this license will terminate automatically
|
||||
without notice from NVIDIA if you fail to comply with any term and condition of
|
||||
this license or if you commence or participate in any legal proceeding against
|
||||
NVIDIA with respect to the SDK. NVIDIA may terminate this license with advance
|
||||
written notice to you, if NVIDIA decides to no longer provide the SDK in a
|
||||
country or, in NVIDIA's sole discretion, the continued use of it is no longer
|
||||
commercially viable. Upon any termination of this license, you agree to promptly
|
||||
discontinue use of the SDK and destroy all copies in your possession or control.
|
||||
Your prior distributions in accordance with this license are not affected by the
|
||||
termination of this license. All provisions of this license will survive
|
||||
termination, except for the license granted to you.
|
||||
|
||||
13. APPLICABLE LAW. This license will be governed in all respects by the laws of
|
||||
the United States and of the State of Delaware, without regard to the conflicts
|
||||
of laws principles. The United Nations Convention on Contracts for the
|
||||
International Sale of Goods is specifically disclaimed. You agree to all terms
|
||||
of this license in the English language. The state or federal courts residing in
|
||||
Santa Clara County, California shall have exclusive jurisdiction over any
|
||||
dispute or claim arising out of this license. Notwithstanding this, you agree
|
||||
that NVIDIA shall still be allowed to apply for injunctive remedies or urgent
|
||||
legal relief in any jurisdiction.
|
||||
|
||||
14. NO ASSIGNMENT. This license and your rights and obligations thereunder may
|
||||
not be assigned by you by any means or operation of law without NVIDIA's
|
||||
permission. Any attempted assignment not approved by NVIDIA in writing shall be
|
||||
void and of no effect. NVIDIA may assign, delegate or transfer this license and
|
||||
its rights and obligations, and if to a non-affiliate you will be notified.
|
||||
|
||||
15. EXPORT. The SDK is subject to United States export laws and regulations. You
|
||||
agree to comply with all applicable U.S. and international export laws,
|
||||
including the Export Administration Regulations (EAR) administered by the U.S.
|
||||
Department of Commerce and economic sanctions administered by the U.S.
|
||||
Department of Treasury's Office of Foreign Assets Control (OFAC). These laws
|
||||
include restrictions on destinations, end-users and end-use. By accepting this
|
||||
license, you confirm that you are not currently residing in a country or region
|
||||
currently embargoed by the U.S. and that you are not otherwise prohibited from
|
||||
receiving the SDK.
|
||||
|
||||
16. GOVERNMENT USE. The SDK is, and shall be treated as being, "Commercial
|
||||
Items" as that term is defined at 48 CFR § 2.101, consisting of "commercial
|
||||
computer software" and "commercial computer software documentation",
|
||||
respectively, as such terms are used in, respectively, 48 CFR § 12.212 and 48
|
||||
CFR §§ 227.7202 & 252.227-7014(a)(1). Use, duplication or disclosure by the U.S.
|
||||
Government or a U.S. Government subcontractor is subject to the restrictions in
|
||||
this license pursuant to 48 CFR § 12.212 or 48 CFR § 227.7202. In no event shall
|
||||
the US Government user acquire rights in the SDK beyond those specified in 48
|
||||
C.F.R. 52.227-19(b)(1)-(2).
|
||||
|
||||
17. NOTICES. You agree that any notices that NVIDIA sends you electronically,
|
||||
such as via email, will satisfy any legal communication requirements. Please
|
||||
direct your legal notices or other correspondence to NVIDIA Corporation, 2788
|
||||
San Tomas Expressway, Santa Clara, California 95051, United States of America,
|
||||
Attention: Legal Department.
|
||||
|
||||
18. ENTIRE AGREEMENT. This license is the final, complete and exclusive
|
||||
agreement between the parties relating to the subject matter of this license and
|
||||
supersedes all prior or contemporaneous understandings and agreements relating
|
||||
to this subject matter, whether oral or written. If any court of competent
|
||||
jurisdiction determines that any provision of this license is illegal, invalid
|
||||
or unenforceable, the remaining provisions will remain in full force and effect.
|
||||
Any amendment or waiver under this license shall be in writing and signed by
|
||||
representatives of both parties.
|
||||
|
||||
19. LICENSING. If the distribution terms in this license are not suitable for
|
||||
your organization, or for any questions regarding this license, please contact
|
||||
NVIDIA at nvidia-rtx-license-questions@nvidia.com.
|
||||
|
||||
(v. April 12, 2021)
|
||||
|
||||
|
||||
|
||||
NVIDIA RTX SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE
|
||||
DEVELOPMENT KITS
|
||||
|
||||
The terms in this supplement govern your use of the NVIDIA RTX SDKs, including
|
||||
the DLSS SDK, NGX SDK, RTXGI SDK, RTXDI SDK and/or NRD SDK, if and when made
|
||||
available to you (in each case, the "SDK") under the terms of your license
|
||||
agreement ("Agreement") as modified by this supplement. Capitalized terms used
|
||||
but not defined below have the meaning assigned to them in the Agreement.
|
||||
|
||||
This supplement is an exhibit to the Agreement and is incorporated as an
|
||||
integral part of the Agreement. In the event of conflict between the terms in
|
||||
this supplement and the terms in the Agreement, the terms in this supplement
|
||||
govern.
|
||||
|
||||
1. Interoperability. Your applications that incorporate, or are based on, the
|
||||
SDK must be fully interoperable with compatible GPU hardware products designed
|
||||
by NVIDIA or its affiliates. Further, the DLSS SDK and NGX SDK are licensed for
|
||||
you to develop applications only for their use in systems with NVIDIA GPUs.
|
||||
|
||||
2. Limitations for the DLSS SDK and NGX SDK. Your applications that incorporate,
|
||||
or are based on, the DLSS SDK or NGX SDK may be deployed in a cloud service that
|
||||
runs on systems that consume NVIDIA vGPU software, and any other cloud service
|
||||
use of such SDKs or their functionality is outside of the scope of the
|
||||
Agreement. For the purpose of this section, cloud services include application
|
||||
service providers or service bureaus, operators of hosted/virtual system
|
||||
environments, or hosting, time sharing or providing any other type of service to
|
||||
others.
|
||||
|
||||
3. Notification for the DLSS SDK and NGX SDK. You are required to notify NVIDIA
|
||||
prior to commercial release of an application (including a plug-in to a
|
||||
commercial application) that incorporates, or is based on, the DLSS SDK or NGX
|
||||
SDK. Please send notifications to: https://developer.nvidia.com/sw-notification
|
||||
and provide the following information in the email: company name, publisher and
|
||||
developer name, NVIDIA SDK used, application name, platform (i.e. PC, Linux),
|
||||
scheduled ship date, and weblink to product/video.
|
||||
|
||||
4. Audio and Video Encoders and Decoders. You acknowledge and agree that it is
|
||||
your sole responsibility to obtain any additional third-party licenses required
|
||||
to make, have made, use, have used, sell, import, and offer for sale your
|
||||
products or services that include or incorporate any third-party software and
|
||||
content relating to audio and/or video encoders and decoders from, including but
|
||||
not limited to, Microsoft, Thomson, Fraunhofer IIS, Sisvel S.p.A., MPEG-LA, and
|
||||
Coding Technologies. NVIDIA does not grant to you under this Agreement any
|
||||
necessary patent or other rights with respect to any audio and/or video encoders
|
||||
and decoders.
|
||||
|
||||
5. DLSS SDK Terms. By installing or using the DLSS SDK you agree that NVIDIA can
|
||||
make over-the-air updates of DLSS in systems that have DLSS installed, including
|
||||
(without limitation) for quality, stability or performance improvements or to
|
||||
support new hardware. If you publicly release a DLSS integration in an end user
|
||||
game or application that presents material stability, performance, image
|
||||
quality, or other technical issues impacting the user experience, you will work
|
||||
to quickly address the integration issues. In the case issues are not addressed,
|
||||
NVIDIA reserves the right, as a last resort, to temporarily disable the DLSS
|
||||
integration until the issues can be fixed.
|
||||
|
||||
6. Marketing.
|
||||
|
||||
6.1 Marketing Activities. Your license to the SDK(s) under the Agreement is
|
||||
subject to your compliance with the following marketing terms:
|
||||
|
||||
(a) Identification by You in the DLSS SDK or NGX SDK. During the term of the
|
||||
Agreement, NVIDIA agrees that you may identify NVIDIA on your websites, printed
|
||||
collateral, trade-show displays and other retail packaging materials, as the
|
||||
supplier of the DLSS SDK or NGX SDK for the applications that were developed
|
||||
with use of such SDKs, provided that all such references to NVIDIA will be
|
||||
subject to NVIDIA's prior review and written approval, which will not be
|
||||
unreasonably withheld or delayed.
|
||||
|
||||
(b) NVIDIA Trademark Placement in Applications with the DLSS SDK or NGX SDK.
|
||||
For applications that incorporate the DLSS SDK or NGX SDK or portions thereof,
|
||||
you must attribute the use of the applicable SDK and include the NVIDIA Marks
|
||||
on splash screens, in the about box of the application (if present), and in
|
||||
credits for game applications.
|
||||
|
||||
(c) NVIDIA Trademark Placement in Applications with a licensed SDK, other than
|
||||
the DLSS SDK or NGX SDK. For applications that incorporates and/or makes use of
|
||||
a licensed SDK, other than the DLSS SDK or NGX SDK, you must attribute the use
|
||||
of the applicable SDK and include the NVIDIA Marks on the credit screen for
|
||||
applications that have such credit screen, or where a credit screen is not
|
||||
present prominently in end user documentation for the application. d)
|
||||
Identification by NVIDIA in the DLSS SDK or NGX SDK. You agree that NVIDIA may
|
||||
identify you on NVIDIA's websites, printed collateral, trade-show displays, and
|
||||
other retail packaging materials as an individual or entity that produces
|
||||
products and services which incorporate the DLSS SDK or NGX SDK as applicable.
|
||||
To the extent that you provide NVIDIA with input or usage requests with regard
|
||||
to the use of your logo or materials, NVIDIA will use commercially reasonable
|
||||
efforts to comply with such requests. For the avoidance of doubt, NVIDIA's
|
||||
rights pursuant to this section shall survive any expiration or termination of
|
||||
the Agreement with respect to existing applications which incorporate the DLSS
|
||||
SDK or NGX SDK.
|
||||
|
||||
(e) Applications Marketing Material in the DLSS SDK or NGX SDK. You may provide
|
||||
NVIDIA with screenshots, imagery, and video footage of applications
|
||||
representative of your use of the NVIDIA DLSS SDK or NGX SDKs in your
|
||||
application (collectively, "Assets"). You hereby grant to NVIDIA the right to
|
||||
create and display self-promotional demo materials using the Assets, and after
|
||||
release of the application to the public to distribute, sub-license, and use
|
||||
the Assets to promote and market the NVIDIA RTX SDKs. To the extent you
|
||||
provide NVIDIA with input or usage requests with regard to the use of your logo
|
||||
or materials, NVIDIA will use commercially reasonable efforts to comply with
|
||||
such requests. For the avoidance of doubt, NVIDIA's rights pursuant to this
|
||||
section shall survive any termination of the Agreement with respect to
|
||||
applications which incorporate the NVIDIA RTX SDK.
|
||||
|
||||
6.2 Trademark Ownership and Licenses. Trademarks are owned and licenses as
|
||||
follows:
|
||||
|
||||
(a) Ownership of Trademarks. Each party owns the trademarks, logos, and trade
|
||||
names (collectively "Marks") for their respective products or services,
|
||||
including without limitation in applications, and the NVIDIA RTX SDKs. Each
|
||||
party agrees to use the Marks of the other only as permitted in this exhibit.
|
||||
|
||||
(b) Trademark License to NVIDIA. You grant to NVIDIA a non-exclusive, non-sub
|
||||
licensable, non-transferable (except as set forth in the assignment provision
|
||||
of the Agreement), worldwide license to refer to you and your applications, and
|
||||
to use your Marks on NVIDIA's marketing materials and on NVIDIA's website
|
||||
(subject to any reasonable conditions of you) solely for NVIDIA's marketing
|
||||
activities set forth in this exhibit Sections (d)-(e) above. NVIDIA will
|
||||
follow your specifications for your Marks as to style, color, and typeface as
|
||||
reasonably provided to NVIDIA.
|
||||
|
||||
(c) Trademark License to You. NVIDIA grants to you a non-exclusive, non-sub
|
||||
licensable, non-transferable (except as set forth in the assignment provision
|
||||
of the Agreement), worldwide license, subject to the terms of this exhibit and
|
||||
the Agreement, to use NVIDIA RTX™, NVIDIA GeForce RTX™ in combination with
|
||||
GeForce products, and/or NVIDIA Quadro RTX™ in combination with Quadro
|
||||
products (collectively, the "NVIDIA Marks") on your marketing materials and on
|
||||
your website (subject to any reasonable conditions of NVIDIA) solely for your
|
||||
marketing activities set forth in this exhibit Sections 6.1 (a)-(c) above. For
|
||||
the avoidance of doubt, you will not and will not permit others to use any
|
||||
NVIDIA Mark for any other goods or services, or in a way that tarnishes,
|
||||
degrades, disparages or reflects adversely any of the NVIDIA Marks or NVIDIA's
|
||||
business or reputation, or that dilutes or otherwise harms the value,
|
||||
reputation or distinctiveness of or NVIDIA's goodwill in any NVIDIA Mark. In
|
||||
addition to the termination rights set forth in the Agreement, NVIDIA may
|
||||
terminate this trademark license at any time upon written notice to you. You
|
||||
will follow NVIDIA's use guidelines and specifications for NVIDIA's Marks as to
|
||||
style, color and typeface as provided in NVIDIA Marks and submit a sample of
|
||||
each proposed use of NVIDIA's Marks at least ten (10) business days prior to
|
||||
the desired implementation of such use to obtain NVIDIA's prior written
|
||||
approval (which approval will not be unreasonably withheld or delayed. Use of
|
||||
NVIDIA marks is not authorized until NVIDIA provides written approval. All
|
||||
goodwill associated with use of NVIDIA Marks will inure to the sole benefit of
|
||||
NVIDIA.
|
||||
|
||||
6.3 Use Guidelines. Use of the NVIDIA Marks is subject to the following
|
||||
guidelines:
|
||||
|
||||
(a) Business Practices. You covenant that you will: (a) conduct business with
|
||||
respect to NVIDIA's products in a manner that reflects favorably at all times
|
||||
on the good name, goodwill and reputation of such products; (b) avoid
|
||||
deceptive, misleading or unethical practices that are detrimental to NVIDIA,
|
||||
its customers, or end users; (c) make no false or misleading representations
|
||||
with regard to NVIDIA or its products; and (d) not publish or employ or
|
||||
cooperate in the publication or employment of any misleading or deceptive
|
||||
advertising or promotional materials.
|
||||
|
||||
(b) No Combination Marks or Similar Marks. You agree not to (a) combine NVIDIA
|
||||
Marks with any other content without NVIDIA's prior written approval, or (b)
|
||||
use any other trademark, trade name, or other designation of source which
|
||||
creates a likelihood of confusion with NVIDIA Marks.
|
||||
|
||||
(v. April 12, 2021)
|
||||
109
Plugins/DLSS/Source/ThirdParty/NGX/NGX.Build.cs
vendored
Normal file
109
Plugins/DLSS/Source/ThirdParty/NGX/NGX.Build.cs
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 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.
|
||||
*/
|
||||
|
||||
#if UE_5_0_OR_LATER
|
||||
using EpicGames.Core;
|
||||
#else
|
||||
using Tools.DotNETCommon;
|
||||
#endif
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.IO;
|
||||
|
||||
public class NGX : ModuleRules
|
||||
{
|
||||
|
||||
protected virtual bool IsSupportedWindowsPlatform(ReadOnlyTargetRules Target)
|
||||
{
|
||||
return Target.Platform == UnrealTargetPlatform.Win64;
|
||||
}
|
||||
|
||||
public NGX (ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
Type = ModuleType.External;
|
||||
|
||||
if (IsSupportedWindowsPlatform(Target))
|
||||
{
|
||||
string NGXPath = ModuleDirectory + "/";
|
||||
|
||||
PublicSystemIncludePaths.Add(NGXPath + "Include/");
|
||||
|
||||
PublicIncludePaths.Add(NGXPath + "Include/");
|
||||
|
||||
if ((Target.Configuration == UnrealTargetConfiguration.Debug) && Target.bDebugBuildsActuallyUseDebugCRT)
|
||||
{
|
||||
if (Target.bUseStaticCRT)
|
||||
{
|
||||
PublicAdditionalLibraries.Add(NGXPath + "Lib/x64/" + "nvsdk_ngx_s_dbg.lib");
|
||||
}
|
||||
else
|
||||
{
|
||||
PublicAdditionalLibraries.Add(NGXPath + "Lib/x64/" + "nvsdk_ngx_d_dbg.lib");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Target.bUseStaticCRT)
|
||||
{
|
||||
PublicAdditionalLibraries.Add(NGXPath + "Lib/x64/" + "nvsdk_ngx_s.lib");
|
||||
}
|
||||
else
|
||||
{
|
||||
PublicAdditionalLibraries.Add(NGXPath + "Lib/x64/" + "nvsdk_ngx_d.lib");
|
||||
}
|
||||
}
|
||||
|
||||
string[] NGXSnippetDLLs =
|
||||
{
|
||||
"nvngx_dlss.dll",
|
||||
};
|
||||
|
||||
PublicDefinitions.Add("NGX_DLSS_BINARY_NAME=TEXT(\"" + NGXSnippetDLLs[0] + "\")");
|
||||
|
||||
foreach (string NGXSnippetDLL in NGXSnippetDLLs)
|
||||
{
|
||||
bool bHasProjectBinary = false;
|
||||
if (Target.ProjectFile != null)
|
||||
{
|
||||
string ProjectDLLPath = DirectoryReference.Combine(Target.ProjectFile.Directory, "Binaries/ThirdParty/NVIDIA/NGX/Win64", NGXSnippetDLL).FullName;
|
||||
if (File.Exists(ProjectDLLPath))
|
||||
{
|
||||
bHasProjectBinary = true;
|
||||
//Log.TraceInformation("NGX project specific production DLSS binary found at {0}.", ProjectDLLPath);
|
||||
RuntimeDependencies.Add(ProjectDLLPath, StagedFileType.NonUFS);
|
||||
}
|
||||
}
|
||||
|
||||
// useful to have both plugin and project specific binary during testing, but if we have a project specific binary, then we want to ship with only that
|
||||
if (!bHasProjectBinary || Target.Configuration != UnrealTargetConfiguration.Shipping)
|
||||
{
|
||||
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/Win64/" + NGXSnippetDLL, StagedFileType.NonUFS);
|
||||
}
|
||||
|
||||
// useful to have debug overlay during testing, but we don't want to ship with that
|
||||
if (Target.Configuration != UnrealTargetConfiguration.Shipping)
|
||||
{
|
||||
RuntimeDependencies.Add("$(PluginDir)/Binaries/ThirdParty/Win64/Development/" + NGXSnippetDLL, StagedFileType.DebugNonUFS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
7
Plugins/DLSS/Source/ThirdParty/NGX/NGX.tps
vendored
Normal file
7
Plugins/DLSS/Source/ThirdParty/NGX/NGX.tps
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TpsData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Name>NGX</Name>
|
||||
<Location>/Engine/Source/ThirdParty/NVIDIA/NGX</Location>
|
||||
<Function>NGX</Function>
|
||||
<Justification>SDK for DLSS and other NVIDIA DeepLearning technologies</Justification>
|
||||
</TpsData>
|
||||
87
Plugins/DLSS/Source/ThirdParty/NGX/Utils/DLSS_Debug_Jitter_Configs.txt
vendored
Normal file
87
Plugins/DLSS/Source/ThirdParty/NGX/Utils/DLSS_Debug_Jitter_Configs.txt
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
Jitter Offset Configurations
|
||||
|
||||
To assist in debugging issues with sub-pixel jitter, the DLSS SDK library can optionally adjust the jitter offset components using the CTRL+ALT+F9 hotkey. The configurations are listed below and pressing the hotkey cycles through them in order.
|
||||
|
||||
To exchange (ie swap) the X and Y offsets, use the CTRL+ALT+F10 hotkey.
|
||||
|
||||
|
||||
// By default, jitter offsets are used as sent from the engine
|
||||
Config 0: OFF
|
||||
|
||||
|
||||
// Combinations halving and negating both vector components
|
||||
Config 1:
|
||||
JitterOffsetX *= 0.5f;
|
||||
JitterOffsetY *= 0.5f;
|
||||
|
||||
Config 2:
|
||||
JitterOffsetX *= 0.5f;
|
||||
JitterOffsetY *= -0.5f;
|
||||
|
||||
Config 3:
|
||||
JitterOffsetX *= -0.5f;
|
||||
JitterOffsetY *= 0.5f;
|
||||
|
||||
Config 4:
|
||||
JitterOffsetX *= -0.5f;
|
||||
JitterOffsetY *= -0.5f;
|
||||
|
||||
|
||||
// Combinations doubling and negating both vector components
|
||||
Config 5:
|
||||
JitterOffsetX *= 2.0f;
|
||||
JitterOffsetY *= 2.0f;
|
||||
|
||||
Config 6:
|
||||
JitterOffsetX *= 2.0f;
|
||||
JitterOffsetY *= -2.0f;
|
||||
|
||||
Config 7:
|
||||
JitterOffsetX *= -2.0f;
|
||||
JitterOffsetY *= 2.0f;
|
||||
|
||||
Config 8:
|
||||
JitterOffsetX *= -2.0f;
|
||||
JitterOffsetY *= -2.0f;
|
||||
|
||||
|
||||
// Combinations negating one or both vector components
|
||||
Config 9:
|
||||
JitterOffsetX *= 1.0f;
|
||||
JitterOffsetY *= -1.0f;
|
||||
|
||||
Config 10:
|
||||
JitterOffsetX *= -1.0f;
|
||||
JitterOffsetY *= 1.0f;
|
||||
|
||||
Config 11:
|
||||
JitterOffsetX *= -1.0f;
|
||||
JitterOffsetY *= -1.0f;
|
||||
|
||||
|
||||
// Combinations halving and negating individual vector components
|
||||
Config 12:
|
||||
JitterOffsetX *= 0.5f;
|
||||
|
||||
Config 13:
|
||||
JitterOffsetY *= 0.5f;
|
||||
|
||||
Config 14:
|
||||
JitterOffsetX *= -0.5f;
|
||||
|
||||
Config 15:
|
||||
JitterOffsetY *= -0.5f;
|
||||
|
||||
|
||||
// Combinations doubling and negating individual vector components
|
||||
Config 16:
|
||||
JitterOffsetX *= 2.0f;
|
||||
|
||||
Config 17:
|
||||
JitterOffsetY *= 2.0f;
|
||||
|
||||
Config 18:
|
||||
JitterOffsetX *= -2.0f;
|
||||
|
||||
Config 19:
|
||||
JitterOffsetY *= -2.0f;
|
||||
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_driver_onscreenindicator.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_driver_onscreenindicator.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_driver_onscreenindicator_off.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_driver_onscreenindicator_off.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_off.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_off.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_on.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_on.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_verbose.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_verbose.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_window_off.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_window_off.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_window_on.reg
vendored
Normal file
BIN
Plugins/DLSS/Source/ThirdParty/NGX/Utils/ngx_log_window_on.reg
vendored
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FIForestSpawner.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FIForestSpawner.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FINursery.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FINursery.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FITree.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/Blueprints/BP_FITree.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/DataDefinitions/FFIForestData.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/DataDefinitions/FFIForestData.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/DataDefinitions/ForestData.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/DataDefinitions/ForestData.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/EditorBlueprints/EBP_ForestImporter.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/EditorBlueprints/EBP_ForestImporter.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -0,0 +1,17 @@
|
||||
[
|
||||
{"Name":"1","x":"-15.12","y":"7.64","z":"-5.40682839506173","r":"0.0479799561281845","dbh":"9.6","h":"9.444"},
|
||||
{"Name":"2","x":"-6.88","y":"10.26","z":"-0.243574999999998","r":"0.0419804284258564","dbh":"8.4","h":"11.3532"},
|
||||
{"Name":"3","x":"-2.06999999999999","y":"10.64","z":"2.45335828877006","r":"0.190900975744225","dbh":"38.2","h":"9.707"},
|
||||
{"Name":"4","x":"-4.83","y":"14.3","z":"1.67841221122112","r":"0.143288313874472","dbh":"28.7","h":"10.4663"},
|
||||
{"Name":"5","x":"-15.92","y":"15.29","z":"-4.08376397058823","r":"0.25582628359995","dbh":"51.2","h":"13.2696"},
|
||||
{"Name":"6","x":"0.510000000000005","y":"15.66","z":"5.12503727272727","r":"0.248212293732132","dbh":"49.6","h":"10.5504"},
|
||||
{"Name":"7","x":"-15.5","y":"17.96","z":"-2.80311261682243","r":"0.207707718070789","dbh":"41.5","h":"10.5709"},
|
||||
{"Name":"8","x":"-5.98","y":"18.47","z":"2.27009333333334","r":"0.0690890157121087","dbh":"13.8","h":"11.7931"},
|
||||
{"Name":"9","x":"-14.43","y":"20.64","z":"-2.49187435897436","r":"0.224657636678472","dbh":"44.9","h":"11.1663"},
|
||||
{"Name":"10","x":"-3.3","y":"20.26","z":"4.4628838362069","r":"0.234632402008446","dbh":"46.9","h":"26.1493"},
|
||||
{"Name":"11","x":"-7.28","y":"21.27","z":"1.90214520958084","r":"0.122116516019407","dbh":"24.4","h":"8.8303"},
|
||||
{"Name":"12","x":"-5.36","y":"21.83","z":"3.32361354166667","r":"0.221026336614948","dbh":"44.2","h":"26.4361"},
|
||||
{"Name":"13","x":"-9.16","y":"23.43","z":"1.50600110132159","r":"0.276642239001447","dbh":"55.3","h":"9.0957"},
|
||||
{"Name":"14","x":"-9","y":"26.02","z":"2.61905555555556","r":"0.0254846663744571","dbh":"5.1","h":"23.765"},
|
||||
{"Name":"15","x":"-0.109999999999999","y":"27.19","z":"7.17721333333334","r":"0.159445021558632","dbh":"31.9","h":"25.2112"}
|
||||
]
|
||||
BIN
Plugins/ForestImporter/Content/Helpers/BP_Helpers.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/Helpers/BP_Helpers.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Plugins/ForestImporter/Content/Helpers/BP_MacroHelpers.uasset
(Stored with Git LFS)
Normal file
BIN
Plugins/ForestImporter/Content/Helpers/BP_MacroHelpers.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
Reference in New Issue
Block a user