2021-06-10 08:42:48 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "PostProcess/TemporalAA.h"
|
|
|
|
|
#include "PostProcess/PostProcessTonemap.h"
|
|
|
|
|
#include "PostProcess/PostProcessing.h"
|
|
|
|
|
#include "ClearQuad.h"
|
|
|
|
|
#include "PostProcessing.h"
|
|
|
|
|
#include "SceneTextureParameters.h"
|
|
|
|
|
#include "PixelShaderUtils.h"
|
|
|
|
|
#include "ScenePrivate.h"
|
|
|
|
|
#include "RendererModule.h"
|
|
|
|
|
|
|
|
|
|
#define COMPILE_TSR_DEBUG_PASSES (!UE_BUILD_SHIPPING)
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
TAutoConsoleVariable<float> CVarTSRHistorySP(
|
2022-01-07 10:12:38 -05:00
|
|
|
TEXT("r.TSR.History.ScreenPercentage"),
|
2021-06-10 08:42:48 -04:00
|
|
|
100.0f,
|
|
|
|
|
TEXT("Size of TSR's history."),
|
2022-01-03 06:45:53 -05:00
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
TAutoConsoleVariable<int32> CVarTSRR11G11B10History(
|
2022-01-07 10:12:38 -05:00
|
|
|
TEXT("r.TSR.History.R11G11B10"), 1,
|
2021-06-10 08:42:48 -04:00
|
|
|
TEXT("Select the bitdepth of the history."),
|
2022-01-07 10:12:38 -05:00
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
|
|
|
|
|
|
TAutoConsoleVariable<int32> CVarTSRHistoryUpdateQuality(
|
|
|
|
|
TEXT("r.TSR.History.UpdateQuality"), 3,
|
|
|
|
|
TEXT("Select the quality of the history update."),
|
|
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRHistoryHighFrequencyOnly(
|
|
|
|
|
TEXT("r.TSR.History.HighFrequencyOnly"), 0,
|
|
|
|
|
TEXT("Experimental store only high frequency in the history for performance saving (default = 0)."),
|
|
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRHalfResShadingRejection(
|
|
|
|
|
TEXT("r.TSR.ShadingRejection.HalfRes"), 0,
|
|
|
|
|
TEXT("Whether the shading rejection should be done at half res. Saves performance but may introduce back some flickering (default = 0)."),
|
|
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
|
|
|
|
TAutoConsoleVariable<int32> CVarTSRFilterShadingRejection(
|
|
|
|
|
TEXT("r.TSR.ShadingRejection.SpatialFilter"), 1,
|
|
|
|
|
TEXT("Whether the shading rejection should have spatial statistical filtering pass to reduce flickering (default = 1).\n")
|
|
|
|
|
TEXT(" 0: Disabled;\n")
|
|
|
|
|
TEXT(" 1: Spatial filter pass is run at lower resolution than CompareHistory pass (default);\n")
|
|
|
|
|
TEXT(" 2: Spatial filter pass is run CompareHistory pass resolution to improve stability."),
|
2022-01-07 10:12:38 -05:00
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRRejectionAntiAliasingQuality(
|
|
|
|
|
TEXT("r.TSR.RejectionAntiAliasingQuality"), 3,
|
|
|
|
|
TEXT("Controls the quality of spatial anti-aliasing on history rejection (default=1)."),
|
|
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
|
|
|
|
|
2022-03-17 06:13:37 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRAsyncCompute(
|
|
|
|
|
TEXT("r.TSR.AsyncCompute"), 0,
|
2022-05-31 04:53:12 -04:00
|
|
|
TEXT("Whether to run TSR on async compute. Some TSR passes can overlap with previous passe.\n")
|
|
|
|
|
TEXT(" 0: Disabled (default);\n")
|
|
|
|
|
TEXT(" 1: Only ClearPrevTextures pass;\n")
|
|
|
|
|
TEXT(" 2: Only ClearPrevTextures through DecimateHistory passes;\n")
|
|
|
|
|
TEXT(" 3: All passes;"),
|
2022-03-17 06:13:37 -04:00
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
2021-07-27 15:36:37 -04:00
|
|
|
TAutoConsoleVariable<float> CVarTSRTranslucencyHighlightLuminance(
|
|
|
|
|
TEXT("r.TSR.Translucency.HighlightLuminance"), -1.0f,
|
|
|
|
|
TEXT("Sets the liminance at which translucency is considered an highlights (default=-1.0)."),
|
|
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
2022-02-24 20:09:13 -05:00
|
|
|
//TAutoConsoleVariable<int32> CVarTSRTranslucencyPreviousFrameRejection(
|
|
|
|
|
// TEXT("r.TSR.Translucency.PreviousFrameRejection"), 0,
|
|
|
|
|
// TEXT("Enable heuristic to reject Separate translucency based on previous frame translucency."),
|
|
|
|
|
// ECVF_RenderThreadSafe);
|
2021-07-12 14:15:42 -04:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSREnableResponiveAA(
|
2021-07-12 14:15:42 -04:00
|
|
|
TEXT("r.TSR.Translucency.EnableResponiveAA"), 1,
|
|
|
|
|
TEXT("Whether the responsive AA should keep history fully clamped."),
|
2021-06-10 08:42:48 -04:00
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
2021-07-21 15:22:43 -04:00
|
|
|
TAutoConsoleVariable<float> CVarTSRWeightClampingPixelSpeed(
|
|
|
|
|
TEXT("r.TSR.Velocity.WeightClampingPixelSpeed"), 1.0f,
|
|
|
|
|
TEXT("Defines the pixel velocity at which the the high frequencies of the history get's their contributing weight clamped. ")
|
|
|
|
|
TEXT("Smallest reduce blur in movement (Default = 1.0f)."),
|
|
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
2022-01-04 06:33:05 -05:00
|
|
|
TAutoConsoleVariable<float> CVarTSRVelocityExtrapolation(
|
|
|
|
|
TEXT("r.TSR.Velocity.Extrapolation"), 1.0f,
|
|
|
|
|
TEXT("Defines how much the velocity should be extrapolated on geometric discontinuities (Default = 1.0f)."),
|
2022-01-07 10:12:38 -05:00
|
|
|
ECVF_Scalability | ECVF_RenderThreadSafe);
|
2022-01-04 06:33:05 -05:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
|
2022-05-09 13:33:38 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRDebugArraySize(
|
|
|
|
|
TEXT("r.TSR.Debug.ArraySize"), 1,
|
|
|
|
|
TEXT("Size of array for the TSR.Debug.* RDG textures"),
|
|
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
TAutoConsoleVariable<int32> CVarTSRSetupDebugPasses(
|
|
|
|
|
TEXT("r.TSR.Debug.SetupExtraPasses"), 0,
|
|
|
|
|
TEXT("Whether to enable the debug passes"),
|
|
|
|
|
ECVF_RenderThreadSafe);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRCommonParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, InputInfo)
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, LowFrequencyInfo)
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, RejectionInfo)
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, HistoryInfo)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, InputPixelPosMin)
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, InputPixelPosMax)
|
2021-12-03 10:04:47 -05:00
|
|
|
SHADER_PARAMETER(FScreenTransform, InputPixelPosToScreenPos)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
SHADER_PARAMETER(FVector2f, InputJitter)
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(int32, bCameraCut)
|
2021-12-03 13:11:15 -05:00
|
|
|
SHADER_PARAMETER(FVector2f, ScreenVelocityToInputPixelVelocity)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, InputPixelVelocityToScreenVelocity)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_STRUCT_REF(FViewUniformShaderParameters, ViewUniformBuffer)
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRHistoryArrayIndices, )
|
|
|
|
|
SHADER_PARAMETER(int32, LowFrequency)
|
|
|
|
|
SHADER_PARAMETER(int32, HighFrequency)
|
|
|
|
|
SHADER_PARAMETER(int32, Translucency)
|
2022-05-05 14:06:16 -04:00
|
|
|
SHADER_PARAMETER(int32, Size)
|
2022-05-03 09:58:40 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRHistoryTextures, )
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistoryArrayIndices, ArrayIndices)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2DArray, ColorArray)
|
2022-03-18 18:51:06 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, HighFrequencyHalfRes)
|
2021-07-13 14:26:09 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, Metadata)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SubpixelDetails)
|
2021-07-27 15:36:37 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, TranslucencyAlpha)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, )
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, LowFrequency)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, HighFrequency)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, HighFrequencyHalfRes)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, Metadata)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, SubpixelDetails)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, Translucency)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, TranslucencyAlpha)
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRHistoryUAVs, )
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistoryArrayIndices, ArrayIndices)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, ColorArray)
|
2022-03-18 18:51:06 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HighFrequencyHalfRes)
|
2021-07-13 14:26:09 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, Metadata)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, SubpixelDetails)
|
2021-07-27 15:36:37 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, TranslucencyAlpha)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FTSRPrevHistoryParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, PrevHistoryInfo)
|
|
|
|
|
SHADER_PARAMETER(FScreenTransform, ScreenPosToPrevHistoryBufferUV)
|
2022-03-21 14:42:53 -04:00
|
|
|
SHADER_PARAMETER(FScreenTransform, ScreenPosToPrevSubpixelDetails)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, PrevSubpixelDetailsExtent)
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(float, HistoryPreExposureCorrection)
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
2022-05-05 14:06:16 -04:00
|
|
|
enum class ETSRHistoryFormatBits : uint32
|
|
|
|
|
{
|
|
|
|
|
LowFrequency = 1 << 0,
|
|
|
|
|
Translucency = 1 << 1,
|
|
|
|
|
};
|
|
|
|
|
ENUM_CLASS_FLAGS(ETSRHistoryFormatBits);
|
|
|
|
|
|
|
|
|
|
FTSRHistoryArrayIndices TranslateHistoryFormatBitsToArrayIndices(ETSRHistoryFormatBits HistoryFormatBits)
|
|
|
|
|
{
|
|
|
|
|
FTSRHistoryArrayIndices ArrayIndices;
|
|
|
|
|
ArrayIndices.Size = 2;
|
|
|
|
|
ArrayIndices.HighFrequency = 0;
|
|
|
|
|
ArrayIndices.Translucency = 1;
|
|
|
|
|
|
|
|
|
|
if (EnumHasAnyFlags(HistoryFormatBits, ETSRHistoryFormatBits::LowFrequency))
|
|
|
|
|
{
|
|
|
|
|
ArrayIndices.LowFrequency = ArrayIndices.Size;
|
|
|
|
|
ArrayIndices.Size += 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ArrayIndices.LowFrequency = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ArrayIndices;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
FTSRHistorySRVs CreateSRVs(FRDGBuilder& GraphBuilder, const FTSRHistoryTextures& Textures)
|
|
|
|
|
{
|
|
|
|
|
FTSRHistorySRVs SRVs;
|
|
|
|
|
if (Textures.ArrayIndices.LowFrequency >= 0)
|
|
|
|
|
{
|
|
|
|
|
SRVs.LowFrequency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateForSlice(Textures.ColorArray, Textures.ArrayIndices.LowFrequency));
|
|
|
|
|
}
|
|
|
|
|
SRVs.HighFrequency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateForSlice(Textures.ColorArray, Textures.ArrayIndices.HighFrequency));
|
|
|
|
|
if (Textures.HighFrequencyHalfRes)
|
|
|
|
|
{
|
|
|
|
|
SRVs.HighFrequencyHalfRes = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(Textures.HighFrequencyHalfRes));
|
|
|
|
|
}
|
|
|
|
|
SRVs.Metadata = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(Textures.Metadata));
|
|
|
|
|
SRVs.SubpixelDetails = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(Textures.SubpixelDetails));
|
|
|
|
|
SRVs.Translucency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::CreateForSlice(Textures.ColorArray, Textures.ArrayIndices.Translucency));
|
|
|
|
|
SRVs.TranslucencyAlpha = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(Textures.TranslucencyAlpha)); // TODO: move into metadata
|
|
|
|
|
return SRVs;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
FTSRHistoryUAVs CreateUAVs(FRDGBuilder& GraphBuilder, const FTSRHistoryTextures& Textures)
|
|
|
|
|
{
|
|
|
|
|
FTSRHistoryUAVs UAVs;
|
2022-05-03 09:58:40 -04:00
|
|
|
UAVs.ArrayIndices = Textures.ArrayIndices;
|
|
|
|
|
UAVs.ColorArray = GraphBuilder.CreateUAV(Textures.ColorArray);
|
2022-03-18 18:51:06 -04:00
|
|
|
if (Textures.HighFrequencyHalfRes)
|
|
|
|
|
{
|
|
|
|
|
UAVs.HighFrequencyHalfRes = GraphBuilder.CreateUAV(Textures.HighFrequencyHalfRes);
|
|
|
|
|
}
|
2021-07-13 14:26:09 -04:00
|
|
|
UAVs.Metadata = GraphBuilder.CreateUAV(Textures.Metadata);
|
|
|
|
|
UAVs.SubpixelDetails = GraphBuilder.CreateUAV(Textures.SubpixelDetails);
|
2022-03-10 22:02:57 -05:00
|
|
|
UAVs.TranslucencyAlpha = GraphBuilder.CreateUAV(Textures.TranslucencyAlpha); // TODO: move into metadata
|
2021-06-10 08:42:48 -04:00
|
|
|
return UAVs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FTSRShader : public FGlobalShader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FTSRShader(const ShaderMetaType::CompiledShaderInitializerType& Initializer)
|
|
|
|
|
: FGlobalShader(Initializer)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
FTSRShader()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
|
|
|
{
|
2021-06-23 11:54:40 -04:00
|
|
|
return SupportsTSR(Parameters.Platform);
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
2022-04-06 13:43:51 -04:00
|
|
|
if (FDataDrivenShaderPlatformInfo::GetSupportsRealTypes(Parameters.Platform) == ERHIFeatureSupport::RuntimeGuaranteed)
|
|
|
|
|
{
|
|
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_AllowRealTypes);
|
|
|
|
|
}
|
2022-01-21 06:47:55 -05:00
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_WarningsAsErrors);
|
2022-03-29 12:07:21 -04:00
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_HLSL2021);
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
}; // class FTemporalSuperResolutionShader
|
|
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
class FTSRHighFrequencyOnlyDim : SHADER_PERMUTATION_BOOL("DIM_HIGH_FREQUENCY_ONLY");
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
class FTSRClearPrevTexturesCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRClearPrevTexturesCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRClearPrevTexturesCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, PrevUseCountOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, PrevClosestDepthOutput)
|
|
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRClearPrevTexturesCS
|
|
|
|
|
|
|
|
|
|
class FTSRDilateVelocityCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRDilateVelocityCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRDilateVelocityCS, FTSRShader);
|
|
|
|
|
|
2021-12-03 13:05:09 -05:00
|
|
|
class FMotionBlurDirectionsDim : SHADER_PERMUTATION_INT("DIM_MOTION_BLUR_DIRECTIONS", 3);
|
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FMotionBlurDirectionsDim>;
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
2021-12-03 13:05:09 -05:00
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FVelocityFlattenParameters, VelocityFlattenParameters)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2021-11-18 14:37:34 -05:00
|
|
|
SHADER_PARAMETER(FVector2f, PrevOutputBufferUVMin)
|
|
|
|
|
SHADER_PARAMETER(FVector2f, PrevOutputBufferUVMax)
|
2021-08-25 13:01:57 -04:00
|
|
|
SHADER_PARAMETER(float, WorldDepthToDepthError)
|
2022-01-04 06:33:05 -05:00
|
|
|
SHADER_PARAMETER(float, VelocityExtrapolationMultiplier)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneDepthTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, SceneVelocityTexture)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, DilatedVelocityOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, ClosestDepthOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, PrevUseCountOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, PrevClosestDepthOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, ParallaxFactorOutput)
|
2021-12-03 13:05:09 -05:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, VelocityFlattenOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, VelocityTileOutput0)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, VelocityTileOutput1)
|
|
|
|
|
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRDilateVelocityCS
|
|
|
|
|
|
|
|
|
|
class FTSRDecimateHistoryCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRDecimateHistoryCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRDecimateHistoryCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
class FOutputHalfRes : SHADER_PERMUTATION_BOOL("DIM_OUTPUT_HALF_RES");
|
|
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FTSRHighFrequencyOnlyDim, FOutputHalfRes>;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
2022-03-29 12:07:21 -04:00
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRPrevHistoryParameters, PrevHistoryParameters)
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(FMatrix44f, RotationalClipToPrevClip)
|
|
|
|
|
SHADER_PARAMETER(FVector3f, OutputQuantizationError)
|
|
|
|
|
SHADER_PARAMETER(float, WorldDepthToPixelWorldRadius)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneColorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, DilatedVelocityTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ClosestDepthTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, PrevUseCountTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, PrevClosestDepthTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ParallaxFactorTexture)
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, PrevHistory)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HalfResSceneColorOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HalfResPredictionSceneColorOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HalfResParallaxRejectionMaskOutput)
|
2022-03-18 18:51:06 -04:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, PredictionSceneColorOutput)
|
2022-03-18 18:51:06 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HoleFilledVelocityOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HoleFilledVelocityMaskOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, ParallaxRejectionMaskOutput)
|
2022-03-21 14:42:53 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HistorySubpixelDetailsOutput)
|
2022-03-18 18:51:06 -04:00
|
|
|
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRDecimateHistoryCS
|
|
|
|
|
|
|
|
|
|
class FTSRCompareTranslucencyCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRCompareTranslucencyCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRCompareTranslucencyCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, TranslucencyInfo)
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, PrevTranslucencyInfo)
|
|
|
|
|
SHADER_PARAMETER(float, PrevTranslucencyPreExposureCorrection)
|
2021-07-27 15:36:37 -04:00
|
|
|
SHADER_PARAMETER(float, TranslucencyHighlightLuminance)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER(FScreenTransform, ScreenPosToPrevTranslucencyTextureUV)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, DilatedVelocityTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, TranslucencyTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, PrevTranslucencyTexture)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, TranslucencyRejectionOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRCompareTranslucencyCS
|
|
|
|
|
|
|
|
|
|
class FTSRFilterFrequenciesCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRFilterFrequenciesCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRFilterFrequenciesCS, FTSRShader);
|
|
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
class FOutputAALumaDim : SHADER_PERMUTATION_BOOL("DIM_OUTPUT_ANTI_ALIASING_LUMA");
|
|
|
|
|
|
2021-12-16 19:28:03 -05:00
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FOutputAALumaDim>;
|
2021-06-22 12:07:46 -04:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER(FVector3f, OutputQuantizationError)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, PredictionSceneColorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ParallaxRejectionMaskTexture)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, FilteredInputOutput)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, FilteredPredictionSceneColorOutput)
|
2021-06-22 12:07:46 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, InputSceneColorLdrLumaOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRFilterFrequenciesCS
|
|
|
|
|
|
|
|
|
|
class FTSRCompareHistoryCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRCompareHistoryCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRCompareHistoryCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
class FOutputHalfRes : SHADER_PERMUTATION_BOOL("DIM_OUTPUT_HALF_RES");
|
2021-12-16 19:28:03 -05:00
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FOutputHalfRes>;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ParallaxRejectionMaskTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, FilteredInputTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, FilteredPredictionSceneColorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HistoryRejectionOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRCompareHistoryCS
|
|
|
|
|
|
|
|
|
|
class FTSRPostfilterRejectionCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRPostfilterRejectionCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRPostfilterRejectionCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
class FOutputHalfRes : SHADER_PERMUTATION_BOOL("DIM_OUTPUT_HALF_RES");
|
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FOutputHalfRes>;
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER(FIntRect, HistoryRejectionViewport)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, HistoryRejectionTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, HistoryRejectionOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRPostfilterRejectionCS
|
|
|
|
|
|
|
|
|
|
class FTSRDilateRejectionCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRDilateRejectionCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRDilateRejectionCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, HistoryRejectionTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, DilatedHistoryRejectionOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRDilateRejectionCS
|
|
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
class FTSRSpatialAntiAliasingCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRSpatialAntiAliasingCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRSpatialAntiAliasingCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
class FQualityDim : SHADER_PERMUTATION_INT("DIM_QUALITY_PRESET", 3);
|
|
|
|
|
|
|
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FQualityDim>;
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneColorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneColorLdrLumaTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, AntiAliasingOutput)
|
2021-09-06 16:11:26 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, NoiseFilteringOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-22 12:07:46 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
|
|
|
|
static bool ShouldCompilePermutation(const FGlobalShaderPermutationParameters& Parameters)
|
|
|
|
|
{
|
|
|
|
|
FPermutationDomain PermutationVector(Parameters.PermutationId);
|
|
|
|
|
|
|
|
|
|
// There is no Quality=0 because the pass doesn't get setup.
|
|
|
|
|
if (PermutationVector.Get<FQualityDim>() == 0)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FTSRShader::ShouldCompilePermutation(Parameters);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FTSRShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Wave32);
|
|
|
|
|
}
|
|
|
|
|
}; // class FTSRSpatialAntiAliasingCS
|
|
|
|
|
|
|
|
|
|
class FTSRFilterAntiAliasingCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRFilterAntiAliasingCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRFilterAntiAliasingCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, AntiAliasingTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, AntiAliasingOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-22 12:07:46 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
}; // class FTSRFilterAntiAliasingCS
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
class FTSRUpdateHistoryCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRUpdateHistoryCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRUpdateHistoryCS, FTSRShader);
|
|
|
|
|
|
2022-01-07 10:12:38 -05:00
|
|
|
enum class EQuality
|
|
|
|
|
{
|
|
|
|
|
Low,
|
|
|
|
|
Medium,
|
|
|
|
|
High,
|
|
|
|
|
Epic,
|
|
|
|
|
MAX
|
|
|
|
|
};
|
2021-06-22 12:07:46 -04:00
|
|
|
|
2022-01-07 10:12:38 -05:00
|
|
|
class FQualityDim : SHADER_PERMUTATION_ENUM_CLASS("DIM_UPDATE_QUALITY", EQuality);
|
|
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FTSRHighFrequencyOnlyDim, FQualityDim>;
|
2021-06-22 12:07:46 -04:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneColorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_SRV(Texture2D, InputSceneStencilTexture)
|
2021-07-12 14:15:42 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, InputSceneTranslucencyTexture)
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, HistoryRejectionTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, TranslucencyRejectionTexture)
|
|
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, DilatedVelocityTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ParallaxFactorTexture)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, ParallaxRejectionMaskTexture)
|
2021-06-22 12:07:46 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, AntiAliasingTexture)
|
2021-09-06 16:11:26 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, NoiseFilteringTexture)
|
2021-12-03 03:42:40 -05:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE(Texture2D, HoleFilledVelocityMaskTexture)
|
2022-05-31 01:21:02 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FScreenPassTextureViewportParameters, TranslucencyInfo)
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, TranslucencyPixelPosMin)
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, TranslucencyPixelPosMax)
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(FScreenTransform, HistoryPixelPosToScreenPos)
|
2022-05-31 01:21:02 -04:00
|
|
|
SHADER_PARAMETER(FScreenTransform, HistoryPixelPosToInputPPCo)
|
|
|
|
|
SHADER_PARAMETER(FScreenTransform, HistoryPixelPosToTranslucencyPPCo)
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(FVector3f, HistoryQuantizationError)
|
|
|
|
|
SHADER_PARAMETER(float, MinTranslucencyRejection)
|
2021-07-21 15:22:43 -04:00
|
|
|
SHADER_PARAMETER(float, InvWeightClampingPixelSpeed)
|
2021-09-06 16:11:26 -04:00
|
|
|
SHADER_PARAMETER(float, InputToHistoryFactor)
|
2021-06-10 08:42:48 -04:00
|
|
|
SHADER_PARAMETER(int32, ResponsiveStencilMask)
|
2021-12-03 12:40:10 -05:00
|
|
|
SHADER_PARAMETER(int32, bGenerateOutputMip1)
|
2022-03-10 22:02:57 -05:00
|
|
|
SHADER_PARAMETER(int32, bHasSeparateTranslucency)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRPrevHistoryParameters, PrevHistoryParameters)
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, PrevHistory)
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2021-12-03 12:40:10 -05:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, SceneColorOutputMip0)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, SceneColorOutputMip1)
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistoryUAVs, HistoryOutput)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2021-06-10 08:42:48 -04:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
|
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FTSRShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_Wave32);
|
|
|
|
|
}
|
|
|
|
|
}; // class FTSRUpdateHistoryCS
|
|
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
class FTSRResolveHistoryCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRResolveHistoryCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRResolveHistoryCS, FTSRShader);
|
|
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
using FPermutationDomain = TShaderPermutationDomain<FTSRHighFrequencyOnlyDim>;
|
2022-03-01 14:36:09 -05:00
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
|
|
|
|
SHADER_PARAMETER(FScreenTransform, DispatchThreadToHistoryPixelPos)
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, OutputViewRectMin)
|
|
|
|
|
SHADER_PARAMETER(FIntPoint, OutputViewRectMax)
|
|
|
|
|
SHADER_PARAMETER(int32, bGenerateOutputMip1)
|
|
|
|
|
SHADER_PARAMETER(float, HistoryValidityMultiply)
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, History)
|
2022-01-03 06:45:53 -05:00
|
|
|
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, SceneColorOutputMip0)
|
|
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2D, SceneColorOutputMip1)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2022-01-03 06:45:53 -05:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
2022-01-23 07:15:43 -05:00
|
|
|
|
|
|
|
|
static void ModifyCompilationEnvironment(const FGlobalShaderPermutationParameters& Parameters, FShaderCompilerEnvironment& OutEnvironment)
|
|
|
|
|
{
|
|
|
|
|
FTSRShader::ModifyCompilationEnvironment(Parameters, OutEnvironment);
|
|
|
|
|
OutEnvironment.CompilerFlags.Add(CFLAG_ForceOptimization);
|
|
|
|
|
}
|
2022-01-03 06:45:53 -05:00
|
|
|
}; // class FTSRResolveHistoryCS
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
|
|
|
|
|
class FTSRDebugHistoryCS : public FTSRShader
|
|
|
|
|
{
|
|
|
|
|
DECLARE_GLOBAL_SHADER(FTSRDebugHistoryCS);
|
|
|
|
|
SHADER_USE_PARAMETER_STRUCT(FTSRDebugHistoryCS, FTSRShader);
|
|
|
|
|
|
|
|
|
|
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
|
|
|
|
|
SHADER_PARAMETER_STRUCT_INCLUDE(FTSRCommonParameters, CommonParameters)
|
2022-05-03 09:58:40 -04:00
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, History)
|
|
|
|
|
SHADER_PARAMETER_STRUCT(FTSRHistorySRVs, PrevHistory)
|
2022-05-09 13:33:38 -04:00
|
|
|
SHADER_PARAMETER_RDG_TEXTURE_UAV(RWTexture2DArray, DebugOutput)
|
2022-01-03 06:45:53 -05:00
|
|
|
END_SHADER_PARAMETER_STRUCT()
|
2021-06-10 08:42:48 -04:00
|
|
|
}; // class FTSRDebugHistoryCS
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRClearPrevTexturesCS, "/Engine/Private/TemporalSuperResolution/TSRClearPrevTextures.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRDilateVelocityCS, "/Engine/Private/TemporalSuperResolution/TSRDilateVelocity.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRDecimateHistoryCS, "/Engine/Private/TemporalSuperResolution/TSRDecimateHistory.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRCompareTranslucencyCS, "/Engine/Private/TemporalSuperResolution/TSRCompareTranslucency.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRFilterFrequenciesCS, "/Engine/Private/TemporalSuperResolution/TSRFilterFrequencies.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRCompareHistoryCS, "/Engine/Private/TemporalSuperResolution/TSRCompareHistory.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRPostfilterRejectionCS, "/Engine/Private/TemporalSuperResolution/TSRPostfilterRejection.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRDilateRejectionCS, "/Engine/Private/TemporalSuperResolution/TSRDilateRejection.usf", "MainCS", SF_Compute);
|
2021-06-22 12:07:46 -04:00
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRSpatialAntiAliasingCS, "/Engine/Private/TemporalSuperResolution/TSRSpatialAntiAliasing.usf", "MainCS", SF_Compute);
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRFilterAntiAliasingCS, "/Engine/Private/TemporalSuperResolution/TSRFilterAntiAliasing.usf", "MainCS", SF_Compute);
|
2021-06-10 08:42:48 -04:00
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRUpdateHistoryCS, "/Engine/Private/TemporalSuperResolution/TSRUpdateHistory.usf", "MainCS", SF_Compute);
|
2022-01-03 06:45:53 -05:00
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRResolveHistoryCS, "/Engine/Private/TemporalSuperResolution/TSRResolveHistory.usf", "MainCS", SF_Compute);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
IMPLEMENT_GLOBAL_SHADER(FTSRDebugHistoryCS, "/Engine/Private/TemporalSuperResolution/TSRDebugHistory.usf", "MainCS", SF_Compute);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
DECLARE_GPU_STAT(TemporalSuperResolution)
|
|
|
|
|
|
|
|
|
|
} //! namespace
|
|
|
|
|
|
|
|
|
|
FVector ComputePixelFormatQuantizationError(EPixelFormat PixelFormat);
|
|
|
|
|
|
2021-07-12 14:15:42 -04:00
|
|
|
bool ComposeSeparateTranslucencyInTSR(const FViewInfo& View)
|
|
|
|
|
{
|
2022-03-10 22:02:57 -05:00
|
|
|
return true;
|
2021-07-12 14:15:42 -04:00
|
|
|
}
|
|
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
static FRDGTextureUAVRef CreateDummyUAV(FRDGBuilder& GraphBuilder, EPixelFormat PixelFormat)
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
FIntPoint(1, 1),
|
|
|
|
|
PixelFormat,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
FRDGTextureRef DummyTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.DummyOutput"));
|
|
|
|
|
GraphBuilder.RemoveUnusedTextureWarning(DummyTexture);
|
|
|
|
|
|
|
|
|
|
return GraphBuilder.CreateUAV(DummyTexture);
|
|
|
|
|
};
|
|
|
|
|
|
2021-12-03 13:05:09 -05:00
|
|
|
ITemporalUpscaler::FOutputs AddTemporalSuperResolutionPasses(
|
2021-06-10 08:42:48 -04:00
|
|
|
FRDGBuilder& GraphBuilder,
|
|
|
|
|
const FViewInfo& View,
|
2021-12-03 13:05:09 -05:00
|
|
|
const ITemporalUpscaler::FPassInputs& PassInputs)
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
2021-07-13 14:26:09 -04:00
|
|
|
const FTSRHistory& InputHistory = View.PrevViewInfo.TSRHistory;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
const bool bSetupDebugPasses = CVarTSRSetupDebugPasses.GetValueOnRenderThread() != 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-18 12:17:21 -05:00
|
|
|
// Whether alpha channel is supported.
|
|
|
|
|
const bool bSupportsAlpha = IsPostProcessingWithAlphaChannelSupported();
|
|
|
|
|
|
2022-03-17 06:13:37 -04:00
|
|
|
// whether TSR passes can run on async compute.
|
2022-05-31 04:53:12 -04:00
|
|
|
int32 AsyncComputePasses = GSupportsEfficientAsyncCompute ? CVarTSRAsyncCompute.GetValueOnRenderThread() : 0;
|
2022-03-17 06:13:37 -04:00
|
|
|
|
2022-05-05 14:06:16 -04:00
|
|
|
const bool bHistoryHighFrequencyOnly = CVarTSRHistoryHighFrequencyOnly.GetValueOnRenderThread() != 0;
|
|
|
|
|
|
|
|
|
|
ETSRHistoryFormatBits HistoryFormatBits;
|
|
|
|
|
{
|
|
|
|
|
HistoryFormatBits = ETSRHistoryFormatBits::Translucency;
|
|
|
|
|
if (!bHistoryHighFrequencyOnly)
|
|
|
|
|
{
|
|
|
|
|
HistoryFormatBits |= ETSRHistoryFormatBits::LowFrequency;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
// Whether to use camera cut shader permutation or not.
|
2022-05-05 14:06:16 -04:00
|
|
|
bool bCameraCut = !InputHistory.IsValid() || View.bCameraCut || ETSRHistoryFormatBits(InputHistory.FormatBit) != HistoryFormatBits;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-01-07 10:12:38 -05:00
|
|
|
FTSRUpdateHistoryCS::EQuality UpdateHistoryQuality = FTSRUpdateHistoryCS::EQuality(FMath::Clamp(CVarTSRHistoryUpdateQuality.GetValueOnRenderThread(), 0, int32(FTSRUpdateHistoryCS::EQuality::MAX) - 1));
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
bool bHalfResLowFrequency = CVarTSRHalfResShadingRejection.GetValueOnRenderThread() != 0;
|
|
|
|
|
|
2022-01-28 08:13:09 -05:00
|
|
|
bool bIsSeperateTranslucyTexturesValid = PassInputs.PostDOFTranslucencyResources.IsValid();
|
2021-07-12 14:15:42 -04:00
|
|
|
|
2022-02-24 20:09:13 -05:00
|
|
|
const bool bRejectSeparateTranslucency = false; // bIsSeperateTranslucyTexturesValid && CVarTSRTranslucencyPreviousFrameRejection.GetValueOnRenderThread() != 0;
|
2021-08-09 10:04:37 -04:00
|
|
|
|
2022-03-18 18:51:06 -04:00
|
|
|
// Whether the UpdateHistory pass also output half res history to reduce memory bottleneck up the FTSRDecimateHistoryCS.
|
|
|
|
|
const bool bHalfResHistory = bHistoryHighFrequencyOnly;
|
|
|
|
|
|
2022-03-21 14:42:53 -04:00
|
|
|
// Whether the subpixel details are stored at input or output resolution
|
|
|
|
|
const bool bSubPixelDetailsAtOutputResolution = !bHistoryHighFrequencyOnly;
|
|
|
|
|
|
2022-01-18 12:17:21 -05:00
|
|
|
EPixelFormat ColorFormat = bSupportsAlpha ? PF_FloatRGBA : PF_FloatR11G11B10;
|
|
|
|
|
|
2022-01-07 10:12:38 -05:00
|
|
|
int32 RejectionAntiAliasingQuality = FMath::Clamp(CVarTSRRejectionAntiAliasingQuality.GetValueOnRenderThread(), 1, 2);
|
|
|
|
|
if (UpdateHistoryQuality == FTSRUpdateHistoryCS::EQuality::Low)
|
|
|
|
|
{
|
|
|
|
|
RejectionAntiAliasingQuality = 0;
|
|
|
|
|
}
|
2021-06-22 12:07:46 -04:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
enum class ERejectionPostFilter : uint8
|
|
|
|
|
{
|
|
|
|
|
Disabled,
|
|
|
|
|
PostRejectionDownsample,
|
|
|
|
|
PreRejectionDownsample,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ERejectionPostFilter PostFilter = ERejectionPostFilter(FMath::Clamp(CVarTSRFilterShadingRejection.GetValueOnRenderThread(), 0, 2));
|
|
|
|
|
|
|
|
|
|
FIntPoint InputExtent = PassInputs.SceneColorTexture->Desc.Extent;
|
|
|
|
|
FIntRect InputRect = View.ViewRect;
|
|
|
|
|
|
|
|
|
|
FIntPoint LowFrequencyExtent = InputExtent;
|
2022-02-14 12:28:20 -05:00
|
|
|
FIntRect LowFrequencyRect = InputRect;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
if (bHalfResLowFrequency)
|
|
|
|
|
{
|
|
|
|
|
LowFrequencyExtent = InputExtent / 2;
|
|
|
|
|
LowFrequencyRect = FIntRect(FIntPoint(0, 0), FIntPoint::DivideAndRoundUp(InputRect.Size(), 2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FIntPoint RejectionExtent = LowFrequencyExtent / 2;
|
|
|
|
|
FIntRect RejectionRect = FIntRect(FIntPoint(0, 0), FIntPoint::DivideAndRoundUp(LowFrequencyRect.Size(), 2));
|
|
|
|
|
|
|
|
|
|
FIntPoint OutputExtent;
|
|
|
|
|
FIntRect OutputRect;
|
|
|
|
|
if (View.PrimaryScreenPercentageMethod == EPrimaryScreenPercentageMethod::TemporalUpscale)
|
|
|
|
|
{
|
|
|
|
|
OutputRect.Min = FIntPoint(0, 0);
|
|
|
|
|
OutputRect.Max = View.GetSecondaryViewRectSize();
|
|
|
|
|
|
|
|
|
|
FIntPoint QuantizedPrimaryUpscaleViewSize;
|
|
|
|
|
QuantizeSceneBufferSize(OutputRect.Max, QuantizedPrimaryUpscaleViewSize);
|
|
|
|
|
|
|
|
|
|
OutputExtent = FIntPoint(
|
|
|
|
|
FMath::Max(InputExtent.X, QuantizedPrimaryUpscaleViewSize.X),
|
|
|
|
|
FMath::Max(InputExtent.Y, QuantizedPrimaryUpscaleViewSize.Y));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OutputRect.Min = FIntPoint(0, 0);
|
|
|
|
|
OutputRect.Max = View.ViewRect.Size();
|
|
|
|
|
OutputExtent = InputExtent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FIntPoint HistoryExtent;
|
|
|
|
|
FIntPoint HistorySize;
|
|
|
|
|
{
|
2022-01-03 10:08:20 -05:00
|
|
|
float MaxHistoryUpscaleFactor = FMath::Max(float(GMaxTextureDimensions) / float(FMath::Max(OutputRect.Width(), OutputRect.Height())), 1.0f);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-01-03 10:08:20 -05:00
|
|
|
float HistoryUpscaleFactor = FMath::Clamp(CVarTSRHistorySP.GetValueOnRenderThread() / 100.0f, 1.0f, 2.0f);
|
|
|
|
|
if (HistoryUpscaleFactor > MaxHistoryUpscaleFactor)
|
|
|
|
|
{
|
|
|
|
|
HistoryUpscaleFactor = 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
HistorySize = FIntPoint(
|
2022-01-03 10:08:20 -05:00
|
|
|
FMath::CeilToInt(OutputRect.Width() * HistoryUpscaleFactor),
|
|
|
|
|
FMath::CeilToInt(OutputRect.Height() * HistoryUpscaleFactor));
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
FIntPoint QuantizedHistoryViewSize;
|
|
|
|
|
QuantizeSceneBufferSize(HistorySize, QuantizedHistoryViewSize);
|
|
|
|
|
|
|
|
|
|
HistoryExtent = FIntPoint(
|
|
|
|
|
FMath::Max(InputExtent.X, QuantizedHistoryViewSize.X),
|
|
|
|
|
FMath::Max(InputExtent.Y, QuantizedHistoryViewSize.Y));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 10:04:47 -05:00
|
|
|
float ScreenPercentage = float(InputRect.Width()) / float(OutputRect.Width());
|
|
|
|
|
float InvScreenPercentage = float(OutputRect.Width()) / float(InputRect.Width());
|
|
|
|
|
|
2022-01-18 12:17:21 -05:00
|
|
|
RDG_EVENT_SCOPE(GraphBuilder, "TemporalSuperResolution(%s) %dx%d -> %dx%d",
|
|
|
|
|
bSupportsAlpha ? TEXT("Alpha") : TEXT(""),
|
|
|
|
|
InputRect.Width(), InputRect.Height(),
|
|
|
|
|
OutputRect.Width(), OutputRect.Height());
|
2021-06-10 08:42:48 -04:00
|
|
|
RDG_GPU_STAT_SCOPE(GraphBuilder, TemporalSuperResolution);
|
|
|
|
|
|
|
|
|
|
FRDGTextureRef BlackUintDummy = GSystemTextures.GetZeroUIntDummy(GraphBuilder);
|
2021-12-03 10:04:47 -05:00
|
|
|
FRDGTextureRef BlackDummy = GSystemTextures.GetBlackDummy(GraphBuilder);
|
2022-01-28 08:13:09 -05:00
|
|
|
FRDGTextureRef BlackAlphaOneDummy = GSystemTextures.GetBlackAlphaOneDummy(GraphBuilder);
|
2021-12-03 10:04:47 -05:00
|
|
|
FRDGTextureRef WhiteDummy = GSystemTextures.GetWhiteDummy(GraphBuilder);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
FIntRect SeparateTranslucencyRect = FIntRect(0, 0, 1, 1);
|
|
|
|
|
FRDGTextureRef SeparateTranslucencyTexture = BlackAlphaOneDummy;
|
|
|
|
|
bool bHasSeparateTranslucency = PassInputs.PostDOFTranslucencyResources.IsValid();
|
|
|
|
|
if (bHasSeparateTranslucency)
|
2022-01-28 08:13:09 -05:00
|
|
|
{
|
|
|
|
|
SeparateTranslucencyTexture = PassInputs.PostDOFTranslucencyResources.ColorTexture.Resolve;
|
|
|
|
|
SeparateTranslucencyRect = PassInputs.PostDOFTranslucencyResources.ViewRect;
|
|
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
FTSRCommonParameters CommonParameters;
|
|
|
|
|
{
|
|
|
|
|
CommonParameters.InputInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
|
|
|
|
InputExtent, InputRect));
|
|
|
|
|
CommonParameters.InputPixelPosMin = CommonParameters.InputInfo.ViewportMin;
|
|
|
|
|
CommonParameters.InputPixelPosMax = CommonParameters.InputInfo.ViewportMax - 1;
|
2022-02-14 12:28:20 -05:00
|
|
|
CommonParameters.InputPixelPosToScreenPos = (FScreenTransform::Identity + 0.5f) * FScreenTransform::ChangeTextureBasisFromTo(FScreenPassTextureViewport(
|
|
|
|
|
InputExtent, InputRect), FScreenTransform::ETextureBasis::TexelPosition, FScreenTransform::ETextureBasis::ScreenPosition);
|
2021-12-03 10:04:47 -05:00
|
|
|
CommonParameters.ScreenVelocityToInputPixelVelocity = (FScreenTransform::Identity / CommonParameters.InputPixelPosToScreenPos).Scale;
|
2021-12-16 19:10:30 -05:00
|
|
|
CommonParameters.InputPixelVelocityToScreenVelocity = CommonParameters.InputPixelPosToScreenPos.Scale.GetAbs();
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
CommonParameters.LowFrequencyInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
|
|
|
|
LowFrequencyExtent, LowFrequencyRect));
|
|
|
|
|
|
|
|
|
|
CommonParameters.RejectionInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
|
|
|
|
RejectionExtent, RejectionRect));
|
|
|
|
|
|
|
|
|
|
CommonParameters.HistoryInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
|
|
|
|
HistoryExtent, FIntRect(FIntPoint(0, 0), HistorySize)));
|
|
|
|
|
|
2022-02-02 01:43:41 -05:00
|
|
|
CommonParameters.InputJitter = FVector2f(View.TemporalJitterPixels);
|
2021-06-10 08:42:48 -04:00
|
|
|
CommonParameters.bCameraCut = bCameraCut;
|
|
|
|
|
CommonParameters.ViewUniformBuffer = View.ViewUniformBuffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto CreateDebugUAV = [&](const FIntPoint& Extent, const TCHAR* DebugName)
|
|
|
|
|
{
|
2022-05-09 13:33:38 -04:00
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
uint16 ArraySize = uint16(FMath::Clamp(CVarTSRDebugArraySize.GetValueOnRenderThread(), 1, GMaxTextureArrayLayers));
|
|
|
|
|
#else
|
|
|
|
|
const uint16 ArraySize = 1;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
FRDGTextureDesc DebugDesc = FRDGTextureDesc::Create2DArray(
|
2021-06-10 08:42:48 -04:00
|
|
|
Extent,
|
|
|
|
|
PF_FloatRGBA,
|
|
|
|
|
FClearValueBinding::None,
|
2022-05-09 13:33:38 -04:00
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV,
|
|
|
|
|
ArraySize);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
FRDGTextureRef DebugTexture = GraphBuilder.CreateTexture(DebugDesc, DebugName);
|
|
|
|
|
|
|
|
|
|
return GraphBuilder.CreateUAV(DebugTexture);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Clear atomic scattered texture.
|
|
|
|
|
FRDGTextureRef PrevUseCountTexture;
|
|
|
|
|
FRDGTextureRef PrevClosestDepthTexture;
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_R32_UINT,
|
|
|
|
|
FClearValueBinding::None,
|
2021-08-24 05:51:25 -04:00
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV | TexCreate_AtomicCompatible);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
PrevUseCountTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.PrevUseCountTexture"));
|
|
|
|
|
PrevClosestDepthTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.PrevClosestDepthTexture"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTSRClearPrevTexturesCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRClearPrevTexturesCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->PrevUseCountOutput = GraphBuilder.CreateUAV(PrevUseCountTexture);
|
|
|
|
|
PassParameters->PrevClosestDepthOutput = GraphBuilder.CreateUAV(PrevClosestDepthTexture);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRClearPrevTexturesCS> ComputeShader(View.ShaderMap);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR ClearPrevTextures %dx%d", InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 1 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
2022-03-15 15:53:01 -04:00
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), 8 * 2));
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Dilate the velocity texture & scatter reprojection into previous frame
|
|
|
|
|
FRDGTextureRef DilatedVelocityTexture;
|
|
|
|
|
FRDGTextureRef ClosestDepthTexture;
|
|
|
|
|
FRDGTextureRef ParallaxFactorTexture;
|
2021-12-03 13:05:09 -05:00
|
|
|
FVelocityFlattenTextures VelocityFlattenTextures;
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_G16R16,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
2022-03-18 18:51:06 -04:00
|
|
|
DilatedVelocityTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Velocity.Dilated"));
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
Desc.Format = PF_R16F;
|
|
|
|
|
ClosestDepthTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.ClosestDepthTexture"));
|
|
|
|
|
|
|
|
|
|
Desc.Format = PF_R8_UINT;
|
|
|
|
|
ParallaxFactorTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.ParallaxFactor"));
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 13:05:09 -05:00
|
|
|
int32 TileSize = 8;
|
|
|
|
|
FTSRDilateVelocityCS::FPermutationDomain PermutationVector;
|
2021-06-10 08:42:48 -04:00
|
|
|
FTSRDilateVelocityCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRDilateVelocityCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->PrevOutputBufferUVMin = CommonParameters.InputInfo.UVViewportBilinearMin - CommonParameters.InputInfo.ExtentInverse;
|
|
|
|
|
PassParameters->PrevOutputBufferUVMax = CommonParameters.InputInfo.UVViewportBilinearMax + CommonParameters.InputInfo.ExtentInverse;
|
2021-08-25 13:01:57 -04:00
|
|
|
{
|
|
|
|
|
float TanHalfFieldOfView = View.ViewMatrices.GetInvProjectionMatrix().M[0][0];
|
|
|
|
|
|
|
|
|
|
// Should be multiplied 0.5* for the diameter to radius, and by 2.0 because GetTanHalfFieldOfView() cover only half of the pixels.
|
|
|
|
|
float WorldDepthToPixelWorldRadius = TanHalfFieldOfView / float(View.ViewRect.Width());
|
|
|
|
|
|
|
|
|
|
PassParameters->WorldDepthToDepthError = WorldDepthToPixelWorldRadius * 2.0f;
|
|
|
|
|
}
|
2022-01-04 06:33:05 -05:00
|
|
|
PassParameters->VelocityExtrapolationMultiplier = FMath::Clamp(CVarTSRVelocityExtrapolation.GetValueOnRenderThread(), 0.0f, 1.0f);
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->SceneDepthTexture = PassInputs.SceneDepthTexture;
|
|
|
|
|
PassParameters->SceneVelocityTexture = PassInputs.SceneVelocityTexture;
|
2021-12-03 13:05:09 -05:00
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DilatedVelocityOutput = GraphBuilder.CreateUAV(DilatedVelocityTexture);
|
|
|
|
|
PassParameters->ClosestDepthOutput = GraphBuilder.CreateUAV(ClosestDepthTexture);
|
|
|
|
|
PassParameters->PrevUseCountOutput = GraphBuilder.CreateUAV(PrevUseCountTexture);
|
|
|
|
|
PassParameters->PrevClosestDepthOutput = GraphBuilder.CreateUAV(PrevClosestDepthTexture);
|
|
|
|
|
PassParameters->ParallaxFactorOutput = GraphBuilder.CreateUAV(ParallaxFactorTexture);
|
2021-12-03 13:05:09 -05:00
|
|
|
|
|
|
|
|
// Setup up the motion blur's velocity flatten pass.
|
|
|
|
|
if (PassInputs.bGenerateVelocityFlattenTextures)
|
|
|
|
|
{
|
|
|
|
|
const int32 MotionBlurDirections = GetMotionBlurDirections();
|
|
|
|
|
PermutationVector.Set<FTSRDilateVelocityCS::FMotionBlurDirectionsDim>(MotionBlurDirections);
|
|
|
|
|
TileSize = FVelocityFlattenTextures::kTileSize;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_FloatR11G11B10,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
GFastVRamConfig.VelocityFlat | TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
VelocityFlattenTextures.VelocityFlatten.Texture = GraphBuilder.CreateTexture(Desc, TEXT("MotionBlur.VelocityTile"));
|
|
|
|
|
VelocityFlattenTextures.VelocityFlatten.ViewRect = InputRect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
FIntPoint::DivideAndRoundUp(InputRect.Size(), FVelocityFlattenTextures::kTileSize),
|
|
|
|
|
PF_FloatRGBA,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
GFastVRamConfig.MotionBlur | TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
VelocityFlattenTextures.VelocityTile[0].Texture = GraphBuilder.CreateTexture(Desc, TEXT("MotionBlur.VelocityTile"));
|
|
|
|
|
VelocityFlattenTextures.VelocityTile[0].ViewRect = FIntRect(FIntPoint::ZeroValue, Desc.Extent);
|
|
|
|
|
|
|
|
|
|
Desc.Format = PF_G16R16F;
|
|
|
|
|
VelocityFlattenTextures.VelocityTile[1].Texture = GraphBuilder.CreateTexture(Desc, TEXT("MotionBlur.VelocityTile"));
|
|
|
|
|
VelocityFlattenTextures.VelocityTile[1].ViewRect = FIntRect(FIntPoint::ZeroValue, Desc.Extent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PassParameters->VelocityFlattenParameters = GetVelocityFlattenParameters(View);
|
|
|
|
|
PassParameters->VelocityFlattenOutput = GraphBuilder.CreateUAV(VelocityFlattenTextures.VelocityFlatten.Texture);
|
|
|
|
|
PassParameters->VelocityTileOutput0 = GraphBuilder.CreateUAV(VelocityFlattenTextures.VelocityTile[0].Texture);
|
|
|
|
|
PassParameters->VelocityTileOutput1 = GraphBuilder.CreateUAV(VelocityFlattenTextures.VelocityTile[1].Texture);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(InputExtent, TEXT("Debug.TSR.DilateVelocity"));
|
|
|
|
|
|
2021-12-03 13:05:09 -05:00
|
|
|
TShaderMapRef<FTSRDilateVelocityCS> ComputeShader(View.ShaderMap, PermutationVector);
|
2021-06-10 08:42:48 -04:00
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
2021-12-03 13:05:09 -05:00
|
|
|
RDG_EVENT_NAME("TSR DilateVelocity(MotionBlurDirections=%d) %dx%d",
|
2021-12-07 06:02:28 -05:00
|
|
|
int32(PermutationVector.Get<FTSRDilateVelocityCS::FMotionBlurDirectionsDim>()),
|
2021-12-03 13:05:09 -05:00
|
|
|
InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 2 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
2021-12-03 13:05:09 -05:00
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), TileSize));
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-13 14:26:09 -04:00
|
|
|
// Create new history.
|
2021-06-10 08:42:48 -04:00
|
|
|
FTSRHistoryTextures History;
|
2022-05-03 09:58:40 -04:00
|
|
|
{
|
2022-05-05 14:06:16 -04:00
|
|
|
History.ArrayIndices = TranslateHistoryFormatBitsToArrayIndices(HistoryFormatBits);
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
FRDGTextureDesc ArrayDesc = FRDGTextureDesc::Create2DArray(
|
|
|
|
|
HistoryExtent,
|
|
|
|
|
(CVarTSRR11G11B10History.GetValueOnRenderThread() != 0 && !bSupportsAlpha) ? PF_FloatR11G11B10 : PF_FloatRGBA,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
TexCreate_ShaderResource | TexCreate_UAV,
|
2022-05-05 14:06:16 -04:00
|
|
|
History.ArrayIndices.Size);
|
2022-05-03 09:58:40 -04:00
|
|
|
|
|
|
|
|
History.ColorArray = GraphBuilder.CreateTexture(ArrayDesc, TEXT("TSR.History.ColorArray"));
|
|
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
HistoryExtent,
|
2022-01-18 12:17:21 -05:00
|
|
|
(CVarTSRR11G11B10History.GetValueOnRenderThread() != 0 && !bSupportsAlpha) ? PF_FloatR11G11B10 : PF_FloatRGBA,
|
2021-06-10 08:42:48 -04:00
|
|
|
FClearValueBinding::None,
|
|
|
|
|
TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
2022-03-18 18:51:06 -04:00
|
|
|
FRDGTextureDesc HalfResDesc = Desc;
|
|
|
|
|
HalfResDesc.Extent /= 2;
|
|
|
|
|
if (bHalfResHistory)
|
|
|
|
|
{
|
|
|
|
|
History.HighFrequencyHalfRes = GraphBuilder.CreateTexture(HalfResDesc, TEXT("TSR.History.HighFrequenciesHalfRes"));
|
|
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
Desc.Format = PF_R8G8;
|
2021-07-13 14:26:09 -04:00
|
|
|
History.Metadata = GraphBuilder.CreateTexture(Desc, TEXT("TSR.History.Metadata"));
|
2021-07-12 14:15:42 -04:00
|
|
|
|
2022-03-10 22:02:57 -05:00
|
|
|
Desc.Format = PF_R8;
|
|
|
|
|
History.TranslucencyAlpha = GraphBuilder.CreateTexture(Desc, TEXT("TSR.History.TranslucencyAlpha"));
|
2021-07-13 14:26:09 -04:00
|
|
|
|
2022-03-21 14:42:53 -04:00
|
|
|
if (bSubPixelDetailsAtOutputResolution)
|
|
|
|
|
{
|
|
|
|
|
Desc.Format = PF_R16_UINT;
|
|
|
|
|
History.SubpixelDetails = GraphBuilder.CreateTexture(Desc, TEXT("TSR.History.SubpixelInfo"));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc SubpixelDetailsDesc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_R16_UINT,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
History.SubpixelDetails = GraphBuilder.CreateTexture(SubpixelDetailsDesc, TEXT("TSR.History.SubpixelInfo"));
|
|
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
// Setup a dummy history
|
|
|
|
|
FTSRHistorySRVs DummyHistorySRVs;
|
|
|
|
|
{
|
|
|
|
|
DummyHistorySRVs.LowFrequency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackDummy));
|
|
|
|
|
DummyHistorySRVs.HighFrequency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackDummy));
|
|
|
|
|
DummyHistorySRVs.HighFrequencyHalfRes = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackDummy));
|
|
|
|
|
DummyHistorySRVs.Metadata = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackDummy));
|
|
|
|
|
DummyHistorySRVs.Translucency = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackDummy));
|
|
|
|
|
DummyHistorySRVs.TranslucencyAlpha = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(WhiteDummy));
|
|
|
|
|
|
|
|
|
|
DummyHistorySRVs.SubpixelDetails = GraphBuilder.CreateSRV(FRDGTextureSRVDesc::Create(BlackUintDummy));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup the previous frame history
|
|
|
|
|
FTSRHistorySRVs PrevHistorySRVs;
|
2022-05-05 14:06:16 -04:00
|
|
|
if (!bCameraCut)
|
2022-05-03 09:58:40 -04:00
|
|
|
{
|
|
|
|
|
FTSRHistoryTextures PrevHistory;
|
|
|
|
|
PrevHistory.ArrayIndices = History.ArrayIndices;
|
|
|
|
|
|
|
|
|
|
// Register filterable history
|
|
|
|
|
PrevHistory.ColorArray = GraphBuilder.RegisterExternalTexture(InputHistory.ColorArray);
|
|
|
|
|
PrevHistory.HighFrequencyHalfRes = InputHistory.HighFrequencyHalfRes.IsValid() ? GraphBuilder.RegisterExternalTexture(InputHistory.HighFrequencyHalfRes) : DummyHistorySRVs.HighFrequencyHalfRes->Desc.Texture;
|
|
|
|
|
PrevHistory.Metadata = GraphBuilder.RegisterExternalTexture(InputHistory.Metadata);
|
|
|
|
|
PrevHistory.TranslucencyAlpha = InputHistory.TranslucencyAlpha.IsValid() ? GraphBuilder.RegisterExternalTexture(InputHistory.TranslucencyAlpha) : DummyHistorySRVs.TranslucencyAlpha->Desc.Texture;
|
|
|
|
|
|
|
|
|
|
// Register non-filterable history
|
|
|
|
|
PrevHistory.SubpixelDetails = GraphBuilder.RegisterExternalTexture(InputHistory.SubpixelDetails);
|
|
|
|
|
|
|
|
|
|
PrevHistorySRVs = CreateSRVs(GraphBuilder, PrevHistory);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PrevHistorySRVs = DummyHistorySRVs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Setup the shader parameters for previous frame history
|
|
|
|
|
FTSRPrevHistoryParameters PrevHistoryParameters;
|
|
|
|
|
{
|
|
|
|
|
// Setup prev history parameters.
|
|
|
|
|
FScreenPassTextureViewport PrevHistoryViewport(PrevHistorySRVs.HighFrequency->Desc.Texture->Desc.Extent, InputHistory.OutputViewportRect);
|
|
|
|
|
FScreenPassTextureViewport PrevSubpixelDetailsViewport(PrevHistorySRVs.SubpixelDetails->Desc.Texture->Desc.Extent, bSubPixelDetailsAtOutputResolution ? InputHistory.OutputViewportRect : InputHistory.InputViewportRect);
|
|
|
|
|
|
|
|
|
|
if (bCameraCut)
|
|
|
|
|
{
|
|
|
|
|
PrevHistoryViewport.Extent = FIntPoint(1, 1);
|
|
|
|
|
PrevHistoryViewport.Rect = FIntRect(FIntPoint(0, 0), FIntPoint(1, 1));
|
|
|
|
|
PrevSubpixelDetailsViewport.Extent = FIntPoint(1, 1);
|
|
|
|
|
PrevSubpixelDetailsViewport.Rect = FIntRect(FIntPoint(0, 0), FIntPoint(1, 1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrevHistoryParameters.PrevHistoryInfo = GetScreenPassTextureViewportParameters(PrevHistoryViewport);
|
|
|
|
|
PrevHistoryParameters.ScreenPosToPrevHistoryBufferUV = FScreenTransform::ChangeTextureBasisFromTo(
|
|
|
|
|
PrevHistoryViewport, FScreenTransform::ETextureBasis::ScreenPosition, FScreenTransform::ETextureBasis::TextureUV);
|
|
|
|
|
PrevHistoryParameters.ScreenPosToPrevSubpixelDetails = FScreenTransform::ChangeTextureBasisFromTo(
|
|
|
|
|
PrevSubpixelDetailsViewport, FScreenTransform::ETextureBasis::ScreenPosition, FScreenTransform::ETextureBasis::TextureUV);
|
|
|
|
|
PrevHistoryParameters.PrevSubpixelDetailsExtent = PrevSubpixelDetailsViewport.Extent;
|
|
|
|
|
PrevHistoryParameters.HistoryPreExposureCorrection = View.PreExposure / View.PrevViewInfo.SceneColorPreExposure;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
// Decimate input to flicker at same frequency as input.
|
|
|
|
|
FRDGTextureRef HalfResInputSceneColorTexture = nullptr;
|
|
|
|
|
FRDGTextureRef HalfResPredictionSceneColorTexture = nullptr;
|
|
|
|
|
FRDGTextureRef HalfResParallaxRejectionMaskTexture = nullptr;
|
|
|
|
|
FRDGTextureRef PredictionSceneColorTexture = nullptr;
|
|
|
|
|
FRDGTextureRef ParallaxRejectionMaskTexture = nullptr;
|
2022-03-18 18:51:06 -04:00
|
|
|
FRDGTextureRef HoleFilledVelocityMaskTexture = nullptr;
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
2022-03-18 18:51:06 -04:00
|
|
|
FRDGTextureRef HoleFilledVelocityTexture;
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_R8,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
ParallaxRejectionMaskTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.ParallaxRejectionMask"));
|
2022-03-18 18:51:06 -04:00
|
|
|
|
|
|
|
|
Desc.Format = PF_G16R16;
|
|
|
|
|
HoleFilledVelocityTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Velocity.HoleFilled"));
|
|
|
|
|
|
|
|
|
|
Desc.Format = PF_R8G8;
|
|
|
|
|
HoleFilledVelocityMaskTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.velocity.HoleFillMask"));
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTSRDecimateHistoryCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRDecimateHistoryCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
{
|
|
|
|
|
const FViewMatrices& ViewMatrices = View.ViewMatrices;
|
|
|
|
|
const FViewMatrices& PrevViewMatrices = View.PrevViewInfo.ViewMatrices;
|
|
|
|
|
|
|
|
|
|
FMatrix RotationalInvViewProj = ViewMatrices.ComputeInvProjectionNoAAMatrix() * (ViewMatrices.GetTranslatedViewMatrix().RemoveTranslation().GetTransposed());
|
|
|
|
|
FMatrix RotationalPrevViewProj = (PrevViewMatrices.GetTranslatedViewMatrix().RemoveTranslation()) * PrevViewMatrices.ComputeProjectionNoAAMatrix();
|
|
|
|
|
|
2022-01-27 07:20:20 -05:00
|
|
|
PassParameters->RotationalClipToPrevClip = FMatrix44f(RotationalInvViewProj * RotationalPrevViewProj); // LWC_TODO: Precision loss?
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
2022-02-02 07:59:31 -05:00
|
|
|
PassParameters->OutputQuantizationError = (FVector3f)ComputePixelFormatQuantizationError(ColorFormat);
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
|
|
|
|
float TanHalfFieldOfView = View.ViewMatrices.GetInvProjectionMatrix().M[0][0];
|
|
|
|
|
|
|
|
|
|
// Should be multiplied 0.5* for the diameter to radius, and by 2.0 because GetTanHalfFieldOfView() cover only half of the pixels.
|
|
|
|
|
PassParameters->WorldDepthToPixelWorldRadius = TanHalfFieldOfView / float(View.ViewRect.Width());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PassParameters->InputSceneColorTexture = PassInputs.SceneColorTexture;
|
|
|
|
|
PassParameters->DilatedVelocityTexture = DilatedVelocityTexture;
|
|
|
|
|
PassParameters->ClosestDepthTexture = ClosestDepthTexture;
|
|
|
|
|
PassParameters->PrevUseCountTexture = PrevUseCountTexture;
|
|
|
|
|
PassParameters->PrevClosestDepthTexture = PrevClosestDepthTexture;
|
|
|
|
|
PassParameters->ParallaxFactorTexture = ParallaxFactorTexture;
|
|
|
|
|
|
|
|
|
|
PassParameters->PrevHistoryParameters = PrevHistoryParameters;
|
2022-05-03 09:58:40 -04:00
|
|
|
PassParameters->PrevHistory = PrevHistorySRVs;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
if (bHalfResLowFrequency)
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
LowFrequencyExtent,
|
2022-01-18 12:17:21 -05:00
|
|
|
ColorFormat,
|
2021-06-10 08:42:48 -04:00
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
HalfResInputSceneColorTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.HalfResInput"));
|
|
|
|
|
HalfResPredictionSceneColorTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Prediction.SceneColor"));
|
|
|
|
|
|
|
|
|
|
Desc.Format = PF_R8;
|
|
|
|
|
HalfResParallaxRejectionMaskTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.HalfResParallaxRejectionMask"));
|
|
|
|
|
|
|
|
|
|
PassParameters->HalfResSceneColorOutput = GraphBuilder.CreateUAV(HalfResInputSceneColorTexture);
|
|
|
|
|
PassParameters->HalfResPredictionSceneColorOutput = GraphBuilder.CreateUAV(HalfResPredictionSceneColorTexture);
|
|
|
|
|
PassParameters->HalfResParallaxRejectionMaskOutput = GraphBuilder.CreateUAV(HalfResParallaxRejectionMaskTexture);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
2022-01-18 12:17:21 -05:00
|
|
|
ColorFormat,
|
2021-06-10 08:42:48 -04:00
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
PredictionSceneColorTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Prediction.SceneColor"));
|
|
|
|
|
|
|
|
|
|
PassParameters->PredictionSceneColorOutput = GraphBuilder.CreateUAV(PredictionSceneColorTexture);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 18:51:06 -04:00
|
|
|
PassParameters->HoleFilledVelocityOutput = GraphBuilder.CreateUAV(HoleFilledVelocityTexture);
|
|
|
|
|
PassParameters->HoleFilledVelocityMaskOutput = GraphBuilder.CreateUAV(HoleFilledVelocityMaskTexture);
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->ParallaxRejectionMaskOutput = GraphBuilder.CreateUAV(ParallaxRejectionMaskTexture);
|
2022-03-21 14:42:53 -04:00
|
|
|
PassParameters->HistorySubpixelDetailsOutput = GraphBuilder.CreateUAV(History.SubpixelDetails);
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(LowFrequencyExtent, TEXT("Debug.TSR.DecimateHistory"));
|
|
|
|
|
|
|
|
|
|
FTSRDecimateHistoryCS::FPermutationDomain PermutationVector;
|
2022-03-10 22:02:57 -05:00
|
|
|
PermutationVector.Set<FTSRHighFrequencyOnlyDim>(bHistoryHighFrequencyOnly);
|
2021-06-10 08:42:48 -04:00
|
|
|
PermutationVector.Set<FTSRDecimateHistoryCS::FOutputHalfRes>(bHalfResLowFrequency);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRDecimateHistoryCS> ComputeShader(View.ShaderMap, PermutationVector);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
2022-03-10 22:02:57 -05:00
|
|
|
RDG_EVENT_NAME("TSR DecimateHistory(%s%s) %dx%d",
|
|
|
|
|
bHistoryHighFrequencyOnly ? TEXT("HighFrequency") : TEXT("LowFrequency"),
|
|
|
|
|
bHalfResLowFrequency ? TEXT(" HalfResShadingOutput") : TEXT(""),
|
2021-06-10 08:42:48 -04:00
|
|
|
InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 2 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), 8));
|
2022-03-18 18:51:06 -04:00
|
|
|
|
|
|
|
|
DilatedVelocityTexture = HoleFilledVelocityTexture;
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FRDGTextureRef TranslucencyRejectionTexture = nullptr;
|
|
|
|
|
if (bRejectSeparateTranslucency && View.PrevViewInfo.SeparateTranslucency != nullptr)
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureRef PrevTranslucencyTexture;
|
|
|
|
|
FScreenPassTextureViewport PrevTranslucencyViewport;
|
|
|
|
|
|
|
|
|
|
if (View.PrevViewInfo.SeparateTranslucency)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
PrevTranslucencyTexture = GraphBuilder.RegisterExternalTexture(View.PrevViewInfo.SeparateTranslucency);
|
2022-01-28 08:13:09 -05:00
|
|
|
PrevTranslucencyViewport = FScreenPassTextureViewport(PrevTranslucencyTexture->Desc.Extent, View.PrevViewInfo.SeparateTranslucencyViewRect);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-01-28 08:13:09 -05:00
|
|
|
PrevTranslucencyTexture = BlackAlphaOneDummy;
|
2021-06-10 08:42:48 -04:00
|
|
|
PrevTranslucencyViewport = FScreenPassTextureViewport(FIntPoint(1, 1), FIntRect(FIntPoint(0, 0), FIntPoint(1, 1)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_R8,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
TranslucencyRejectionTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.TranslucencyRejection"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTSRCompareTranslucencyCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRCompareTranslucencyCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
|
|
|
|
|
PassParameters->TranslucencyInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
2022-01-28 08:13:09 -05:00
|
|
|
SeparateTranslucencyTexture->Desc.Extent, SeparateTranslucencyRect));
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->PrevTranslucencyInfo = GetScreenPassTextureViewportParameters(PrevTranslucencyViewport);
|
|
|
|
|
PassParameters->PrevTranslucencyPreExposureCorrection = PrevHistoryParameters.HistoryPreExposureCorrection;
|
2021-07-27 15:36:37 -04:00
|
|
|
PassParameters->TranslucencyHighlightLuminance = CVarTSRTranslucencyHighlightLuminance.GetValueOnRenderThread();
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
PassParameters->ScreenPosToPrevTranslucencyTextureUV = FScreenTransform::ChangeTextureBasisFromTo(
|
|
|
|
|
PrevTranslucencyViewport, FScreenTransform::ETextureBasis::ScreenPosition, FScreenTransform::ETextureBasis::TextureUV);
|
|
|
|
|
|
|
|
|
|
PassParameters->DilatedVelocityTexture = DilatedVelocityTexture;
|
|
|
|
|
PassParameters->TranslucencyTexture = SeparateTranslucencyTexture;
|
|
|
|
|
PassParameters->PrevTranslucencyTexture = PrevTranslucencyTexture;
|
|
|
|
|
|
|
|
|
|
PassParameters->TranslucencyRejectionOutput = GraphBuilder.CreateUAV(TranslucencyRejectionTexture);
|
2021-06-22 12:07:46 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(LowFrequencyExtent, TEXT("Debug.TSR.CompareTranslucency"));
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRCompareTranslucencyCS> ComputeShader(View.ShaderMap);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
2021-06-22 12:07:46 -04:00
|
|
|
RDG_EVENT_NAME("TSR CompareTranslucency %dx%d", InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Reject the history with frequency decomposition.
|
|
|
|
|
FRDGTextureRef HistoryRejectionTexture;
|
2021-06-22 12:07:46 -04:00
|
|
|
FRDGTextureRef InputSceneColorLdrLumaTexture = nullptr;
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
|
|
|
|
// Filter out the high frquencies
|
|
|
|
|
FRDGTextureRef FilteredInputTexture;
|
|
|
|
|
FRDGTextureRef FilteredPredictionSceneColorTexture;
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
LowFrequencyExtent,
|
2022-01-18 12:17:21 -05:00
|
|
|
ColorFormat,
|
2021-06-10 08:42:48 -04:00
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
FilteredInputTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Filtered.SceneColor"));
|
|
|
|
|
FilteredPredictionSceneColorTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Filtered.Prediction.SceneColor"));
|
|
|
|
|
}
|
2021-06-22 12:07:46 -04:00
|
|
|
|
|
|
|
|
if (RejectionAntiAliasingQuality > 0)
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
LowFrequencyExtent,
|
|
|
|
|
PF_R8,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
InputSceneColorLdrLumaTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.SceneColorLdrLuma"));
|
|
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
FTSRFilterFrequenciesCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRFilterFrequenciesCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
2022-02-02 07:59:31 -05:00
|
|
|
PassParameters->OutputQuantizationError = (FVector3f)ComputePixelFormatQuantizationError(FilteredInputTexture->Desc.Format);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
if (bHalfResLowFrequency)
|
|
|
|
|
{
|
|
|
|
|
PassParameters->InputTexture = HalfResInputSceneColorTexture;
|
|
|
|
|
PassParameters->PredictionSceneColorTexture = HalfResPredictionSceneColorTexture;
|
|
|
|
|
PassParameters->ParallaxRejectionMaskTexture = HalfResParallaxRejectionMaskTexture;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PassParameters->InputTexture = PassInputs.SceneColorTexture;
|
|
|
|
|
PassParameters->PredictionSceneColorTexture = PredictionSceneColorTexture;
|
|
|
|
|
PassParameters->ParallaxRejectionMaskTexture = ParallaxRejectionMaskTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PassParameters->FilteredInputOutput = GraphBuilder.CreateUAV(FilteredInputTexture);
|
|
|
|
|
PassParameters->FilteredPredictionSceneColorOutput = GraphBuilder.CreateUAV(FilteredPredictionSceneColorTexture);
|
2021-06-22 12:07:46 -04:00
|
|
|
PassParameters->InputSceneColorLdrLumaOutput = InputSceneColorLdrLumaTexture ? GraphBuilder.CreateUAV(InputSceneColorLdrLumaTexture) : nullptr;
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(LowFrequencyExtent, TEXT("Debug.TSR.FilterFrequencies"));
|
|
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
FTSRFilterFrequenciesCS::FPermutationDomain PermutationVector;
|
|
|
|
|
PermutationVector.Set<FTSRFilterFrequenciesCS::FOutputAALumaDim>(RejectionAntiAliasingQuality > 0);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRFilterFrequenciesCS> ComputeShader(View.ShaderMap, PermutationVector);
|
2021-06-10 08:42:48 -04:00
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
2021-06-22 12:07:46 -04:00
|
|
|
RDG_EVENT_NAME("TSR FilterFrequencies(%s) %dx%d",
|
|
|
|
|
PermutationVector.Get<FTSRFilterFrequenciesCS::FOutputAALumaDim>() ? TEXT("OutputAALuma") : TEXT(""),
|
|
|
|
|
LowFrequencyRect.Width(), LowFrequencyRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(LowFrequencyRect.Size(), 16));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Compare the low frequencies
|
|
|
|
|
{
|
|
|
|
|
bool bOutputHalfRes = PostFilter != ERejectionPostFilter::PreRejectionDownsample;
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
bOutputHalfRes ? RejectionExtent : LowFrequencyExtent,
|
|
|
|
|
PF_R8,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
HistoryRejectionTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.HistoryRejection"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTSRCompareHistoryCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRCompareHistoryCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->ParallaxRejectionMaskTexture = ParallaxRejectionMaskTexture;
|
|
|
|
|
PassParameters->FilteredInputTexture = FilteredInputTexture;
|
|
|
|
|
PassParameters->FilteredPredictionSceneColorTexture = FilteredPredictionSceneColorTexture;
|
|
|
|
|
|
|
|
|
|
PassParameters->HistoryRejectionOutput = GraphBuilder.CreateUAV(HistoryRejectionTexture);
|
|
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(LowFrequencyExtent, TEXT("Debug.TSR.CompareHistory"));
|
|
|
|
|
|
|
|
|
|
FTSRCompareHistoryCS::FPermutationDomain PermutationVector;
|
|
|
|
|
PermutationVector.Set<FTSRCompareHistoryCS::FOutputHalfRes>(bOutputHalfRes);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRCompareHistoryCS> ComputeShader(View.ShaderMap, PermutationVector);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR CompareHistory %dx%d", LowFrequencyRect.Width(), LowFrequencyRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(LowFrequencyRect.Size(), 16));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
// Spatial anti-aliasing when doing history rejection.
|
|
|
|
|
FRDGTextureRef AntiAliasingTexture = nullptr;
|
2021-09-06 16:11:26 -04:00
|
|
|
FRDGTextureRef NoiseFilteringTexture = nullptr;
|
2021-06-22 12:07:46 -04:00
|
|
|
if (RejectionAntiAliasingQuality > 0)
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureRef RawAntiAliasingTexture;
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
InputExtent,
|
|
|
|
|
PF_R8_UINT,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
RawAntiAliasingTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.AntiAliasing.Raw"));
|
|
|
|
|
AntiAliasingTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.AntiAliasing.Filtered"));
|
2021-09-06 16:11:26 -04:00
|
|
|
|
|
|
|
|
Desc.Format = PF_R8;
|
|
|
|
|
NoiseFilteringTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.AntiAliasing.Noise"));
|
2021-06-22 12:07:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FTSRSpatialAntiAliasingCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRSpatialAntiAliasingCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->InputSceneColorTexture = PassInputs.SceneColorTexture;
|
|
|
|
|
PassParameters->InputSceneColorLdrLumaTexture = InputSceneColorLdrLumaTexture;
|
|
|
|
|
PassParameters->AntiAliasingOutput = GraphBuilder.CreateUAV(RawAntiAliasingTexture);
|
2021-09-06 16:11:26 -04:00
|
|
|
PassParameters->NoiseFilteringOutput = GraphBuilder.CreateUAV(NoiseFilteringTexture);
|
2021-06-22 12:07:46 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(InputExtent, TEXT("Debug.TSR.SpatialAntiAliasing"));
|
|
|
|
|
|
|
|
|
|
FTSRSpatialAntiAliasingCS::FPermutationDomain PermutationVector;
|
|
|
|
|
PermutationVector.Set<FTSRSpatialAntiAliasingCS::FQualityDim>(RejectionAntiAliasingQuality);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRSpatialAntiAliasingCS> ComputeShader(View.ShaderMap, PermutationVector);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR SpatialAntiAliasing(Quality=%d) %dx%d",
|
|
|
|
|
RejectionAntiAliasingQuality,
|
|
|
|
|
InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-22 12:07:46 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
FTSRFilterAntiAliasingCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRFilterAntiAliasingCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->AntiAliasingTexture = RawAntiAliasingTexture;
|
|
|
|
|
PassParameters->AntiAliasingOutput = GraphBuilder.CreateUAV(AntiAliasingTexture);
|
|
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(InputExtent, TEXT("Debug.TSR.FilterAntiAliasing"));
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRFilterAntiAliasingCS> ComputeShader(View.ShaderMap);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR FilterAntiAliasing %dx%d", InputRect.Width(), InputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-22 12:07:46 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(InputRect.Size(), 8));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
// Post filter the rejection.
|
|
|
|
|
if (PostFilter != ERejectionPostFilter::Disabled)
|
|
|
|
|
{
|
|
|
|
|
bool bOutputHalfRes = PostFilter == ERejectionPostFilter::PreRejectionDownsample;
|
2022-02-14 12:28:20 -05:00
|
|
|
FIntRect Rect = bOutputHalfRes ? FIntRect(FIntPoint(0, 0), LowFrequencyRect.Size()) : RejectionRect;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
FRDGTextureRef FilteredHistoryRejectionTexture;
|
|
|
|
|
{
|
|
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
RejectionExtent,
|
|
|
|
|
PF_R8,
|
|
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV);
|
|
|
|
|
|
|
|
|
|
FilteredHistoryRejectionTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.HistoryRejection"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FTSRPostfilterRejectionCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRPostfilterRejectionCS::FParameters>();
|
|
|
|
|
PassParameters->HistoryRejectionViewport = Rect;
|
|
|
|
|
PassParameters->HistoryRejectionTexture = HistoryRejectionTexture;
|
|
|
|
|
PassParameters->HistoryRejectionOutput = GraphBuilder.CreateUAV(FilteredHistoryRejectionTexture);
|
|
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(bOutputHalfRes ? LowFrequencyExtent : RejectionExtent, TEXT("Debug.TSR.PostfilterRejection"));
|
|
|
|
|
|
|
|
|
|
FTSRPostfilterRejectionCS::FPermutationDomain PermutationVector;
|
|
|
|
|
PermutationVector.Set<FTSRPostfilterRejectionCS::FOutputHalfRes>(PostFilter == ERejectionPostFilter::PreRejectionDownsample);
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRPostfilterRejectionCS> ComputeShader(View.ShaderMap, PermutationVector);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR PostfilterRejection %dx%d", Rect.Width(), Rect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(Rect.Size(), 8));
|
|
|
|
|
|
|
|
|
|
HistoryRejectionTexture = FilteredHistoryRejectionTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Dilate the rejection.
|
|
|
|
|
FRDGTextureRef DilatedHistoryRejectionTexture;
|
|
|
|
|
{
|
|
|
|
|
DilatedHistoryRejectionTexture = GraphBuilder.CreateTexture(HistoryRejectionTexture->Desc, TEXT("TSR.DilatedHistoryRejection"));
|
|
|
|
|
|
|
|
|
|
FTSRDilateRejectionCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRDilateRejectionCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->HistoryRejectionTexture = HistoryRejectionTexture;
|
|
|
|
|
PassParameters->DilatedHistoryRejectionOutput = GraphBuilder.CreateUAV(DilatedHistoryRejectionTexture);
|
|
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(RejectionExtent, TEXT("Debug.TSR.DilateRejection"));
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRDilateRejectionCS> ComputeShader(View.ShaderMap);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR DilateRejection %dx%d", RejectionRect.Width(), RejectionRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(RejectionRect.Size(), 8));
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
// Allocate output
|
2021-06-10 08:42:48 -04:00
|
|
|
FRDGTextureRef SceneColorOutputTexture;
|
2022-05-13 07:23:22 -04:00
|
|
|
FRDGTextureRef SceneColorOutputHalfResTexture = nullptr;
|
2021-06-10 08:42:48 -04:00
|
|
|
{
|
2022-05-13 07:23:22 -04:00
|
|
|
check(!(PassInputs.bGenerateOutputMip1 && PassInputs.bAllowDownsampleSceneColor));
|
2022-01-03 06:45:53 -05:00
|
|
|
FRDGTextureDesc Desc = FRDGTextureDesc::Create2D(
|
|
|
|
|
OutputExtent,
|
2022-01-18 12:17:21 -05:00
|
|
|
ColorFormat,
|
2022-01-03 06:45:53 -05:00
|
|
|
FClearValueBinding::None,
|
|
|
|
|
/* InFlags = */ TexCreate_ShaderResource | TexCreate_UAV,
|
|
|
|
|
/* NumMips = */ PassInputs.bGenerateOutputMip1 ? 2 : 1);
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
SceneColorOutputTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.Output"));
|
2022-05-13 07:23:22 -04:00
|
|
|
|
|
|
|
|
if (PassInputs.bAllowDownsampleSceneColor)
|
|
|
|
|
{
|
|
|
|
|
Desc.Extent /= 2;
|
|
|
|
|
SceneColorOutputHalfResTexture = GraphBuilder.CreateTexture(Desc, TEXT("TSR.HalfResOutput"));
|
|
|
|
|
}
|
2022-01-03 06:45:53 -05:00
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-01-03 06:45:53 -05:00
|
|
|
// Update temporal history.
|
|
|
|
|
{
|
2022-01-07 10:12:38 -05:00
|
|
|
static const TCHAR* const kUpdateQualityNames[] = {
|
|
|
|
|
TEXT("Low"),
|
|
|
|
|
TEXT("Medium"),
|
|
|
|
|
TEXT("High"),
|
|
|
|
|
TEXT("Epic"),
|
|
|
|
|
};
|
|
|
|
|
static_assert(UE_ARRAY_COUNT(kUpdateQualityNames) == int32(FTSRUpdateHistoryCS::EQuality::MAX), "Fix me!");
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
FTSRUpdateHistoryCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRUpdateHistoryCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->InputSceneColorTexture = PassInputs.SceneColorTexture;
|
|
|
|
|
PassParameters->InputSceneStencilTexture = GraphBuilder.CreateSRV(
|
|
|
|
|
FRDGTextureSRVDesc::CreateWithPixelFormat(PassInputs.SceneDepthTexture, PF_X24_G8));
|
2021-07-12 14:15:42 -04:00
|
|
|
PassParameters->InputSceneTranslucencyTexture = SeparateTranslucencyTexture;
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->HistoryRejectionTexture = DilatedHistoryRejectionTexture;
|
|
|
|
|
PassParameters->TranslucencyRejectionTexture = TranslucencyRejectionTexture ? TranslucencyRejectionTexture : BlackDummy;
|
|
|
|
|
|
|
|
|
|
PassParameters->DilatedVelocityTexture = DilatedVelocityTexture;
|
|
|
|
|
PassParameters->ParallaxFactorTexture = ParallaxFactorTexture;
|
|
|
|
|
PassParameters->ParallaxRejectionMaskTexture = ParallaxRejectionMaskTexture;
|
2021-06-22 12:07:46 -04:00
|
|
|
PassParameters->AntiAliasingTexture = AntiAliasingTexture;
|
2021-09-06 16:11:26 -04:00
|
|
|
PassParameters->NoiseFilteringTexture = NoiseFilteringTexture;
|
2021-12-03 03:42:40 -05:00
|
|
|
PassParameters->HoleFilledVelocityMaskTexture = HoleFilledVelocityMaskTexture;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
2022-05-31 01:21:02 -04:00
|
|
|
PassParameters->TranslucencyInfo = GetScreenPassTextureViewportParameters(FScreenPassTextureViewport(
|
|
|
|
|
PassParameters->TranslucencyRejectionTexture->Desc.Extent, SeparateTranslucencyRect));
|
|
|
|
|
PassParameters->TranslucencyPixelPosMin = PassParameters->TranslucencyInfo.ViewportMin;
|
|
|
|
|
PassParameters->TranslucencyPixelPosMax = PassParameters->TranslucencyInfo.ViewportMax - 1;
|
|
|
|
|
|
2021-06-10 08:42:48 -04:00
|
|
|
FScreenTransform HistoryPixelPosToViewportUV = (FScreenTransform::Identity + 0.5f) * CommonParameters.HistoryInfo.ViewportSizeInverse;
|
|
|
|
|
PassParameters->HistoryPixelPosToScreenPos = HistoryPixelPosToViewportUV * FScreenTransform::ViewportUVToScreenPos;
|
2022-05-31 01:21:02 -04:00
|
|
|
PassParameters->HistoryPixelPosToInputPPCo = HistoryPixelPosToViewportUV * CommonParameters.InputInfo.ViewportSize + CommonParameters.InputJitter + CommonParameters.InputPixelPosMin;
|
|
|
|
|
PassParameters->HistoryPixelPosToTranslucencyPPCo = HistoryPixelPosToViewportUV * PassParameters->TranslucencyInfo.ViewportSize + CommonParameters.InputJitter * PassParameters->TranslucencyInfo.ViewportSize / CommonParameters.InputInfo.ViewportSize + SeparateTranslucencyRect.Min;
|
2022-05-03 09:58:40 -04:00
|
|
|
PassParameters->HistoryQuantizationError = (FVector3f)ComputePixelFormatQuantizationError(History.ColorArray->Desc.Format);
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->MinTranslucencyRejection = TranslucencyRejectionTexture == nullptr ? 1.0 : 0.0;
|
2021-07-21 15:22:43 -04:00
|
|
|
PassParameters->InvWeightClampingPixelSpeed = 1.0f / CVarTSRWeightClampingPixelSpeed.GetValueOnRenderThread();
|
2021-09-06 16:11:26 -04:00
|
|
|
PassParameters->InputToHistoryFactor = float(HistorySize.X) / float(InputRect.Width());
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->ResponsiveStencilMask = CVarTSREnableResponiveAA.GetValueOnRenderThread() ? (STENCIL_TEMPORAL_RESPONSIVE_AA_MASK) : 0;
|
2022-05-13 07:23:22 -04:00
|
|
|
PassParameters->bGenerateOutputMip1 = ((PassInputs.bGenerateOutputMip1 || PassInputs.bAllowDownsampleSceneColor) && HistorySize == OutputRect.Size()) ? 1 : 0;
|
2022-03-10 22:02:57 -05:00
|
|
|
PassParameters->bHasSeparateTranslucency = bHasSeparateTranslucency;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
PassParameters->PrevHistoryParameters = PrevHistoryParameters;
|
2022-05-03 09:58:40 -04:00
|
|
|
PassParameters->PrevHistory = PrevHistorySRVs;
|
2021-06-10 08:42:48 -04:00
|
|
|
|
|
|
|
|
PassParameters->HistoryOutput = CreateUAVs(GraphBuilder, History);
|
2022-01-03 06:45:53 -05:00
|
|
|
if (HistorySize != OutputRect.Size())
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip0 = CreateDummyUAV(GraphBuilder, PF_FloatR11G11B10);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip0 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputTexture, /* InMipLevel = */ 0));
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-13 07:23:22 -04:00
|
|
|
if (!PassParameters->bGenerateOutputMip1)
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = CreateDummyUAV(GraphBuilder, PF_FloatR11G11B10);
|
|
|
|
|
}
|
|
|
|
|
else if (PassInputs.bGenerateOutputMip1)
|
2021-12-03 12:40:10 -05:00
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputTexture, /* InMipLevel = */ 1));
|
|
|
|
|
}
|
2022-05-13 07:23:22 -04:00
|
|
|
else if (PassInputs.bAllowDownsampleSceneColor)
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputHalfResTexture));
|
|
|
|
|
}
|
2021-12-03 12:40:10 -05:00
|
|
|
else
|
|
|
|
|
{
|
2022-05-13 07:23:22 -04:00
|
|
|
unimplemented();
|
2021-12-03 12:40:10 -05:00
|
|
|
}
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(HistoryExtent, TEXT("Debug.TSR.UpdateHistory"));
|
|
|
|
|
|
2021-06-22 12:07:46 -04:00
|
|
|
FTSRUpdateHistoryCS::FPermutationDomain PermutationVector;
|
2022-03-10 22:02:57 -05:00
|
|
|
PermutationVector.Set<FTSRHighFrequencyOnlyDim>(bHistoryHighFrequencyOnly);
|
2022-01-07 10:12:38 -05:00
|
|
|
PermutationVector.Set<FTSRUpdateHistoryCS::FQualityDim>(UpdateHistoryQuality);
|
2021-06-22 12:07:46 -04:00
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRUpdateHistoryCS> ComputeShader(View.ShaderMap, PermutationVector);
|
2021-06-10 08:42:48 -04:00
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
2022-01-07 10:12:38 -05:00
|
|
|
RDG_EVENT_NAME("TSR UpdateHistory(Quality=%s %s%s%s) %dx%d",
|
|
|
|
|
kUpdateQualityNames[int32(PermutationVector.Get<FTSRUpdateHistoryCS::FQualityDim>())],
|
2022-05-03 09:58:40 -04:00
|
|
|
History.ColorArray->Desc.Format == PF_FloatR11G11B10 ? TEXT("R11G11B10") : TEXT(""),
|
2022-03-10 22:02:57 -05:00
|
|
|
PermutationVector.Get<FTSRHighFrequencyOnlyDim>() ? TEXT("") : TEXT(" LowFrequency"),
|
2022-05-13 07:23:22 -04:00
|
|
|
PassParameters->bGenerateOutputMip1 ? TEXT(" OutputMip1") : TEXT(""),
|
2021-06-10 08:42:48 -04:00
|
|
|
HistorySize.X, HistorySize.Y),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(HistorySize, 8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Debug the history.
|
|
|
|
|
#if COMPILE_TSR_DEBUG_PASSES
|
|
|
|
|
if (bSetupDebugPasses)
|
|
|
|
|
{
|
|
|
|
|
const int32 kHistoryUpscalingFactor = 2;
|
|
|
|
|
|
|
|
|
|
FTSRDebugHistoryCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRDebugHistoryCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
2022-05-03 09:58:40 -04:00
|
|
|
PassParameters->History = CreateSRVs(GraphBuilder, History);
|
|
|
|
|
PassParameters->PrevHistory = PrevHistorySRVs;
|
2021-06-10 08:42:48 -04:00
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(HistoryExtent * kHistoryUpscalingFactor, TEXT("Debug.TSR.History"));
|
|
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRDebugHistoryCS> ComputeShader(View.ShaderMap);
|
|
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR DebugHistory %dx%d", HistorySize.X, HistorySize.Y),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2021-06-10 08:42:48 -04:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(HistorySize * kHistoryUpscalingFactor, 8));
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// If we upscaled the history buffer, downsize back to the secondary screen percentage size.
|
|
|
|
|
if (HistorySize != OutputRect.Size())
|
|
|
|
|
{
|
2022-01-03 06:45:53 -05:00
|
|
|
FTSRResolveHistoryCS::FParameters* PassParameters = GraphBuilder.AllocParameters<FTSRResolveHistoryCS::FParameters>();
|
|
|
|
|
PassParameters->CommonParameters = CommonParameters;
|
|
|
|
|
PassParameters->DispatchThreadToHistoryPixelPos = (
|
|
|
|
|
FScreenTransform::DispatchThreadIdToViewportUV(OutputRect) *
|
|
|
|
|
FScreenTransform::ChangeTextureBasisFromTo(
|
|
|
|
|
HistoryExtent, FIntRect(FIntPoint(0, 0), HistorySize),
|
|
|
|
|
FScreenTransform::ETextureBasis::ViewportUV, FScreenTransform::ETextureBasis::TexelPosition));
|
|
|
|
|
PassParameters->OutputViewRectMin = OutputRect.Min;
|
|
|
|
|
PassParameters->OutputViewRectMax = OutputRect.Max;
|
2022-05-13 07:23:22 -04:00
|
|
|
PassParameters->bGenerateOutputMip1 = (PassInputs.bGenerateOutputMip1 || PassInputs.bAllowDownsampleSceneColor) ? 1 : 0;
|
2022-01-03 06:45:53 -05:00
|
|
|
PassParameters->HistoryValidityMultiply = float(HistorySize.X * HistorySize.Y) / float(OutputRect.Width() * OutputRect.Height());
|
|
|
|
|
|
2022-05-03 09:58:40 -04:00
|
|
|
PassParameters->History = CreateSRVs(GraphBuilder, History);
|
2022-01-03 06:45:53 -05:00
|
|
|
|
|
|
|
|
PassParameters->SceneColorOutputMip0 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputTexture, /* InMipLevel = */ 0));
|
2022-05-13 07:23:22 -04:00
|
|
|
if (PassInputs.bGenerateOutputMip1)
|
2022-01-03 06:45:53 -05:00
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputTexture, /* InMipLevel = */ 1));
|
|
|
|
|
}
|
2022-05-13 07:23:22 -04:00
|
|
|
else if (PassInputs.bAllowDownsampleSceneColor)
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = GraphBuilder.CreateUAV(FRDGTextureUAVDesc(SceneColorOutputHalfResTexture));
|
|
|
|
|
}
|
2022-01-03 06:45:53 -05:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PassParameters->SceneColorOutputMip1 = CreateDummyUAV(GraphBuilder, PF_FloatR11G11B10);
|
|
|
|
|
}
|
|
|
|
|
PassParameters->DebugOutput = CreateDebugUAV(HistoryExtent, TEXT("Debug.TSR.ResolveHistory"));
|
|
|
|
|
|
2022-03-01 14:36:09 -05:00
|
|
|
FTSRResolveHistoryCS::FPermutationDomain PermutationVector;
|
2022-03-10 22:02:57 -05:00
|
|
|
PermutationVector.Set<FTSRHighFrequencyOnlyDim>(bHistoryHighFrequencyOnly);
|
2022-03-01 14:36:09 -05:00
|
|
|
|
|
|
|
|
TShaderMapRef<FTSRResolveHistoryCS> ComputeShader(View.ShaderMap, PermutationVector);
|
2022-01-03 06:45:53 -05:00
|
|
|
FComputeShaderUtils::AddPass(
|
|
|
|
|
GraphBuilder,
|
|
|
|
|
RDG_EVENT_NAME("TSR ResolveHistory %dx%d", OutputRect.Width(), OutputRect.Height()),
|
2022-05-31 04:53:12 -04:00
|
|
|
AsyncComputePasses >= 3 ? ERDGPassFlags::AsyncCompute : ERDGPassFlags::Compute,
|
2022-01-03 06:45:53 -05:00
|
|
|
ComputeShader,
|
|
|
|
|
PassParameters,
|
|
|
|
|
FComputeShaderUtils::GetGroupCount(OutputRect.Size(), 8));
|
2021-06-10 08:42:48 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-13 14:26:09 -04:00
|
|
|
// Extract all resources for next frame.
|
|
|
|
|
if (!View.bStatePrevViewInfoIsReadOnly)
|
|
|
|
|
{
|
|
|
|
|
FTSRHistory& OutputHistory = View.ViewState->PrevFrameViewInfo.TSRHistory;
|
2022-03-21 14:42:53 -04:00
|
|
|
OutputHistory.InputViewportRect = InputRect;
|
2021-07-13 14:26:09 -04:00
|
|
|
OutputHistory.OutputViewportRect = FIntRect(FIntPoint(0, 0), HistorySize);
|
2022-05-05 14:06:16 -04:00
|
|
|
OutputHistory.FormatBit = uint32(HistoryFormatBits);
|
2021-07-13 14:26:09 -04:00
|
|
|
|
|
|
|
|
// Extract filterable history
|
2022-05-03 09:58:40 -04:00
|
|
|
GraphBuilder.QueueTextureExtraction(History.ColorArray, &OutputHistory.ColorArray);
|
2021-07-13 14:26:09 -04:00
|
|
|
GraphBuilder.QueueTextureExtraction(History.Metadata, &OutputHistory.Metadata);
|
2022-03-10 22:02:57 -05:00
|
|
|
GraphBuilder.QueueTextureExtraction(History.TranslucencyAlpha, &OutputHistory.TranslucencyAlpha);
|
2021-07-13 14:26:09 -04:00
|
|
|
|
|
|
|
|
// Extract non-filterable history
|
|
|
|
|
GraphBuilder.QueueTextureExtraction(History.SubpixelDetails, &OutputHistory.SubpixelDetails);
|
|
|
|
|
|
2022-03-18 18:51:06 -04:00
|
|
|
// Extract half res history
|
|
|
|
|
if (bHalfResHistory)
|
|
|
|
|
{
|
|
|
|
|
GraphBuilder.QueueTextureExtraction(History.HighFrequencyHalfRes, &OutputHistory.HighFrequencyHalfRes);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 14:26:09 -04:00
|
|
|
// Extract the translucency buffer to compare it with next frame
|
|
|
|
|
if (bRejectSeparateTranslucency)
|
|
|
|
|
{
|
|
|
|
|
GraphBuilder.QueueTextureExtraction(
|
|
|
|
|
SeparateTranslucencyTexture, &View.ViewState->PrevFrameViewInfo.SeparateTranslucency);
|
2022-01-28 08:13:09 -05:00
|
|
|
View.ViewState->PrevFrameViewInfo.SeparateTranslucencyViewRect = InputRect;
|
2021-07-13 14:26:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extract the output for next frame SSR so that separate translucency shows up in SSR.
|
|
|
|
|
{
|
|
|
|
|
GraphBuilder.QueueTextureExtraction(
|
2021-07-29 13:49:02 -04:00
|
|
|
SceneColorOutputTexture, &View.ViewState->PrevFrameViewInfo.CustomSSRInput.RT[0]);
|
|
|
|
|
|
|
|
|
|
View.ViewState->PrevFrameViewInfo.CustomSSRInput.ViewportRect = OutputRect;
|
|
|
|
|
View.ViewState->PrevFrameViewInfo.CustomSSRInput.ReferenceBufferSize = OutputExtent;
|
2021-07-13 14:26:09 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 13:05:09 -05:00
|
|
|
|
|
|
|
|
ITemporalUpscaler::FOutputs Outputs;
|
|
|
|
|
Outputs.FullRes.Texture = SceneColorOutputTexture;
|
|
|
|
|
Outputs.FullRes.ViewRect = OutputRect;
|
2022-05-13 07:23:22 -04:00
|
|
|
if (PassInputs.bAllowDownsampleSceneColor)
|
|
|
|
|
{
|
|
|
|
|
Outputs.HalfRes.Texture = SceneColorOutputHalfResTexture;
|
|
|
|
|
Outputs.HalfRes.ViewRect.Min = OutputRect.Min / 2;
|
|
|
|
|
Outputs.HalfRes.ViewRect.Max = Outputs.HalfRes.ViewRect.Min + FIntPoint::DivideAndRoundUp(OutputRect.Size(), 2);
|
|
|
|
|
}
|
2021-12-03 13:05:09 -05:00
|
|
|
Outputs.VelocityFlattenTextures = VelocityFlattenTextures;
|
|
|
|
|
return Outputs;
|
2021-06-10 08:42:48 -04:00
|
|
|
} // AddTemporalSuperResolutionPasses()
|